rewritten SetColor()

This commit is contained in:
ManjaroOne666 2018-05-07 17:44:18 +01:00
parent b5a82577c1
commit 9f3fa1e5d8
1 changed files with 72 additions and 33 deletions

View File

@ -1,44 +1,83 @@
function! SetColor(name, fg, bg, fg_l, bg_l, attr) abort
"{{{
let l:is_dark = &background ==? 'dark'
if a:fg ==? 'none'
let l:gui_fg = l:is_dark ? a:bg : a:bg_l
let l:c_fg = l:is_dark ? 'black' : 'white'
let l:fg = l:c_fg
elseif a:fg ==? ''
let l:gui_fg = l:is_dark ? g:l_normal_fg : g:d_normal_fg
let l:c_fg = l:is_dark ? 'white' : 'black'
let l:fg = l:c_fg
else
let l:gui_fg = l:is_dark ? a:fg : a:fg_l
let l:c_fg = 'white'
let l:fg = 'white'
function! SetColor(name, fg, bg, fg_l, bg_l, style) abort
if &background ==? 'dark'
if a:fg ==? 'normal'
let l:guifg = ' guifg=' . g:d_normal_fg
let l:ctermfg = 'ctermfg=black'
" let l:termfg = 'termfg=black'
elseif a:fg ==? 'none'
let l:guifg = ' guifg=' . g:d_normal_bg
let l:ctermfg = ' ctermfg=white'
" let l:termfg = ' termfg=white'
elseif a:fg ==? ''
let l:guifg = ''
let l:ctermfg = ''
" let l:termfg = ''
else
let l:guifg = ' guifg=' . a:fg
let l:ctermfg = ' ctermfg=black'
" let l:termfg = ' termfg=black'
endif
if a:bg ==? 'none'
let l:guibg = ' guibg=NONE'
let l:ctermbg = ' ctermbg=none'
" let l:termbg = ' termbg=none'
elseif a:bg ==? ''
let l:guibg = ''
let l:ctermbg = ''
" let l:termbg = ''
else
let l:guibg = ' guibg=' . a:bg
let l:ctermbg = ' ctermbg=black'
endif
else " light background
if a:fg_l ==? 'normal'
let l:guifg = ' guifg=' . g:l_normal_fg
let l:ctermfg = ' ctermfg=black'
" let l:termfg = ' termfg=black'
elseif a:fg_l ==? 'none'
let l:guifg = ' guifg=' . g:l_normal_bg
let l:ctermfg = ' ctermfg=white'
" let l:termfg = ' termfg=white'
elseif a:fg_l ==? ''
let l:guifg = ''
let l:ctermfg = ''
let l:termfg = ''
else
let l:guifg = ' guifg=' . a:fg_l
let l:ctermfg = ' ctermfg=black'
" let l:termfg = ' termfg=black'
endif
if a:bg_l ==? 'none'
let l:guibg = ' guibg=NONE'
let l:ctermbg = ' ctermbg=none'
" let l:termbg = ' termbg=none'
elseif a:bg_l ==? ''
let l:guibg = ''
let l:ctermbg = ''
" let l:termbg = ''
else
let l:guibg = ' guibg=' . a:bg_l
let l:ctermbg = ' ctermbg=white'
" let l:termbg = ' termbg=white'
endif
endif
if a:bg ==? ''
let l:gui_bg = l:is_dark ? g:d_normal_bg : g:l_normal_bg
let l:c_bg = l:is_dark ? 'none' : 'white'
let l:bg = l:c_bg
if a:style ==? ''
let l:style = ' term=none cterm=none gui=NONE'
else
let l:gui_bg = l:is_dark ? a:bg : a:bg_l
let l:c_bg = l:is_dark ? 'black' : 'white'
let l:bg = l:c_bg
let l:style = ' term=' . a:style . ' cterm=' . a:style . ' gui=' . a:style
endif
let l:attr_str = a:attr ==# '' ? 'none' : a:attr
let l:gui_attr = l:attr_str
let l:c_attr = l:attr_str
let l:attr = l:attr_str
let l:histring = 'hi! ' . a:name . l:guifg . l:guibg . l:style
let l:histring .= l:ctermfg . l:ctermbg
" let l:histring .= l:termfg . l:termbg
let l:guistring = 'guifg=' . l:gui_fg . ' guibg=' . l:gui_bg . ' gui=' . l:gui_attr
let l:cstring = ' cterm=' . l:c_attr
let l:tstring = ' term=' . l:attr
let l:histring = 'hi! ' . a:name . ' ' . l:guistring . l:cstring . l:tstring
" echom l:histring
execute 'hi clear ' . a:name
execute l:histring
endfunction"}}}
endfunction
" TODO better name
function! GetStatusFrag(condition, colorname, conditionprefix, text) abort