Move strchars into util.vim
This commit is contained in:
parent
5b7b9cf656
commit
51bb8dd7e0
|
@ -16,7 +16,7 @@ endfunction
|
|||
|
||||
function! s:prototype.try_insert_title(index, group, pos, sep_size, force) dict
|
||||
let title = self.get_title(a:index)
|
||||
let self._remaining_space -= s:strchars(s:evaluate_tabline(title)) + a:sep_size
|
||||
let self._remaining_space -= airline#util#strchars(s:evaluate_tabline(title)) + a:sep_size
|
||||
if a:force || self._remaining_space >= 0
|
||||
let pos = a:pos
|
||||
if has_key(self, "get_pretitle")
|
||||
|
@ -37,7 +37,7 @@ function! s:prototype.try_insert_title(index, group, pos, sep_size, force) dict
|
|||
|
||||
return 1
|
||||
else
|
||||
let self._remaining_space += s:strchars(s:evaluate_tabline(title)) + a:sep_size
|
||||
let self._remaining_space += airline#util#strchars(s:evaluate_tabline(title)) + a:sep_size
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
@ -58,15 +58,15 @@ endfunction
|
|||
|
||||
function! s:prototype.build() dict
|
||||
if has_key(self, '_left_position')
|
||||
let self._remaining_space = &columns - s:strchars(s:evaluate_tabline(self._build()))
|
||||
let self._remaining_space = &columns - airline#util#strchars(s:evaluate_tabline(self._build()))
|
||||
|
||||
let center_active = get(g:, 'airline#extensions#tabline#center_active', 0)
|
||||
|
||||
let sep_size = s:strchars(s:evaluate_tabline(self._context.left_sep))
|
||||
let alt_sep_size = s:strchars(s:evaluate_tabline(self._context.left_alt_sep))
|
||||
let sep_size = airline#util#strchars(s:evaluate_tabline(self._context.left_sep))
|
||||
let alt_sep_size = airline#util#strchars(s:evaluate_tabline(self._context.left_alt_sep))
|
||||
|
||||
let overflow_marker = get(g:, 'airline#extensions#tabline#overflow_marker', g:airline_symbols.ellipsis)
|
||||
let overflow_marker_size = s:strchars(s:evaluate_tabline(overflow_marker))
|
||||
let overflow_marker_size = airline#util#strchars(s:evaluate_tabline(overflow_marker))
|
||||
" Allow space for the markers before we begin filling in titles.
|
||||
let self._remaining_space -= 2 * overflow_marker_size
|
||||
|
||||
|
@ -153,16 +153,6 @@ function! s:evaluate_tabline(tabline)
|
|||
return tabline
|
||||
endfunction
|
||||
|
||||
" Compatibility wrapper for strchars, in case this vim version does not
|
||||
" have it natively
|
||||
function! s:strchars(str)
|
||||
if exists('*strchars')
|
||||
return strchars(a:str)
|
||||
else
|
||||
return strlen(substitute(a:str, '.', 'a', 'g'))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#builder#new(context)
|
||||
let builder = airline#builder#new(a:context)
|
||||
let builder._build = builder.build
|
||||
|
|
|
@ -86,3 +86,13 @@ else
|
|||
return 0
|
||||
endfunction
|
||||
endif
|
||||
|
||||
" Compatibility wrapper for strchars, in case this vim version does not
|
||||
" have it natively
|
||||
function! airline#util#strchars(str)
|
||||
if exists('*strchars')
|
||||
return strchars(a:str)
|
||||
else
|
||||
return strlen(substitute(a:str, '.', 'a', 'g'))
|
||||
endif
|
||||
endfunction
|
||||
|
|
Loading…
Reference in New Issue