Rename remaining tab -> title in tabline/builder
This commit is contained in:
parent
0b47adf087
commit
5b7b9cf656
@ -143,11 +143,11 @@ function! airline#extensions#tabline#buffers#get()
|
|||||||
let s:column_width = &columns
|
let s:column_width = &columns
|
||||||
let s:current_tabline = b.build()
|
let s:current_tabline = b.build()
|
||||||
let s:current_visible_buffers = copy(b.buffers)
|
let s:current_visible_buffers = copy(b.buffers)
|
||||||
if b._right_tab <= last_buffer
|
if b._right_title <= last_buffer
|
||||||
call remove(s:current_visible_buffers, b._right_tab, last_buffer)
|
call remove(s:current_visible_buffers, b._right_title, last_buffer)
|
||||||
endif
|
endif
|
||||||
if b._left_tab > 0
|
if b._left_title > 0
|
||||||
call remove(s:current_visible_buffers, 0, b._left_tab)
|
call remove(s:current_visible_buffers, 0, b._left_title)
|
||||||
endif
|
endif
|
||||||
return s:current_tabline
|
return s:current_tabline
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -5,39 +5,39 @@ scriptencoding utf-8
|
|||||||
|
|
||||||
let s:prototype = {}
|
let s:prototype = {}
|
||||||
|
|
||||||
function! s:prototype.insert_titles(curtab, first_tab, last_tab) dict
|
function! s:prototype.insert_titles(current, first, last) dict
|
||||||
let self._first_tab = a:first_tab
|
let self._first_title = a:first
|
||||||
let self._last_tab = a:last_tab
|
let self._last_title = a:last
|
||||||
let self._left_tab = a:curtab
|
let self._left_title = a:current
|
||||||
let self._right_tab = a:curtab + 1
|
let self._right_title = a:current + 1
|
||||||
let self._left_position = self.get_position()
|
let self._left_position = self.get_position()
|
||||||
let self._right_position = self._left_position
|
let self._right_position = self._left_position
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:prototype.try_insert_title(tab, group, pos, sep_size, force) dict
|
function! s:prototype.try_insert_title(index, group, pos, sep_size, force) dict
|
||||||
let tab_title = self.get_title(a:tab)
|
let title = self.get_title(a:index)
|
||||||
let self._remaining_space -= s:strchars(s:evaluate_tabline(tab_title)) + a:sep_size
|
let self._remaining_space -= s:strchars(s:evaluate_tabline(title)) + a:sep_size
|
||||||
if a:force || self._remaining_space >= 0
|
if a:force || self._remaining_space >= 0
|
||||||
let pos = a:pos
|
let pos = a:pos
|
||||||
if has_key(self, "get_pretitle")
|
if has_key(self, "get_pretitle")
|
||||||
call self.insert_raw(self.get_pretitle(a:tab), pos)
|
call self.insert_raw(self.get_pretitle(a:index), pos)
|
||||||
let self._right_position += 1
|
let self._right_position += 1
|
||||||
let pos += 1
|
let pos += 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call self.insert_section(a:group, tab_title, pos)
|
call self.insert_section(a:group, title, pos)
|
||||||
let self._right_position += 1
|
let self._right_position += 1
|
||||||
let pos += 1
|
let pos += 1
|
||||||
|
|
||||||
if has_key(self, "get_posttitle")
|
if has_key(self, "get_posttitle")
|
||||||
call self.insert_raw(self.get_posttitle(a:tab), pos)
|
call self.insert_raw(self.get_posttitle(a:index), pos)
|
||||||
let self._right_position += 1
|
let self._right_position += 1
|
||||||
let pos += 1
|
let pos += 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
let self._remaining_space += s:strchars(s:evaluate_tabline(tab_title)) + a:sep_size
|
let self._remaining_space += s:strchars(s:evaluate_tabline(title)) + a:sep_size
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
@ -73,55 +73,55 @@ function! s:prototype.build() dict
|
|||||||
let outer_left_group = airline#builder#get_prev_group(self._sections, self._left_position)
|
let outer_left_group = airline#builder#get_prev_group(self._sections, self._left_position)
|
||||||
let outer_right_group = airline#builder#get_next_group(self._sections, self._right_position)
|
let outer_right_group = airline#builder#get_next_group(self._sections, self._right_position)
|
||||||
|
|
||||||
" Add the current tab
|
" Add the current title
|
||||||
let group = self.get_group(self._left_tab)
|
let group = self.get_group(self._left_title)
|
||||||
let sep_change =
|
let sep_change =
|
||||||
\ s:get_separator_change(group, "", outer_left_group, sep_size, alt_sep_size) +
|
\ s:get_separator_change(group, "", outer_left_group, sep_size, alt_sep_size) +
|
||||||
\ s:get_separator_change(group, "", outer_right_group, sep_size, alt_sep_size)
|
\ s:get_separator_change(group, "", outer_right_group, sep_size, alt_sep_size)
|
||||||
let left_group = group
|
let left_group = group
|
||||||
let right_group = group
|
let right_group = group
|
||||||
let self._left_tab -=
|
let self._left_title -=
|
||||||
\ self.try_insert_title(self._left_tab, group, self._left_position, sep_change, 1)
|
\ self.try_insert_title(self._left_title, group, self._left_position, sep_change, 1)
|
||||||
|
|
||||||
if get(g:, 'airline#extensions#tabline#current_first', 0)
|
if get(g:, 'airline#extensions#tabline#current_first', 0)
|
||||||
" always have current tabpage first
|
" always have current title first
|
||||||
let self._left_position += 1
|
let self._left_position += 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Add the tab to the right
|
" Add the title to the right
|
||||||
if !center_active && self._right_tab <= self._last_tab
|
if !center_active && self._right_title <= self._last_title
|
||||||
let group = self.get_group(self._right_tab)
|
let group = self.get_group(self._right_title)
|
||||||
let sep_change =
|
let sep_change =
|
||||||
\ s:get_separator_change(group, right_group, outer_right_group, sep_size, alt_sep_size)
|
\ s:get_separator_change(group, right_group, outer_right_group, sep_size, alt_sep_size)
|
||||||
let right_group = group
|
let right_group = group
|
||||||
let self._right_tab +=
|
let self._right_title +=
|
||||||
\ self.try_insert_title(self._right_tab, group, self._right_position, sep_change, 1)
|
\ self.try_insert_title(self._right_title, group, self._right_position, sep_change, 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
while self._remaining_space > 0
|
while self._remaining_space > 0
|
||||||
let done = 0
|
let done = 0
|
||||||
if self._left_tab >= self._first_tab
|
if self._left_title >= self._first_title
|
||||||
let group = self.get_group(self._left_tab)
|
let group = self.get_group(self._left_title)
|
||||||
let sep_change =
|
let sep_change =
|
||||||
\ s:get_separator_change(group, left_group, outer_left_group, sep_size, alt_sep_size)
|
\ s:get_separator_change(group, left_group, outer_left_group, sep_size, alt_sep_size)
|
||||||
let left_group = group
|
let left_group = group
|
||||||
let done = self.try_insert_title(self._left_tab, group, self._left_position, sep_change, 0)
|
let done = self.try_insert_title(self._left_title, group, self._left_position, sep_change, 0)
|
||||||
let self._left_tab -= done
|
let self._left_title -= done
|
||||||
endif
|
endif
|
||||||
if self._right_tab <= self._last_tab && (center_active || !done)
|
if self._right_title <= self._last_title && (center_active || !done)
|
||||||
let group = self.get_group(self._right_tab)
|
let group = self.get_group(self._right_title)
|
||||||
let sep_change =
|
let sep_change =
|
||||||
\ s:get_separator_change(group, right_group, outer_right_group, sep_size, alt_sep_size)
|
\ s:get_separator_change(group, right_group, outer_right_group, sep_size, alt_sep_size)
|
||||||
let right_group = group
|
let right_group = group
|
||||||
let done = self.try_insert_title(self._right_tab, group, self._right_position, sep_change, 0)
|
let done = self.try_insert_title(self._right_title, group, self._right_position, sep_change, 0)
|
||||||
let self._right_tab += done
|
let self._right_title += done
|
||||||
endif
|
endif
|
||||||
if !done
|
if !done
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
if self._left_tab >= self._first_tab
|
if self._left_title >= self._first_title
|
||||||
if get(g:, 'airline#extensions#tabline#current_first', 0)
|
if get(g:, 'airline#extensions#tabline#current_first', 0)
|
||||||
let self._left_position -= 1
|
let self._left_position -= 1
|
||||||
endif
|
endif
|
||||||
@ -129,7 +129,7 @@ function! s:prototype.build() dict
|
|||||||
let self._right_position += 1
|
let self._right_position += 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if self._right_tab <= self._last_tab
|
if self._right_title <= self._last_title
|
||||||
call self.insert_raw('%#'.self.overflow_group.'#'.overflow_marker, self._right_position)
|
call self.insert_raw('%#'.self.overflow_group.'#'.overflow_marker, self._right_position)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user