mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-23 05:55:38 +02: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
|
return info.statusline
|
||||||
endfunction
|
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()
|
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', '')
|
call setwinvar(winnr(), '&statusline', '')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -134,7 +118,7 @@ function! airline#update_statusline()
|
|||||||
for section in s:sections
|
for section in s:sections
|
||||||
unlet! w:airline_section_{section}
|
unlet! w:airline_section_{section}
|
||||||
endfor
|
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))
|
call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1))
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -94,7 +94,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:sync_active_winnr()
|
function! s:sync_active_winnr()
|
||||||
if exists('#airline') && winnr() != s: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
|
return
|
||||||
endif
|
endif
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
@ -158,6 +158,6 @@ function! airline#extensions#load()
|
|||||||
call airline#extensions#iminsert#init()
|
call airline#extensions#iminsert#init()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
call airline#util#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||||
endfunction
|
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…
x
Reference in New Issue
Block a user