2013-08-30 23:56:12 +02:00
|
|
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
|
|
|
function! s:get_val(key, append)
|
|
|
|
let part = airline#parts#get(a:key)
|
|
|
|
if exists('part.function')
|
|
|
|
let func = (part.function).'()'
|
|
|
|
elseif exists('part.text')
|
|
|
|
let func = '"'.(part.text).'"'
|
|
|
|
elseif exists('part.raw')
|
|
|
|
return part.raw
|
|
|
|
else
|
|
|
|
return a:key
|
|
|
|
endif
|
|
|
|
|
2013-08-31 03:15:41 +02:00
|
|
|
let val = ''
|
2013-08-30 23:56:12 +02:00
|
|
|
if a:append > 0
|
|
|
|
let val .= '%{airline#util#append('.func.')}'
|
|
|
|
elseif a:append < 0
|
2013-08-31 03:15:41 +02:00
|
|
|
let val .= '%{airline#util#prepend('.func.')}'
|
2013-08-30 23:56:12 +02:00
|
|
|
else
|
2013-08-31 03:15:41 +02:00
|
|
|
let val .= '%{'.func.'}'
|
2013-08-30 23:56:12 +02:00
|
|
|
endif
|
|
|
|
return val
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create(parts)
|
|
|
|
return join(map(a:parts, 's:get_val(v:val, 0)'), '')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create_left(parts)
|
|
|
|
let _ = s:get_val(a:parts[0], 0)
|
|
|
|
for i in range(1, len(a:parts) - 1)
|
|
|
|
let _ .= s:get_val(a:parts[i], 1)
|
|
|
|
endfor
|
|
|
|
return _
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#section#create_right(parts)
|
|
|
|
let _ = ''
|
|
|
|
for i in range(0, len(a:parts) - 2)
|
|
|
|
let _ .= s:get_val(a:parts[i], -1)
|
|
|
|
endfor
|
|
|
|
let _ .= s:get_val(a:parts[-1], 0)
|
|
|
|
return _
|
|
|
|
endfunction
|
|
|
|
|