From 30c3613924802f9594bbad815ff8ebf24d76d2dd Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 24 Aug 2013 02:49:24 +0000 Subject: [PATCH] improve algorithm for inactive colors. resolves #178. --- autoload/airline/builder.vim | 19 ++++++++----------- autoload/airline/extensions/readonly.vim | 2 +- autoload/airline/highlighter.vim | 10 +++++----- autoload/airline/themes.vim | 12 ++++++------ autoload/airline/themes/dark.vim | 6 ++++-- autoload/airline/themes/simple.vim | 5 +++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index d136f55..2c3266d 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -5,19 +5,17 @@ let s:prototype = {} function! s:prototype.split(gutter) let self._side = 0 - let self._line .= '%#'.self._group(self._curgroup).'#'.a:gutter + let self._line .= '%#'.self._curgroup.'#'.a:gutter endfunction function! s:prototype.add_section(group, contents) if self._curgroup != '' - 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 + call self._highlighter.add_separator(self._curgroup, a:group, self._side) + let self._line .= '%#'.self._curgroup.'_to_'.a:group.'#' + let self._line .= self._side ? g:airline_left_sep : g:airline_right_sep endif - let self._line .= '%#'.self._group(a:group).'#'.a:contents + let self._line .= '%#'.a:group.'#'.a:contents let self._curgroup = a:group endfunction @@ -25,11 +23,10 @@ function! s:prototype.add_raw(text) let self._line .= a:text endfunction -function! s:prototype._group(group) - return self._active ? a:group : a:group.'_inactive' -endfunction - function! s:prototype.build() + if !self._active + let self._line = substitute(self._line, '%#.\{-}\ze#', '\0_inactive', 'g') + endif return self._line endfunction diff --git a/autoload/airline/extensions/readonly.vim b/autoload/airline/extensions/readonly.vim index 6238e7c..8bff4d4 100644 --- a/autoload/airline/extensions/readonly.vim +++ b/autoload/airline/extensions/readonly.vim @@ -9,7 +9,7 @@ function! airline#extensions#readonly#get_mark() endfunction function! airline#extensions#readonly#init() - let g:airline_section_gutter = ' %#airline_file#%{airline#extensions#readonly#get_mark()}%#airline_c# ' + let g:airline_section_gutter = ' %#airline_file#%{airline#extensions#readonly#get_mark()} ' \ .g:airline_section_gutter endfunction diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 7f75356..6e274dc 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -29,10 +29,10 @@ function! airline#highlighter#exec(group, colors) \ get(colors, 4, '') != '' ? 'term='.colors[4] : '') endfunction -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 +function! s:exec_separator(dict, from, to, inverse, suffix) + let l:from = airline#themes#get_highlight(a:from.a:suffix) + let l:to = airline#themes#get_highlight(a:to.a:suffix) + let group = a:from.'_to_'.a:to.a:suffix if a:inverse let colors = [ l:from[1], l:to[1], l:from[3], l:to[3] ] else @@ -68,7 +68,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, sep[1][2]) + call exec_separator(dict, sep[1][0], sep[1][1], sep[1][2], suffix) endfor endif endfor diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index 5b80fd9..d4b987d 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -58,13 +58,13 @@ function! airline#themes#patch(palette) " colors from 'airline_c' into it. for mode in keys(a:palette) let overrides = split(mode, '_') - if len(overrides) > 1 - let mode_colors = a:palette[overrides[0]] - if exists('mode_colors.airline_file') - let file_colors = mode_colors.airline_file - let file_colors[1] = mode_colors.airline_c[1] - let file_colors[3] = mode_colors.airline_c[3] + let mode_colors = a:palette[overrides[0]] + if exists('mode_colors.airline_file') + let file_colors = mode_colors.airline_file + let file_colors[1] = mode_colors.airline_c[1] + let file_colors[3] = mode_colors.airline_c[3] + if len(overrides) > 1 let override_colors = a:palette[overrides[0].'_'.overrides[1]] let override_colors.airline_file = copy(file_colors) let override_status_colors = get(override_colors, 'airline_c', mode_colors.airline_c) diff --git a/autoload/airline/themes/dark.vim b/autoload/airline/themes/dark.vim index 73b818a..7ce6412 100644 --- a/autoload/airline/themes/dark.vim +++ b/autoload/airline/themes/dark.vim @@ -80,8 +80,10 @@ let g:airline#themes#dark#palette.visual_modified = { \ } -let s:IA = [ '#4e4e4e' , '#1c1c1c' , 239 , 234 , '' ] -let g:airline#themes#dark#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA, s:file) +let s:IA1 = [ '#606060' , '#1c1c1c' , 239 , 234 , '' ] +let s:IA2 = [ '#4e4e4e' , '#1c1c1c' , 239 , 235 , '' ] +let s:IA3 = [ '#4e4e4e' , '#1c1c1c' , 239 , 236 , '' ] +let g:airline#themes#dark#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3, s:file) " Here we define the color map for ctrlp. We check for the g:loaded_ctrlp diff --git a/autoload/airline/themes/simple.vim b/autoload/airline/themes/simple.vim index 0234d19..7163174 100644 --- a/autoload/airline/themes/simple.vim +++ b/autoload/airline/themes/simple.vim @@ -38,6 +38,7 @@ let g:airline#themes#simple#palette.visual = airline#themes#generate_color_map(s let g:airline#themes#simple#palette.visual_modified = copy(g:airline#themes#simple#palette.normal_modified) -let s:IA = [ '#4e4e4e' , s:guibg , 239 , s:termbg , '' ] -let g:airline#themes#simple#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA, s:file) +let s:IA = [ '#4e4e4e' , s:guibg , 239 , s:termbg , '' ] +let s:IA2 = [ '#4e4e4e' , s:guibg2 , 239 , s:termbg2 , '' ] +let g:airline#themes#simple#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA2, s:IA2, s:file)