main: disable airline on FocusLost
When switching away from Vim and your terminal supports the FocusLost autocommand, set the statusline to inactive, so it won't distract you too much when working with another application. In the gui, the FocusLost autocommand should always trigger. This is now the default, if people start complaining, that behaviour should probably be made configurable. closes #1807
This commit is contained in:
parent
13993d120e
commit
f045452743
|
@ -103,14 +103,9 @@ function! airline#update_statusline()
|
|||
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
|
||||
return
|
||||
endif
|
||||
for nr in filter(range(1, winnr('$')), 'v:val != winnr()')
|
||||
if airline#util#getwinvar(nr, 'airline_disabled', 0)
|
||||
continue
|
||||
endif
|
||||
call setwinvar(nr, 'airline_active', 0)
|
||||
let context = { 'winnr': nr, 'active': 0, 'bufnr': winbufnr(nr) }
|
||||
call s:invoke_funcrefs(context, s:inactive_funcrefs)
|
||||
endfor
|
||||
let range = filter(range(1, winnr('$')), 'v:val != winnr()')
|
||||
" create inactive statusline
|
||||
call airline#update_statusline_inactive(range)
|
||||
|
||||
unlet! w:airline_render_left w:airline_render_right
|
||||
exe 'unlet! ' 'w:airline_section_'. join(s:sections, ' w:airline_section_')
|
||||
|
@ -120,6 +115,20 @@ function! airline#update_statusline()
|
|||
call s:invoke_funcrefs(context, g:airline_statusline_funcrefs)
|
||||
endfunction
|
||||
|
||||
function! airline#update_statusline_inactive(range)
|
||||
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
|
||||
return
|
||||
endif
|
||||
for nr in a:range
|
||||
if airline#util#getwinvar(nr, 'airline_disabled', 0)
|
||||
continue
|
||||
endif
|
||||
call setwinvar(nr, 'airline_active', 0)
|
||||
let context = { 'winnr': nr, 'active': 0, 'bufnr': winbufnr(nr) }
|
||||
call s:invoke_funcrefs(context, s:inactive_funcrefs)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
let s:contexts = {}
|
||||
let s:core_funcrefs = [
|
||||
\ function('airline#extensions#apply'),
|
||||
|
|
|
@ -105,6 +105,8 @@ function! s:airline_toggle()
|
|||
if exists("##TerminalOpen")
|
||||
autocmd TerminalOpen * call <sid>on_colorscheme_changed()
|
||||
endif
|
||||
" Set all statuslines to inactive
|
||||
autocmd FocusLost * call airline#update_statusline_inactive(range(1, winnr('$')))
|
||||
" Refresh airline for :syntax off
|
||||
autocmd SourcePre */syntax/syntax.vim
|
||||
\ call airline#extensions#tabline#buffers#invalidate()
|
||||
|
@ -119,7 +121,7 @@ function! s:airline_toggle()
|
|||
\ | call <sid>on_window_changed()
|
||||
\ | endif
|
||||
|
||||
autocmd VimResized * unlet! w:airline_lastmode | :call <sid>airline_refresh()
|
||||
autocmd VimResized,FocusGained * unlet! w:airline_lastmode | :call <sid>airline_refresh()
|
||||
autocmd TabEnter * :unlet! w:airline_lastmode | let w:airline_active=1
|
||||
autocmd BufWritePost */autoload/airline/themes/*.vim
|
||||
\ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0]
|
||||
|
|
Loading…
Reference in New Issue