On 2006-04-12, Bram Moolenaar <[EMAIL PROTECTED]> wrote:
> Gary Johnson wrote:
> 
> > > > Does anyone know what codes need to be sent to at
> > > > least xterm to have the cursor shape/color restored on vim exit?
> > > 
> > > As far as I know it's impossible, there doesn't appear a way to obtain
> > > the cursor color that is in use when Vim is started.
> > 
> > (I'm catching up on some old unread list e-mail.)
> > 
> > According to the ctlseqs.ms document that came with xterm-165:
> > 
> > 
> >     Operating System Controls
> >     OSC Ps ; Pt ST
> >     OSC Ps ; Pt BEL
> >            Set Text Parameters.  For colors and font, if Pt is a
> >            "?", the control sequence elicits a response which con-
> >            sists of the control sequence which would set the
> >            corresponding value. ....
> >            ...
> >              Ps = 1 2  -> Change colors starting with text cursor to
> >            Pt
> > 
> > 
> > I executed this command at a Linux shell prompt,
> > 
> >     echo -e '\033]12;?\007' ; read x
> > 
> > and got the following response:
> > 
> >     ^[]12;rgb:ffff/ffff/ffff^G
> > 
> > After setting the cursor to red and repeating the command, I got
> > this:
> > 
> >     ^[]12;rgb:ffff/0000/0000^G
> > 
> > So, xterm does have the mechanism to obtain the cursor color when
> > vim is started.  I just don't know how to obtain the terminal's
> > response from within vim and don't have the time to experiment
> > further at the moment.  I did discover, though, that you can echo
> > back the color in that same format, so no parsing of the terminal
> > response would be necessary.
> 
> Interesting, this must have been added recently.

This is from xterm-165, which appears to be from January 2002.

> 
> I wonder what triggers the "rgb:" response.  It doesn't state somewhere
> why this happens instead of the "ordinary" color numbers.  Perhaps
> because xterm was compiled with more than 16 colors?

I don't know.  How do you tell how many colors the xterm binary 
supports?  The xterm I built for SunOS behaves the same as the Linux 
one I tested above and I didn't specify anything about colors when I 
configured the build, so I think it has only 16 colors.

If I set "rgb:ff00/7f00/fe00", then query the value, the response is 
"rgb:ffff/7f7f/fefe".  So something limits the resolution to 256 
values per color component.  Some limited experimentation shows that 
the actual resolution is enough to get more than 16 cursor colors.
So maybe a default build of xterm does support 256 colors.

Gary

-- 
Gary Johnson                 | Agilent Technologies
[EMAIL PROTECTED]     | Wireless Division
                             | Spokane, Washington, USA

Reply via email to