[Parser] Action Execute should dispatch and go back to ground #1617

Closed
opened 2026-01-30 22:32:07 +00:00 by claunia · 2 comments
Owner

Originally created by @zadjii-msft on GitHub (Jun 12, 2019).

From MSFT:20168257

See:
(internal) Pull Request 2743337: Add support for Ctrl+Alt+char in the input state machine engine

For the string "\x1b\x03[31m", we should ActionPrint("\x1b\x03"), then actionPrint("[31m")

When we see a C0 in any state, instead of ActionExecuting it, we should PrintString the buffer we've accumulated so far

Weird cases:
"\x1b[\x0331m"
for input, should be translated to M-[, C-c, 3, 1, m. For output, should be print("\x1b["), print("\x03"), print("31m")

Test case for all C0's:

for i in range(0, 0x1f):
    write('\x1b')
    write(chr(i))
    print('[31m  This text should not be red ({:02X})'.format(i))
    sgr()

Fixing this in the context of #19407947 would be too risky for 19H1

Originally created by @zadjii-msft on GitHub (Jun 12, 2019). From MSFT:20168257 See: (internal) Pull Request 2743337: Add support for Ctrl+Alt+char in the input state machine engine For the string "\x1b\x03[31m", we should ActionPrint("\x1b\x03"), then actionPrint("[31m") When we see a C0 in any state, instead of ActionExecuting it, we should PrintString the buffer we've accumulated so far Weird cases: "\x1b[\x0331m" for input, should be translated to M-[, C-c, 3, 1, m. For output, should be print("\x1b["), print("\x03"), print("31m") Test case for all C0's: ``` python for i in range(0, 0x1f): write('\x1b') write(chr(i)) print('[31m This text should not be red ({:02X})'.format(i)) sgr() ``` Fixing this in the context of #19407947 would be too risky for 19H1
claunia added the Product-ConhostIssue-BugArea-VTNeeds-Tag-Fix labels 2026-01-30 22:32:07 +00:00
Author
Owner

@j4james commented on GitHub (Jul 17, 2019):

It's possible I'm misunderstanding what this issue is about, because it sounds like you're talking about keyboard input and the input state machine at first, but then that final test case looks like an output test, so I'm not sure. I just wanted to make it clear that the current output behaviour is actually correct, as I understand it.

Quoting from the DEC STD 070 manual:

if a control character is transmitted in the middle of an escape sequence, the control character is executed as if the escape sequence were not present (that is, as if the control character had been received immediately before the escape sequence), with the exceptions noted below.

The exceptions essentially being the Cancel and Substitute characters, which abort the sequence, and the Escape character, which starts a new sequence (and those cases are already handled correctly).

And this matches the XTerm behaviour too. For the test case script above, the text actually is red for every case except Cancel and Substitute.

@j4james commented on GitHub (Jul 17, 2019): It's possible I'm misunderstanding what this issue is about, because it sounds like you're talking about keyboard input and the input state machine at first, but then that final test case looks like an output test, so I'm not sure. I just wanted to make it clear that the current output behaviour is actually correct, as I understand it. Quoting from the DEC STD 070 manual: > if a control character is transmitted in the middle of an escape sequence, the control character is executed as if the escape sequence were not present (that is, as if the control character had been received immediately before the escape sequence), with the exceptions noted below. The exceptions essentially being the _Cancel_ and _Substitute_ characters, which abort the sequence, and the _Escape_ character, which starts a new sequence (and those cases are already handled correctly). And this matches the XTerm behaviour too. For the test case script above, the text actually is red for every case except _Cancel_ and _Substitute_.
Author
Owner

@zadjii-msft commented on GitHub (Sep 7, 2023):

Huh, I never saw @j4james's reply here 4 years ago. I'll defer to your expertise here. Sounds like we've been doing this right for some long time now 😝

@zadjii-msft commented on GitHub (Sep 7, 2023): Huh, I never saw @j4james's reply here _4 years ago_. I'll defer to your expertise here. Sounds like we've been doing this right for some long time now 😝
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1617