From: Iain Patterson Date: Fri, 14 Aug 2009 13:26:37 +0000 (+0100) Subject: More display stuff. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=1e27defe0c925c11a18879a3fe2745421e8d848e;p=profile.git More display stuff. Unicode alternative for caret sign. Made Highlight_StatusLine() compatible with Vim 5. There's still no point calling it with anything less than Vim 7. Use User1 highlighting to emphasise filename, line and column. --- diff --git a/.vim/colors/iain.vim b/.vim/colors/iain.vim index 6d0d776..8de7066 100644 --- a/.vim/colors/iain.vim +++ b/.vim/colors/iain.vim @@ -268,7 +268,8 @@ if has("gui_running") || &t_Co == 88 || &t_Co == 256 hi def Normal guifg=#c0c0c0 guibg=#000020 call X("StatusLineNC", "black", "#808080", "none") - call X("StatusLine", "white", "#000080", "bold") + call X("StatusLine", "white", "#000080", "none") + call X("User1", "white", "#000080", "bold") call X("WildMenu", "blue", "white", "bold") call X("Todo", "black", "green", "bold") call X("MoreMsg", "#00ff00", "", "none") diff --git a/.vimrc b/.vimrc index b63d1ba..4057ea7 100644 --- a/.vimrc +++ b/.vimrc @@ -252,8 +252,8 @@ endfun "}}}2 " Show the status line. fun! Show_StatusLine() "{{{2 call Iain_Vars() - let l:sl1='%2n\:\ %<%f\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ ' - let l:sl3='L:%4.6l/%-4.6L\ C:%3.6c\ \|\ %P' + let l:sl1='%2n\:\ %<%1*%f%0*\ [%{Show_List()}%{Show_Case()}%{Show_Tabstop()}%{Show_Paste()}%Y%M%R]\ ' + let l:sl3='L:%1*%4.6l%0*/%-4.6L\ C:%1*%3.6c%0*\ \|\ %P' let l:hexformat='%b' if b:iainhex let l:hexformat='0\x%02B' @@ -482,6 +482,85 @@ fun! Startup_Resize() "{{{2 endif endfun "}}}2 +" Change status bar colour when various things happen. +" Flags: H/h: Cursor held/moved. +" F/f: Focus gained/lost. +" I/i: Insert mode entered/left. +fun! Highlight_StatusLine(flag) "{{{2 + " Get current status. + call Iain_Vars() + + " Change the status based on the flag. XXX: Does Vim let us to do flags? + let l:ic = &ic + set ic + let b:iainstatus = substitute(b:iainstatus, a:flag, a:flag, "") + let &ic = l:ic + + let l:normalcolour = "darkblue" + let l:editingcolour = "darkmagenta" + let l:warningcolour = "darkred" + let l:readonlycolour = "red" + + " Default colour. + let l:colour = l:normalcolour + " 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 l:colour = l:warningcolour + else + let l:colour = l:editingcolour + endif + endif + else + if b:iainstatus =~# "I" + " Regular insert mode. + let l:colour = l:editingcolour + endif + endif + + " Override again if readonly. + if l:colour != l:normalcolour + if getbufvar("", "&ro") + let l:colour = l:readonlycolour + endif + endif + + let l:termcolour = Iain_Colour(l:colour) + + exec "highlight StatusLine gui=none term=none cterm=none guifg=white guibg=" . l:colour . " ctermfg=white ctermbg=" . l:termcolour + exec "highlight User1 gui=bold term=bold cterm=bold guifg=white guibg=" . l:colour . " ctermfg=white ctermbg=" . l:termcolour +endfun "}}}2 + +fun! Iain_Colour(colour) "{{{2 + if &t_Co == 88 + if a:colour == "darkblue" + return 17 + elseif a:colour == "darkmagenta" + return 33 + elseif a:colour == "darkred" + return 32 + elseif a:colour == "red" + return 64 + endif + elseif &t_Co == 256 + if a:colour == "darkblue" + return 17 + elseif a:colour == "darkmagenta" + return 90 + elseif a:colour == "darkred" + return 88 + elseif a:colour == "red" + return 196 + endif + else + return a:colour + endif +endfun "}}}2 + +au StatusLine VimEnter * call Highlight_StatusLine("") + " Show numbers by default. au Display VimEnter * if ! Uncluttered_Buffer() | call Number(0) | endif @@ -647,12 +726,13 @@ fun! Cycle_Signs(resize) "{{{2 sign define MarkDash text=’ texthl=MarkSign sign define MarkDot text=• texthl=MarkDot sign define MarkQuote text=” texthl=MarkSign + sign define MarkCaret text=ʌ texthl=MarkDot else sign define MarkDash text=' texthl=MarkSign sign define MarkDot text=* texthl=MarkDot sign define MarkQuote text=" texthl=MarkSign + sign define MarkCaret text=^ texthl=MarkDot endif - sign define MarkCaret text=^ texthl=MarkDot sign define MarkLess text=< texthl=MarkSign sign define MarkGreater text=> texthl=MarkSign sign define MarkLeft text=( texthl=MarkSign @@ -834,82 +914,6 @@ call Mapping("S", ":filetype detect:") " Toggle marks with \m. call Mapping("m", ":call Cycle_Signs(1):") -fun! Iain_Colour(colour) "{{{2 - if &t_Co == 88 - if a:colour == "darkblue" - return 17 - elseif a:colour == "darkmagenta" - return 33 - elseif a:colour == "darkred" - return 32 - elseif a:colour == "red" - return 64 - endif - elseif &t_Co == 256 - if a:colour == "darkblue" - return 17 - elseif a:colour == "darkmagenta" - return 90 - elseif a:colour == "darkred" - return 88 - elseif a:colour == "red" - return 196 - endif - else - return a:colour - endif -endfun "}}}2 - -" Change status bar colour when various things happen. -" Flags: H/h: Cursor held/moved. -" F/f: Focus gained/lost. -" I/i: Insert mode entered/left. -fun! Highlight_StatusLine(flag) "{{{2 - " 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, "") - - let l:normalcolour = "darkblue" - let l:editingcolour = "darkmagenta" - let l:warningcolour = "darkred" - let l:readonlycolour = "red" - - " Default colour. - let l:colour = l:normalcolour - " 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 l:colour = l:warningcolour - else - let l:colour = l:editingcolour - endif - endif - else - if b:iainstatus =~# "I" - " Regular insert mode. - let l:colour = l:editingcolour - endif - endif - - " Override again if readonly. - if l:colour != l:normalcolour - if getbufvar("", "&ro") - let l:colour = l:readonlycolour - endif - endif - - let l:termcolour = Iain_Colour(l:colour) - - exec "highlight StatusLine gui=bold term=bold cterm=bold guifg=white guibg=" . l:colour . " ctermfg=white ctermbg=" . l:termcolour -endfun "}}}2 - -au Display VimEnter * call Highlight_StatusLine("") - " Show signs by default. au Display VimEnter * call Cycle_Signs(0) endif "}}}1