On Thu, 15 Jul 2010, Tony Mechelynck wrote:
> On 15/07/10 00:34, Benjamin R. Haskell wrote:
> > On Wed, 14 Jul 2010, Tony Mechelynck wrote:
> >
> > > On 14/07/10 22:57, Bram Moolenaar wrote:
> > > >
> > > > Matt Wozniski wrote:
> > > >
> > > > [about a patch to support #rrggbb in a terminal]
> > > >
> > > > Where can I find the latest version of this patch? I only see
> > > > one that is two years old.
> > > >
> > >
> > > Is such a patch necessary? The CSApprox plugin gives me uniform
> > > look& feel between GUI and xterm-256color; OTOH I can still use
> > > _different_ cterm ctermbg ctermfg colors for the Linux console
> > > which has only (IIUC) 8 colors + foreground bold.
> > >
> > > With this plugin installed I can think (and program my
> > > colorshceme) in terms of: term= black& white only, possibly bold
> > > and/or underline; cterm= 8 to 16 colors; gui= 88 to 16777216
> > > colors — CSApprox does the "dirty work" of converting "gui" rrggbb
> > > values to palette ordinal numbers when in 88- or 256-color
> > > consoles.
> >
> > In the off-chance you hadn't noticed, Matt Wozniski is the author of
> > both the patch in question and the CSApprox plugin.
> >
> > I'm not sure how either the patch or the plugin works currently, but
> > personally, I'd prefer that #rrggbb conversion for terminals gets
> > integrated into the main program.
> [...]
> > I agree that getting it working so that colorschemes can be written
> > toward the following guidelines would be most convenient:
> >
> > term= no 'colors'
> > cterm= 8 or 16 colors
> > gui= 88 / 256 / 'true' colors
> >
> > But as I said, I'd rather it not require a plugin.
> >
>
> Well, at least we agree on one point: we'd prefer guifg=#123456 to
> work in 88+ color terminal, rather than ctermfg=#123456 which would
> prevent writing "ctermfg=cyan guifg=#123456" to cover low-color
> terminals too.
>
> OTOH, I believe that CSApprox does the job well, with no appreciable
> delay, and I don't feel the necessity of patching the C code. It even
> has accessible "hooks" for special cases (see below). What _would_ be
> useful would be to distribute that plugin as part of the vanilla Vim
> distribution, maybe "disabled matchit-like" if people don't want Vim
> in xterm-256 and gvim to look alike.
>
> Example of a special case: (my vimrc sets CSApprox_loaded to 1 on the
> Linux console and) my colorscheme includes the following:
>
> > " display the status line of the active window in a distinctive color:
> > " bold black on bright red in the GUI, white on green in the console
> > " (where the bg is never bright, and dark red is sometimes an ugly sort
> > " of reddish brown).
> > hi StatusLine gui=NONE,bold guibg=red guifg=black
> > \ cterm=NONE,bold ctermbg=darkgreen ctermfg=white
> > hi WildMenu gui=NONE,bold guibg=green guifg=black
> > \ cterm=NONE,bold ctermbg=black ctermfg=white
> > " make the status line bold-reverse (but B&W) for inactive windows
> > hi StatusLineNC gui=reverse,bold
> > \ cterm=NONE ctermbg=black ctermfg=lightgrey
> > " make the active status line colours alternate between two settings
> > " to give a visual notice of the CursorHold/CursorHoldI events
> > if ! exists("s:statuslineflag")
> > let s:statuslineflag = 0
> > endif
> > "
> > " The following 'fancy footwork' is needed to have our CursorHold
> > autocommand
> > " work smoothly with 256-color cterms handled by the 3rd-party csapprox.vim
> > plugin
> > if exists('g:CSApprox_approximator_function')
> > let s:ctbg1 = g:CSApprox_approximator_function(0, 255, 0) " green
> > let s:ctbg2 = g:CSApprox_approximator_function(255, 0, 0) " red
> > let s:ctfg = g:CSApprox_approximator_function(0, 0, 0) " black
> > else
> > let s:ctbg1 = 'darkgreen'
> > let s:ctbg2 = 'black'
> > let s:ctfg = 'white'
> > endif
> >
> > function! ToggleStatusLine()
> > if s:statuslineflag
> > exe 'hi StatusLine'
> > \ 'cterm=NONE,bold ctermbg=' . s:ctbg1 'ctermfg=' . s:ctfg
> > \ 'gui=NONE,bold guibg=green guifg=black'
> > exe 'hi WildMenu'
> > \ 'cterm=NONE,bold ctermbg=' . s:ctbg2 'ctermfg=' . s:ctfg
> > \ 'gui=NONE,bold guibg=red guifg=black'
> > else
> > exe 'hi StatusLine'
> > \ 'cterm=NONE,bold ctermbg=' . s:ctbg2 'ctermfg=' . s:ctfg
> > \ 'gui=NONE,bold guibg=red guifg=black'
> > exe 'hi WildMenu'
> > \ 'cterm=NONE,bold ctermbg=' . s:ctbg1 'ctermfg=' . s:ctfg
> > \ 'gui=NONE,bold guibg=green guifg=black'
> > endif
> > let s:statuslineflag = ! s:statuslineflag
> > endfunction
> >
> > exe "augroup" s:colors_name
> > au! CursorHold,CursorHoldI * call ToggleStatusLine()
> > au! ColorScheme *
> > \ if g:colors_name != s:colors_name | exe "au!" s:colors_name |
> > endif
> > augroup END
Narrowing your example down to just the portion (I think?) that uses
CSApprox, and simplifying a bit to isolate the effect of CSApprox:
" elsewhere - disable CSApprox if on linux console
if exists('g:CSApprox_approximator_function')
let s:ctbg1 = g:CSApprox_approximator_function(0, 255, 0) " green
let s:ctbg2 = g:CSApprox_approximator_function(255, 0, 0) " red
else
let s:ctbg1 = 'darkgreen'
let s:ctbg2 = 'black'
endif
function! ToggleStatusLine()
if s:statuslineflag
exe 'hi StatusLine ctermbg=' . s:ctbg1 . 'guibg=green'
else
exe 'hi StatusLine ctermbg=' . s:ctbg2 . 'guibg=red'
endif
let s:statuslineflag = ! s:statuslineflag
endfunction
Why is that preferable to:
" elsewhere - set g:on_linux_console if on linux console
if !exists('g:on_linux_console')
let s:ctbg1 = '#00ff00'
let s:ctbg2 = '#ff0000'
else
let s:ctbg1 = 'darkgreen'
let s:ctbg2 = 'black'
endif
function! ToggleStatusLine()
if s:statuslineflag
exe 'hi StatusLine ctermbg=' . s:ctbg1 . 'guibg=green'
else
exe 'hi StatusLine ctermbg=' . s:ctbg2 . 'guibg=red'
endif
let s:statuslineflag = ! s:statuslineflag
endfunction
It seems to me it's just something you want to special-case regardless
of whether you're using CSApprox, and using built-in #rrggbb recognition
prevents having to call a plugin function.
Or am I missing something with which one of ctermbg/guibg applies at
what points?
linux terminal = 8 colors (modulo playing with fb), but special-cased,
so ctermbg=darkgreen
xterm = 256 colors, so you want ctermbg='#00ff00' (green) rather than
guibg=green? (6 of one, half a dozen of the other)
gui = 24-bit color, so guibg=green
I agree, though, that a disabled-but-shipped plugin would be better than
nothing.
--
Best,
Ben
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php