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.
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