Vim: Support xterm focus tracking

Created on 29 Jan 2016  路  5Comments  路  Source: vim/vim

:help FocusGained says "Only for the GUI version and a few console versions where this can be detected."

xterm supports this: CSI ? 1004 h enables focus tracking (1, 2), which then sends CSI I for FocusGained and CSI O for FocusLost.

gnome-terminal supports this.

I'd like vim to support this as well.

enhancement patch

Most helpful comment

patch version 3:
https://gist.github.com/saitoha/a013bdfebe368cf1e0306a66b75621f4

  • prevent strlen overrun in add_termcode()
  • introduce new option t_fe/t_fd to disable this feature
  • set t_fe/t_fd by default only if term=xterm*

I'm glad if someone reviews it.

All 5 comments

Marius Gedminas wrote:

:help FocusGained says "Only for the GUI version and a few console
versions where this can be detected."

xterm supports this: CSI ? 1004 h enables focus tracking (1, 2), which then sends CSI I for FocusGained and CSI O for FocusLost.

gnome-terminal supports this.

I'd like vim to support this as well.

I wonder if we can just do this always or whether this would break
something. I tend to think it's OK, we can have a key sequence for it
and if someone doesn't like it making that key sequence empty would
disable it.

We could add the enable/disable sequences to t_ti/t_te or t_ks/t_ke.

There was a patch by Hayaki Saito, but I have a note that it has a
problem.

Q: How many legs does a giraffe have?
A: Eight: two in front, two behind, two on the left and two on the right

/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \
\ an exciting new programming language -- http://www.Zimbu.org ///
\ help me help AIDS victims -- http://ICCF-Holland.org ///

Hello, is the feature still considered? Is the patch in question this one https://groups.google.com/forum/#!topic/vim_dev/ASn8QqQqVe0 ?

Gregory Pakosz wrote:

Hello, is the feature still considered? Is the patch in question this
one https://groups.google.com/forum/#!topic/vim_dev/ASn8QqQqVe0 ?

It's in the todo list. Someone mentioned a problem with it.
But perhaps the second version of the patch already fixes that.

Did Adam and Eve have navels?

/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \
\ an exciting new programming language -- http://www.Zimbu.org ///
\ help me help AIDS victims -- http://ICCF-Holland.org ///

patch version 3:
https://gist.github.com/saitoha/a013bdfebe368cf1e0306a66b75621f4

  • prevent strlen overrun in add_termcode()
  • introduce new option t_fe/t_fd to disable this feature
  • set t_fe/t_fd by default only if term=xterm*

I'm glad if someone reviews it.

@saitoha I just tried your patch against vim-8.0.1542 and it doesn't apply cleanly. Do you have an updated version that applies cleanly to master?

I am trying to use vim in terminal (kitty) again after many years of gvim so that I can get working ligatures. Unfortunately I really miss vim noticing when I run a git command then switch back to vim. I seem to get burned by this a few times a day.

Was this page helpful?
0 / 5 - 0 ratings