" Set up our variables.
fun! Iain_Vars() "{{{2
- call Prep_Var("b:iainlist", 0)
+ call Prep_Var("w:iainlist", 0)
call Prep_Var("b:iainhex", 0)
call Prep_Var("b:iainverbose", 0)
" Window Flags: (F)ocused, (I)nsert mode, Cursor (H)old.
call Prep_Var("b:iainstatus", "'Fih'")
- call Prep_Var("g:iainextracolumnsnumber", 0)
- call Prep_Var("g:iainextracolumnslist", 0)
+ call Prep_Var("g:iainextracolumnsnumber", "''")
+ call Prep_Var("g:iainextracolumnslist", "''")
if has("signs")
call Prep_Var("g:marksigns", 0)
call Prep_Var("g:firstsign", 100)
" Show space, underscore or dollar sign depending on list mode.
fun! Show_List() "{{{2
call Iain_Vars()
- if b:iainlist == 0
+ if w:iainlist == 0
" No list.
return " "
elseif <SID>Has_Unicode()
- if b:iainlist == 1
+ if w:iainlist == 1
" Just tabs.
return "»"
else
return "¶"
endif
else
- if b:iainlist == 1
+ if w:iainlist == 1
return "_"
else
return "\$"
" Set extra columns depending on window status.
fun! Extra_Columns(extra, var, ...) "{{{2
- if v:version < "700"
+ " Vim 6 doesn't have winnr("$"). Determine which windows are open
+ " ourselves by using :windo to incremement a counter. As Vim 5
+ " doesn't have :windo we require Vim 6 for this.
+ if v:version < "600"
return ""
endif
+ " Remember which window we're in.
+ let l:winnr = winnr()
+ let l:num_windows = 0
+ windo let l:num_windows = l:num_windows + 1
+ " Switch back to the window we were in.
+ exe l:winnr . "wincmd w"
+
call Iain_Vars()
if a:0 == 0
let l:condition = a:1
endif
+ let l:n = 0
let l:i = 1
- let l:num_windows = 0
- while l:i <= winnr("$")
+ let l:windows = ""
+ while l:n < l:num_windows
+ " If window w exists then getwinvar(w, "&modified") will be 0 or 1.
+ 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:num_windows = l:num_windows + 1
+ exe "let l:windows = '" . l:windows . ":" . l:i . "'"
+ endif
endif
let l:i = l:i + 1
endwhile
let l:extra = "g:iainextracolumns" . a:extra
exe "let l:val = " . l:extra
+ exe "let " . l:extra . " = '" . l:windows . "'"
- if l:num_windows == l:val
+ if l:windows == l:val
return ""
endif
- exe "let " . l:extra . " = " . l:num_windows
- if l:num_windows == 0
+ if l:windows == ""
return "-"
- elseif l:val == 0
+ elseif l:val == ""
return "+"
endif
endfun "}}}2
" Entering Make mode.
fun! MakeMode_map() "{{{2
call Iain_Vars()
- let b:iainlist=1
+ let w:iainlist=1
call Cycle_List()
set ts=8
set noexpandtab
endif
endif
call Iain_Vars()
- let b:iainlist = b:iainlist + 1
- if b:iainlist > 2
- let b:iainlist = 0
+ let w:iainlist = w:iainlist + 1
+ if w:iainlist > 2
+ let w:iainlist = 0
endif
- if b:iainlist == 0
+ if w:iainlist == 0
setlocal nolist
- elseif b:iainlist == 1
+ elseif w:iainlist == 1
exec "setlocal lcs=" . basic
setlocal list
else
setlocal list
endif
- call Resize_Columns(Extra_Columns("list", "&lcs", " =~# 'eol'"), 1)
+ call Resize_Columns(Extra_Columns("list", "iainlist", " == 2"), 1)
endfun "}}}2
" Cycle between hex and decimal display of toolbar stuff.