Skip to content

Commit 59bafc8

Browse files
habamaxchrisbra
authored andcommitted
patch 9.1.0068: Visual highlighting can still be improved
Problem: Visual highlighting can still be improved Solution: Update Visual highlighting for 8 color terminals, use uniform grey highlighting for dark and light bg (Maxim Kim) Update terminal Visual 1. Use `ctermbg=Grey ctermfg=Black` for both dark and light This uniforms Visual highlighting between default dark and light colors And should work for vim usually detecting light background for terminals with black/dark background colors. Previously used `ctermfg=White` leaks `cterm=bold` if available colors are less than 16. 2. Use `term=reverse cterm=reverse ctermbg=NONE ctermfg=NONE` for terminals reporting less than 8 colors available If the terminal has less than 8 colors, grey just doesn't work right closes: #13940 Signed-off-by: Maxim Kim <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent e1cd1fd commit 59bafc8

40 files changed

Lines changed: 83 additions & 78 deletions

src/highlight.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ static char *(highlight_init_light[]) = {
221221
CENT("SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue",
222222
"SignColumn term=standout ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue"),
223223
#endif
224-
CENT("Visual ctermbg=DarkGrey ctermfg=White",
225-
"Visual ctermbg=DarkGrey ctermfg=White guibg=LightGrey"),
224+
CENT("Visual ctermbg=Grey ctermfg=Black",
225+
"Visual ctermbg=Grey ctermfg=Black guibg=LightGrey"),
226226
#ifdef FEAT_DIFF
227227
CENT("DiffAdd term=bold ctermbg=LightBlue",
228228
"DiffAdd term=bold ctermbg=LightBlue guibg=LightBlue"),
@@ -433,8 +433,11 @@ init_highlight(
433433
for (i = 0; pp[i] != NULL; ++i)
434434
do_highlight((char_u *)pp[i], reset, TRUE);
435435

436-
// Reverse looks ugly, but grey may not work for 8 colors. Thus let it
437-
// depend on the number of colors available.
436+
// Reverse looks ugly, but grey may not work for less than 8 colors. Thus
437+
// let it depend on the number of colors available.
438+
if (t_colors < 8)
439+
do_highlight((char_u *)"Visual term=reverse cterm=reverse ctermbg=NONE ctermfg=NONE",
440+
FALSE, TRUE);
438441
// With 8 colors brown is equal to yellow, need to use black for Search fg
439442
// to avoid Statement highlighted text disappears.
440443
// Clear the attributes, needed when changing the t_Co value.

src/testdir/dumps/Test_balloon_eval_term_02.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
|o+0&#ffffff0|n|e| |o|n|e| |o|n|e| @38
22
|t|w|o| |t|X|o| |t|w|o| @38
3-
|t|h|r|e|e+0#ffffff16#6c6c6c255| |t|h>r+0#0000000#ffffff0|e@1| |t|h|r|e@1| @32
3+
|t|h|r|e|e+0#0000001#a8a8a8255| |t|h>r+0#0000000#ffffff0|e@1| |t|h|r|e@1| @32
44
|~+0#4040ff13&| @2| +0#0000001#ffd7ff255@17| +0#4040ff13#ffffff0@27
55
|~| @2| +0#0000001#ffd7ff255|l|i|n|e| |3| |c|o|l|u|m|n| |5|:| | +0#4040ff13#ffffff0@27
66
|~| @2| +0#0000001#ffd7ff255|e| |t|h|r|<| @10| +0#4040ff13#ffffff0@27

src/testdir/dumps/Test_cursorline_with_visualmode_01.dump

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
|a+0#ffffff16#6c6c6c255|b|c| | +0#0000000#ffffff0@70
2-
|a+0#ffffff16#6c6c6c255|b|c| | +0#0000000#ffffff0@70
3-
|a+0#ffffff16#6c6c6c255|b|c| | +0#0000000#ffffff0@70
4-
|a+0#ffffff16#6c6c6c255|b|c| | +0#0000000#ffffff0@70
5-
|a+0#ffffff16#6c6c6c255|b|c| | +0#0000000#ffffff0@70
6-
>a|b+0#ffffff16#6c6c6c255|c| | +0#0000000#ffffff0@70
1+
|a+0#0000001#a8a8a8255|b|c| | +0#0000000#ffffff0@70
2+
|a+0#0000001#a8a8a8255|b|c| | +0#0000000#ffffff0@70
3+
|a+0#0000001#a8a8a8255|b|c| | +0#0000000#ffffff0@70
4+
|a+0#0000001#a8a8a8255|b|c| | +0#0000000#ffffff0@70
5+
|a+0#0000001#a8a8a8255|b|c| | +0#0000000#ffffff0@70
6+
>a|b+0#0000001#a8a8a8255|c| | +0#0000000#ffffff0@70
77
|a|b|c| @71
88
|a|b|c| @71
99
|a|b|c| @71

src/testdir/dumps/Test_display_scroll_update_visual.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| +0#0000e05#a8a8a8255@1>f+0#0000000#ffffff0|o+0#ffffff16#6c6c6c255@1| | +0#0000000#ffffff0@53
1+
| +0#0000e05#a8a8a8255@1>f+0#0000000#ffffff0|o+0#0000001#a8a8a8255@1| | +0#0000000#ffffff0@53
22
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @54
33
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @54
44
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @54

src/testdir/dumps/Test_echowin_showmode.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
>o+0&#ffffff0|n+0#ffffff16#6c6c6c255|e| | +0#0000000#ffffff0@70
1+
>o+0&#ffffff0|n+0#0000001#a8a8a8255|e| | +0#0000000#ffffff0@70
22
|t|w|o| @71
33
|~+0#4040ff13&| @73
44
|~| @73
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
|x+0&#ffffff0@2| |y+2&#ffff4012|y+2#ffffff16#6c6c6c255@1| +0&&|z@2| | +0#0000000#ffffff0@27
2-
|x+0#ffffff16#6c6c6c255@2| |y+2&&@2| +0&&|z@2| | +0#0000000#ffffff0@27
3-
|x+0#ffffff16#6c6c6c255@2| |y+2&&>y+2#0000000#ffff4012@1| +0&#ffffff0|z@2| @28
1+
|x+0&#ffffff0@2| |y+2&#ffff4012|y+2#0000001#a8a8a8255@1| +0&&|z@2| | +0#0000000#ffffff0@27
2+
|x+0#0000001#a8a8a8255@2| |y+2&&@2| +0&&|z@2| | +0#0000000#ffffff0@27
3+
|x+0#0000001#a8a8a8255@2| |y+2&&>y+2#0000000#ffff4012@1| +0&#ffffff0|z@2| @28
44
|~+0#4040ff13&| @38
55
|~| @38
66
|-+2#0000000&@1| |V|I|S|U|A|L| |-@1|3+0&&| @8|3|,|6| @10|A|l@1|

src/testdir/dumps/Test_popup_command_03.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
|o+0&#ffffff0|n|e| |t|w|o| |t|h|r|e@1| |f|o|u|r| |f|i|v|e| @51
2-
|a|n|d| |o|n|e| |t|w|o| |X+0#ffffff16#6c6c6c255|t|h|r|e@1> +0#0000000#ffffff0|f|o|u|r| |f|i|v|e| @46
2+
|a|n|d| |o|n|e| |t|w|o| |X+0#0000001#a8a8a8255|t|h|r|e@1> +0#0000000#ffffff0|f|o|u|r| |f|i|v|e| @46
33
|o|n|e| |m|o|r|e| |t|w|o| |t|h|r|e@1| |f|o|u|r| |f|i|v|e| @46
44
|~+0#4040ff13&| @73
55
|~| @73

src/testdir/dumps/Test_prop_inserts_text_1.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
|i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| |t|e|x|t| |S+0#ffffff16#e000002|O|M|E| |h+0#0000000#ffffff0|e|r|e| |a|n|d| |o|t|h|e|r| |t|e|x|t| |O+0&#ffff4012|T|H|E|R| |t+0&#ffffff0|h|e|r|e| |a|n|d| |s|o
22
|m|e| |m|o|r|e| |t|e|x|t| |a|f|t|e|r| |M+0&#5fd7ff255|O|R|E| |w+0&#ffffff0|r|a|p@1|i|n>g| @27
3-
|p|r|e|s+0#ffffff16#6c6c6c255|ö|m|e|和*&|平|t+&|é|x|t|p+0#0000000#ffffff0|o|s|t| @40
3+
|p|r|e|s+0#0000001#a8a8a8255|ö|m|e|和*&|平|t+&|é|x|t|p+0#0000000#ffffff0|o|s|t| @40
44
|F|o@1| |f|o@1| |=| |{| |.+0#0000e05&|x|=|1+0#0000000&|,| |.+0#0000e05&|y|=|2+0#0000000&| |}|;| @34
55
|e+0#ffffff16#e000002|m|p|t|y| |l|i|n|e| +0#0000000#ffffff0@49
66
|l|o@1|k| |n|o| |h|i|g|h|l|i|g|h|t| @42

src/testdir/dumps/Test_prop_inserts_text_2.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| +0#0000e05#a8a8a8255@1|i+0#0000000#ffffff0|n|s|e|r|t| |s|o|m|e| |t|e|x|t| |S+0#ffffff16#e000002|O|M|E| |h+0#0000000#ffffff0|e|r|e| |a|n|d| |o|t|h|e|r| |t|e|x|t| |O+0&#ffff4012|T|H|E|R| |t+0&#ffffff0|h|e|r|e| |a|n|d|
22
| +0#0000e05#a8a8a8255@1|s+0#0000000#ffffff0|o|m|e| |m|o|r|e| |t|e|x|t| |a|f|t|e|r| |M+0&#5fd7ff255|O|R|E| |w+0&#ffffff0|r|a|p@1|i|n>g| @23
3-
| +0#0000e05#a8a8a8255@1|p+0#0000000#ffffff0|r|e|s+0#ffffff16#6c6c6c255|ö|m|e|和*&|平|t+&|é|x|t|p+0#0000000#ffffff0|o|s|t| @38
3+
| +0#0000e05#a8a8a8255@1|p+0#0000000#ffffff0|r|e|s+0#0000001#a8a8a8255|ö|m|e|和*&|平|t+&|é|x|t|p+0#0000000#ffffff0|o|s|t| @38
44
| +0#0000e05#a8a8a8255@1|F+0#0000000#ffffff0|o@1| |f|o@1| |=| |{| |.+0#0000e05&|x|=|1+0#0000000&|,| |.+0#0000e05&|y|=|2+0#0000000&| |}|;| @32
55
| +0#0000e05#a8a8a8255@1|e+0#ffffff16#e000002|m|p|t|y| |l|i|n|e| +0#0000000#ffffff0@47
66
| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|o@1|k| |n|o| |h|i|g|h|l|i|g|h|t| @40

src/testdir/dumps/Test_prop_inserts_text_3.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| +0#0000e05#a8a8a8255@1|i+0#0000000#ffffff0|n|s|e|r|t| |s|o|m|e| |t|e|x|t| |S+0#ffffff16#e000002|O|M|E| |h+0#0000000#ffffff0|e|r|e| |a|n|d| |o|t|h|e|r| |t|e|x|t| |O+0&#ffff4012|T|H|E|R| |t+0&#ffffff0|h|e|r|e| |a|n|d|
22
| +0#0000e05#a8a8a8255@1|s+0#0000000#ffffff0|o|m|e| |m|o|r|e| |t|e|x|t| |a|f|t|e|r| |M+0&#5fd7ff255|O|R|E| |w+0&#ffffff0|r|a|p@1|i|n|g| @23
3-
| +0#0000e05#a8a8a8255@1|p+0#0000000#ffffff0|r|e|s+0#ffffff16#6c6c6c255|ö|m|e|和*&|平|t+&|é|x|t|p+0#0000000#ffffff0|o|s>t| @38
3+
| +0#0000e05#a8a8a8255@1|p+0#0000000#ffffff0|r|e|s+0#0000001#a8a8a8255|ö|m|e|和*&|平|t+&|é|x|t|p+0#0000000#ffffff0|o|s>t| @38
44
| +0#0000e05#a8a8a8255@1|F+0#0000000#ffffff0|o@1| |f|o@1| |=| |{| |.+0#0000e05&|x|=|1+0#0000000&|,| |.+0#0000e05&|y|=|2+0#0000000&| |}|;| @32
55
| +0#0000e05#a8a8a8255@1|e+0#ffffff16#e000002|m|p|t|y| |l|i|n|e| +0#0000000#ffffff0@47
66
| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|o@1|k| |n|o| |h|i|g|h|l|i|g|h|t| @40

0 commit comments

Comments
 (0)