aboutsummaryrefslogtreecommitdiff
path: root/view.c
diff options
context:
space:
mode:
authorRichard Burke <rich.g.burke@gmail.com>2016-02-19 22:52:45 +0000
committerMarc André Tanner <mat@brain-dump.org>2016-02-20 15:23:49 +0100
commitb3ad505ce694c17eddbdcdda089b3149ddc5360a (patch)
tree778212b612a4983678fdadf7ca8a97a1a8b73230 /view.c
parentdc71e4263423e136a609232c618b1d5f9d960f73 (diff)
downloadvis-b3ad505ce694c17eddbdcdda089b3149ddc5360a.tar.gz
vis-b3ad505ce694c17eddbdcdda089b3149ddc5360a.tar.xz
colorcolumn enhancement
Allow colorcolumn to be greater than the view width. Lines that wrap now have the colorcolumn highlighted.
Diffstat (limited to 'view.c')
-rw-r--r--view.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/view.c b/view.c
index a577826..80c472e 100644
--- 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;
}
}