Statusline: Use separator widths to calculate whether a title will fit

This commit is contained in:
mrmr1993
2018-03-18 00:52:34 +00:00
parent 896c14bded
commit 84bf60c405
2 changed files with 60 additions and 16 deletions
+17 -4
View File
@@ -34,7 +34,7 @@ function! s:prototype.get_position() dict
return len(self._sections)
endfunction
function! s:get_prev_group(sections, i)
function! airline#builder#get_prev_group(sections, i)
let x = a:i - 1
while x >= 0
let group = a:sections[x][0]
@@ -46,6 +46,19 @@ function! s:get_prev_group(sections, i)
return ''
endfunction
function! airline#builder#get_next_group(sections, i)
let x = a:i + 1
let l = len(a:sections)
while x < l
let group = a:sections[x][0]
if group != '' && group != '|'
return group
endif
let x = x + 1
endwhile
return ''
endfunction
function! s:prototype.build() dict
let side = 1
let line = ''
@@ -60,7 +73,7 @@ function! s:prototype.build() dict
let group = section[0]
let contents = section[1]
let pgroup = prev_group
let prev_group = s:get_prev_group(self._sections, i)
let prev_group = airline#builder#get_prev_group(self._sections, i)
if group ==# 'airline_c' && &buftype ==# 'terminal' && self._context.active
let group = 'airline_term'
elseif group ==# 'airline_c' && !self._context.active && has_key(self._context, 'bufnr')
@@ -114,7 +127,7 @@ function! s:prototype.build() dict
return line
endfunction
function! s:should_change_group(group1, group2)
function! airline#builder#should_change_group(group1, group2)
if a:group1 == a:group2
return 0
endif
@@ -144,7 +157,7 @@ function! s:get_transitioned_seperator(self, prev_group, group, side)
endfunction
function! s:get_seperator(self, prev_group, group, side)
if s:should_change_group(a:prev_group, a:group)
if airline#builder#should_change_group(a:prev_group, a:group)
return s:get_transitioned_seperator(a:self, a:prev_group, a:group, a:side)
else
return a:side ? a:self._context.left_alt_sep : a:self._context.right_alt_sep