mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #5025 'input.c: Restore double click'
This commit is contained in:
commit
6da7d6890c
@ -4399,9 +4399,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
*'mousetime'* *'mouset'*
|
*'mousetime'* *'mouset'*
|
||||||
'mousetime' 'mouset' number (default 500)
|
'mousetime' 'mouset' number (default 500)
|
||||||
global
|
global
|
||||||
Only for GUI, Windows and Unix with xterm. Defines the maximum
|
Defines the maximum time in msec between two mouse clicks for the
|
||||||
time in msec between two mouse clicks for the second click to be
|
second click to be recognized as a multi click.
|
||||||
recognized as a multi click.
|
|
||||||
|
|
||||||
*'nrformats'* *'nf'*
|
*'nrformats'* *'nf'*
|
||||||
'nrformats' 'nf' string (default "bin,hex")
|
'nrformats' 'nf' string (default "bin,hex")
|
||||||
|
@ -266,29 +266,32 @@ static unsigned int handle_mouse_event(char **ptr, uint8_t *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int orig_num_clicks = 0;
|
static int orig_num_clicks = 0;
|
||||||
static int orig_mouse_code = 0;
|
if (mouse_code != KE_LEFTRELEASE && mouse_code != KE_RIGHTRELEASE
|
||||||
static int orig_mouse_col = 0;
|
&& mouse_code != KE_MIDDLERELEASE) {
|
||||||
static int orig_mouse_row = 0;
|
static int orig_mouse_code = 0;
|
||||||
static uint64_t orig_mouse_time = 0; // time of previous mouse click
|
static int orig_mouse_col = 0;
|
||||||
uint64_t mouse_time = os_hrtime(); // time of current mouse click
|
static int orig_mouse_row = 0;
|
||||||
|
static uint64_t orig_mouse_time = 0; // time of previous mouse click
|
||||||
|
uint64_t mouse_time = os_hrtime(); // time of current mouse click (ns)
|
||||||
|
|
||||||
// compute the time elapsed since the previous mouse click and
|
// compute the time elapsed since the previous mouse click and
|
||||||
// convert p_mouse from ms to ns
|
// convert p_mouse from ms to ns
|
||||||
uint64_t timediff = mouse_time - orig_mouse_time;
|
uint64_t timediff = mouse_time - orig_mouse_time;
|
||||||
uint64_t mouset = (uint64_t)p_mouset * 1000000;
|
uint64_t mouset = (uint64_t)p_mouset * 1000000;
|
||||||
if (mouse_code == orig_mouse_code
|
if (mouse_code == orig_mouse_code
|
||||||
&& timediff < mouset
|
&& timediff < mouset
|
||||||
&& orig_num_clicks != 4
|
&& orig_num_clicks != 4
|
||||||
&& orig_mouse_col == mouse_col
|
&& orig_mouse_col == mouse_col
|
||||||
&& orig_mouse_row == mouse_row) {
|
&& orig_mouse_row == mouse_row) {
|
||||||
orig_num_clicks++;
|
orig_num_clicks++;
|
||||||
} else {
|
} else {
|
||||||
orig_num_clicks = 1;
|
orig_num_clicks = 1;
|
||||||
|
}
|
||||||
|
orig_mouse_code = mouse_code;
|
||||||
|
orig_mouse_col = mouse_col;
|
||||||
|
orig_mouse_row = mouse_row;
|
||||||
|
orig_mouse_time = mouse_time;
|
||||||
}
|
}
|
||||||
orig_mouse_code = mouse_code;
|
|
||||||
orig_mouse_col = mouse_col;
|
|
||||||
orig_mouse_row = mouse_row;
|
|
||||||
orig_mouse_time = mouse_time;
|
|
||||||
|
|
||||||
uint8_t modifiers = 0;
|
uint8_t modifiers = 0;
|
||||||
if (orig_num_clicks == 2) {
|
if (orig_num_clicks == 2) {
|
||||||
|
@ -16,9 +16,9 @@ describe('Mouse input', function()
|
|||||||
clear()
|
clear()
|
||||||
meths.set_option('mouse', 'a')
|
meths.set_option('mouse', 'a')
|
||||||
meths.set_option('listchars', 'eol:$')
|
meths.set_option('listchars', 'eol:$')
|
||||||
-- set mouset to very high value to ensure that even in valgrind/travis,
|
-- set mousetime to very high value to ensure that even in valgrind/travis,
|
||||||
-- nvim will still pick multiple clicks
|
-- nvim will still pick multiple clicks
|
||||||
meths.set_option('mouset', 5000)
|
meths.set_option('mousetime', 5000)
|
||||||
screen = Screen.new(25, 5)
|
screen = Screen.new(25, 5)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
@ -45,7 +45,7 @@ describe('Mouse input', function()
|
|||||||
screen:detach()
|
screen:detach()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('left click moves cursor', function()
|
it('single left click moves cursor', function()
|
||||||
feed('<LeftMouse><2,1>')
|
feed('<LeftMouse><2,1>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
testing |
|
testing |
|
||||||
@ -64,6 +64,54 @@ describe('Mouse input', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('double left click enters visual mode', function()
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
screen:expect([[
|
||||||
|
{1:testin}^g |
|
||||||
|
mouse |
|
||||||
|
support and selection |
|
||||||
|
~ |
|
||||||
|
{2:-- VISUAL --} |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('triple left click enters visual line mode', function()
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
screen:expect([[
|
||||||
|
^t{1:esting}{3: } |
|
||||||
|
mouse |
|
||||||
|
support and selection |
|
||||||
|
~ |
|
||||||
|
{2:-- VISUAL LINE --} |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('quadruple left click enters visual block mode', function()
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
feed('<LeftMouse><0,0>')
|
||||||
|
feed('<LeftRelease><0,0>')
|
||||||
|
screen:expect([[
|
||||||
|
^testing |
|
||||||
|
mouse |
|
||||||
|
support and selection |
|
||||||
|
~ |
|
||||||
|
{2:-- VISUAL BLOCK --} |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
describe('tabline', function()
|
describe('tabline', function()
|
||||||
local tab_attrs = {
|
local tab_attrs = {
|
||||||
tab = { background=Screen.colors.LightGrey, underline=true },
|
tab = { background=Screen.colors.LightGrey, underline=true },
|
||||||
|
Loading…
Reference in New Issue
Block a user