move palette conversion for Windows to colortable.vim

This commit is contained in:
itchyny
2020-06-19 11:11:45 +09:00
parent 2202c7a996
commit 3afa0102ce
2 changed files with 13 additions and 9 deletions

View File

@@ -2,7 +2,7 @@
" Filename: autoload/lightline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2020/06/19 07:27:34.
" Last Change: 2020/06/19 11:08:46.
" =============================================================================
let s:save_cpo = &cpo
@@ -198,13 +198,7 @@ function! lightline#colorscheme() abort
let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette
finally
if has('win32') && !has('gui_running') && &t_Co < 256
for u in values(s:lightline.palette)
for v in values(u)
for _ in v
let [_[2], _[3]] = [lightline#colortable#gui2cui(_[0], _[2]), lightline#colortable#gui2cui(_[1], _[3])]
endfor
endfor
endfor
call lightline#colortable#gui2cui_palette(s:lightline.palette)
endif
let s:highlight = {}
call lightline#highlight('normal')

View File

@@ -2,7 +2,7 @@
" Filename: autoload/lightline/colortable.vim
" Author: itchyny
" License: MIT License
" Last Change: 2015/03/29 06:21:39.
" Last Change: 2020/06/19 11:07:13.
" =============================================================================
let s:save_cpo = &cpo
@@ -38,5 +38,15 @@ function! lightline#colortable#gui2cui(rgb, fallback) abort
return rgb[0] + rgb[1] + rgb[2]
endfunction
function! lightline#colortable#gui2cui_palette(palette) abort
for u in values(a:palette)
for v in values(u)
for w in v
let [w[2], w[3]] = [lightline#colortable#gui2cui(w[0], w[2]), lightline#colortable#gui2cui(w[1], w[3])]
endfor
endfor
endfor
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo