+" Cycle between hex and decimal display of toolbar stuff.
+fun! Cycle_HexStatusLine() "{{{2
+ call Iain_Vars()
+ let b:iainhex = ! b:iainhex
+ call Show_StatusLine()
+endfun "}}}2
+
+" Cycle verbose display of toolbar stuff.
+fun! Cycle_VerboseStatusLine() "{{{2
+ call Iain_Vars()
+ let b:iainverbose = ! b:iainverbose
+ call Show_StatusLine()
+endfun "}}}2
+
+" Toggle quickfix window.
+fun! Cycle_Quickfix() "{{{2
+ if g:quickfixing == 1
+ cclose
+ let g:quickfixing=0
+ else
+ copen
+ endif
+endfun "}}}2
+
+" Swap hex/decimal statusline with \x.
+call Mapping("x", ":call Cycle_HexStatusLine()<CR>:<CR>")
+" Change statusline verbosity with \v.
+call Mapping("V", ":call Cycle_VerboseStatusLine()<CR>:<CR>")
+" Cycle list styles with \l.
+call Mapping("l", ":call Cycle_List()<CR>:<CR>")
+" Toggle tags with \t.
+call Mapping("t", ":Tlist<CR>")
+" Change foldmethod with \f.
+call Mapping("f", ":se foldenable!<CR>:<CR>")
+" Toggle quickfix window with \q.
+call Mapping("q", ":call Cycle_Quickfix()<CR>:<CR>")
+" Rerun filetype detection with \s. The s is for syntax, as this will be
+" updated as a side-effect.
+call Mapping("S", ":filetype detect<CR>:<CR>")
+" Toggle marks with \m.
+call Mapping("m", ":call <SID>Cycle_Signs(1)<CR>:<CR>")
+
+" Show signs by default.
+au Display VimEnter * call <SID>Cycle_Signs(0)
+endif "}}}1
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" Handle options only available in Vim 7 and above.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if version >= "700" "{{{1
+version 7.0
+
+" Helper to show tab name.
+fun! <SID>TabName(label, gui) "{{{2
+ let l:label = a:label
+ if l:label == ""
+ let l:label = "No Name"
+ if a:gui
+ let l:label = "[" . l:label . "]"
+ endif
+ else
+ let l:label = fnamemodify(l:label, ":t")
+ if strlen(l:label) >= 18
+ let l:label = l:label[0:17] . ".."
+ endif
+ endif
+ return l:label
+endfun "}}}2
+
+" Find out if any buffer was modified.
+fun! <SID>TabModified(buflist) "{{{2
+ let l:i = 0
+ while l:i < len(a:buflist)
+ if getbufvar(a:buflist[l:i], "&modified") == 1
+ return "+"
+ endif
+ let l:i = l:i + 1
+ endwhile
+ return ""
+endfun "}}}2
+
+" Tab line.
+fun! Show_TabLine() "{{{2
+ let l:s = "%#TabLineFill#Tabs:"
+
+ let l:i = 0
+ while l:i < tabpagenr("$")
+ let l:i = l:i + 1
+ " Get the label.
+ let l:buflist = tabpagebuflist(l:i)
+ let l:winnr = tabpagewinnr(l:i)
+ let l:n = tabpagewinnr(l:i, "$")
+ let l:label = <SID>TabName(bufname(l:buflist[l:winnr - 1]), 0)
+ let l:modified = <SID>TabModified(l:buflist)
+
+ " Choose highlighting.
+ if l:i == tabpagenr()
+ let l:s .= "%#TabLineSel#[" . l:n . l:modified . " " . l:label . "]"
+ else
+ let l:s .= "%#TabLine# " . l:n . l:modified . " " . l:label . " "
+ endif
+ endwhile
+
+ " Padding.
+ let l:s .= "%#TabLine#%T"
+ return l:s
+endfun "}}}2
+
+" Per tab label for the GUI.
+fun! Show_GUITabLine() "{{{2
+ let l:buflist = tabpagebuflist(v:lnum)
+ let l:winnr = tabpagewinnr(v:lnum)
+ let l:s = tabpagewinnr(v:lnum, "$")
+ let l:label = <SID>TabName(bufname(l:buflist[l:winnr - 1]), 1)
+ let l:modified = <SID>TabModified(l:buflist)
+
+ let l:s .= l:modified . " " . l:label
+ return l:s
+endfun "}}}2
+
+se tabline=%!Show_TabLine()
+se guitablabel=%!Show_GUITabLine()
+
+au StatusLine CursorHoldI * call Highlight_StatusLine("H")
+au StatusLine CursorMovedI * call Highlight_StatusLine("h")
+au StatusLine FocusGained * call Highlight_StatusLine("F")
+au StatusLine FocusLost * call Highlight_StatusLine("f")
+au StatusLine InsertEnter * call Highlight_StatusLine("I")
+au StatusLine InsertLeave * call Highlight_StatusLine("i")
+
+if has("signs")
+ au Signs InsertEnter * call <SID>Highlight_Signs()
+ au Signs InsertLeave * call <SID>Highlight_Signs()
+endif
+
+" Limit the size of the popup menu when completing.
+se pumheight=20
+
+" Make diffs vertical by default.
+se diffopt+=vertical
+
+" Set size of numbers column.
+se numberwidth=5
+
+" Add "previous tab" mapping as gb.
+map gb :tabprevious<CR>:<CR>
+
+" Transparency.
+if has("gui_macvim")
+ se transparency=15
+endif
+
+" Yet more GUI options. Add tabs.
+se go+=e
+
+" Perforce.
+let g:p4EnableMenu=1
+let g:p4Presets='P4CONFIG'
+
+" BufExplorer.
+let g:bufExplorerShowRelativePath=1
+let g:bufExplorerSplitOutPathName=0
+endif "}}}1
+
+" Resize after startup.
+if version >= "500" "{{{1
+au Display VimEnter * call Startup_Resize()
+endif "}}}1