autoload: add comments

This commit is contained in:
Christian Brabandt 2018-11-08 16:20:37 +01:00
parent 99971aa24d
commit f08078d683
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -7,6 +7,11 @@ let g:airline_statusline_funcrefs = get(g:, 'airline_statusline_funcrefs', [])
let s:sections = ['a','b','c','gutter','x','y','z', 'error', 'warning']
let s:inactive_funcrefs = []
let s:contexts = {}
let s:core_funcrefs = [
\ function('airline#extensions#apply'),
\ function('airline#extensions#default#apply') ]
function! airline#add_statusline_func(name)
call airline#add_statusline_funcref(function(a:name))
@ -52,6 +57,7 @@ function! airline#load_theme()
call airline#update_statusline()
endfunction
" Load an airline theme
function! airline#switch_theme(name)
try
let palette = g:airline#themes#{a:name}#palette "also lazy loads the theme
@ -74,6 +80,7 @@ function! airline#switch_theme(name)
call airline#check_mode(winnr())
endfunction
" Try to load the right theme for the current colorscheme
function! airline#switch_matching_theme()
if exists('g:colors_name')
let existing = g:airline_theme
@ -99,6 +106,7 @@ function! airline#switch_matching_theme()
return 0
endfunction
" Update the statusline
function! airline#update_statusline()
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
return
@ -110,11 +118,14 @@ function! airline#update_statusline()
unlet! w:airline_render_left w:airline_render_right
exe 'unlet! ' 'w:airline_section_'. join(s:sections, ' w:airline_section_')
" Now create the active statusline
let w:airline_active = 1
let context = { 'winnr': winnr(), 'active': 1, 'bufnr': winbufnr(winnr()) }
call s:invoke_funcrefs(context, g:airline_statusline_funcrefs)
endfunction
" Function to be called to make all statuslines inactive
" Triggered on FocusLost autocommand
function! airline#update_statusline_focuslost()
if get(g:, 'airline_focuslost_inactive', 0)
let bufnr=bufnr('%')
@ -123,6 +134,8 @@ function! airline#update_statusline_focuslost()
call airline#update_statusline_inactive(range(1, winnr('$')))
endif
endfunction
" Function to draw inactive statuslines for inactive windows
function! airline#update_statusline_inactive(range)
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
return
@ -137,10 +150,8 @@ function! airline#update_statusline_inactive(range)
endfor
endfunction
let s:contexts = {}
let s:core_funcrefs = [
\ function('airline#extensions#apply'),
\ function('airline#extensions#default#apply') ]
" Gather output from all funcrefs which will later be returned by the
" airline#statusline() function
function! s:invoke_funcrefs(context, funcrefs)
let builder = airline#builder#new(a:context)
let err = airline#util#exec_funcrefs(a:funcrefs + s:core_funcrefs, builder, a:context)
@ -151,6 +162,8 @@ function! s:invoke_funcrefs(context, funcrefs)
endif
endfunction
" Main statusline function per window
" will be set to the statusline option
function! airline#statusline(winnr)
if has_key(s:contexts, a:winnr)
return '%{airline#check_mode('.a:winnr.')}'.s:contexts[a:winnr].line
@ -160,6 +173,7 @@ function! airline#statusline(winnr)
return ''
endfunction
" Check if mode as changed
function! airline#check_mode(winnr)
if !has_key(s:contexts, a:winnr)
return ''