diff options
-rw-r--r-- | runtime/doc/ui.txt | 2 | ||||
-rw-r--r-- | src/nvim/highlight.c | 7 | ||||
-rw-r--r-- | src/nvim/terminal.c | 1 | ||||
-rw-r--r-- | test/functional/ui/float_spec.lua | 34 | ||||
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 2 |
6 files changed, 32 insertions, 17 deletions
diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 1440e2ac78..7d213f959b 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -292,6 +292,8 @@ numerical highlight ids to the actual attributes. `bold`: bold text. `underline`: underlined text. The line has `special` color. `undercurl`: undercurled text. The curl has `special` color. + `blend`: Blend level (0-100). Could be used by UIs to support + blending floating windows to the background. For absent color keys the default color should be used. Don't store the default value in the table, rather a sentinel value, so that diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index f11880cb2b..3a61409dfe 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -233,6 +233,7 @@ int hl_get_underline(void) .rgb_fg_color = -1, .rgb_bg_color = -1, .rgb_sp_color = -1, + .hl_blend = -1, }, .kind = kHlUI, .id1 = 0, @@ -427,6 +428,8 @@ int hl_blend_attrs(int back_attr, int front_attr, bool *through) cattrs.rgb_bg_color = rgb_blend(ratio, battrs.rgb_bg_color, fattrs.rgb_bg_color); + cattrs.hl_blend = -1; // blend property was consumed + HlKind kind = *through ? kHlBlendThrough : kHlBlend; id = get_attr_entry((HlEntry){ .attr = cattrs, .kind = kind, .id1 = back_attr, .id2 = front_attr }); @@ -614,6 +617,10 @@ Dictionary hlattrs2dict(HlAttrs ae, bool use_rgb) } } + if (ae.hl_blend > -1) { + PUT(hl, "blend", INTEGER_OBJ(ae.hl_blend)); + } + return hl; } diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 5aeea3223b..3faf6dd5bb 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -662,6 +662,7 @@ void terminal_get_line_attributes(Terminal *term, win_T *wp, int linenr, .rgb_fg_color = vt_fg, .rgb_bg_color = vt_bg, .rgb_sp_color = -1, + .hl_blend = -1, }); } diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 2d3f3b2ed0..8dfe36c799 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -4365,7 +4365,11 @@ describe('floating windows', function() [5] = {foreground = tonumber('0x990000'), background = tonumber('0xfff1ff')}, [6] = {foreground = tonumber('0x332533'), background = tonumber('0xfff1ff')}, [7] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0x0000d8')}, - [8] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1} + [8] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1}, + [9] = {background = Screen.colors.LightMagenta, blend=30}, + [10] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend=0}, + [11] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend=80}, + [12] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1, blend=30}, }) insert([[ Lorem ipsum dolor sit amet, consectetur @@ -4445,9 +4449,9 @@ describe('floating windows', function() qui officia deserunt mollit anim id est | laborum^. | ## grid 4 - {1:test }| - {1: }| - {1:popup text }| + {9:test }| + {9: }| + {9:popup text }| ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true} else screen:expect([[ @@ -4487,9 +4491,9 @@ describe('floating windows', function() qui officia deserunt mollit anim id est | laborum^. | ## grid 4 - {1:test }| - {1: }| - {4:popup text}{1: }| + {9:test }| + {9: }| + {10:popup text}{9: }| ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}} else screen:expect([[ @@ -4497,7 +4501,7 @@ describe('floating windows', function() exercitation ullamco laboris nisi ut aliquip ex | ea co{2:test}{3:o consequat}. Duis aute irure dolor in | repre{3:henderit in vol}uptate velit esse cillum | - dolor{4:popup text}{3:ul}la pariatur. Excepteur sint | + dolor{10:popup text}{3:ul}la pariatur. Excepteur sint | occaecat cupidatat non proident, sunt in culpa | qui officia deserunt mollit anim id est | laborum^. | @@ -4528,9 +4532,9 @@ describe('floating windows', function() qui officia deserunt mollit anim id est | laborum^. | ## grid 4 - {1:test }| - {1: }| - {4:popup text}{1: }| + {9:test }| + {9: }| + {11:popup text}{9: }| ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true} else screen:expect([[ @@ -4570,9 +4574,9 @@ describe('floating windows', function() qui officia deserunt mollit anim id est | laborum^. | ## grid 4 - {4:popup text}{1: }| - {8:~ }| - {8:~ }| + {11:popup text}{9: }| + {12:~ }| + {12:~ }| ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}} else meths.input_mouse('wheel', 'down', '', 0, 4, 7) @@ -4672,7 +4676,7 @@ describe('floating windows', function() [2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')}, [3] = {bold = true, foreground = Screen.colors.Blue1}, [4] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0xb282ff')}, - [5] = {background = Screen.colors.LightMagenta}, + [5] = {background = Screen.colors.LightMagenta, blend=30}, }) if multigrid then screen:expect{grid=[[ diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 9bfea28ed7..c4cfc9d8d3 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1644,6 +1644,7 @@ describe('builtin popupmenu', function() [42] = {foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5')}, [43] = {background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f')}, [44] = {foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f')}, + [45] = {background = Screen.colors.WebGray, blend=0}, }) command('syntax on') command('set mouse=a') @@ -1761,7 +1762,7 @@ describe('builtin popupmenu', function() Lorem ipsum d{1:ol}or sit amet, consectetur | adipisicing elit, sed do eiusmod tempor | bla bla incididunt^ | - incidid{22: incididunt }{27: }d{1:ol}ore magna aliqua. | + incidid{45: incididunt }{27: }d{1:ol}ore magna aliqua. | Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud | exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex | {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }| diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 517e8590a2..df0fce4199 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -1496,7 +1496,7 @@ function Screen:_equal_attrs(a, b) a.underline == b.underline and a.undercurl == b.undercurl and a.italic == b.italic and a.reverse == b.reverse and a.foreground == b.foreground and a.background == b.background and - a.special == b.special + a.special == b.special and a.blend == b.blend end function Screen:_equal_info(a, b) |