Add interface fallback (Powerline>Unicode>ASCII)

Basically what the title says. First check if the user has Powerline,
fall back to Unicode symbols if he doesn't and fall back to ASCII
symbols if he doesn't have that either.
This commit is contained in:
Jorrit Visser 2017-02-16 19:51:30 +01:00 committed by Christian Brabandt
parent 72478dee02
commit 078537f1e2
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -17,10 +17,10 @@ function! airline#init#bootstrap()
let s:loaded = 1 let s:loaded = 1
let g:airline#init#bootstrapping = 1 let g:airline#init#bootstrapping = 1
call s:check_defined('g:airline_left_sep', get(g:, 'airline_powerline_fonts', 0) ? "\ue0b0" : " ")
call s:check_defined('g:airline_left_alt_sep', get(g:, 'airline_powerline_fonts', 0) ? "\ue0b1" : "|") let g:airline#util#async = v:version >= 800 && has('job')
call s:check_defined('g:airline_right_sep', get(g:, 'airline_powerline_fonts', 0) ? "\ue0b2" : " ") let g:airline#util#is_windows = has('win32') || has('win64')
call s:check_defined('g:airline_right_alt_sep', get(g:, 'airline_powerline_fonts', 0) ? "\ue0b3" : "|")
call s:check_defined('g:airline_detect_modified', 1) call s:check_defined('g:airline_detect_modified', 1)
call s:check_defined('g:airline_detect_paste', 1) call s:check_defined('g:airline_detect_paste', 1)
call s:check_defined('g:airline_detect_crypt', 1) call s:check_defined('g:airline_detect_crypt', 1)
@ -32,9 +32,6 @@ function! airline#init#bootstrap()
call s:check_defined('g:airline_exclude_preview', 0) call s:check_defined('g:airline_exclude_preview', 0)
call s:check_defined('g:airline_gui_mode', airline#init#gui_mode()) call s:check_defined('g:airline_gui_mode', airline#init#gui_mode())
let g:airline#util#async = v:version >= 800 && has('job')
let g:airline#util#is_windows = has('win32') || has('win64')
call s:check_defined('g:airline_mode_map', {}) call s:check_defined('g:airline_mode_map', {})
call extend(g:airline_mode_map, { call extend(g:airline_mode_map, {
\ '__' : '------', \ '__' : '------',
@ -64,20 +61,65 @@ function! airline#init#bootstrap()
\ }, 'keep') \ }, 'keep')
call s:check_defined('g:airline_symbols', {}) call s:check_defined('g:airline_symbols', {})
" First define the symbols,
" that are common in Powerline/Unicode/ASCII mode,
" then add specific symbols for either mode
call extend(g:airline_symbols, { call extend(g:airline_symbols, {
\ 'paste': 'PASTE', \ 'paste': 'PASTE',
\ 'spell': 'SPELL', \ 'spell': 'SPELL',
\ 'readonly': get(g:, 'airline_powerline_fonts', 0) ? "\ue0a2" : 'RO',
\ 'whitespace': get(g:, 'airline_powerline_fonts', 0) ? "\u2632" : "\u2632",
\ 'linenr': get(g:, 'airline_powerline_fonts', 0) ? "\ue0a1" : "\u33D1",
\ 'maxlinenr': get(g:, 'airline_powerline_fonts', 0) ? "\u2630" : "\u2630",
\ 'branch': get(g:, 'airline_powerline_fonts', 0) ? "\ue0a0" : "\u16A0",
\ 'notexists': "\u2204",
\ 'modified': '+', \ 'modified': '+',
\ 'space': ' ', \ 'space': ' '
\ 'crypt': get(g:, 'airline_crypt_symbol', nr2char(0x1F512)),
\ }, 'keep') \ }, 'keep')
if exists('g:airline_powerline_fonts')
" Symbols for Powerline terminals
call s:check_defined('g:airline_left_sep', "\ue0b0") " 
call s:check_defined('g:airline_left_alt_sep', "\ue0b1") " 
call s:check_defined('g:airline_right_sep', "\ue0b2") " 
call s:check_defined('g:airline_right_alt_sep', "\ue0b3") " 
" ro=, ws=☲, lnr=☰, mlnr=, br=, nx=Ɇ, crypt=🔒
call extend(g:airline_symbols, {
\ 'readonly': "\ue0a2",
\ 'whitespace': "\u2632",
\ 'linenr': "\u2630",
\ 'maxlinenr': "\ue0a1",
\ 'branch': "\ue0a0",
\ 'notexists': "\u0246",
\ 'crypt': nr2char(0x1F512),
\ }, 'keep')
elseif &encoding==?'utf-8'
" Symbols for Unicode terminals
call s:check_defined('g:airline_left_sep', "")
call s:check_defined('g:airline_left_alt_sep', "")
call s:check_defined('g:airline_right_sep', "")
call s:check_defined('g:airline_right_alt_sep', "")
" ro=⊝, ws=☲, lnr=☰, mlnr=㏑, br=ᚠ, nx=Ɇ, crypt=🔒
call extend(g:airline_symbols, {
\ 'readonly': "\u229D",
\ 'whitespace': "\u2632",
\ 'linenr': "\u2630",
\ 'maxlinenr': "\u33D1",
\ 'branch': "\u16A0",
\ 'notexists': "\u0246",
\ 'crypt': nr2char(0x1F512),
\ }, 'keep')
else
" Symbols for ASCII terminals
call s:check_defined('g:airline_left_sep', "")
call s:check_defined('g:airline_left_alt_sep', "")
call s:check_defined('g:airline_right_sep', "")
call s:check_defined('g:airline_right_alt_sep', "")
call extend(g:airline_symbols, {
\ 'readonly': 'RO',
\ 'whitespace': '!',
\ 'linenr': 'ln',
\ 'maxlinenr': ':',
\ 'branch': '',
\ 'notexists': '?',
\ 'crypt': 'cr',
\ }, 'keep')
endif
call airline#parts#define('mode', { call airline#parts#define('mode', {
\ 'function': 'airline#parts#mode', \ 'function': 'airline#parts#mode',
\ 'accent': 'bold', \ 'accent': 'bold',