Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General purpose command to query for color support programatically #36

Open
BridgeAR opened this issue Oct 24, 2021 · 3 comments
Open

Comments

@BridgeAR
Copy link

I would like to discuss a similar command as DECRQSS that would be recommended to be implemented by commonly used terminals across different OS.

That way there would be a reliable way to detect actual color support. For now it's not reliable at all by checking for environment variables.

I did not yet think of an ideal solution and would first like to know if there's interest in drafting such command.

@eabase
Copy link

eabase commented Jan 11, 2022

@BridgeAR Can you link to info about that DECRQSS?

@kurahaupo
Copy link
Member

kurahaupo commented May 18, 2022

@eabase In the Xterm escape sequence documentation it describes the general form as:

Request Status String DECRQSS

DCS $ q Pt ST

Pt Designation
" q DECSCA
" p DECSCL
r DECSTBM
m SGR

Xterm responds with

DCS 1 $ r Pt ST

for valid requests, replacing the Pt with the corresponding CSI string, or

DCS 0 $ r Pt ST

for invalid requests.

The original Xterm documentation used the convention of P denoting a parameter string, with two sub-forms P1 ... P9 being an array of numeric parameters; and Pt meaning any byte sequence excluding BEL and ST.

Unfortunately the version on that page has lost the subscript and italicization so it just looks like Pt. Where it mentions "the first parameter", that's Pt within the DECRQSS sequence.

Where it mentions "the corresponding CSI string", I think it simply means the Pt parameter as supplied.

@kurahaupo
Copy link
Member

Example of DECRQSS:

$ ( echo "Wait 2 seconds then hit ^D^D^D"
>   stty -echo
>   printf '\eP$qm\e\\'
>   hd
>   stty echo )
Wait 2 seconds then hit ^D^D^D
00000000  1b 50 31 24 72 30 6d 1b  5c                       |.P1$r0m.\|
00000009

or

$ ( echo "Wait 2 seconds then hit ^D^D^D"
>   stty -echo
>   printf '\eP$qq\e\\'
>   hd
>   stty echo )
Wait 2 seconds then hit ^D^D^D
00000000  18                                                |.|
00000001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants