Friday, January 1, 2016

Re: When is an xterm's t_Co detected?

On 2015-12-31, Bram Moolenaar wrote:
> 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?

I thought more about the problem I was actually trying to solve, and
about why I thought that the color scheme was not being reloaded
when Co was received from xterm, and I think that the current
behavior and a color scheme that checks the value of t_Co will work
fine--actually better than what I thought I wanted.

Thank you for your help.

Regards,
Gary

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