pass context into the builder.

This commit is contained in:
Bailey Ling 2013-08-24 03:18:43 +00:00
parent 2cfab73f1b
commit 3bb451f1f4
3 changed files with 10 additions and 6 deletions

View File

@ -95,7 +95,8 @@ endfunction
function! airline#update_statusline()
for nr in filter(range(1, winnr('$')), 'v:val != winnr()')
call setwinvar(nr, 'airline_active', 0)
let builder = airline#builder#new(0, s:highlighter)
let context = { 'winnr': nr, 'active': 0 }
let builder = airline#builder#new(context, s:highlighter)
call setwinvar(nr, '&statusline', airline#get_statusline(builder, nr, 0))
endfor
@ -107,7 +108,8 @@ function! airline#update_statusline()
unlet! w:airline_section_{section}
endfor
let builder = airline#builder#new(1, s:highlighter)
let context = { 'winnr': winnr(), 'active': 1 }
let builder = airline#builder#new(context, s:highlighter)
let err = airline#util#exec_funcrefs(g:airline_statusline_funcrefs, builder)
if err == 0
call setwinvar(winnr(), '&statusline', airline#get_statusline(builder, winnr(), 1))

View File

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

View File

@ -300,6 +300,9 @@ statuslines to your liking. Here is an example: >
return -1
endfunction
<
The second variable is the context, which is a dictionary containing various
values such as whether the statusline is active or not, and the window number.
*airline-pipeline-return-codes*
The pipeline accepts various return codes and can be used to determine the
next action. The following are the supported codes: >