aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGennadiy Volkov <git@gennadiy.33mail.com>2020-03-08 19:55:17 +1100
committerGennadiy Volkov <git@gennadiy.33mail.com>2020-03-17 23:35:51 +1100
commitbae3c238adad2b9bbfc6a8ad340caab1c6149ed4 (patch)
tree2d6de839dc4f2a33832d955d0a585582317fffa6
parent9fd9b1810c445e31d4599eb72e2fce3e67aa9c4c (diff)
downloadvis-bae3c238adad2b9bbfc6a8ad340caab1c6149ed4.tar.gz
vis-bae3c238adad2b9bbfc6a8ad340caab1c6149ed4.tar.xz
color-column: Don't change fg/bg if not set explicitly
eg. if your long line is a comment with green fg, and you set your column color bg red while not specifying the fg, then the result is green fg on red bg. Prior to this change the result would be default fg on red bg, thus one char in the long line of green text would look odd/wrong. Of course if you do explicitly set the column color fg to default in your theme then the result will not be what you expect - ideally we need an UNSPECIFIED color type instead of relying on DEFAULT.
-rw-r--r--ui-terminal-curses.c4
-rw-r--r--ui-terminal-vt100.c4
-rw-r--r--ui.h2
-rw-r--r--vis.c7
4 files changed, 16 insertions, 1 deletions
diff --git a/ui-terminal-curses.c b/ui-terminal-curses.c
index 59f5bc3..e5ab853 100644
--- a/ui-terminal-curses.c
+++ b/ui-terminal-curses.c
@@ -289,3 +289,7 @@ static void ui_curses_free(UiTerm *term) {
ui_curses_suspend(term);
endwin();
}
+
+bool is_default_color(CellColor c) {
+ return c == CELL_COLOR_DEFAULT;
+}
diff --git a/ui-terminal-vt100.c b/ui-terminal-vt100.c
index b584276..3ef2740 100644
--- a/ui-terminal-vt100.c
+++ b/ui-terminal-vt100.c
@@ -215,3 +215,7 @@ static void ui_vt100_free(UiTerm *tui) {
ui_vt100_suspend(tui);
buffer_release(&vtui->buf);
}
+
+bool is_default_color(CellColor c) {
+ return c.index == ((CellColor) CELL_COLOR_DEFAULT).index;
+}
diff --git a/ui.h b/ui.h
index 786fdfb..4ee4589 100644
--- a/ui.h
+++ b/ui.h
@@ -115,4 +115,6 @@ struct UiWin {
int (*window_height)(UiWin*);
};
+bool is_default_color(CellColor c);
+
#endif
diff --git a/vis.c b/vis.c
index 3cca4fa..72447a1 100644
--- a/vis.c
+++ b/vis.c
@@ -27,6 +27,8 @@
#include "util.h"
#include "vis-core.h"
#include "sam.h"
+#include "ui.h"
+
static void macro_replay(Vis *vis, const Macro *macro);
static void macro_replay_internal(Vis *vis, const Macro *macro);
@@ -294,7 +296,10 @@ static void window_draw_colorcolumn(Win *win) {
/* This screen line contains the cell we want to highlight */
if (cc <= line_cols + width) {
- l->cells[(cc - 1) - line_cols].style = style;
+ CellStyle *orig = &l->cells[cc - 1 - line_cols].style;
+ orig->attr = style.attr;
+ orig->fg = is_default_color(style.fg) ? orig->fg : style.fg;
+ orig->bg = is_default_color(style.bg) ? orig->bg : style.bg;
line_cc_set = true;
} else {
line_cols += width;