How can I read the result of query escape sequence?

74 views
Skip to first unread message

yoshihik...@gmail.com

unread,
Feb 18, 2013, 12:34:03 PM2/18/13
to mintty-...@googlegroups.com

Hello, all

I'm using mintty every day, nice program.

I'd like to know how can I read the result of text color querying by escape sequence (e.g. ctrl seq "OSC 10;? BEL").
I think the query result is written to pty directly, so I could not read it from stdin pipe.
It would be only displayed on the screen.
I'd like to change ansi colours from dark settings to light, and from light to dark, depending on current settings.
Any suggestion?
 
Thanks in advance.

Andy Koppe

unread,
Feb 18, 2013, 2:32:36 PM2/18/13
to mintty
On Feb 18, 5:34 pm, yoshihiko.kas...@gmail.com wrote:
> I'd like to know how can I read the result of text color querying by escape
> sequence (e.g. ctrl seq "OSC 10;? BEL").
> I think the query result is written to pty directly, so I could not read it
> from stdin pipe.
> It would be only displayed on the screen.

It's written to the master side of the pty the same way as keyboard
input, which means the process(es) on the slave side do receive it on
stdin. However, the terminal driver, which sits between the two sides,
echoes input back to output unless told otherwise, which is how it
usually ends up on the screen.

I haven't actually got any experience with trying to receive those
replys programmatically, so I'm afraid I can't provide any concrete
help. I'd try to put the terminal line into raw mode (using the stty
command or the tcsetattr() function), write the request sequence, and
wait for a reply on stdin, ideally with some sort of timeout so it
doesn't hang if there is no reply for whatever reason. And restore the
original terminal line settings at the end.

Regards,
Andy

yoshihik...@gmail.com

unread,
Feb 20, 2013, 12:38:19 PM2/20/13
to mintty-...@googlegroups.com

I'd try to put the terminal line into raw mode (using the stty
command or the tcsetattr() function), write the request sequence, and
wait for a reply on stdin, ideally with some sort of timeout so it
doesn't hang if there is no reply for whatever reason. And restore the
original terminal line settings at the end.

 
Hi Andy,
 
Thanks for your reply.
I could read the query result successfully by following script.
The 'count=25' of dd command is the expected length of result string.
 
  saved_stty=$(stty -g)
  stty raw
  echo -ne "\e]10;?\a"
  dd bs=1 count=25 > hoge
  stty $saved_stty
 
BTW, I'm guessing the result would be "\e]10;rgb:ffff/ffff/ffff\e\\", but it differs.
Each time running script, the portion of OSC control sequence argument value '10' varies.
If this value has '0', then window title will be changed to "rgb:ffff/ffff/ffff" due to the resulting escape sequence output.
Is this behavior correct? Is there a bug around the result string?
Thanks.
--
kash

Andy Koppe

unread,
Feb 20, 2013, 2:39:32 PM2/20/13
to mintty
On Feb 20, 5:38 pm, yoshihiko.kas...@gmail.com wrote:
> > I'd try to put the terminal line into raw mode (using the stty
> > command or the tcsetattr() function), write the request sequence, and
> > wait for a reply on stdin, ideally with some sort of timeout so it
> > doesn't hang if there is no reply for whatever reason. And restore the
> > original terminal line settings at the end.
>
> Hi Andy,
>
> Thanks for your reply.
> I could read the query result successfully by following script.
> The 'count=25' of dd command is the expected length of result string.
>
>   saved_stty=$(stty -g)
>   stty raw
>   echo -ne "\e]10;?\a"
>   dd bs=1 count=25 > hoge
>   stty $saved_stty

Makes sense; thanks for reporting back.

> BTW, I'm guessing the result would be "\e]10;rgb:ffff/ffff/ffff\e\\", but
> it differs.
> Each time running script, the portion of OSC control sequence argument
> value '10' varies.
> If this value has '0', then window title will be changed to
> "rgb:ffff/ffff/ffff" due to the resulting escape sequence output.
> Is this behavior correct? Is there a bug around the result string?

You're right, there is, I should have remembered to warn you about it:

https://code.google.com/p/mintty/issues/detail?id=356

It's fixed for the next release.

Andy

yoshihik...@gmail.com

unread,
Feb 21, 2013, 10:00:51 AM2/21/13
to mintty-...@googlegroups.com
> BTW, I'm guessing the result would be "\e]10;rgb:ffff/ffff/ffff\e\\", but
> it differs.
> Each time running script, the portion of OSC control sequence argument
> value '10' varies.
> If this value has '0', then window title will be changed to
> "rgb:ffff/ffff/ffff" due to the resulting escape sequence output.
> Is this behavior correct? Is there a bug around the result string?
 
You're right, there is, I should have remembered to warn you about it:
 
 
It's fixed for the next release.  
 
Ok, I wait for the next release.
Thanks.
 
kash
Reply all
Reply to author
Forward
0 new messages