Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/togglecursor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions plugin/togglecursor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -138,6 +147,11 @@ function! s:TmuxEscape(line)
return "\<Esc>Ptmux;" . escaped_line . "\<Esc>\\"
endfunction

function! s:GnuScreenEscape(line)
let escaped_line = substitute(a:line, "\<Esc>", "\eP\e", 'g')
return escaped_line . "\e\\"
endfunction

function! s:SupportedTerminal()
if s:supported_terminal == ''
return 0
Expand All @@ -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

Expand Down