X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=.vimrc;h=85b1595c96cebada42a17bc3407c86c8734fe3cc;hp=26ce8dbbebc199c00d4d058669be8b7469438c0f;hb=500ba2b170e6f1bfad014c9bca55e19225a9bbe8;hpb=3f3bc49b281988f04653f35e777d375f49398a77 diff --git a/.vimrc b/.vimrc index 26ce8db..85b1595 100644 --- a/.vimrc +++ b/.vimrc @@ -129,10 +129,13 @@ augroup StatusLine autocmd! augroup END -" Save the current window width so we can restore it when we quit. +" Save the current window dimensions so we can restore them when we quit. if ! exists("g:oldcols") let g:oldcols=&columns endif +if ! exists("g:oldlines") + let g:oldlines=&lines +endif " More GUI options. Add icon and tearoffs. se go+=i @@ -184,6 +187,7 @@ fun! Iain_Vars() "{{{2 call Prep_Var("g:marksigns", 0) call Prep_Var("g:firstsign", 100) endif + call Prep_Var("g:resizable", "''") endfun "}}}2 " Helper for status line. @@ -279,12 +283,38 @@ fun! Invert_Case() "{{{2 let &ic = ! &ic endfun "}}}2 -" Grow or shrink the window size. +" Can we resize this window? +fun! Can_Resize() "{{{2 + call Iain_Vars() + + if g:resizable == "0" || g:resizable == "1" + return g:resizable + endif + + " Do we KNOW we can(not) resize? + if has("gui_running") + let g:resizable = 1 + elseif $RESIZABLE == &term + let g:resizable = 1 + elseif $RESIZABLE == "0" + let g:resizable = 0 + else + " Assume we can. Allow overriding. + let g:resizable = 1 + endif + return g:resizable +endfun "}}}2 + +" Grow or shrink the window width. fun! Resize_Columns(op, ...) "{{{2 if a:op == "" return endif + if ! Can_Resize() + return + endif + if a:0 == 0 " Vim 5 hardcodes the size of numbers column to 8. if version >= "700" @@ -313,6 +343,25 @@ fun! Resize_Columns(op, ...) "{{{2 exe l:resize endfun "}}}2 +" Grow or shrink the window height. +fun! Resize_Lines(op, lines) "{{{2 + if a:op == "" + return + endif + + if ! Can_Resize() + return + endif + + exe "let l:resize=" . &lines . a:op . a:lines + if &term =~ '^screen' + let l:resize = l:resize + 1 + endif + let l:resize = "se lines=" . l:resize + + exe l:resize +endfun "}}}2 + " Set extra columns depending on window status. fun! Extra_Columns(extra, var, ...) "{{{2 " Vim 6 doesn't have winnr("$"). Determine which windows are open @@ -345,9 +394,9 @@ fun! Extra_Columns(extra, var, ...) "{{{2 if getwinvar(l:i, "&modified") =~ '^\d' let l:n = l:n + 1 - let l:val = 0 - exe "if getwinvar(" . l:i . ", '" . a:var . "') " . l:condition . " | let l:val = 1 | endif" - if l:val + let l:val = 0 + exe "if getwinvar(" . l:i . ", '" . a:var . "') " . l:condition . " | let l:val = 1 | endif" + if l:val exe "let l:windows = '" . l:windows . ":" . l:i . "'" endif endif @@ -384,7 +433,10 @@ fun! Number(resize) "{{{2 endfun "}}}2 " Restore window size. -au Display VimLeave * if exists("g:oldcols") | call Resize_Columns("-", (&columns - g:oldcols)) | endif +if ! has("gui_running") + au Display VimLeave * if exists("g:oldcols") | call Resize_Columns("-", (&columns - g:oldcols)) | endif + au Display VimLeave * if exists("g:oldlines") | call Resize_Lines("-", (&lines - g:oldlines)) | endif +endif " Map Makefile mode. au Mode BufEnter * if &ft == "make" | call MakeMode_map() | endif @@ -681,7 +733,7 @@ fun! Highlight_Signs(...) "{{{2 let l:var = tolower(l:name) let l:sign = substitute(l:sign, '^[A-Za-z]\+', "", "") let l:ascii = matchstr(l:sign, '^:.') - let l:mark = substitute(l:sign, '^\(:.\)*[.-=]', "", "") + let l:mark = substitute(l:sign, '^\(:.\)*[.=-]', "", "") if strlen(l:ascii) let l:ascii = substitute(l:ascii, '^:', "", "") else @@ -735,7 +787,7 @@ fun! Cycle_Signs(resize) "{{{2 let l:sign = substitute(l:sign, ':.', "", "") let l:sign = substitute(l:sign, '=', " texthl=MarkSign text=", "") let l:sign = substitute(l:sign, '\.', " texthl=MarkDot text=", "") - let l:sign = substitute(l:sign, '-', " texthl=MarkLine text=", "") + let l:sign = substitute(l:sign, '-', " texthl=MarkLine linehl=MarkLine text=", "") exe "sign define Mark" . l:sign