modify active window algorithm, resolves #106.
This commit is contained in:
parent
8f52831cc0
commit
d56b9bbfcd
@ -83,20 +83,17 @@ function! airline#update_externals()
|
|||||||
\ : ''
|
\ : ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:get_section(key)
|
function! s:getwinvar(winnr, key, ...)
|
||||||
return exists('w:airline_section_{a:key}') ? w:airline_section_{a:key} : g:airline_section_{a:key}
|
" for 7.2 compatibility
|
||||||
|
let winvals = getwinvar(a:winnr, '')
|
||||||
|
return get(winvals, a:key, (a:0 ? a:1 : ''))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#update_statusline(active)
|
function! s:get_section(winnr, key)
|
||||||
let w:airline_active = a:active
|
return s:getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key})
|
||||||
if s:is_excluded_window()
|
endfunction
|
||||||
call setwinvar(winnr(), '&statusline', '')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
call airline#update_externals()
|
|
||||||
call s:apply_window_overrides()
|
|
||||||
|
|
||||||
|
function! s:get_statusline(winnr, active)
|
||||||
let l:mode_color = a:active ? "%#Al2#" : "%#Al2_inactive#"
|
let l:mode_color = a:active ? "%#Al2#" : "%#Al2_inactive#"
|
||||||
let l:mode_sep_color = a:active ? "%#Al3#" : "%#Al3_inactive#"
|
let l:mode_sep_color = a:active ? "%#Al3#" : "%#Al3_inactive#"
|
||||||
let l:info_color = a:active ? "%#Al4#" : "%#Al4_inactive#"
|
let l:info_color = a:active ? "%#Al4#" : "%#Al4_inactive#"
|
||||||
@ -105,35 +102,54 @@ function! airline#update_statusline(active)
|
|||||||
let l:file_flag_color = a:active ? "%#Al7#" : "%#Al7_inactive#"
|
let l:file_flag_color = a:active ? "%#Al7#" : "%#Al7_inactive#"
|
||||||
|
|
||||||
let sl = '%{airline#update_highlight()}'
|
let sl = '%{airline#update_highlight()}'
|
||||||
if a:active || exists('w:airline_left_only')
|
if a:active || s:getwinvar(a:winnr, 'airline_left_only', 0)
|
||||||
let sl.=l:mode_color.' '.s:get_section('a').' '
|
let sl.=l:mode_color.' '.s:get_section(a:winnr, 'a').' '
|
||||||
let sl.='%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}'
|
let sl.='%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}'
|
||||||
let sl.=l:mode_sep_color
|
let sl.=l:mode_sep_color
|
||||||
let sl.=a:active ? g:airline_left_sep : g:airline_left_alt_sep
|
let sl.=a:active ? g:airline_left_sep : g:airline_left_alt_sep
|
||||||
let sl.=l:info_color
|
let sl.=l:info_color
|
||||||
let sl.=' '.s:get_section('b').' '
|
let sl.=' '.s:get_section(a:winnr, 'b').' '
|
||||||
let sl.=l:info_sep_color
|
let sl.=l:info_sep_color
|
||||||
let sl.=g:airline_left_sep
|
let sl.=g:airline_left_sep
|
||||||
let sl.=l:status_color.' %<'.s:get_section('c').' '
|
let sl.=l:status_color.' %<'.s:get_section(a:winnr, 'c').' '
|
||||||
let gutter = get(w:, 'airline_section_gutter', get(g:, 'airline_section_gutter', ''))
|
let gutter = s:getwinvar(a:winnr, 'airline_section_gutter', get(g:, 'airline_section_gutter', ''))
|
||||||
let sl.=gutter != ''
|
let sl.=gutter != ''
|
||||||
\ ? gutter
|
\ ? gutter
|
||||||
\ : '%#warningmsg#'.g:airline_externals_syntastic.l:file_flag_color."%{&ro ? g:airline_readonly_symbol : ''}".l:status_color
|
\ : '%#warningmsg#'.g:airline_externals_syntastic.l:file_flag_color."%{&ro ? g:airline_readonly_symbol : ''}".l:status_color
|
||||||
else
|
else
|
||||||
let sl.=l:status_color.' %f%m'
|
let sl.=l:status_color.' %f%m'
|
||||||
endif
|
endif
|
||||||
if !exists('w:airline_left_only')
|
if !s:getwinvar(a:winnr, 'airline_left_only', 0)
|
||||||
let sl.='%= '.s:get_section('x').' '
|
let sl.='%= '.s:get_section(a:winnr, 'x').' '
|
||||||
let sl.=l:info_sep_color
|
let sl.=l:info_sep_color
|
||||||
let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep
|
let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep
|
||||||
let sl.=l:info_color
|
let sl.=l:info_color
|
||||||
let sl.=' '.s:get_section('y').' '
|
let sl.=' '.s:get_section(a:winnr, 'y').' '
|
||||||
let sl.=l:mode_sep_color
|
let sl.=l:mode_sep_color
|
||||||
let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep
|
let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep
|
||||||
let sl.=l:mode_color
|
let sl.=l:mode_color
|
||||||
let sl.=' '.s:get_section('z').' '
|
let sl.=' '.s:get_section(a:winnr, 'z').' '
|
||||||
endif
|
endif
|
||||||
call setwinvar(winnr(), '&statusline', sl)
|
return sl
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#update_statusline()
|
||||||
|
let w:airline_active = 1
|
||||||
|
if s:is_excluded_window()
|
||||||
|
call setwinvar(winnr(), '&statusline', '')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call airline#update_externals()
|
||||||
|
call s:apply_window_overrides()
|
||||||
|
call setwinvar(winnr(), '&statusline', s:get_statusline(winnr(), 1))
|
||||||
|
|
||||||
|
for nr in range(1, winnr('$'))
|
||||||
|
if nr != winnr() && getwinvar(nr, 'airline_active')
|
||||||
|
call setwinvar(nr, '&statusline', s:get_statusline(nr, 0))
|
||||||
|
call setwinvar(nr, 'airline_active', 0)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let g:airline_current_mode_text = ''
|
let g:airline_current_mode_text = ''
|
||||||
|
@ -75,7 +75,6 @@ command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call
|
|||||||
augroup airline
|
augroup airline
|
||||||
au!
|
au!
|
||||||
autocmd ColorScheme * call airline#highlight(['normal'])
|
autocmd ColorScheme * call airline#highlight(['normal'])
|
||||||
autocmd WinLeave * call airline#update_statusline(0)
|
autocmd WinEnter,BufWinEnter,FileType,BufUnload * call <sid>init() | call airline#update_statusline()
|
||||||
autocmd WinEnter,BufWinEnter,FileType,BufUnload * call <sid>init() | call airline#update_statusline(1)
|
|
||||||
autocmd ShellCmdPost * call airline#update_externals()
|
autocmd ShellCmdPost * call airline#update_externals()
|
||||||
augroup END
|
augroup END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user