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)
|
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
for nr in filter(range(1, winnr('$')), 'v:val != winnr()')
|
let range = filter(range(1, winnr('$')), 'v:val != winnr()')
|
||||||
if airline#util#getwinvar(nr, 'airline_disabled', 0)
|
" create inactive statusline
|
||||||
continue
|
call airline#update_statusline_inactive(range)
|
||||||
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
|
|
||||||
|
|
||||||
unlet! w:airline_render_left w:airline_render_right
|
unlet! w:airline_render_left w:airline_render_right
|
||||||
exe 'unlet! ' 'w:airline_section_'. join(s:sections, ' w:airline_section_')
|
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)
|
call s:invoke_funcrefs(context, g:airline_statusline_funcrefs)
|
||||||
endfunction
|
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:contexts = {}
|
||||||
let s:core_funcrefs = [
|
let s:core_funcrefs = [
|
||||||
\ function('airline#extensions#apply'),
|
\ function('airline#extensions#apply'),
|
||||||
|
|
|
@ -105,6 +105,8 @@ function! s:airline_toggle()
|
||||||
if exists("##TerminalOpen")
|
if exists("##TerminalOpen")
|
||||||
autocmd TerminalOpen * call <sid>on_colorscheme_changed()
|
autocmd TerminalOpen * call <sid>on_colorscheme_changed()
|
||||||
endif
|
endif
|
||||||
|
" Set all statuslines to inactive
|
||||||
|
autocmd FocusLost * call airline#update_statusline_inactive(range(1, winnr('$')))
|
||||||
" Refresh airline for :syntax off
|
" Refresh airline for :syntax off
|
||||||
autocmd SourcePre */syntax/syntax.vim
|
autocmd SourcePre */syntax/syntax.vim
|
||||||
\ call airline#extensions#tabline#buffers#invalidate()
|
\ call airline#extensions#tabline#buffers#invalidate()
|
||||||
|
@ -119,7 +121,7 @@ function! s:airline_toggle()
|
||||||
\ | call <sid>on_window_changed()
|
\ | call <sid>on_window_changed()
|
||||||
\ | endif
|
\ | 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 TabEnter * :unlet! w:airline_lastmode | let w:airline_active=1
|
||||||
autocmd BufWritePost */autoload/airline/themes/*.vim
|
autocmd BufWritePost */autoload/airline/themes/*.vim
|
||||||
\ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0]
|
\ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0]
|
||||||
|
|
Loading…
Reference in New Issue