I’m asking this question while using xfce4-terminal, but I’m interested in a general solution: is there a way to stop a terminal emulator announcing mouse support in consoles? I need mouse-select and copy-paste much more frequent that I need mouse support in vim or wherever.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can hold the Shift key to use the normal mouse selection while xterm mouse-tracking is enabled. That works in all terminal emulators that I know (xterm, vte (like xfce-terminal) or rxvt-based ones).
In vim specifically, mouse is normally not enabled by default in terminals. So there’s probably a set mouse=a somewhere in you ~/.vimrc or your OS-supplied system vimrc. You can always add:
set mouse=
to your ~/.vimrc to disable it. Or:
if !has("gui_running")
set mouse=
endif
to avoid disabling it for the GUI versions of vim.
Mouse support is (sort of) advertised in the terminfo database with the kmous capability. Now, not all applications rely on that to decide whether to enable mouse tracking or not.
You could redefine the entry for your terminal (in a local terminfo database) to remove that capability:
infocmp -1x | grep -v kmous= | TERMINFO=~/.terminfo tic -x - export TERMINFO=~/.terminfo
For applications using ncurses, it’s enough to set the XM user-defined capability (not documented in terminfo(5) but mentioned in curs_caps(5) and curs_mouse(3)) to the empty string. That doesn’t prevent the application from handling mouse events if they’re sent by the terminal, but that prevents the application from sending the sequence that enters the mouse tracking mode. So you can combine both with:
infocmp -1x | sed '/kmous=/d;/XM=/d;$s/$/XM=,/' | TERMINFO=~/.terminfo tic -x - export TERMINFO=~/.terminfo
Method 2
Add the following two lines at the end of /etc/vim/vimrc :
set mouse= set ttymouse=
Method 3
I’m using this patch:
--- a/src/vteseq.cc 2020-01-25 21:39:47.737317745 +0100
+++ b/src/vteseq.cc 2020-01-25 21:40:12.811424242 +0100
@@ -462,18 +462,7 @@
void
Terminal::update_mouse_protocol() noexcept
{
- if (m_modes_private.XTERM_MOUSE_ANY_EVENT())
- m_mouse_tracking_mode = MOUSE_TRACKING_ALL_MOTION_TRACKING;
- else if (m_modes_private.XTERM_MOUSE_BUTTON_EVENT())
- m_mouse_tracking_mode = MOUSE_TRACKING_CELL_MOTION_TRACKING;
- else if (m_modes_private.XTERM_MOUSE_VT220_HIGHLIGHT())
- m_mouse_tracking_mode = MOUSE_TRACKING_HILITE_TRACKING;
- else if (m_modes_private.XTERM_MOUSE_VT220())
- m_mouse_tracking_mode = MOUSE_TRACKING_SEND_XY_ON_BUTTON;
- else if (m_modes_private.XTERM_MOUSE_X10())
- m_mouse_tracking_mode = MOUSE_TRACKING_SEND_XY_ON_CLICK;
- else
- m_mouse_tracking_mode = MOUSE_TRACKING_NONE;
+ m_mouse_tracking_mode = MOUSE_TRACKING_NONE;
m_mouse_smooth_scroll_delta = 0.0;
vte doesn’t care about my mouse anymore, so vim isn’t aware that I have one.
Method 4
In xterm/uxterm I was able to disable sending mouse position changes with this patch:
--- a/button.c
@@ -261,6 +261,7 @@ SendMousePosition(XtermWidget xw, XEvent *event)
{
XButtonEvent *my_event = (XButtonEvent *) event;
Bool result = False;
+ return False;
switch (okSendMousePos(xw)) {
case MOUSE_OFF:
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0