mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
feat(api): add "move" to nvim_input_mouse
This commit is contained in:
parent
04bd700ac3
commit
ceb09701f2
@ -1067,9 +1067,11 @@ nvim_input_mouse({button}, {action}, {modifier}, {grid}, {row}, {col})
|
|||||||
|api-fast|
|
|api-fast|
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{button} Mouse button: one of "left", "right", "middle", "wheel".
|
{button} Mouse button: one of "left", "right", "middle", "wheel",
|
||||||
|
"move".
|
||||||
{action} For ordinary buttons, one of "press", "drag", "release".
|
{action} For ordinary buttons, one of "press", "drag", "release".
|
||||||
For the wheel, one of "up", "down", "left", "right".
|
For the wheel, one of "up", "down", "left", "right".
|
||||||
|
Ignored for "move".
|
||||||
{modifier} String of modifiers each represented by a single char. The
|
{modifier} String of modifiers each represented by a single char. The
|
||||||
same specifiers are used as for a key press, except that
|
same specifiers are used as for a key press, except that
|
||||||
the "-" separator is optional, so "C-A-", "c-a" and "CA"
|
the "-" separator is optional, so "C-A-", "c-a" and "CA"
|
||||||
|
@ -336,9 +336,9 @@ Integer nvim_input(String keys)
|
|||||||
/// mouse input in a GUI. The deprecated pseudokey form
|
/// mouse input in a GUI. The deprecated pseudokey form
|
||||||
/// ("<LeftMouse><col,row>") of |nvim_input()| has the same limitation.
|
/// ("<LeftMouse><col,row>") of |nvim_input()| has the same limitation.
|
||||||
///
|
///
|
||||||
/// @param button Mouse button: one of "left", "right", "middle", "wheel".
|
/// @param button Mouse button: one of "left", "right", "middle", "wheel", "move".
|
||||||
/// @param action For ordinary buttons, one of "press", "drag", "release".
|
/// @param action For ordinary buttons, one of "press", "drag", "release".
|
||||||
/// For the wheel, one of "up", "down", "left", "right".
|
/// For the wheel, one of "up", "down", "left", "right". Ignored for "move".
|
||||||
/// @param modifier String of modifiers each represented by a single char.
|
/// @param modifier String of modifiers each represented by a single char.
|
||||||
/// The same specifiers are used as for a key press, except
|
/// The same specifiers are used as for a key press, except
|
||||||
/// that the "-" separator is optional, so "C-A-", "c-a"
|
/// that the "-" separator is optional, so "C-A-", "c-a"
|
||||||
@ -365,6 +365,8 @@ void nvim_input_mouse(String button, String action, String modifier, Integer gri
|
|||||||
code = KE_RIGHTMOUSE;
|
code = KE_RIGHTMOUSE;
|
||||||
} else if (strequal(button.data, "wheel")) {
|
} else if (strequal(button.data, "wheel")) {
|
||||||
code = KE_MOUSEDOWN;
|
code = KE_MOUSEDOWN;
|
||||||
|
} else if (strequal(button.data, "move")) {
|
||||||
|
code = KE_MOUSEMOVE;
|
||||||
} else {
|
} else {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -381,7 +383,7 @@ void nvim_input_mouse(String button, String action, String modifier, Integer gri
|
|||||||
} else {
|
} else {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (code != KE_MOUSEMOVE) {
|
||||||
if (strequal(action.data, "press")) {
|
if (strequal(action.data, "press")) {
|
||||||
// pass
|
// pass
|
||||||
} else if (strequal(action.data, "drag")) {
|
} else if (strequal(action.data, "drag")) {
|
||||||
|
@ -1585,7 +1585,20 @@ describe('ui/mouse/input', function()
|
|||||||
eq(0, meths.get_var('mouse_up2'))
|
eq(0, meths.get_var('mouse_up2'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('feeding <MouseMove> does not use uninitialized memory #19480', function()
|
it('<MouseMove> is not translated into multiclicks and can be mapped', function()
|
||||||
|
meths.set_var('mouse_move', 0)
|
||||||
|
meths.set_var('mouse_move2', 0)
|
||||||
|
command('nnoremap <MouseMove> <Cmd>let g:mouse_move += 1<CR>')
|
||||||
|
command('nnoremap <2-MouseMove> <Cmd>let g:mouse_move2 += 1<CR>')
|
||||||
|
feed('<MouseMove><0,0>')
|
||||||
|
feed('<MouseMove><0,0>')
|
||||||
|
meths.input_mouse('move', '', '', 0, 0, 0)
|
||||||
|
meths.input_mouse('move', '', '', 0, 0, 0)
|
||||||
|
eq(4, meths.get_var('mouse_move'))
|
||||||
|
eq(0, meths.get_var('mouse_move2'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('feeding <MouseMove> in Normal mode does not use uninitialized memory #19480', function()
|
||||||
feed('<MouseMove>')
|
feed('<MouseMove>')
|
||||||
helpers.poke_eventloop()
|
helpers.poke_eventloop()
|
||||||
helpers.assert_alive()
|
helpers.assert_alive()
|
||||||
|
@ -3075,5 +3075,68 @@ describe('builtin popupmenu with ui/ext_multigrid', function()
|
|||||||
:let g:menustr = 'foo' |
|
:let g:menustr = 'foo' |
|
||||||
]]})
|
]]})
|
||||||
eq('foo', meths.get_var('menustr'))
|
eq('foo', meths.get_var('menustr'))
|
||||||
|
meths.input_mouse('right', 'press', '', 2, 0, 4)
|
||||||
|
screen:expect({grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[3:--------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
^popup menu test |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
:let g:menustr = 'foo' |
|
||||||
|
## grid 4
|
||||||
|
{n: foo }|
|
||||||
|
{n: bar }|
|
||||||
|
{n: baz }|
|
||||||
|
]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}})
|
||||||
|
meths.input_mouse('move', '', '', 2, 3, 6)
|
||||||
|
screen:expect({grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[3:--------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
^popup menu test |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
:let g:menustr = 'foo' |
|
||||||
|
## grid 4
|
||||||
|
{n: foo }|
|
||||||
|
{n: bar }|
|
||||||
|
{s: baz }|
|
||||||
|
]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}})
|
||||||
|
meths.input_mouse('left', 'press', '', 2, 2, 6)
|
||||||
|
screen:expect({grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[2:--------------------------------]|
|
||||||
|
[3:--------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
^popup menu test |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
:let g:menustr = 'bar' |
|
||||||
|
]]})
|
||||||
|
eq('bar', meths.get_var('menustr'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user