inactivate existing statusline without building a new one.

This commit is contained in:
Bailey Ling 2013-08-24 03:43:55 +00:00
parent 3bb451f1f4
commit 53b856b0c5
2 changed files with 9 additions and 11 deletions

View File

@ -94,10 +94,12 @@ endfunction
function! airline#update_statusline() function! airline#update_statusline()
for nr in filter(range(1, winnr('$')), 'v:val != winnr()') for nr in filter(range(1, winnr('$')), 'v:val != winnr()')
if airline#util#getwinvar(nr, 'airline_active', 0)
call setwinvar(nr, 'airline_active', 0) call setwinvar(nr, 'airline_active', 0)
let context = { 'winnr': nr, 'active': 0 } let stl = getwinvar(nr, '&statusline')
let builder = airline#builder#new(context, s:highlighter) let line = substitute(stl, '%#.\{-}\ze#', '\0_inactive', 'g')
call setwinvar(nr, '&statusline', airline#get_statusline(builder, nr, 0)) call setwinvar(nr, '&statusline', line)
endif
endfor endfor
let w:airline_active = 1 let w:airline_active = 1
@ -109,8 +111,8 @@ function! airline#update_statusline()
endfor endfor
let context = { 'winnr': winnr(), 'active': 1 } let context = { 'winnr': winnr(), 'active': 1 }
let builder = airline#builder#new(context, s:highlighter) let builder = airline#builder#new(s:highlighter)
let err = airline#util#exec_funcrefs(g:airline_statusline_funcrefs, builder) let err = airline#util#exec_funcrefs(g:airline_statusline_funcrefs, builder, context)
if err == 0 if err == 0
call setwinvar(winnr(), '&statusline', airline#get_statusline(builder, winnr(), 1)) call setwinvar(winnr(), '&statusline', airline#get_statusline(builder, winnr(), 1))
elseif err == 1 elseif err == 1

View File

@ -24,15 +24,11 @@ function! s:prototype.add_raw(text)
endfunction endfunction
function! s:prototype.build() function! s:prototype.build()
if !self._context.active
let self._line = substitute(self._line, '%#.\{-}\ze#', '\0_inactive', 'g')
endif
return self._line return self._line
endfunction endfunction
function! airline#builder#new(context, highlighter) function! airline#builder#new(highlighter)
let builder = copy(s:prototype) let builder = copy(s:prototype)
let builder._context = a:context
let builder._highlighter = a:highlighter let builder._highlighter = a:highlighter
let builder._side = 1 let builder._side = 1
let builder._curgroup = '' let builder._curgroup = ''