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

Implement a control sequence parser #59

Open
alexrp opened this issue Dec 28, 2021 · 3 comments
Open

Implement a control sequence parser #59

alexrp opened this issue Dec 28, 2021 · 3 comments
Assignees
Labels
area: build Issues related to the build system. area: samples Issues related to the sample projects. area: sequences Issues related to the control sequence APIs. state: approved Enhancements and tasks that have been approved.
Milestone

Comments

@alexrp
Copy link
Member

alexrp commented Dec 28, 2021

This should basically be a state machine that processes UTF-8 text and invokes handler methods when successfully processing sequences. This will be at the heart of all of our input processing and terminal state tracking.

Can draw inspiration from Windows Terminal: https://github.com/microsoft/terminal/tree/main/src/terminal/parser

@alexrp alexrp added type: feature state: approved Enhancements and tasks that have been approved. area: build Issues related to the build system. area: samples Issues related to the sample projects. area: sequences Issues related to the control sequence APIs. labels Dec 28, 2021
@alexrp alexrp added this to the v1.0 milestone Dec 28, 2021
@alexrp alexrp self-assigned this Dec 28, 2021
@alexrp
Copy link
Member Author

alexrp commented Dec 28, 2021

@alexrp
Copy link
Member Author

alexrp commented Jul 24, 2022

I'm not sure how to handle the classic ESC ambiguity in input parsing. You can only use brittle heuristics (e.g. input buffer size or timing) to attempt to distinguish an Escape key press from a longer input sequence that happens to start with the ESC character. This is necessarily going to have a sweeping effect on the parser API shape...

@scottbilas
Copy link
Contributor

When I implemented ambiguous ESC key detection in my own tooling, I did a small survey of established tools and libraries to see how others handled it, and the timeout method was the most common.

The tcell term library (which I use as a gold standard) implemented it that way here:

https://github.com/gdamore/tcell/blob/master/tscreen.go#L1624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build Issues related to the build system. area: samples Issues related to the sample projects. area: sequences Issues related to the control sequence APIs. state: approved Enhancements and tasks that have been approved.
Development

No branches or pull requests

2 participants