improve algorithm for inactive colors. resolves #178.

This commit is contained in:
Bailey Ling 2013-08-24 02:49:24 +00:00
parent e8d0d24163
commit 30c3613924
6 changed files with 27 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <sid>exec_separator(dict, sep[1][0].suffix, sep[1][1].suffix, sep[1][2])
call <sid>exec_separator(dict, sep[1][0], sep[1][1], sep[1][2], suffix)
endfor
endif
endfor

View File

@ -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)

View File

@ -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

View File

@ -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)