Thursday, June 15, 2017

Re: How does vim choose a color that is not in the terminals color palette?

On Wed, 14 Jun 2017 17:54:50 -0700 (PDT)
Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:

> On Thursday, June 15, 2017 at 2:35:39 AM UTC+2, S. Jacobi wrote:
> > I am using termite as my terminal emulator, which advertises 256
> > colors support via terminfo. I only defined 20 colors: fg, fg_bold,
> > bg, cursor and the 16 colors in their normal and bright variants.
> > I do not use a vim colorscheme, just the terminal colors. In some
> > shell scripts I see colors that I have not defined and which are
> > not affected if I change my color palette. So my question is: How
> > are those colors determined and how can I change them?
> >
> > How to reproduce:
> > 1) set t_Co=256 in vimrc (if it is set to 16 those "new" colors do
> > not appear)
> > 2) I set all 16 colors in my termite config file to #ff0000 (to
> > oberserve the changes)
> > 3) Minimal shell script:
> > #/bin/bash
> > $testvar=1
> > cd dir
> > ./command --help
> > 4) $testvar is in cyan, --help is in some pinkish color
> >
> > I haven't tested setting all 256 colors in my config file to red, if
> > this affects those two cases I found.
> >
> > Kind regards
>
> First, check that Vim knows that yout terminal allows 256 colors:
>
> :set t_Co?
>
> The answer should be
>
> t_Co=256
>
> If it isn't, and you know that your current console _does_ support
> 256 colors, you can set it. Even in your vimrc if you know how to
> identify that terminal (as opposed to a dumb 16-color text console)
> at startup, e.g. from its 'term' value.
>
> Then, if you don't want to bother to identify where (at which
> ordinal) in the terminal palette a certain pink or green or whichever
> color is found, I recommend to use gui-like settings in the cterm.
> There are two ways to do that:
>
> a) (easiest)
> if has('termguicolors')
> set termguicolors
> endif
>
> b) to use guifg= guibg= in the cterm even with a gui-enabled Vim not
> compiled with +termguicolors, you could also take advantage of the
> CSApprox plugin, see
> http://vim.wikia.com/wiki/Using_GUI_color_settings_in_a_terminal#Solution_2:_the_CSApprox_plugin
>
>
> Best regards,
> Tony.
>

Thanks for your answer. Me setting t_Co=256 in my vimrc was just
keeping this line for testing purposes. If t_Co is not set at all, it
is set automatically to 256 because this is what termite adertises via
terminfo. I can manually force it to 16 so the "extra" colors are not
used.
My vim was not compiled with the termguicolors feature, so I don't know
if b) applies here, too.
But I am actually interested in the internals. Is there a way to find
the color index without manually checking color16 to color 255? Or
even a comprehensive list of all uses of colorX with X > 15? No vim
color scheme is used.

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment