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