Merge pull request #10798 from bfredl/multifix

multigrid: fixes
This commit is contained in:
Björn Linse 2019-08-18 13:52:59 +02:00 committed by GitHub
commit 9bbac874f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 53 deletions

View File

@ -292,6 +292,8 @@ numerical highlight ids to the actual attributes.
`bold`: bold text. `bold`: bold text.
`underline`: underlined text. The line has `special` color. `underline`: underlined text. The line has `special` color.
`undercurl`: undercurled text. The curl 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 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 the default value in the table, rather a sentinel value, so that

View File

@ -100,7 +100,7 @@ void raw_line(Integer grid, Integer row, Integer startcol,
void event(char *name, Array args, bool *args_consumed) void event(char *name, Array args, bool *args_consumed)
FUNC_API_NOEXPORT; FUNC_API_NOEXPORT;
void win_pos(Integer grid, Integer win, Integer startrow, void win_pos(Integer grid, Window win, Integer startrow,
Integer startcol, Integer width, Integer height) Integer startcol, Integer width, Integer height)
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
void win_float_pos(Integer grid, Window win, String anchor, Integer anchor_grid, void win_float_pos(Integer grid, Window win, String anchor, Integer anchor_grid,

View File

@ -233,6 +233,7 @@ int hl_get_underline(void)
.rgb_fg_color = -1, .rgb_fg_color = -1,
.rgb_bg_color = -1, .rgb_bg_color = -1,
.rgb_sp_color = -1, .rgb_sp_color = -1,
.hl_blend = -1,
}, },
.kind = kHlUI, .kind = kHlUI,
.id1 = 0, .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, cattrs.rgb_bg_color = rgb_blend(ratio, battrs.rgb_bg_color,
fattrs.rgb_bg_color); fattrs.rgb_bg_color);
cattrs.hl_blend = -1; // blend property was consumed
HlKind kind = *through ? kHlBlendThrough : kHlBlend; HlKind kind = *through ? kHlBlendThrough : kHlBlend;
id = get_attr_entry((HlEntry){ .attr = cattrs, .kind = kind, id = get_attr_entry((HlEntry){ .attr = cattrs, .kind = kind,
.id1 = back_attr, .id2 = front_attr }); .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; return hl;
} }

View File

@ -662,6 +662,7 @@ void terminal_get_line_attributes(Terminal *term, win_T *wp, int linenr,
.rgb_fg_color = vt_fg, .rgb_fg_color = vt_fg,
.rgb_bg_color = vt_bg, .rgb_bg_color = vt_bg,
.rgb_sp_color = -1, .rgb_sp_color = -1,
.hl_blend = -1,
}); });
} }

View File

@ -4144,14 +4144,14 @@ describe('floating windows', function()
[4:----------------------------------------]| [4:----------------------------------------]|
[4:----------------------------------------]| [4:----------------------------------------]|
:tabnew | :tabnew |
## grid 2 ## grid 2 (hidden)
x | x |
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
## grid 3 ## grid 3 (hidden)
{1:y }| {1:y }|
{2:~ }| {2:~ }|
## grid 4 ## grid 4
@ -4193,7 +4193,7 @@ describe('floating windows', function()
## grid 3 ## grid 3
{1:y }| {1:y }|
{2:~ }| {2:~ }|
## grid 4 ## grid 4 (hidden)
| |
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
@ -4223,13 +4223,13 @@ describe('floating windows', function()
[4:----------------------------------------]| [4:----------------------------------------]|
[4:----------------------------------------]| [4:----------------------------------------]|
:tabnext | :tabnext |
## grid 2 ## grid 2 (hidden)
x | x |
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
## grid 3 ## grid 3 (hidden)
{1:y }| {1:y }|
{2:~ }| {2:~ }|
## grid 4 ## grid 4
@ -4267,7 +4267,7 @@ describe('floating windows', function()
[4:----------------------------------------]| [4:----------------------------------------]|
[4:----------------------------------------]| [4:----------------------------------------]|
:tabnew | :tabnew |
## grid 2 ## grid 2 (hidden)
x | x |
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
@ -4313,7 +4313,7 @@ describe('floating windows', function()
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
## grid 4 ## grid 4 (hidden)
| |
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
@ -4333,7 +4333,7 @@ describe('floating windows', function()
[4:----------------------------------------]| [4:----------------------------------------]|
[4:----------------------------------------]| [4:----------------------------------------]|
:tabnext | :tabnext |
## grid 2 ## grid 2 (hidden)
x | x |
{0:~ }| {0:~ }|
{0:~ }| {0:~ }|
@ -4365,7 +4365,11 @@ describe('floating windows', function()
[5] = {foreground = tonumber('0x990000'), background = tonumber('0xfff1ff')}, [5] = {foreground = tonumber('0x990000'), background = tonumber('0xfff1ff')},
[6] = {foreground = tonumber('0x332533'), background = tonumber('0xfff1ff')}, [6] = {foreground = tonumber('0x332533'), background = tonumber('0xfff1ff')},
[7] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0x0000d8')}, [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([[ insert([[
Lorem ipsum dolor sit amet, consectetur Lorem ipsum dolor sit amet, consectetur
@ -4445,9 +4449,9 @@ describe('floating windows', function()
qui officia deserunt mollit anim id est | qui officia deserunt mollit anim id est |
laborum^. | laborum^. |
## grid 4 ## grid 4
{1:test }| {9:test }|
{1: }| {9: }|
{1:popup text }| {9:popup text }|
]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true} ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true}
else else
screen:expect([[ screen:expect([[
@ -4487,9 +4491,9 @@ describe('floating windows', function()
qui officia deserunt mollit anim id est | qui officia deserunt mollit anim id est |
laborum^. | laborum^. |
## grid 4 ## grid 4
{1:test }| {9:test }|
{1: }| {9: }|
{4:popup text}{1: }| {10:popup text}{9: }|
]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}} ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}}
else else
screen:expect([[ screen:expect([[
@ -4497,7 +4501,7 @@ describe('floating windows', function()
exercitation ullamco laboris nisi ut aliquip ex | exercitation ullamco laboris nisi ut aliquip ex |
ea co{2:test}{3:o consequat}. Duis aute irure dolor in | ea co{2:test}{3:o consequat}. Duis aute irure dolor in |
repre{3:henderit in vol}uptate velit esse cillum | 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 | occaecat cupidatat non proident, sunt in culpa |
qui officia deserunt mollit anim id est | qui officia deserunt mollit anim id est |
laborum^. | laborum^. |
@ -4528,9 +4532,9 @@ describe('floating windows', function()
qui officia deserunt mollit anim id est | qui officia deserunt mollit anim id est |
laborum^. | laborum^. |
## grid 4 ## grid 4
{1:test }| {9:test }|
{1: }| {9: }|
{4:popup text}{1: }| {11:popup text}{9: }|
]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true} ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true}
else else
screen:expect([[ screen:expect([[
@ -4570,9 +4574,9 @@ describe('floating windows', function()
qui officia deserunt mollit anim id est | qui officia deserunt mollit anim id est |
laborum^. | laborum^. |
## grid 4 ## grid 4
{4:popup text}{1: }| {11:popup text}{9: }|
{8:~ }| {12:~ }|
{8:~ }| {12:~ }|
]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}} ]], float_pos={[4] = {{id = 1002}, "NW", 1, 2, 5, true}}}
else else
meths.input_mouse('wheel', 'down', '', 0, 4, 7) meths.input_mouse('wheel', 'down', '', 0, 4, 7)
@ -4672,7 +4676,7 @@ describe('floating windows', function()
[2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')}, [2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')},
[3] = {bold = true, foreground = Screen.colors.Blue1}, [3] = {bold = true, foreground = Screen.colors.Blue1},
[4] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0xb282ff')}, [4] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0xb282ff')},
[5] = {background = Screen.colors.LightMagenta}, [5] = {background = Screen.colors.LightMagenta, blend=30},
}) })
if multigrid then if multigrid then
screen:expect{grid=[[ screen:expect{grid=[[

View File

@ -76,7 +76,7 @@ describe('ext_multigrid', function()
it('positions windows correctly', function() it('positions windows correctly', function()
command('vsplit') command('vsplit')
screen:expect([[ screen:expect{grid=[[
## grid 1 ## grid 1
[3:--------------------------]{12:│}[2:--------------------------]| [3:--------------------------]{12:│}[2:--------------------------]|
[3:--------------------------]{12:│}[2:--------------------------]| [3:--------------------------]{12:│}[2:--------------------------]|
@ -118,15 +118,15 @@ describe('ext_multigrid', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
]], nil, nil, function() ]], condition=function()
eq({ eq({
[2] = { win = 1000, startrow = 0, startcol = 27, width = 26, height = 12 }, [2] = { win = {id=1000}, startrow = 0, startcol = 27, width = 26, height = 12 },
[3] = { win = 1001, startrow = 0, startcol = 0, width = 26, height = 12 } [3] = { win = {id=1001}, startrow = 0, startcol = 0, width = 26, height = 12 }
}, screen.win_position) }, screen.win_position)
end) end}
command('wincmd l') command('wincmd l')
command('split') command('split')
screen:expect([[ screen:expect{grid=[[
## grid 1 ## grid 1
[3:--------------------------]{12:│}[4:--------------------------]| [3:--------------------------]{12:│}[4:--------------------------]|
[3:--------------------------]{12:│}[4:--------------------------]| [3:--------------------------]{12:│}[4:--------------------------]|
@ -168,16 +168,16 @@ describe('ext_multigrid', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
]], nil, nil, function() ]], condition=function()
eq({ eq({
[2] = { win = 1000, startrow = 7, startcol = 27, width = 26, height = 5 }, [2] = { win = {id=1000}, startrow = 7, startcol = 27, width = 26, height = 5 },
[3] = { win = 1001, startrow = 0, startcol = 0, width = 26, height = 12 }, [3] = { win = {id=1001}, startrow = 0, startcol = 0, width = 26, height = 12 },
[4] = { win = 1002, startrow = 0, startcol = 27, width = 26, height = 6 } [4] = { win = {id=1002}, startrow = 0, startcol = 27, width = 26, height = 6 }
}, screen.win_position) }, screen.win_position)
end) end}
command('wincmd h') command('wincmd h')
command('q') command('q')
screen:expect([[ screen:expect{grid=[[
## grid 1 ## grid 1
[4:-----------------------------------------------------]| [4:-----------------------------------------------------]|
[4:-----------------------------------------------------]| [4:-----------------------------------------------------]|
@ -206,12 +206,12 @@ describe('ext_multigrid', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
]], nil, nil, function() ]], condition=function()
eq({ eq({
[2] = { win = 1000, startrow = 7, startcol = 0, width = 53, height = 5 }, [2] = { win = {id=1000}, startrow = 7, startcol = 0, width = 53, height = 5 },
[4] = { win = 1002, startrow = 0, startcol = 0, width = 53, height = 6 } [4] = { win = {id=1002}, startrow = 0, startcol = 0, width = 53, height = 6 }
}, screen.win_position) }, screen.win_position)
end) end}
end) end)
describe('split', function () describe('split', function ()
@ -1206,7 +1206,7 @@ describe('ext_multigrid', function()
]]) ]])
end) end)
it('handles switich tabs', function() it('handles switch tabs', function()
command('vsp') command('vsp')
screen:expect([[ screen:expect([[
## grid 1 ## grid 1
@ -1271,7 +1271,7 @@ describe('ext_multigrid', function()
[4:-----------------------------------------------------]| [4:-----------------------------------------------------]|
{11:[No Name] }| {11:[No Name] }|
| |
## grid 2 ## grid 2 (hidden)
| |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
@ -1284,7 +1284,7 @@ describe('ext_multigrid', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
## grid 3 ## grid 3 (hidden)
| |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
@ -1328,7 +1328,7 @@ describe('ext_multigrid', function()
[4:-----------------------------------------------------]| [4:-----------------------------------------------------]|
{12:[No Name] }| {12:[No Name] }|
| |
## grid 2 ## grid 2 (hidden)
| |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
@ -1341,7 +1341,7 @@ describe('ext_multigrid', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
## grid 3 ## grid 3 (hidden)
| |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
@ -1409,13 +1409,13 @@ describe('ext_multigrid', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
## grid 4 ## grid 4 (hidden)
| |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
## grid 5 ## grid 5 (hidden)
| |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
@ -1440,7 +1440,7 @@ describe('ext_multigrid', function()
[4:-----------------------------------------------------]| [4:-----------------------------------------------------]|
{12:[No Name] }| {12:[No Name] }|
| |
## grid 2 ## grid 2 (hidden)
| |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
@ -1452,7 +1452,7 @@ describe('ext_multigrid', function()
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
## grid 3 ## grid 3 (hidden)
| |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|

View File

@ -1644,6 +1644,7 @@ describe('builtin popupmenu', function()
[42] = {foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5')}, [42] = {foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5')},
[43] = {background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f')}, [43] = {background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f')},
[44] = {foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f')}, [44] = {foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f')},
[45] = {background = Screen.colors.WebGray, blend=0},
}) })
command('syntax on') command('syntax on')
command('set mouse=a') command('set mouse=a')
@ -1761,7 +1762,7 @@ describe('builtin popupmenu', function()
Lorem ipsum d{1:ol}or sit amet, consectetur | Lorem ipsum d{1:ol}or sit amet, consectetur |
adipisicing elit, sed do eiusmod tempor | adipisicing elit, sed do eiusmod tempor |
bla bla incididunt^ | 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 | 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 | 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: }| {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|

View File

@ -316,9 +316,10 @@ local ext_keys = {
-- cmdline_block: Expected ext_cmdline block (for function definitions) -- cmdline_block: Expected ext_cmdline block (for function definitions)
-- wildmenu_items: Expected items for ext_wildmenu -- wildmenu_items: Expected items for ext_wildmenu
-- wildmenu_pos: Expected position for ext_wildmenu -- wildmenu_pos: Expected position for ext_wildmenu
function Screen:expect(expected, attr_ids, attr_ignore) function Screen:expect(expected, attr_ids, attr_ignore, ...)
local grid, condition = nil, nil local grid, condition = nil, nil
local expected_rows = {} local expected_rows = {}
assert(next({...}) == nil, "invalid args to expect()")
if type(expected) == "table" then if type(expected) == "table" then
assert(not (attr_ids ~= nil or attr_ignore ~= nil)) assert(not (attr_ids ~= nil or attr_ignore ~= nil))
local is_key = {grid=true, attr_ids=true, attr_ignore=true, condition=true, local is_key = {grid=true, attr_ids=true, attr_ignore=true, condition=true,
@ -1211,7 +1212,11 @@ function Screen:render(headers, attr_state, preview)
local rv = {} local rv = {}
for igrid,grid in pairs(self._grids) do for igrid,grid in pairs(self._grids) do
if headers then if headers then
table.insert(rv, "## grid "..igrid) local suffix = ""
if igrid > 1 and self.win_position[igrid] == nil and self.float_pos[igrid] == nil then
suffix = " (hidden)"
end
table.insert(rv, "## grid "..igrid..suffix)
end end
for i = 1, grid.height do for i = 1, grid.height do
local cursor = self._cursor.grid == igrid and self._cursor.row == i local cursor = self._cursor.grid == igrid and self._cursor.row == i
@ -1491,7 +1496,7 @@ function Screen:_equal_attrs(a, b)
a.underline == b.underline and a.undercurl == b.undercurl and a.underline == b.underline and a.undercurl == b.undercurl and
a.italic == b.italic and a.reverse == b.reverse and a.italic == b.italic and a.reverse == b.reverse and
a.foreground == b.foreground and a.background == b.background 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 end
function Screen:_equal_info(a, b) function Screen:_equal_info(a, b)