From 52471c5a76b6f4d5d87abeba48d2afae6ac0acfa Mon Sep 17 00:00:00 2001 From: hk4n Date: Sun, 28 May 2023 17:23:13 +0200 Subject: [PATCH 1/2] Add support for GNU Screen --- plugin/togglecursor.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 From 9177aa1b2c1e11caa46ea25205eb8209a6fb9d2a Mon Sep 17 00:00:00 2001 From: hk4n Date: Sun, 28 May 2023 17:45:23 +0200 Subject: [PATCH 2/2] Update documentation to reflect GNU Screen support --- doc/togglecursor.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) 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.