Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Good doc on xTerm control sequences

@Charles Dye, this might interest you as a plugin writer. There are at least a few control sequences that return (to stdin) information and I suppose WT implements some of them. I haven't (yet) gone through that document looking for them, but I will, looking for ideas. Retrieving the information is quite easy. I do it with just this.

Code:
    GetConsoleMode(hIn, &dwInputMode);
    SetConsoleMode(hIn, (dwInputMode | ENABLE_VIRTUAL_TERMINAL_INPUT) & ~ENABLE_LINE_INPUT);

    WriteConsole(hOut, szQueryAll, nQueryAllLength, &dwWritten, 0);
    WaitForSingleObject(hIn, 100);
    ReadConsole(hIn, szResponseAll, 600, &dwRead, 0); // expecting 522 characters
    SetConsoleMode(hIn, dwInputMode);

My query is this, a "chained (16 + 4)" version of 20 color queries.

Code:
#define OSC L"\x001b]"        // Operating System Command
#define ST L"\x001b\x005c"    // (ESC \) long version of Sequence Terminator

    INT nQueryAllLength = wsprintf(szQueryAll,
        OSC L"4;0;?;1;?;2;?;3;?;4;?;5;?;6;?;7;?;8;?;9;?;10;?;11;?;12;?;13;?;14;?;15;?" ST OSC L"10;?;?;?;;;;;?" ST);

The response is the necessary sequences (unchained, 20 of them) to set those colors; it goes to stdin. In CMD, the query and the response look like this ... below, the response is wrapped by me and (having gone to stdin) appears after the next prompt, ^[ is ESC.

Code:
v:\>  echo %esc%]4;0;?;1;?;2;?;3;?;4;?;5;?;6;?;7;?;8;?;9;?;10;?;11;?;12;?;13;?;14;?;15;?%esc%\%esc%]10;?;?;?;;;;;?%esc%\


v:\> ^[]4;0;rgb:0c0c/0c0c/0c0c^[\^[]4;1;rgb:c5c5/0f0f/1f1f^[\^[]4;2;rgb:1313/a1a1/0e0e^[\^[]4;3;rgb:c1c1/9c9c/0000^[\
^[]4;4;rgb:0000/3737/dada^[\^[]4;5;rgb:8888/1717/9898^[\^[]4;6;rgb:3a3a/9696/dddd^[\^[]4;7;rgb:cccc/cccc/cccc^[\
^[]4;8;rgb:7676/7676/7676^[^[\^[]4;9;rgb:e7e7/4848/5656^[\^[]4;10;rgb:1616/c6c6/0c0c^[\^[]4;11;rgb:f9f9/f1f1/a5a5^[\
^[]4;12;rgb:3b3b/7878/ffff^[\^[]4;13;rgb:b4b4/0000/9e9e^[\^[]4;14;rgb:6161/d6d6/d6d6^[\^[]4;15;rgb:f2f2/f2f2/f2f2^[\
^[]10;rgb:cccc/cccc/cccc^[\^[]11;rgb:0c0c/0c0c/0c0c^[\^[]12;rgb:ffff/ffff/ffff^[\^[]17;rgb:ffff/ffff/ffff^[\

Digging the color data out of that string took some thinking but, in the end, not much code. Other info that might be queried might not require so much unraveling.

So now I have

Code:
v:\> echo %_theme
1 (Campbell)

... not terribly useful, but fun creating it.
 
Here's one, again in CMD. It's telling me the current cursor position or rather the sequence needed to put it where it is now.

Code:
v:\> echo %esc%[6n

v:\> ^[[11;1R

And another ... this one queries device attributes ... no clue how to imterpret the result

Code:
v:\> echo %esc%[0c

v:\> ^[[?61;4;6;7;14;21;22;23;24;28;32;42c

I found this list in the WT forum; it isn't very enlightening.

1 = 132 column mode
6 = Selective erase
7 = Soft fonts
22 = Color text
23 = Greek character sets
24 = Turkish character sets
28 = Rectangular area operations
32 = Text macros
42 = ISO Latin-2 character set
 
This one will tell you rows and columns.

Code:
Microsoft Windows [Version 10.0.19045.5131]
(c) Microsoft Corporation. All rights reserved.

v:\> echo %esc%[18t


v:\> ^[[8;42;128t
 
Back
Top