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

Add support for DEC macro operations #14402

Merged
13 commits merged into from
Dec 9, 2022
Merged

Conversation

j4james
Copy link
Collaborator

@j4james j4james commented Nov 17, 2022

Summary of the Pull Request

This PR adds support for the DEC macro operations DECDMAC (Define Macro), and DECINVM (Invoke Macro), which allow an application to define a sequence of characters as a macro, and then later invoke that macro to execute the content as if it had just been received from the host.

This PR also adds two new DSR queries: one for reporting the available space remaining in the macro buffer (DECMSR), and another reporting a checksum of the macros that are currently defined (DECCKSR).

PR Checklist

  • Closes Add support for the VT macro operations #14205
  • CLA signed.
  • Tests added/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. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

I've created a separate MacroBuffer class to handle the parsing and storage of macros, so the AdaptDispatch class doesn't have to do much more than delegate the macro operations to that.

The one complication is the macro invocation, which requires injecting characters back into the state machine's input stream. Ideally we'd just pass the content to the ProcessString method, but we can't do that when it's already in the middle of a CSI dispatch.

My solution for this was to add an OnCsiComplete method via which we could register a callback function that injects the macro sequence only once the state machine has returned to the ground state. This feels a bit hacky, but that was the best approach I could come up with.

Validation Steps Performed

Thanks to @KalleOlaviNiemitalo, we've been able to do some testing on a real VT420 to determine how the macro operations are intended to work, and I've tried to get our implementation to match that behavior as much as possible (we differ in some aspects of the checksum reporting, where the VT420 behavior seemed undesirable, or potentially buggy).

I've also added unit tests covering some of the same scenarios that we tested on the VT420.

@ghost ghost added Area-VT Virtual Terminal sequence support Issue-Task It's a feature request, but it doesn't really need a major design. labels Nov 17, 2022
@j4james j4james marked this pull request as ready for review November 18, 2022 01:09
@j4james
Copy link
Collaborator Author

j4james commented Nov 18, 2022

I understand this may not be the approach you want to take, so feel free to reject this PR if you want to go another route. You're also welcome to use any parts that you think are worth keeping.

src/terminal/adapter/MacroBuffer.cpp Show resolved Hide resolved
src/terminal/adapter/MacroBuffer.cpp Outdated Show resolved Hide resolved
src/terminal/adapter/MacroBuffer.cpp Show resolved Hide resolved
src/terminal/adapter/adaptDispatch.cpp Outdated Show resolved Hide resolved
src/terminal/adapter/MacroBuffer.cpp Outdated Show resolved Hide resolved
src/terminal/adapter/MacroBuffer.cpp Outdated Show resolved Hide resolved
src/terminal/adapter/MacroBuffer.hpp Outdated Show resolved Hide resolved
@github-actions

This comment has been minimized.

@lhecker
Copy link
Member

lhecker commented Nov 29, 2022

I believe you need to merge with main to resolve the spelling issues.

@github-actions

This comment has been minimized.

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it. Great work. Thanks!

@carlos-zamora
Copy link
Member

@msftbot merge this in 10 minutes

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 9, 2022
@ghost
Copy link

ghost commented Dec 9, 2022

Hello @carlos-zamora!

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 Fri, 09 Dec 2022 21:10:20 GMT, which is in 10 minutes

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".

@ghost ghost merged commit 4d27a05 into microsoft:main Dec 9, 2022
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An absolute marvel!

@j4james j4james deleted the feature-macros branch December 26, 2022 20:49
@ghost
Copy link

ghost commented Jan 24, 2023

🎉Windows Terminal Preview v1.17.1023 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VT Virtual Terminal sequence support AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. zBugBash-Consider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for the VT macro operations
5 participants