Konsole now supports the xterm color palette

And apparently has for some time[1].  Thanks to Will Gray (graywh) for
pointing this out to me.

[1] http://websvn.kde.org/?revision=909719&view=revision)
This commit is contained in:
Matt Wozniski 2010-07-17 20:24:15 -04:00
parent 6890d1ecf0
commit 4b6b1648d0
3 changed files with 65 additions and 20 deletions

View File

@ -25,7 +25,14 @@ function! csapprox#common#PaletteType()
let type = 'xterm' let type = 'xterm'
endif endif
elseif &term =~? '^konsole' elseif &term =~? '^konsole'
let type = 'konsole' " Konsole only used its own palette up til KDE 4.2.0
if executable('kde4-config') && system('kde4-config --kde-version') =~ '^4\.[10]\.'
let type = 'konsole'
elseif executable('kde-config') && system('kde-config --version') =~# 'KDE: 3\.'
let type = 'konsole'
else
let type = 'xterm'
endif
elseif &term =~? '^eterm' elseif &term =~? '^eterm'
let type = 'eterm' let type = 'eterm'
else else

View File

@ -146,20 +146,41 @@ set to something that implies high color support. Possible choices include
"xterm-256color" for 256 color support and "rxvt-unicode" for 88 color "xterm-256color" for 256 color support and "rxvt-unicode" for 88 color
support. support.
*csapprox-palettes* *csapprox-palettes*
Also, there are three different 256 color cube palettes available and CSApprox Also, there are at least three different 256-color palettes in use. Nearly
has no way to tell which you're using unless $TERM is set to something that is all terminals use an xterm-compatible palette, so most users need not concern
specific to the terminal, like "konsole-256color" or "Eterm". Because of this, the themselves with this, with only two exceptions: Eterm uses a slightly
most sane behavior is assuming the user is using the most popular palette, different palette, and older Konsole (pre KDE 2.2.0) used a third palette.
which is used by all but Konsole and Eterm, whenever $TERM is set to something CSApprox has no reliable way to tell which palette your terminal uses, so it
generic like "xterm" or "screen". You can override this default, however - makes some educated guesses:
see |csapprox-configure|.
i) If vim thinks that there are 88 colors available, CSApprox will use the
xterm/urxvt-compatible 88 color palette (I don't know of any other
88 color palette in use anywhere).
ii) If $TERM starts with "Eterm", CSApprox will approximate based on the
Eterm palette.
iii) If $TERM starts with "konsole", CSApprox will use the legacy Konsole
palette if either "kde4-config --kde-version" or "kde-config --version"
reports that the KDE version on the system is less than 4.2.0.
Otherwise, it will use the xterm palette.
iv) If $TERM starts with "xterm" or "screen", then CSApprox looks for the
vim variables "g:CSApprox_eterm" and "g:CSApprox_konsole".
If g:CSApprox_eterm is true, CSApprox uses the Eterm palette.
If g:CSApprox_konsole is true, CSApprox uses the old konsole palette.
Otherwise, CSApprox uses the xterm palette.
v) For all other $TERM values, CSApprox uses the xterm palette.
*csapprox-terminal-example* *csapprox-terminal-example*
To turn on high color support without fixing $TERM, you can change t_Co in To turn on high color support despite an incorrect $TERM, you can override
your .vimrc, and set either CSApprox_konsole or CSApprox_eterm if appropriate. t_Co (the vim name for the terminfo setting defining how many colors are
One way would be to put something like this into your |vimrc|: available) in your .vimrc, and set either CSApprox_konsole or CSApprox_eterm
if appropriate. You could put something like this into your |vimrc|:
> >
if (&term == 'xterm' || &term =~? '^screen') && hostname() == 'my-machine' if (&term == 'xterm' || &term =~? '^screen') && hostname() == 'my-machine'
" On my machine, I use Konsole with 256 color support " On my machine, I use an old Konsole with 256 color support
set t_Co=256 set t_Co=256
let g:CSApprox_konsole = 1 let g:CSApprox_konsole = 1
endif endif
@ -198,9 +219,9 @@ g:CSApprox_eterm *g:CSApprox_eterm*
palette would be used. This also affects snapshotted schemes. palette would be used. This also affects snapshotted schemes.
g:CSApprox_konsole *g:CSApprox_konsole* g:CSApprox_konsole *g:CSApprox_konsole*
If set to a non-zero number, CSApprox will use the Konsole palette when If set to a non-zero number, CSApprox will use the old Konsole palette
'term' is set to "xterm" or begins with "screen". Otherwise, the xterm when 'term' is set to "xterm" or begins with "screen". Otherwise, the
palette would be used. This also affects snapshotted schemes. xterm palette would be used. This also affects snapshotted schemes.
g:CSApprox_attr_map *g:CSApprox_attr_map* g:CSApprox_attr_map *g:CSApprox_attr_map*
Since some attributes (like 'guisp') can't be used in a terminal, and Since some attributes (like 'guisp') can't be used in a terminal, and
@ -501,10 +522,9 @@ iTerm (iTerm.app):
*csapprox-konsole* *csapprox-konsole*
Konsole (konsole): Konsole (konsole):
256 color palette 256 color palette
Colors composed of: [ 0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF ] Colors used to be composed of: [ 0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF ]
Same greyscales as xterm As of KDE 2.2.0, colors match the xterm palette
You should set the g:CSApprox_konsole variable unless $TERM begins with Always used the same greyscales as xterm
'konsole', case insensitive
*csapprox-eterm* *csapprox-eterm*
eterm (Eterm): eterm (Eterm):

View File

@ -783,6 +783,18 @@ function! s:CSApproxSnapshot(file, overwrite)
let lines += [ ' command! -nargs=+ CSAHi exe "hi" <q-args>' ] let lines += [ ' command! -nargs=+ CSAHi exe "hi" <q-args>' ]
let lines += [ 'endif' ] let lines += [ 'endif' ]
let lines += [ '' ] let lines += [ '' ]
let lines += [ 'function! s:old_kde()' ]
let lines += [ ' " Konsole only used its own palette up til KDE 4.2.0' ]
let lines += [ " if executable('kde4-config') && system('kde4-config --kde-version') =~ '^4\.[10]\.'" ]
let lines += [ ' return 1' ]
let lines += [ " elseif executable('kde-config') && system('kde-config --version') =~# 'KDE: 3\.'" ]
let lines += [ ' return 1' ]
let lines += [ ' else' ]
let lines += [ ' return 0' ]
let lines += [ ' endif' ]
let lines += [ 'endfunction' ]
let lines += [ '' ]
let lines += [ 'if 0' ] let lines += [ 'if 0' ]
for round in [ 'konsole', 'eterm', 'xterm', 'urxvt' ] for round in [ 'konsole', 'eterm', 'xterm', 'urxvt' ]
@ -807,11 +819,17 @@ function! s:CSApproxSnapshot(file, overwrite)
call s:FixupGuiInfo(highlights) call s:FixupGuiInfo(highlights)
if round == 'konsole' || round == 'eterm' if round == 'konsole' || round == 'eterm'
if round == 'konsole'
let term_matches_round = '(&term =~? "^konsole" && s:old_kde())'
else
let term_matches_round = '&term =~? "^' . round . '"'
endif
let lines += [ 'elseif has("gui_running") || (&t_Co == ' . &t_Co let lines += [ 'elseif has("gui_running") || (&t_Co == ' . &t_Co
\ . ' && (&term ==# "xterm" || &term =~# "^screen")' \ . ' && (&term ==# "xterm" || &term =~# "^screen")'
\ . ' && exists("g:CSApprox_' . round . '")' \ . ' && exists("g:CSApprox_' . round . '")'
\ . ' && g:CSApprox_' . round . ')' \ . ' && g:CSApprox_' . round . ')'
\ . ' || &term =~? "^' . round . '"' ] \ . ' || ' . term_matches_round ]
else else
let lines += [ 'elseif has("gui_running") || &t_Co == ' . &t_Co ] let lines += [ 'elseif has("gui_running") || &t_Co == ' . &t_Co ]
endif endif