mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
feat(pum): pretend 'mousemoveevent' is set when showing right-click menu
This commit is contained in:
parent
ceb09701f2
commit
82d128405a
@ -1042,6 +1042,10 @@ void pum_show_popupmenu(vimmenu_T *menu)
|
||||
pum_scrollbar = 0;
|
||||
pum_height = pum_size;
|
||||
pum_position_at_mouse(20);
|
||||
if (!p_mousemev) {
|
||||
// Pretend 'mousemoveevent' is set.
|
||||
ui_call_option_set(STATIC_CSTR_AS_STRING("mousemoveevent"), BOOLEAN_OBJ(true));
|
||||
}
|
||||
|
||||
pum_selected = -1;
|
||||
pum_first = 0;
|
||||
@ -1102,6 +1106,9 @@ void pum_show_popupmenu(vimmenu_T *menu)
|
||||
|
||||
xfree(array);
|
||||
pum_undisplay(true);
|
||||
if (!p_mousemev) {
|
||||
ui_call_option_set(STATIC_CSTR_AS_STRING("mousemoveevent"), BOOLEAN_OBJ(false));
|
||||
}
|
||||
}
|
||||
|
||||
void pum_make_popup(const char *path_name, int use_mouse_pos)
|
||||
|
@ -21,6 +21,7 @@ local nvim_set = helpers.nvim_set
|
||||
local ok = helpers.ok
|
||||
local read_file = helpers.read_file
|
||||
local funcs = helpers.funcs
|
||||
local meths = helpers.meths
|
||||
|
||||
if helpers.pending_win32(pending) then return end
|
||||
|
||||
@ -666,6 +667,57 @@ describe('TUI', function()
|
||||
]], attrs)
|
||||
end)
|
||||
|
||||
it('mouse events work with right-click menu', function()
|
||||
child_session:request('nvim_command', [[
|
||||
call setline(1, 'popup menu test')
|
||||
set mouse=a mousemodel=popup
|
||||
|
||||
aunmenu PopUp
|
||||
menu PopUp.foo :let g:menustr = 'foo'<CR>
|
||||
menu PopUp.bar :let g:menustr = 'bar'<CR>
|
||||
menu PopUp.baz :let g:menustr = 'baz'<CR>
|
||||
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
|
||||
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
|
||||
]])
|
||||
local attrs = screen:get_default_attr_ids()
|
||||
attrs[11] = {underline = true, reverse = true}
|
||||
attrs[12] = {underline = true, reverse = true, bold = true}
|
||||
meths.input_mouse('right', 'press', '', 0, 0, 4)
|
||||
screen:expect([[
|
||||
{1:p}opup menu test |
|
||||
{4:~ }{11: foo }{4: }|
|
||||
{4:~ }{11: bar }{4: }|
|
||||
{4:~ }{11: baz }{4: }|
|
||||
{5:[No Name] [+] }|
|
||||
|
|
||||
{3:-- TERMINAL --} |
|
||||
]], attrs)
|
||||
meths.input_mouse('right', 'release', '', 0, 0, 4)
|
||||
screen:expect_unchanged()
|
||||
meths.input_mouse('move', '', '', 0, 3, 6)
|
||||
screen:expect([[
|
||||
{1:p}opup menu test |
|
||||
{4:~ }{11: foo }{4: }|
|
||||
{4:~ }{11: bar }{4: }|
|
||||
{4:~ }{12: baz }{4: }|
|
||||
{5:[No Name] [+] }|
|
||||
|
|
||||
{3:-- TERMINAL --} |
|
||||
]], attrs)
|
||||
meths.input_mouse('left', 'press', '', 0, 2, 6)
|
||||
screen:expect([[
|
||||
{1:p}opup menu test |
|
||||
{4:~ }|
|
||||
{4:~ }|
|
||||
{4:~ }|
|
||||
{5:[No Name] [+] }|
|
||||
:let g:menustr = 'bar' |
|
||||
{3:-- TERMINAL --} |
|
||||
]], attrs)
|
||||
meths.input_mouse('left', 'release', '', 0, 2, 6)
|
||||
screen:expect_unchanged()
|
||||
end)
|
||||
|
||||
it('paste: Insert mode', function()
|
||||
-- "bracketed paste"
|
||||
feed_data('i""\027i\027[200~')
|
||||
|
@ -2839,6 +2839,7 @@ describe('builtin popupmenu', function()
|
||||
:let g:menustr = 'foo' |
|
||||
]])
|
||||
eq('foo', meths.get_var('menustr'))
|
||||
eq(false, screen.options.mousemoveevent)
|
||||
feed('<RightMouse><4,0>')
|
||||
screen:expect([[
|
||||
^popup menu test |
|
||||
@ -2848,6 +2849,7 @@ describe('builtin popupmenu', function()
|
||||
{1:~ }|
|
||||
:let g:menustr = 'foo' |
|
||||
]])
|
||||
eq(true, screen.options.mousemoveevent)
|
||||
feed('<MouseMove><6,3>')
|
||||
screen:expect([[
|
||||
^popup menu test |
|
||||
@ -2857,6 +2859,7 @@ describe('builtin popupmenu', function()
|
||||
{1:~ }|
|
||||
:let g:menustr = 'foo' |
|
||||
]])
|
||||
eq(true, screen.options.mousemoveevent)
|
||||
feed('<LeftMouse><6,2>')
|
||||
screen:expect([[
|
||||
^popup menu test |
|
||||
@ -2866,6 +2869,7 @@ describe('builtin popupmenu', function()
|
||||
{1:~ }|
|
||||
:let g:menustr = 'bar' |
|
||||
]])
|
||||
eq(false, screen.options.mousemoveevent)
|
||||
eq('bar', meths.get_var('menustr'))
|
||||
end)
|
||||
end)
|
||||
@ -3075,6 +3079,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function()
|
||||
:let g:menustr = 'foo' |
|
||||
]]})
|
||||
eq('foo', meths.get_var('menustr'))
|
||||
eq(false, screen.options.mousemoveevent)
|
||||
meths.input_mouse('right', 'press', '', 2, 0, 4)
|
||||
screen:expect({grid=[[
|
||||
## grid 1
|
||||
@ -3097,6 +3102,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function()
|
||||
{n: bar }|
|
||||
{n: baz }|
|
||||
]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}})
|
||||
eq(true, screen.options.mousemoveevent)
|
||||
meths.input_mouse('move', '', '', 2, 3, 6)
|
||||
screen:expect({grid=[[
|
||||
## grid 1
|
||||
@ -3119,6 +3125,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function()
|
||||
{n: bar }|
|
||||
{s: baz }|
|
||||
]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}})
|
||||
eq(true, screen.options.mousemoveevent)
|
||||
meths.input_mouse('left', 'press', '', 2, 2, 6)
|
||||
screen:expect({grid=[[
|
||||
## grid 1
|
||||
@ -3137,6 +3144,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function()
|
||||
## grid 3
|
||||
:let g:menustr = 'bar' |
|
||||
]]})
|
||||
eq(false, screen.options.mousemoveevent)
|
||||
eq('bar', meths.get_var('menustr'))
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user