Translate gui=reverse to cterm=reverse

Until now, "gui=reverse" was translated to "ctermbg=fg ctermfg=bg", but
Will Gray (graywh) pointed out to me that this is wrong, since there are
many terminal emulators that do properly handle reverse video.
This commit is contained in:
Matt Wozniski 2010-07-19 22:27:31 -04:00
parent 88df3d0093
commit 63e636157a
2 changed files with 26 additions and 10 deletions

View File

@ -213,6 +213,20 @@ g:CSApprox_verbose_level *g:CSApprox_verbose_level*
shown at verbosity level 1; some less important ones will be shown at shown at verbosity level 1; some less important ones will be shown at
higher verbosity levels. Has no effect on snapshotted schemes. higher verbosity levels. Has no effect on snapshotted schemes.
g:CSApprox_fake_reverse *g:CSApprox_fake_reverse*
In gvim, setting a highlight group like "Visual" (the color of your visual
mode selection) to do reverse video results in it reversing the colors of
each character cell under it. Some terminals don't support this and will
instead always use the default background color on the default foreground
color when asked for reverse video. If this variable is set to a non-zero
number, CSApprox will change any request for reverse video to the "Normal"
group's bg color on the "Normal" group's fg color, instead of asking the
terminal to do reverse video. This provides a middle ground for terminals
that don't properly support reverse video - it's worse than having the
terminal properly reverse the colors of each character cell, but it's
better than the broken behavior of some terminal emulators. This was the
default behavior before CSApprox 4.0.
g:CSApprox_eterm *g:CSApprox_eterm* g:CSApprox_eterm *g:CSApprox_eterm*
If set to a non-zero number, CSApprox will use the Eterm palette when If set to a non-zero number, CSApprox will use the Eterm palette when
'term' is set to "xterm" or begins with "screen". Otherwise, the xterm 'term' is set to "xterm" or begins with "screen". Otherwise, the xterm

View File

@ -396,16 +396,18 @@ function! s:FixupCtermInfo(highlights)
let hl.cterm[s:attr_map('sp')] = hl.gui['sp'] let hl.cterm[s:attr_map('sp')] = hl.gui['sp']
endif endif
if hl.cterm['reverse'] && hl.cterm.bg == '' if exists("g:CSApprox_fake_reverse") && g:CSApprox_fake_reverse
let hl.cterm.bg = 'fg' if hl.cterm['reverse'] && hl.cterm.bg == ''
endif let hl.cterm.bg = 'fg'
endif
if hl.cterm['reverse'] && hl.cterm.fg == '' if hl.cterm['reverse'] && hl.cterm.fg == ''
let hl.cterm.fg = 'bg' let hl.cterm.fg = 'bg'
endif endif
if hl.cterm['reverse'] if hl.cterm['reverse']
let hl.cterm.reverse = '' let hl.cterm.reverse = ''
endif
endif endif
endfor endfor
endfunction endfunction
@ -480,7 +482,7 @@ function! s:SetCtermFromGui(hl)
endfor endfor
" Finally, set the attributes " Finally, set the attributes
let attrs = [ 'bold', 'italic', 'underline', 'undercurl' ] let attrs = [ 'bold', 'italic', 'reverse', 'underline', 'undercurl' ]
call filter(attrs, 'hl.cterm[v:val] == 1') call filter(attrs, 'hl.cterm[v:val] == 1')
if !empty(attrs) if !empty(attrs)
@ -846,7 +848,7 @@ function! s:CSApproxSnapshot(file, overwrite)
let hl = highlights[hlnum] let hl = highlights[hlnum]
let line = ' CSAHi ' . hl.name let line = ' CSAHi ' . hl.name
for type in [ 'term', 'cterm', 'gui' ] for type in [ 'term', 'cterm', 'gui' ]
let attrs = [ 'reverse', 'bold', 'italic', 'underline', 'undercurl' ] let attrs = [ 'bold', 'italic', 'reverse', 'underline', 'undercurl' ]
call filter(attrs, 'hl[type][v:val] == 1') call filter(attrs, 'hl[type][v:val] == 1')
let line .= ' ' . type . '=' . (empty(attrs) ? 'NONE' : join(attrs, ',')) let line .= ' ' . type . '=' . (empty(attrs) ? 'NONE' : join(attrs, ','))
if type != 'term' if type != 'term'