From f780621aa017521c65823f11de0c0b3654ca431d Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 20 Aug 2013 01:56:13 +0000 Subject: [PATCH] support x,y,z theming. resolves #159. --- autoload/airline.vim | 6 +++--- autoload/airline/builder.vim | 6 ++---- autoload/airline/highlighter.vim | 10 +++++----- autoload/airline/themes.vim | 3 +++ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 5e66ba48..2ff44dc3 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -61,9 +61,9 @@ function! airline#get_statusline(winnr, active) call builder.split(s:get_section(a:winnr, 'gutter', '', '')) if airline#util#getwinvar(a:winnr, 'airline_render_right', 1) - call builder.add_section('airline_c', s:get_section(a:winnr, 'x')) - call builder.add_section('airline_b', s:get_section(a:winnr, 'y')) - call builder.add_section('airline_a', s:get_section(a:winnr, 'z')) + call builder.add_section('airline_x', s:get_section(a:winnr, 'x')) + call builder.add_section('airline_y', s:get_section(a:winnr, 'y')) + call builder.add_section('airline_z', s:get_section(a:winnr, 'z')) if a:active call builder.add_raw('%(') call builder.add_section('warningmsg', s:get_section(a:winnr, 'warning', '', '')) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index bd2176fa..d136f55f 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -10,10 +10,8 @@ endfunction function! s:prototype.add_section(group, contents) if self._curgroup != '' - call self._highlighter.add_separator(self._group(self._curgroup), self._group(a:group)) - let self._line .= self._side - \ ? '%#'.self._group(a:group).'_to_'.self._group(self._curgroup).'#' - \ : '%#'.self._group(self._curgroup).'_to_'.self._group(a:group).'#' + call self._highlighter.add_separator(self._group(self._curgroup), self._group(a:group), self._side) + let self._line .= '%#'.self._group(self._curgroup).'_to_'.self._group(a:group).'#' let self._line .= self._side \ ? self._active ? g:airline_left_sep : g:airline_left_alt_sep \ : self._active ? g:airline_right_sep : g:airline_right_alt_sep diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 2238fd40..53868205 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -19,11 +19,11 @@ function! airline#highlighter#exec(group, colors) \ get(colors, 4, '') != '' ? 'term='.colors[4] : '') endfunction -function! s:exec_separator(dict, from, to) +function! s:exec_separator(dict, from, to, inverse) let l:from = airline#themes#get_highlight(a:from) let l:to = airline#themes#get_highlight(a:to) let group = a:from.'_to_'.a:to - let colors = [ l:to[1], l:from[1], l:to[3], l:from[3] ] + let colors = [ l:to[1], l:from[1], l:to[3], l:from[3], a:inverse ? 'inverse' : '' ] let a:dict[group] = colors call airline#highlighter#exec(group, colors) endfunction @@ -37,8 +37,8 @@ function! airline#highlighter#new() call self.highlight(['normal']) endfunction - function! highlighter.add_separator(from, to) - let self._separators[a:from.a:to] = [a:from, a:to] + function! highlighter.add_separator(from, to, inverse) + let self._separators[a:from.a:to] = [a:from, a:to, a:inverse] endfunction function! highlighter.highlight(modes) @@ -54,7 +54,7 @@ function! airline#highlighter#new() " TODO: optimize this for sep in items(self._separators) - call exec_separator(dict, sep[1][0].suffix, sep[1][1].suffix) + call exec_separator(dict, sep[1][0].suffix, sep[1][1].suffix, sep[1][2]) endfor endif endfor diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index 89894ec9..5b80fd9a 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -9,6 +9,9 @@ function! airline#themes#generate_color_map(section1, section2, section3, file) \ 'airline_b': [ a:section2[0] , a:section2[1] , a:section2[2] , a:section2[3] , get(a:section2 , 4 , '' ) ] , \ 'airline_c': [ a:section3[0] , a:section3[1] , a:section3[2] , a:section3[3] , get(a:section3 , 4 , '' ) ] , \ 'airline_file': [ a:file[0] , a:file[1] , a:file[2] , a:file[3] , get(a:file , 4 , '' ) ] , + \ 'airline_x': [ a:section3[0] , a:section3[1] , a:section3[2] , a:section3[3] , get(a:section3 , 4 , '' ) ] , + \ 'airline_y': [ a:section2[0] , a:section2[1] , a:section2[2] , a:section2[3] , get(a:section2 , 4 , '' ) ] , + \ 'airline_z': [ a:section1[0] , a:section1[1] , a:section1[2] , a:section1[3] , get(a:section1 , 4 , '' ) ] , \ } endfunction