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

Preprocess and convert C1 controls to their 7 bit equivalent #7340

Merged
merged 26 commits into from Sep 16, 2020

Conversation

@skyline75489
Copy link
Member

skyline75489 commented Aug 19, 2020

C1 control characters are now first converted to their 7 bit equivalent.
This allows us to unify the logic of C1 and C0 escape handling. This
also adds support for SOS/PM/APC string.

  • Unify the logic for C1 and C0 escape handling by converting C1 to C0
    beforehand. This adds support for various C1 characters, including
    IND(8/4), NEL(8/5), HTS(8/8), RI(8/13), SS2(8/14), SS3(8/15),
    OSC(9/13), etc.
  • Add support for SOS/PM/APC escape sequences. Fixes #7032
  • Use "Variable Length String" logic to unify the string termination
    handling of OSC, DCS and SOS/PM/APC. This fixes an issue where OSC
    action is successfully dispatched even when terminated with non-ST
    character. Introduced by #6328, the DCS PassThrough is spared from
    this issue. This PR puts them together and add test cases for them.

References:
https://vt100.net/docs/vt510-rm/chapter4.html
https://vt100.net/emu/dec_ansi_parser

Closes #7032
Closes #7317

{
return wch == L'\x90';
return wch - L'\x40';

This comment has been minimized.

@skyline75489

skyline75489 Aug 19, 2020 Author Member

This seems correct but I can't find valid reference for this.

This comment has been minimized.

@j4james

j4james Aug 19, 2020 Contributor

Yeah, I believe this is correct. Quoting the DEC ST 070 manual:

expansion escape sequence (Fe) - 2-character escape sequence in which the final character is in columns 4 and 5, and is used to extend the 7-bit code table by being the row equivalent to the corresponding C1 set of controls in columns 8 and 9 of an 8-bit code.

This comment has been minimized.

@DHowett

DHowett Aug 20, 2020 Member

(Should we prefer -0x40 or &~0x40 here?)

This comment has been minimized.

@skyline75489

skyline75489 Aug 20, 2020 Author Member

I choose L'\x40' cuz I want it have the same type as wch. Not that it mean anything, but hey, no implicit conversion.

@zadjii-msft zadjii-msft self-assigned this Aug 19, 2020
// - True if it is. False if it isn't.
const bool StateMachine::_IsVariableLengthStringState() const noexcept
{
return _state == VTStates::OscString || _state == VTStates::DcsPassThrough || _state == VTStates::SosPmApcString;

This comment has been minimized.

@skyline75489

skyline75489 Aug 20, 2020 Author Member

From the graph here https://vt100.net/emu/dec_ansi_parser, these are the only three cases. Not sure if there's more.

// Arguments:
// - wch - Character that triggered the event
// Return Value:
// - <none>
void StateMachine::_EventDcsIgnore(const wchar_t wch) noexcept
void StateMachine::_EventDcsIgnore() noexcept

This comment has been minimized.

@skyline75489

skyline75489 Aug 23, 2020 Author Member

It’s a little weird to have just one case in this, isn’t it. But this is actually the correct way to do this.

Copy link
Member

zadjii-msft left a comment

Well this looks good to me. I'd love to make sure we get @j4james to sign off on this too, if he's willing.

src/terminal/parser/stateMachine.cpp Outdated Show resolved Hide resolved
@zadjii-msft zadjii-msft removed their assignment Aug 26, 2020
Copy link
Contributor

j4james left a comment

This looks good to me. I've run a few basic tests with it, and the C1 controls are now working as expected, and the APC/PM/SOS sequences are being appropriately ignored. I'm a little concerned about the input side of things, because I'm not how to test that, but I think the C1 mapping should still be OK for that.

@skyline75489
Copy link
Member Author

skyline75489 commented Aug 27, 2020

Thanks @j4james . I literally couldn't write any of these PRs without you . You know originally I just want those dazzling Sixel images. But who knows VT sequences are actually full of fun. Be prepared for my following unknown numbers of PRs that's VT related 😄 .

Copy link
Member

DHowett left a comment

Okay - I finally read over this, and I think I understand how this improves our state machine. I've got to trust Mike and James here, as well. Thanks @skyline75489!

@DHowett
Copy link
Member

DHowett commented Sep 16, 2020

@msftbot merge this in 1 minute

@msftbot msftbot bot added the AutoMerge label Sep 16, 2020
@msftbot
Copy link
Contributor

msftbot bot commented Sep 16, 2020

Hello @DHowett!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Wed, 16 Sep 2020 22:30:14 GMT, which is in 1 minute

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@msftbot msftbot bot merged commit f91b53d into microsoft:master Sep 16, 2020
7 checks passed
7 checks passed
Terminal CI Build #0.0.2008.3101 succeeded
Details
Terminal CI (Audit Mode Static Analysis Build x64) Audit Mode Static Analysis Build x64 succeeded
Details
Terminal CI (Build x64 Build x64 Release) Build x64 Build x64 Release succeeded
Details
Terminal CI (Build x86 Build x86 Release) Build x86 Build x86 Release succeeded
Details
Terminal CI (Code Health Scripts Proper Code Formatting Check) Code Health Scripts Proper Code Formatting Check succeeded
Details
auto-merge.config.enforce No dynamic merge policies are applicable.
license/cla All CLA requirements met.
Details
msftbot bot pushed a commit that referenced this pull request Sep 17, 2020
## Summary of the Pull Request

This fixes a typo in the `HyperlinkIdConsistency` unit test which was causing that test to fail. It was mistakenly using a `/` instead of `\` for the string terminator sequences.

## References

The test initially worked because of a bug in the state machine parser, but that bug was recently fixed in PR #7340.

## PR Checklist
* [x] Closes #7654
* [x] CLA signed. 
* [x] Tests passed
* [ ] Documentation updated. 
* [ ] Schema updated.
* [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan.

## Validation Steps Performed

I've run the test again and it now passes.
@skyline75489 skyline75489 deleted the skyline75489:chesterliu/dev/c1-to-c0 branch Sep 22, 2020
@msftbot
Copy link
Contributor

msftbot bot commented Sep 22, 2020

🎉Windows Terminal Preview v1.4.2652.0 has been released which incorporates this pull request.🎉

Handy links:

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

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.