On Sun, Apr 05, 2009 at 02:34:26PM +0200, Bram Moolenaar wrote: > > Taylor Venable wrote: > > > On Thu, Apr 02, 2009 at 07:51:21PM -0700, Gary Johnson wrote: > > > On 2009-04-02, Taylor Venable wrote: > > > > I have an xterm compiled with 256 color support. In Vim 7.2.88 after > > > > it loads up I can do :set t_Co to find that 256 color support is being > > > > found correctly (TERM = xterm-color). However, I cannot figure out > > > > how to determine whether 256 colors are supported on startup, as the > > > > value of t_Co is 8 at the time my .vimrc is loaded. > > > > > > > > I've tried a few autocommands, such as VimEnter and TermChanged but > > > > the value of t_Co in both of them is still 8, rather than the 256 I > > > > expect. At what point does t_Co get set to reflect the capabilities > > > > of the terminal, and how can I detect it during startup? > > > > > > Or are you saying that t_Co gets set automatically somehow to 256 > > > and you don't know where that is? If so, you can find out by > > > executing > > > > > > :verbose set t_Co? > > > > Somebody on IRC suggested this too but all this command shows is that > > t_Co = 256 and no hint of where it came from. The value is definitely > > 8 while .vimrc is being executed but at some point after that (also > > after the VimEnter autocommand) it's being set to 256. > > It's magic! :-) > > What happens is that on startup Vim determines the terminal settings > from the termcap/terminfo and builtin defaults. These may differ from > what the terminal actually uses, so for xterm we have built in a > mechanism to ask the xterm the actual values. This happens after > startup, Vim sends a few escape sequences to xterm and it responds with > a few specific escape sequences. The number of colors supported is one > of the values. This takes a little time, thus it's done asynchronously. > > You may also see that the intro screen disappears. This happens when > the value of the t_Co option changes, Vim needs to redraw the screen > then to get the colors right. > > I haven't tried it, but I think you can use the ColorScheme autocommand > event to handle the change, since when t_Co changes the color scheme is > reloaded.
Thanks for the response. That's interesting how that works, and ultimately good for my case where the termcap database seems to indicate that the terminal supports less colors than it really does. I tried the ColorScheme autocommand but unfortunately it doesn't get triggered in this instance. -- Taylor Christopher Venable http://real.metasyntax.net:2357/ foldr = lambda f, i, l: (len(l) == 1 and [f(l[0], i)] or [f(l[0], foldr(f, i, l[1:]))])[0] --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
