From d1c7f1b4ee2672f0a1ed385cd8d887914d8372d0 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Tue, 6 Oct 2009 11:08:26 +0100 Subject: [PATCH] Highlight cursor line when focus is lost. Set cursorline on FocusLost. Unset cursorline on FocusGained iff it wasn't set before focus was lost. --- .vimrc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.vimrc b/.vimrc index 24e05bc..71c5093 100644 --- a/.vimrc +++ b/.vimrc @@ -174,6 +174,7 @@ fun! Iain_Vars() "{{{2 call Prep_Var("b:iainstatus", "'Fih'") call Prep_Var("g:iainextracolumnsnumber", "''") call Prep_Var("g:iainextracolumnslist", "''") + call Prep_Var("b:iaincul", 0) if has("signs") call Prep_Var("g:marksigns", 0) call Prep_Var("g:firstsign", 100) @@ -1002,6 +1003,19 @@ fun! Show_GUITabLine() "{{{2 return l:s endfun "}}}2 +" Toggle highlighting cursor line when focus changes. +fun! ToggleCursorLine() "{{{2 + call Iain_Vars() + + if b:iainstatus =~# "f" && b:iainstatus =~# "H" && b:iainstatus =~# "I" + " Focus lost while held in insert mode. + let b:iaincul = getbufvar("", "&cursorline") + setlocal cursorline + elseif ! b:iaincul + setlocal nocursorline + endif +endfun "}}}2 + se tabline=%!Show_TabLine() se guitablabel=%!Show_GUITabLine() @@ -1012,6 +1026,8 @@ au StatusLine FocusLost * call Highlight_StatusLine("f") au StatusLine InsertEnter * call Highlight_StatusLine("I") au StatusLine InsertLeave * call Highlight_StatusLine("i") +au Display FocusGained,FocusLost * call ToggleCursorLine() + if has("signs") au Signs InsertEnter * call Highlight_Signs() au Signs InsertLeave * call Highlight_Signs() -- 2.20.1