diff --git a/doc/togglecursor.txt b/doc/togglecursor.txt index 7149769..ab82d60 100644 --- a/doc/togglecursor.txt +++ b/doc/togglecursor.txt @@ -74,6 +74,17 @@ tmux has supported the ability to directly change the cursor for some time now. If you're using an old version that cannot handle this, then you can enable the old escaping behavior. This shouldn't be necessary with modern tmux. + *togglecursor_enable_gnu_screen_escaping* +Enables GNU Screen support by checking if the 'STY' environment variable is set. +When turned on, the cursor toggle should behave as expected both within a screen +session and when exiting screen. + +To turn it on, you can set the g:togglecursor_enable_gnu_screen_escaping +to a non-zero value in your vimrc: > + + let g:togglecursor_enable_gnu_screen_escaping = 1 +< + *togglecursor_disable_neovim* Note: This option is no longer supported. Neovim adopted a different mechanism for enabling the cursor, so this is no longer necessary. diff --git a/plugin/togglecursor.vim b/plugin/togglecursor.vim index 09b3764..ec9053c 100644 --- a/plugin/togglecursor.vim +++ b/plugin/togglecursor.vim @@ -127,6 +127,15 @@ else let s:in_tmux = 0 endif +if !exists("g:togglecursor_enable_gnu_screen_escaping") + let g:togglecursor_enable_gnu_screen_escaping = 0 +endif + +if g:togglecursor_enable_gnu_screen_escaping + let s:in_gnu_screen = exists("$STY") +else + let s:in_gnu_screen = 0 +endif " ------------------------------------------------------------- " Functions @@ -138,6 +147,11 @@ function! s:TmuxEscape(line) return "\Ptmux;" . escaped_line . "\\\" endfunction +function! s:GnuScreenEscape(line) + let escaped_line = substitute(a:line, "\", "\eP\e", 'g') + return escaped_line . "\e\\" +endfunction + function! s:SupportedTerminal() if s:supported_terminal == '' return 0 @@ -157,6 +171,10 @@ function! s:GetEscapeCode(shape) return s:TmuxEscape(l:escape_code) endif + if s:in_gnu_screen + return s:GnuScreenEscape(l:escape_code) + endif + return l:escape_code endfunction