From 35791acb36710ee87b19309ef97f300b76bdbddc Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Thu, 31 Jul 2008 14:14:32 +0000 Subject: [PATCH] Use new Highlight_StatusLine() function to handle statusline highlighting. Turn statusline purple if focus is lost and the cursor is held. git-svn-id: https://svn.cambridge.iain.cx/profile/trunk@118 6be0d1a5-5cfe-0310-89b6-964be062b18b --- .vimrc | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.vimrc b/.vimrc index 30ec753..77a1d45 100644 --- a/.vimrc +++ b/.vimrc @@ -113,6 +113,10 @@ fun! Iain_Vars() if ! exists("b:iainverbose") let b:iainverbose = 0 endif + if ! exists("b:iainstatus") + " Window Flags: (F)ocused, (I)nsert mode, Cursor (H)old. + let b:iainstatus = "Fih" + endif endfun " Helper for status line. @@ -345,8 +349,42 @@ if version >= "700" version 7.0 " Change status bar colour when entering insert mode. -au InsertEnter * highlight StatusLine guifg=white guibg=darkred ctermbg=white ctermfg=darkred -au InsertLeave * highlight StatusLine guifg=white guibg=blue ctermbg=white ctermfg=blue +fun! Highlight_StatusLine(flag) + " Get current status. + call Iain_Vars() + + " Change the status based on the flag. XXX: Does Vim let us to do flags? + let re = "[" . tolower(a:flag) . toupper(a:flag) . "]" + let b:iainstatus = substitute(b:iainstatus, re, a:flag, "") + + " Default colour. + let colour = "darkblue" + " Maybe override depending on status. + if b:iainstatus =~# "H" + if b:iainstatus =~# "I" + " Held in insert mode. Add extra highlight if we don't have focus. + if b:iainstatus =~# "f" + let colour = "darkmagenta" + else + let colour = "darkred" + endif + endif + else + if b:iainstatus =~# "I" + " Regular insert mode. + let colour = "darkred" + endif + endif + + exec "highlight StatusLine guifg=white guibg=" . colour . " ctermbg=white ctermfg=" . colour +endfun + +au CursorHoldI * call Highlight_StatusLine("H") +au CursorMovedI * call Highlight_StatusLine("h") +au FocusGained * call Highlight_StatusLine("F") +au FocusLost * call Highlight_StatusLine("f") +au InsertEnter * call Highlight_StatusLine("I") +au InsertLeave * call Highlight_StatusLine("i") " Make diffs vertical by default. se diffopt+=vertical -- 2.7.4