diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-10-19 23:05:54 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-11-08 13:37:23 +0100 |
| commit | cbc96c96d193829fc882c5b4d83c2006a232cfe6 (patch) | |
| tree | 9997e3115dcf1dd5ce0af96b2f7f4bed6ffe7649 /view.c | |
| parent | 6eb3dbc60f054c81ef071c79b0f438cdd0bbb1f1 (diff) | |
| download | vis-cbc96c96d193829fc882c5b4d83c2006a232cfe6.tar.gz vis-cbc96c96d193829fc882c5b4d83c2006a232cfe6.tar.xz | |
vis: implement :set colorcolumn
Diffstat (limited to 'view.c')
| -rw-r--r-- | view.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -74,6 +74,7 @@ struct View { lua_State *lua; /* lua state used for syntax highlighting */ char *lexer_name; bool need_update; /* whether view has been redrawn */ + int colorcolumn; }; static const SyntaxSymbol symbols_none[] = { @@ -516,6 +517,15 @@ void view_update(View *view) { lua_pop(L, 3); /* _TOKENSTYLES, language specific lexer, lexers global */ } + if (view->colorcolumn > 0 && view->colorcolumn <= view->width) { + size_t lineno = 0; + for (Line *l = view->topline; l; l = l->next) { + if (l->lineno != lineno) + l->cells[view->colorcolumn-1].attr = UI_STYLE_COLOR_COLUMN; + lineno = l->lineno; + } + } + for (Line *l = view->lastline->next; l; l = l->next) { strncpy(l->cells[0].data, view->symbols[SYNTAX_SYMBOL_EOF]->symbol, sizeof(l->cells[0].data)); l->cells[0].attr = view->symbols[SYNTAX_SYMBOL_EOF]->style; @@ -909,6 +919,9 @@ bool view_syntax_set(View *view, const char *name) { lua_getfield(L, -1, "STYLE_LINENUMBER"); view->ui->syntax_style(view->ui, UI_STYLE_LINENUMBER, lua_tostring(L, -1)); lua_pop(L, 1); + lua_getfield(L, -1, "STYLE_COLOR_COLUMN"); + view->ui->syntax_style(view->ui, UI_STYLE_COLOR_COLUMN, lua_tostring(L, -1)); + lua_pop(L, 1); lua_getfield(L, -1, "load"); @@ -975,6 +988,15 @@ enum UiOption view_options_get(View *view) { return view->ui ? view->ui->options_get(view->ui) : 0; } +void view_colorcolumn_set(View *view, int col) { + if (col >= 0) + view->colorcolumn = col; +} + +int view_colorcolumn_get(View *view) { + return view->colorcolumn; +} + size_t view_screenline_goto(View *view, int n) { size_t pos = view->start; for (Line *line = view->topline; --n > 0 && line != view->lastline; line = line->next) |
