Skip to content

Commit

Permalink
automatic truncation in lightline#tabline() (ref morhetz#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Sep 7, 2013
1 parent 41b8827 commit fe48ba6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions autoload/lightline.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" Version: 0.0
" Author: itchyny
" License: MIT License
" Last Change: 2013/09/07 19:33:36.
" Last Change: 2013/09/07 21:05:31.
" =============================================================================

let s:save_cpo = &cpo
Expand Down Expand Up @@ -318,11 +318,13 @@ function! lightline#tabline()
endfunction

function! lightline#tabs()
let [t, l, x, y, z] = [tabpagenr(), tabpagenr('$'), [], [], []]
let [t, l, x, y, z, u, d] = [tabpagenr(), tabpagenr('$'), [], [], [], '...', min([winwidth('.') / 40, 4])]
for i in range(1, l)
call add(i<t?(x):i==t?(y):z, '%'.i.'T%{lightline#onetab('.i.','.(i==t).')}'.(i==l?'%T':''))
endfor
return [x, y, z]
let [a, b, c] = [len(x), len(z), d * 2]
return [a>d&&b>d ? extend(add(x[:d/2-1],u),x[-(d+1)/2:]) : a+b<=c ? x : a<=d ? x : extend(add(x[:(c-b)/2-1],u),x[-(c-b+1)/2:]), y,
\ a>d&&b>d ? extend(add(z[:d/2-1],u),z[-(d+1)/2:]) : a+b<=c ? z : b<=d ? z : extend(add(z[:(c-a)/2-1],u),z[-(c-a+1)/2:])]
endfunction

function! lightline#onetab(n, active)
Expand Down

0 comments on commit fe48ba6

Please sign in to comment.