mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1108: mouse left-right scroll is not supported in terminal window
Problem: Mouse left-right scroll is not supported in terminal window. Solution: Implement mouse codes 6 and 7. (Trygve Aaberge, closes #6363)
This commit is contained in:
57
src/mouse.c
57
src/mouse.c
@@ -2119,6 +2119,7 @@ check_termcode_mouse(
|
||||
# endif
|
||||
int mouse_code = 0; // init for GCC
|
||||
int is_click, is_drag;
|
||||
int is_release, release_is_ambiguous;
|
||||
int wheel_code = 0;
|
||||
int current_button;
|
||||
static int held_button = MOUSE_RELEASE;
|
||||
@@ -2133,7 +2134,7 @@ check_termcode_mouse(
|
||||
long timediff; // elapsed time in msec
|
||||
# endif
|
||||
|
||||
is_click = is_drag = FALSE;
|
||||
is_click = is_drag = is_release = release_is_ambiguous = FALSE;
|
||||
|
||||
# if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \
|
||||
|| defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE)
|
||||
@@ -2256,9 +2257,6 @@ check_termcode_mouse(
|
||||
|| key_name[0] == KS_SGR_MOUSE_RELEASE)
|
||||
mouse_code += 32;
|
||||
|
||||
if (key_name[0] == KS_SGR_MOUSE_RELEASE)
|
||||
mouse_code |= MOUSE_RELEASE;
|
||||
|
||||
mouse_col = getdigits(&p) - 1;
|
||||
if (*p++ != ';')
|
||||
return -1;
|
||||
@@ -2270,6 +2268,19 @@ check_termcode_mouse(
|
||||
*modifiers = 0;
|
||||
}
|
||||
|
||||
if (key_name[0] == KS_SGR_MOUSE
|
||||
|| key_name[0] == KS_SGR_MOUSE_RELEASE)
|
||||
{
|
||||
if (key_name[0] == KS_SGR_MOUSE_RELEASE)
|
||||
is_release = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
release_is_ambiguous = TRUE;
|
||||
if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE)
|
||||
is_release = TRUE;
|
||||
}
|
||||
|
||||
if (key_name[0] == KS_MOUSE
|
||||
# ifdef FEAT_MOUSE_GPM
|
||||
|| key_name[0] == KS_GPM_MOUSE
|
||||
@@ -2331,7 +2342,7 @@ check_termcode_mouse(
|
||||
# ifdef FEAT_XCLIPBOARD
|
||||
else if (!(mouse_code & MOUSE_DRAG & ~MOUSE_CLICK_MASK))
|
||||
{
|
||||
if ((mouse_code & MOUSE_RELEASE) == MOUSE_RELEASE)
|
||||
if (is_release)
|
||||
stop_xterm_trace();
|
||||
else
|
||||
start_xterm_trace(mouse_code);
|
||||
@@ -2469,12 +2480,13 @@ check_termcode_mouse(
|
||||
if (button & 16) mouse_code |= MOUSE_CTRL;
|
||||
break;
|
||||
case 'u': // Button Up
|
||||
is_release = TRUE;
|
||||
if (button & 1)
|
||||
mouse_code |= MOUSE_LEFT | MOUSE_RELEASE;
|
||||
mouse_code |= MOUSE_LEFT;
|
||||
if (button & 2)
|
||||
mouse_code |= MOUSE_MIDDLE | MOUSE_RELEASE;
|
||||
mouse_code |= MOUSE_MIDDLE;
|
||||
if (button & 4)
|
||||
mouse_code |= MOUSE_RIGHT | MOUSE_RELEASE;
|
||||
mouse_code |= MOUSE_RIGHT;
|
||||
if (button & 8)
|
||||
mouse_code |= MOUSE_SHIFT;
|
||||
if (button & 16)
|
||||
@@ -2598,17 +2610,20 @@ check_termcode_mouse(
|
||||
case 2: mouse_code = MOUSE_LEFT;
|
||||
WantQueryMouse = TRUE;
|
||||
break;
|
||||
case 3: mouse_code = MOUSE_RELEASE | MOUSE_LEFT;
|
||||
case 3: mouse_code = MOUSE_LEFT;
|
||||
is_release = TRUE;
|
||||
break;
|
||||
case 4: mouse_code = MOUSE_MIDDLE;
|
||||
WantQueryMouse = TRUE;
|
||||
break;
|
||||
case 5: mouse_code = MOUSE_RELEASE | MOUSE_MIDDLE;
|
||||
case 5: mouse_code = MOUSE_MIDDLE;
|
||||
is_release = TRUE;
|
||||
break;
|
||||
case 6: mouse_code = MOUSE_RIGHT;
|
||||
WantQueryMouse = TRUE;
|
||||
break;
|
||||
case 7: mouse_code = MOUSE_RELEASE | MOUSE_RIGHT;
|
||||
case 7: mouse_code = MOUSE_RIGHT;
|
||||
is_release = TRUE;
|
||||
break;
|
||||
case 8: return -1; // fourth button down
|
||||
case 9: return -1; // fourth button up
|
||||
@@ -2661,7 +2676,7 @@ check_termcode_mouse(
|
||||
break;
|
||||
|
||||
case 32: // Release
|
||||
mouse_code |= MOUSE_RELEASE;
|
||||
is_release = TRUE;
|
||||
break;
|
||||
|
||||
case 33: // Drag
|
||||
@@ -2682,6 +2697,9 @@ check_termcode_mouse(
|
||||
|
||||
// Interpret the mouse code
|
||||
current_button = (mouse_code & MOUSE_CLICK_MASK);
|
||||
if (is_release)
|
||||
current_button |= MOUSE_RELEASE;
|
||||
|
||||
if (current_button == MOUSE_RELEASE
|
||||
# ifdef FEAT_MOUSE_XTERM
|
||||
&& wheel_code == 0
|
||||
@@ -2786,15 +2804,22 @@ check_termcode_mouse(
|
||||
// Work out our pseudo mouse event. Note that MOUSE_RELEASE gets
|
||||
// added, then it's not mouse up/down.
|
||||
key_name[0] = KS_EXTRA;
|
||||
if (wheel_code != 0
|
||||
&& (wheel_code & MOUSE_RELEASE) != MOUSE_RELEASE)
|
||||
if (wheel_code != 0 && (!is_release || release_is_ambiguous))
|
||||
{
|
||||
if (wheel_code & MOUSE_CTRL)
|
||||
*modifiers |= MOD_MASK_CTRL;
|
||||
if (wheel_code & MOUSE_ALT)
|
||||
*modifiers |= MOD_MASK_ALT;
|
||||
key_name[1] = (wheel_code & 1)
|
||||
? (int)KE_MOUSEUP : (int)KE_MOUSEDOWN;
|
||||
|
||||
if (wheel_code & 1 && wheel_code & 2)
|
||||
key_name[1] = (int)KE_MOUSELEFT;
|
||||
else if (wheel_code & 2)
|
||||
key_name[1] = (int)KE_MOUSERIGHT;
|
||||
else if (wheel_code & 1)
|
||||
key_name[1] = (int)KE_MOUSEUP;
|
||||
else
|
||||
key_name[1] = (int)KE_MOUSEDOWN;
|
||||
|
||||
held_button = MOUSE_RELEASE;
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user