jszakmeister / vim-togglecursor

Toggle the cursor shape in the terminal for Vim.
http://www.vim.org/scripts/script.php?script_id=4403
119 stars 20 forks source link

Mouse appears in insert mode when running under tmux #40

Open ddickstein opened 6 years ago

ddickstein commented 6 years ago

I'm using gnome-terminal inside tmux (I ended up manually setting s:supported_terminal to 'xterm') and when I enter insert mode my mouse cursor appears as the text cursor changes to a vertical bar. When I return to normal mode and begin to navigate, my mouse cursor disappears. When using vim I would prefer my mouse to remain hidden at all times unless I move it, so this is a bit distracting. Why is it appearing and how can I keep it hidden?

jszakmeister commented 6 years ago

@ddickstein Honestly, I don't know. Off the cuff, it sounds like a bug in gnome-terminal to me or possibly some interaction with tmux. The only vim-togglecursor does is emit a sequence that allows the necessary escape sequence to pass on through and change the terminal.

FWIW, I don't love this solution as tmux has a way to do cursor overrides, but I haven't sat down to really investigate it yet (see https://github.com/sjl/vitality.vim/issues/8#issuecomment-7791852, but it's an iTerm specific solution and would require modifying your tmux config).

ddickstein commented 6 years ago

I tried using xfce4-terminal and encountered the same issue, so it seems more probable that there's something off either in the sequence emitted or in the way tmux interprets the sequence, rather than a terminal-specific problem.

I'm on a Linux machine so iTerm isn't an option.

ddickstein commented 6 years ago

I'd like to loop in the tmux developers with info about the terminal sequence that's being emitted so we can figure out if it's the right one or if it's a tmux bug.

jszakmeister commented 6 years ago

I'm on a Linux machine so iTerm isn't an option.

I wasn't suggesting it... I was advocating another way of making it worked based on what was done there. You'd have to adapt it to work with gnome-terminal. It is a tmux-specific solution to the problem, not a vim-togglecursor one though (and that may really be where the problem needs to be solved).

I'd like to loop in the tmux developers with info about the terminal sequence that's being emitted so we can figure out if it's the right one or if it's a tmux bug.

The escape sequences are here. gnome-terminal uses VTE under the hood, so it uses the standard DECSCUSR sequences. The only caveat is that by default under tmux, I wrap the sequence using this function, which also escapes the escape sequences. It's pretty straight-forward... the only real magic is trying to determine which sequence to use. :-)

Hope that helps.