mirror of
https://github.com/vim-airline/vim-airline-themes.git
synced 2024-12-05 08:30:03 +08:00
introduce util file
This commit is contained in:
parent
af7dfc8677
commit
0e936d0b9a
|
@ -100,24 +100,8 @@ function! airline#get_statusline(winnr, active)
|
|||
return info.statusline
|
||||
endfunction
|
||||
|
||||
function! airline#exec_funcrefs(list, break_early)
|
||||
" for 7.2; we cannot iterate list, hence why we use range()
|
||||
" for 7.3-[97, 328]; we cannot reuse the variable, hence the {}
|
||||
for i in range(0, len(a:list) - 1)
|
||||
let Fn{i} = a:list[i]
|
||||
if a:break_early
|
||||
if Fn{i}()
|
||||
return 1
|
||||
endif
|
||||
else
|
||||
call Fn{i}()
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! airline#update_statusline()
|
||||
if airline#exec_funcrefs(g:airline_exclude_funcrefs, 1)
|
||||
if airline#util#exec_funcrefs(g:airline_exclude_funcrefs, 1)
|
||||
call setwinvar(winnr(), '&statusline', '')
|
||||
return
|
||||
endif
|
||||
|
@ -134,7 +118,7 @@ function! airline#update_statusline()
|
|||
for section in s:sections
|
||||
unlet! w:airline_section_{section}
|
||||
endfor
|
||||
call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||
call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||
|
||||
call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1))
|
||||
endfunction
|
||||
|
|
|
@ -94,7 +94,7 @@ endfunction
|
|||
|
||||
function! s:sync_active_winnr()
|
||||
if exists('#airline') && winnr() != s:active_winnr
|
||||
if airline#exec_funcrefs(s:ext._cursormove_funcrefs, 1)
|
||||
if airline#util#exec_funcrefs(s:ext._cursormove_funcrefs, 1)
|
||||
return
|
||||
endif
|
||||
call airline#update_statusline()
|
||||
|
@ -158,6 +158,6 @@ function! airline#extensions#load()
|
|||
call airline#extensions#iminsert#init()
|
||||
endif
|
||||
|
||||
call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||
call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||
endfunction
|
||||
|
||||
|
|
18
autoload/airline/util.vim
Normal file
18
autoload/airline/util.vim
Normal file
|
@ -0,0 +1,18 @@
|
|||
" MIT license. Copyright (c) 2013 Bailey Ling.
|
||||
" vim: ts=2 sts=2 sw=2 fdm=indent
|
||||
|
||||
function! airline#util#exec_funcrefs(list, break_early)
|
||||
" for 7.2; we cannot iterate list, hence why we use range()
|
||||
" for 7.3-[97, 328]; we cannot reuse the variable, hence the {}
|
||||
for i in range(0, len(a:list) - 1)
|
||||
let Fn{i} = a:list[i]
|
||||
if a:break_early
|
||||
if Fn{i}()
|
||||
return 1
|
||||
endif
|
||||
else
|
||||
call Fn{i}()
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
Loading…
Reference in New Issue
Block a user