vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 80a2e5d58cda0ce0683d56175e2fbdb9ffe70b7e parent 1d0daf18935fb5ab66ee9b98d1cdaa4476184070 Author: Richard Burke <rich.g.burke@gmail.com> Date: Fri, 19 Feb 2016 22:52:45 +0000 colorcolumn enhancement Allow colorcolumn to be greater than the view width. Lines that wrap now have the colorcolumn highlighted. Diffstat:
| M | view.c | | | 22 | +++++++++++++++++++--- |
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/view.c b/view.c @@ -633,11 +633,27 @@ void view_update(View *view) { view_syntax_color(view); - if (view->colorcolumn > 0 && view->colorcolumn <= view->width) { + if (view->colorcolumn > 0) { size_t lineno = 0; + int line_cols; /* Track the number of columns we've passed on each line */ + bool line_cc_set; /* Has the colorcolumn attribute been set for this line yet */ + for (Line *l = view->topline; l; l = l->next) { - if (l->lineno != lineno) - l->cells[view->colorcolumn-1].attr = UI_STYLE_COLOR_COLUMN; + if (l->lineno != lineno) { + line_cols = 0; + line_cc_set = false; + } + + if (!line_cc_set) { + line_cols += view->width; + + /* This screen line contains the cell we want to highlight */ + if (line_cols >= view->colorcolumn) { + l->cells[(view->colorcolumn - 1) % view->width].attr = UI_STYLE_COLOR_COLUMN; + line_cc_set = true; + } + } + lineno = l->lineno; } }