Add support for mouse buttons 8 and 9 to terminals with xterm-like mouse support (xterm, xterm2, sgr, urxvt).
This adds support for:
<X1Mouse><X2Mouse><X1Release><X2Release><X1Drag><X2Drag>Button 8 corresponds to X1, button 9 to X2.
Adds tests for these newly supported buttons, existing tests continue working.
Adds documentation mentioning the support.
https://github.com/vim/vim/pull/18719
(4 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@notuxic pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@Copilot commented on this pull request.
This PR adds support for mouse buttons 8 and 9 (X1 and X2 buttons) to terminals with xterm-like mouse support (xterm, xterm2, sgr, urxvt). Previously, these buttons were only supported on Win32 and X11 GUI environments.
Key Changes:
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vim.h | Defines MOUSESIDEBUTTONS_LOW constant (0xa0) to identify button 8-9 codes |
| src/mouse.c | Updates mouse code handling to exclude side buttons from wheel processing and adds logic to map button 8/9 to X1/X2 |
| src/testdir/test_termcodes.vim | Adds new test function Test_term_mouse_side_buttons covering various button 8/9 scenarios |
| runtime/doc/term.txt | Updates documentation to mention xterm-like terminal support for X1/X2 buttons |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
In src/testdir/test_termcodes.vim:
> + \ ["<X1Mouse>", TerminalEscapeCode(128, 1, 1, 'M')],
+ \ ["<X1Drag>", TerminalEscapeCode(128+32, 1, 1, 'M')],
+ \ ["<X2Mouse>", TerminalEscapeCode(129, 1, 1, 'M')],
+ \ ["<X2Drag>", TerminalEscapeCode(129+32, 1, 1, 'M')],
+ \ ["<S-X1Mouse>", TerminalEscapeCode(128+4, 1, 1, 'M')],
+ \ ["<S-X2Mouse>", TerminalEscapeCode(129+4, 1, 1, 'M')],
+ \ ["<M-X1Mouse>", TerminalEscapeCode(128+8, 1, 1, 'M')],
+ \ ["<M-X2Mouse>", TerminalEscapeCode(129+8, 1, 1, 'M')],
+ \ ["<C-X1Mouse>", TerminalEscapeCode(128+16, 1, 1, 'M')],
+ \ ["<C-X2Mouse>", TerminalEscapeCode(129+16, 1, 1, 'M')],
+ \ ]
+
+ for [outstr, code] in mouse_codes
+ exe "normal ggC\<C-K>" . code
+ " normal ggD
+ " call feedkeys("i\<C-K>" . code, 'Lx!')
Remove commented-out code. These lines appear to be debugging or alternative testing approaches that were left in. If they're not needed, they should be removed to keep the test clean.
⬇️ Suggested change- " call feedkeys("i\<C-K>" . code, 'Lx!')
In src/mouse.c:
> @@ -2993,7 +2997,13 @@ check_termcode_mouse(
held_button = MOUSE_RELEASE;
}
else
+ {
+#if defined(UNIX)
+ if (use_xterm_mouse() && orig_mouse_code >= MOUSESIDEBUTTONS_LOW)
+ current_button = (current_button) ? MOUSE_X2 : MOUSE_X1;
[nitpick] Consider using (orig_mouse_code & 0x01) instead of (current_button) for clarity. While the current logic is correct (relying on the LSB being preserved through the mask at line 2871), directly checking the LSB of orig_mouse_code would make the intent more explicit: button 8 (0xa0) has LSB=0 → X1, button 9 (0xa1) has LSB=1 → X2.
- current_button = (current_button) ? MOUSE_X2 : MOUSE_X1; + current_button = (orig_mouse_code & 0x01) ? MOUSE_X2 : MOUSE_X1;
In src/vim.h:
> @@ -2095,6 +2095,9 @@ typedef int sock_T; // Lowest button code for using the mouse wheel (xterm only) #define MOUSEWHEEL_LOW 0x60 +// Lowest button code for extra mouse buttons 8-11
The comment mentions "extra mouse buttons 8-11" but the implementation only adds support for buttons 8 and 9 (corresponding to X1 and X2). Consider updating the comment to "extra mouse buttons 8-9" to accurately reflect what's implemented, or clarify that 10-11 are reserved for future use.
⬇️ Suggested change-// Lowest button code for extra mouse buttons 8-11 +// Lowest button code for extra mouse buttons 8-9
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
thanks
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()