Thursday, December 31, 2015

Re: When is an xterm's t_Co detected?

Gary Johnson wrote:

> > > I recently learned that Vim can query an xterm directly for the
> > > number of colors it supports. (This is not necessarily the same
> > > value reported by terminfo. Otherwise, it wouldn't be very useful.)
> > > Vim then sets t_Co to this number. I would like to use that value
> > > to affect other color settings, but I can't figure out when to do
> > > that. I captured the value of &t_Co at the start and end of my
> > > ~/.vimrc and upon these autocommand events,
> > >
> > > BufWinEnter
> > > ColorScheme
> > > FileType
> > > OptionSet
> > > TermResponse
> > > VimEnter
> > >
> > > but the value was always 8. By the time I queried the value from
> > > Vim's command line, though, the value was 256.
> > >
> > > What event do I need to wait for to determine that t_Co may have
> > > changed to 256?
> >
> > Can't think of something. We do have the OptionSet autocommand event,
> > but it's not triggered in this case. Perhaps we should make a change
> > for that. The code is near the end of set_num_option().
>
> That seems like the right thing to do. I'm trying to think of what
> could go wrong. I'm concerned about this statement under ":help
> OptionsSet":
>
> Note: It's a bad idea to reset an option
> during this autocommand, this may break a
> plugin. You can always use `:noa` to prevent
> triggering this autocommand.
>
> I was considering having this autocommand execute a :colorscheme
> {name} command. That would often set 'background'. And if "nested"
> was used, it would trigger a ColorScheme event.
>
> That all seems OK. I'll look at creating a patch.

The color schemes are reloaded when t_Co changes, perhaps you can set a
color scheme that checks the value of t_Co?

--
There are three kinds of people: Those who can count & those who can't.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
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: