%s/s:gui2cui/lightline#colortable#gui2cui/g for speed up

This commit is contained in:
itchyny
2013-08-28 10:10:09 +09:00
parent e61de8911e
commit 0229d1c95e
2 changed files with 18 additions and 18 deletions

View File

@@ -3,7 +3,7 @@
" Version: 0.0
" Author: itchyny
" License: MIT License
" Last Change: 2013/08/22 21:12:21.
" Last Change: 2013/08/28 10:07:13.
" =============================================================================
function! s:load()
@@ -23,3 +23,16 @@ function! lightline#colortable#name_to_rgb(name)
let name = tolower(a:name)
return has_key(s:table, name) ? s:table[name] : []
endfunction
function! lightline#colortable#gui2cui(rgb, fallback)
let rgb = map(matchlist(a:rgb, '#\(..\)\(..\)\(..\)')[1:3], '0 + ("0x".v:val)')
if len(rgb) == 0
let rgb = lightline#colortable#name_to_rgb(a:rgb)
if len(rgb) == 0
throw a:rgb
return a:fallback % 128
endif
endif
let rgb = [rgb[0] > 127 ? 4 : 0, rgb[1] > 127 ? 2 : 0, rgb[2] > 127 ? 1 : 0]
return rgb[0] + rgb[1] + rgb[2]
endfunction