Merge pull request #9607 from bfredl/wildpum

UI: deprecate redundant ext_wildmenu events and allow TUI popupmenu for cmdline
This commit is contained in:
Björn Linse
2019-03-16 20:41:10 +01:00
committed by GitHub
19 changed files with 553 additions and 69 deletions

View File

@@ -600,6 +600,137 @@ local function test_cmdline(linegrid)
pos = 12,
}}}
end)
it('works together with ext_popupmenu', function()
local expected = {
{'define', '', '', ''},
{'jump', '', '', ''},
{'list', '', '', ''},
{'place', '', '', ''},
{'undefine', '', '', ''},
{'unplace', '', '', ''},
}
command('set wildmode=full')
command('set wildmenu')
screen:set_option('ext_popupmenu', true)
feed(':sign <tab>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sign define"}},
pos = 11,
}}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}}
feed('<tab>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sign jump"}},
pos = 9,
}}, popupmenu={items=expected, pos=1, anchor={-1, 0, 5}}}
feed('<left><left>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sign "}},
pos = 5,
}}, popupmenu={items=expected, pos=-1, anchor={-1, 0, 5}}}
feed('<right>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sign define"}},
pos = 11,
}}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}}
feed('a')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sign definea"}},
pos = 12,
}}}
feed('<esc>')
-- check positioning with multibyte char in pattern
command("e långfile1")
command("sp långfile2")
feed(':b lå<tab>')
screen:expect{grid=[[
^ |
{3:långfile2 }|
|
{2:långfile1 }|
|
]], popupmenu={
anchor = { -1, 0, 2 },
items = {{ "långfile1", "", "", "" }, { "långfile2", "", "", "" }},
pos = 0
}, cmdline={{
content = {{ "b långfile1" }},
firstc = ":",
pos = 12
}}}
end)
it('ext_wildmenu takes precedence over ext_popupmenu', function()
local expected = {
'define',
'jump',
'list',
'place',
'undefine',
'unplace',
}
command('set wildmode=full')
command('set wildmenu')
screen:set_option('ext_wildmenu', true)
screen:set_option('ext_popupmenu', true)
feed(':sign <tab>')
screen:expect{grid=[[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
|
]], cmdline={{
firstc = ":",
content = {{"sign define"}},
pos = 11,
}}, wildmenu_items=expected, wildmenu_pos=0}
end)
end
-- the representation of cmdline and cmdline_block contents changed with ext_linegrid

View File

@@ -1341,7 +1341,7 @@ describe('floating windows', function()
]], float_pos={
[3] = {{ id = 1001 }, "NW", 1, 2, 5, true},
}, popupmenu={
anchor = {0, 2, 3}, items = items, pos = 0
anchor = {3, 0, 2}, items = items, pos = 0
}}
else
screen:expect{grid=[[
@@ -1353,7 +1353,7 @@ describe('floating windows', function()
{0:~ }{12:~ }{0: }|
{3:-- INSERT --} |
]], popupmenu={
anchor = {2, 7}, items = items, pos = 0
anchor = {1, 2, 7}, items = items, pos = 0
}}
end
@@ -1423,7 +1423,7 @@ describe('floating windows', function()
]], float_pos={
[3] = {{ id = 1001 }, "NW", 1, 2, 5, true},
}, popupmenu={
anchor = {0, 0, 2}, items = items, pos = 0
anchor = {2, 0, 0}, items = items, pos = 0
}}
else
screen:expect{grid=[[
@@ -1435,7 +1435,7 @@ describe('floating windows', function()
{0:~ }{12:~ }{0: }|
{3:-- INSERT --} |
]], popupmenu={
anchor = {0, 0}, items = items, pos = 0
anchor = {1, 0, 0}, items = items, pos = 0
}}
end

View File

@@ -179,7 +179,7 @@ describe('ui/ext_messages', function()
{1:~ }|
{1:~ }|
]], popupmenu={
anchor = { 2, 0 },
anchor = { 1, 2, 0 },
items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
pos = 1
}, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }}
@@ -194,7 +194,7 @@ describe('ui/ext_messages', function()
{1:~ }|
{1:~ }|
]], popupmenu={
anchor = { 2, 0 },
anchor = { 1, 2, 0 },
items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
pos = 1
}, messages={ {
@@ -210,7 +210,7 @@ describe('ui/ext_messages', function()
{1:~ }|
{1:~ }|
]], popupmenu={
anchor = { 2, 0 },
anchor = { 1, 2, 0 },
items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
pos = 0
}, messages={ {

View File

@@ -50,7 +50,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=0,
anchor={1,0},
anchor={1,1,0},
}}
feed('<c-p>')
@@ -66,7 +66,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=-1,
anchor={1,0},
anchor={1,1,0},
}}
-- down moves the selection in the menu, but does not insert anything
@@ -83,7 +83,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=1,
anchor={1,0},
anchor={1,1,0},
}}
feed('<cr>')
@@ -113,7 +113,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=0,
anchor={1,0},
anchor={1,1,0},
}}
meths.select_popupmenu_item(1,false,false,{})
@@ -129,7 +129,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=1,
anchor={1,0},
anchor={1,1,0},
}}
meths.select_popupmenu_item(2,true,false,{})
@@ -145,7 +145,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=2,
anchor={1,0},
anchor={1,1,0},
}}
meths.select_popupmenu_item(0,true,true,{})
@@ -174,7 +174,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=0,
anchor={1,0},
anchor={1,1,0},
}}
meths.select_popupmenu_item(-1,false,false,{})
@@ -190,7 +190,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=-1,
anchor={1,0},
anchor={1,1,0},
}}
meths.select_popupmenu_item(1,true,false,{})
@@ -206,7 +206,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=1,
anchor={1,0},
anchor={1,1,0},
}}
meths.select_popupmenu_item(-1,true,false,{})
@@ -222,7 +222,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=-1,
anchor={1,0},
anchor={1,1,0},
}}
meths.select_popupmenu_item(0,true,false,{})
@@ -238,7 +238,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=0,
anchor={1,0},
anchor={1,1,0},
}}
meths.select_popupmenu_item(-1,true,true,{})
@@ -269,7 +269,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=0,
anchor={1,0},
anchor={1,1,0},
}}
feed('<f1>')
@@ -285,7 +285,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=2,
anchor={1,0},
anchor={1,1,0},
}}
feed('<f2>')
@@ -301,7 +301,7 @@ describe('ui/ext_popupmenu', function()
]], popupmenu={
items=expected,
pos=-1,
anchor={1,0},
anchor={1,1,0},
}}
feed('<f3>')
@@ -366,6 +366,113 @@ describe('ui/ext_popupmenu', function()
{2:-- INSERT --} |
]])
end)
it('works with wildoptions=pum', function()
screen:try_resize(32,10)
command('set wildmenu')
command('set wildoptions=pum')
local wild_expected = {
{'define', '', '', ''},
{'jump', '', '', ''},
{'list', '', '', ''},
{'place', '', '', ''},
{'undefine', '', '', ''},
{'unplace', '', '', ''},
}
feed(':sign ')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
:sign ^ |
]])
feed('<tab>')
screen:expect{grid=[[
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
:sign define^ |
]], popupmenu={items=wild_expected, pos=0, anchor={1, 9, 6}}}
feed('<left>')
screen:expect{grid=[[
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
:sign ^ |
]], popupmenu={items=wild_expected, pos=-1, anchor={1, 9, 6}}}
feed('<left>')
screen:expect{grid=[[
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
:sign unplace^ |
]], popupmenu={items=wild_expected, pos=5, anchor={1, 9, 6}}}
feed('x')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
:sign unplacex^ |
]])
feed('<esc>')
-- check positioning with multibyte char in pattern
command("e långfile1")
command("sp långfile2")
feed(':b lå<tab>')
screen:expect{grid=[[
|
{1:~ }|
{1:~ }|
{1:~ }|
{4:långfile2 }|
|
{1:~ }|
{1:~ }|
{3:långfile1 }|
:b långfile1^ |
]], popupmenu={
anchor = {1, 9, 3},
items = {{"långfile1", "", "", "" }, {"långfile2", "", "", ""}},
pos = 0,
}}
end)
end)
@@ -1209,7 +1316,7 @@ describe('builtin popupmenu', function()
]])
meths.input_mouse('wheel', 'down', '', 0, 6, 15)
screen:expect([[
screen:expect{grid=[[
choice^ |
{1:~ }|
{n:word }{1: }|
@@ -1218,7 +1325,7 @@ describe('builtin popupmenu', function()
{n:thing }{1: }|
{3:[No Name] [+] }|
{2:-- INSERT --} |
]])
]], unchanged=true}
end)
it('works with kind, menu and abbr attributes', function()
@@ -1273,6 +1380,131 @@ describe('builtin popupmenu', function()
]])
end)
it('works with wildoptions=pum', function()
screen:try_resize(32,10)
command('set wildmenu')
command('set wildoptions=pum')
feed(':sign ')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
:sign ^ |
]])
feed('<tab>')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }{s: define }{1: }|
{1:~ }{n: jump }{1: }|
{1:~ }{n: list }{1: }|
{1:~ }{n: place }{1: }|
{1:~ }{n: undefine }{1: }|
{1:~ }{n: unplace }{1: }|
:sign define^ |
]])
feed('<left>')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }{n: define }{1: }|
{1:~ }{n: jump }{1: }|
{1:~ }{n: list }{1: }|
{1:~ }{n: place }{1: }|
{1:~ }{n: undefine }{1: }|
{1:~ }{n: unplace }{1: }|
:sign ^ |
]])
feed('<left>')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }{n: define }{1: }|
{1:~ }{n: jump }{1: }|
{1:~ }{n: list }{1: }|
{1:~ }{n: place }{1: }|
{1:~ }{n: undefine }{1: }|
{1:~ }{s: unplace }{1: }|
:sign unplace^ |
]])
feed('x')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
:sign unplacex^ |
]])
feed('<esc>')
-- check positioning with multibyte char in pattern
command("e långfile1")
command("sp långfile2")
feed(':b lå<tab>')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }|
{4:långfile2 }|
|
{1:~ }|
{1:~ }{s: långfile1 }{1: }|
{3:lå}{n: långfile2 }{3: }|
:b långfile1^ |
]])
-- check doesn't crash on screen resize
screen:try_resize(20,6)
screen:expect([[
|
{1:~ }|
{4:långfile2 }|
{s: långfile1 } |
{3:lå}{n: långfile2 }{3: }|
:b långfile1^ |
]])
screen:try_resize(50,15)
screen:expect([[
|
{1:~ }|
{4:långfile2 }|
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }{s: långfile1 }{1: }|
{3:lå}{n: långfile2 }{3: }|
:b långfile1^ |
]])
end)
it("'pumblend' RGB-color", function()
screen:try_resize(60,14)
screen:set_default_attr_ids({

View File

@@ -937,10 +937,7 @@ function Screen:_handle_option_set(name, value)
end
function Screen:_handle_popupmenu_show(items, selected, row, col, grid)
if (not self._options.ext_multigrid) and grid == 1 then
grid = nil
end
self.popupmenu = {items=items, pos=selected, anchor={row, col, grid}}
self.popupmenu = {items=items, pos=selected, anchor={grid, row, col}}
end
function Screen:_handle_popupmenu_select(selected)