When using app-misc/mc[-slang] you cannot use your mouse (trackpad). If you click left key for example, mcedit will insert "7;6M7;6m" and when you press right key it will insert "2;3M2;2m". When using app-misc/mc[slang], you can use your mouse as expected.
Screencast showing the problem: https://dev.gentoo.org/~whissi/stuff/mc-copy-paste-problem.webm
I can confirm this weird behavior. As intermediate measure I suggest default-enabling the "slang" USE flag. What do you think Sergei?
(In reply to Lars Wendler (Polynomial-C) from comment #2) > I can confirm this weird behavior. As intermediate measure I suggest > default-enabling the "slang" USE flag. > What do you think Sergei? Sounds OK, but I think we already do it for a long while for some related reason (I vaguely remember function keys have unexpected offset): IUSE="+edit gpm nls samba sftp +slang spell test unicode X +xdg"
Looking at a specific problem '7;6M7;6m' sounds like unhandled escape. Maybe we can dig a bit where handling mismatch happens. What terminal do you both use? - Which X11 terminal or linux console? - What $TERM variable? - What gpm driver is that? (Probably a /etc/conf.d/gpm value or /lib/systemd/system/gpm.service) I think it should only be used for linux console, but i'm not sure.
(In reply to Sergei Trofimovich from comment #4) > Looking at a specific problem '7;6M7;6m' sounds like unhandled escape. > > Maybe we can dig a bit where handling mismatch happens. > > What terminal do you both use? > - Which X11 terminal or linux console? kde-apps/konsole > - What $TERM variable? xterm-256color > - What gpm driver is that? (Probably a /etc/conf.d/gpm value or > /lib/systemd/system/gpm.service) I think it should only be used for linux > console, but i'm not sure. sys-libs/gpm is not installed here Some additional notes: I can see even more escape sequences being "pasted" into mcedit by holding the left mouse button pressed inside mcedit and then start moving the mouse. This "auto-activates" constant escape sequence pasting even when I depress left mouse button again.
Aha, thank you! Reproduced locally as well. I was confused by tmux being able to translate ncurses into something that works. Running mc on top of terminal shows the problem. Looking.
The bug seems to be in the code that attemts to distinct between X10 (old simple mode, enabled by "\e[?9h") and XTERM (extended mode, enabled by "\e[?1000h"). It looks like xterm does not support X10 mode, And yet mc thinks it does and tries to handle the keys: Both `xmouse_seq` and `xmouse_extended_seq` are initialized at: /* There's only one termcap entry "kmous", typically containing "\E[M" or "\E[<". * We need the former in xmouse_seq, the latter in xmouse_extended_seq. * See tickets 2956, 3954, and 4063 for details. */ if (xmouse_seq != NULL) { if (strcmp (xmouse_seq, ESC_STR "[<") == 0) xmouse_seq = ESC_STR "[M"; xmouse_extended_seq = ESC_STR "[<"; } This hack restores the mouse support. I'll file upstream bug. $ git diff | cat diff --git a/lib/tty/key.c b/lib/tty/key.c index 4abfc71d7..22769871e 100644 --- a/lib/tty/key.c +++ b/lib/tty/key.c @@ -2124,8 +2124,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) gboolean extended = c == MCKEY_EXTENDED_MOUSE; #ifdef KEY_MOUSE - extended = extended || (c == KEY_MOUSE && xmouse_seq == NULL - && xmouse_extended_seq != NULL); + extended = extended || (c == KEY_MOUSE && xmouse_extended_seq != NULL); #endif /* KEY_MOUSE */ xmouse_get_event (event, extended);
Wrong bug. My apologies
I have seen this happen in recent versions of x11-terms/xterm as well as in x11-terms/gnome-terminal, not in x11-terms/rxvt-unicode though. Will just merge the proposed patch - my tests suggest it helps under xterm without breaking rxvt-unicode or the USE=slang case, and this patch breaking mouse support under ncurses5 is not a problem for us.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=25aac466357a303896fa961e759488e9d4ea6eee commit 25aac466357a303896fa961e759488e9d4ea6eee Author: Marek Szuba <marecki@gentoo.org> AuthorDate: 2021-07-13 11:46:02 +0000 Commit: Marek Szuba <marecki@gentoo.org> CommitDate: 2021-07-13 11:57:41 +0000 app-misc/mc: fix mouse-key garbage output on ncurses and modern terminals While at it, bump to EAPI 8 and fix some DEPEND/BDEPEND confusion. Closes: https://bugs.gentoo.org/753578 Signed-off-by: Marek Szuba <marecki@gentoo.org> app-misc/mc/files/mc-4.8.26-ncurses-mouse.patch | 16 +++ app-misc/mc/mc-4.8.26-r3.ebuild | 125 ++++++++++++++++++++++++ 2 files changed, 141 insertions(+)