-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
3917068
to
3744a27
Compare
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. |
This comment has been minimized.
This comment has been minimized.
I believe you need to merge with |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this 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!
@msftbot merge this in 10 minutes |
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:
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". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An absolute marvel!
🎉 Handy links: |
Summary of the Pull Request
This PR adds support for the DEC macro operations
DECDMAC
(Define Macro), andDECINVM
(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
Detailed Description of the Pull Request / Additional comments
I've created a separate
MacroBuffer
class to handle the parsing and storage of macros, so theAdaptDispatch
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 aCSI
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.