-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mouse not works in builtin terminal for ncurses app #21106
Comments
It seems that when |
From
From
So it indeed seems to be |
a bit off-topic, i'm amazed by your debugging skill, could you share how you know |
I was just using |
confirmed.
I saw centos 7 does not has tmux-256color terminfo. oh i see, maybe libvterm uses its own xterm-256color terminfo which does not match the one provided by the system? |
libvterm itself by default does not seem to set |
that explains why the TERM workaround works in some terminal emulators for nnn used by nnn.nvim, while in some other terminals, it does not. eg. xterm, konsole. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Do not suggest as a workaround an improper method that sets A more appropriate workaround is to send a sequence that enables mouse input before invoking function nnn() {
printf "\x1b[?1000h"
/usr/bin/nnn ${1+"$@"}
printf "\x1b[?1000l"
} |
Regardless of the host terminal, neovim terminals always behave like It is clear from the following code that vim inherits Ref. https://github.com/vim/vim/blob/ce30ccc06af7f2c03762e5b18dde37b26ea6ec42/src/os_unix.c#L5638-L5640 // Use 'term' or $TERM if it starts with "xterm", otherwise fall
// back to "xterm" or "xterm-color".
if (term == NULL || *term == NUL || STRNCMP(term, "xterm", 5) != 0) |
Yep. Makes no sense for :terminal to claim it is some other $TERM (except perhaps something custom like Child processes can check |
Isn't correct solution to claim |
This issue has been mentioned on Neovim Discourse. There might be relevant details there: |
For terminal progams this has to be setted:
But for for the actual terminal, to enable mouse support one must
Then to make the mouse work on neovim one must
All this work, but it is super hackish. What if we make a neovim option to do all this stuff for the user? I don't think the average user is gonna be willing to go through all of this just to have mouse support. The issue is this may not work for all terminals, but most modern terminals are xterm-256color, so it should be fine. I can think 3 solutions to this border case:
|
Applying the following patch to libvterm may fix this issue: diff --git a/src/libvterm/src/state.c b/src/libvterm/src/state.c
index ee4482469..478b1317c 100644
--- a/src/libvterm/src/state.c
+++ b/src/libvterm/src/state.c
@@ -1370,8 +1370,9 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
break;
case LEADER('?', 0x68): // DEC private mode set
- if(!CSI_ARG_IS_MISSING(args[0]))
- set_dec_mode(state, CSI_ARG(args[0]), 1);
+ for (int i = 0; i < argcount; i++)
+ if(!CSI_ARG_IS_MISSING(args[i]))
+ set_dec_mode(state, CSI_ARG(args[i]), 1);
break;
case 0x6a: // HPB - ECMA-48 8.3.58
@@ -1392,8 +1393,9 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
break;
case LEADER('?', 0x6c): // DEC private mode reset
- if(!CSI_ARG_IS_MISSING(args[0]))
- set_dec_mode(state, CSI_ARG(args[0]), 0);
+ for (int i = 0; i < argcount; i++)
+ if(!CSI_ARG_IS_MISSING(args[i]))
+ set_dec_mode(state, CSI_ARG(args[i]), 0);
break;
case 0x6d: // SGR - ECMA-48 8.3.117 But I don't know if this change is desired. |
Works for me using extra/neovim and AUR neovim-git packages. If you are using AUR neovim-nightly-bin then it will not work. |
Neovim version (nvim -v)
NVIM v0.8.0
Vim (not Nvim) behaves the same?
not tested
Operating system/version
archlinux
Terminal name/version
xterm 375
$TERM environment variable
in xterm it is
xterm
, in nvim terminal it isxterm-256color
Installation
system package manager
How to reproduce the issue
$ xterm
$ nvim --clean +'terminal nnn'
# https://github.com/jarun/nnn$ nvim --clean +'terminal tig'
# https://github.com/jonas/tigExpected behavior
mouse works in nvim's builtin terminal for ncurses app;
Actual behavior
mouse left, right click and scroll up, down do not work as expected, and the two programs are ncurses based.
if I run them in xterm directly, the mouse works well.
more tests
If i do as this, then the mouse works well:
$ xterm
$ echo '\x1b[?1002h
# now we are in nvim's builtin terminal$ nnn
The text was updated successfully, but these errors were encountered: