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

Terminal I/O. #62

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

sunfishcode
Copy link
Member

@sunfishcode sunfishcode commented Feb 8, 2025

Add an API for portable terminal I/O support, including escape sequences and control codes. This aims to cover features used by most applications while remaining portable across popular terminals.

I've marked this a draft PR, as it's very much a rough draft right now. I don't expect to have a lot of time for this, so any help in identifying missing features, errors, or overreaches, or prototyping, is appreciated! Alternative proposals that take a completely different approach would be valuable as well!

Add an API for portable terminal I/O support, including escape sequences
and control codes. This aims to cover features used by most applications
while remaining portable across popular terminals.
sunfishcode and others added 3 commits February 8, 2025 14:02
There's more room for improvement here, but this should hopefully
provide a reasonable path that can be evaluated.
record rows-and-columns {
rows: u16,
columns: u16,
}
}

/// An interface providing an optional `terminal-input` for stdin as a

Choose a reason for hiding this comment

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

should there also be an interface that's equivalent to opening CON or /dev/tty? this is used by things like sudo tee where the inputs/outputs may be redirected but sudo still accesses the controlling terminal to write out the password prompt and read in the password.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it would be straightforward to have an API that returns a terminal-input. terminal-output, and streams for the controlling terminal (alongside the stdio functions). That's independent of what the terminal-input and terminal-output interfaces look like though, so that could be proposed separately.

A potential consideration is that we may not always want sandboxed programs to be able to do that, because that would mean they could bypass stdio redirects and potentially grab input from the terminal meant for another application. So we'd want to think through the use cases.

sunfishcode and others added 5 commits February 9, 2025 18:13
Escape sequences are now "recognized" rather than being "defined for the
appropriate mode", output terminals are now more completely described,
and various sentences are tidied up.
Also, switch to the Unicode "maximal subparts" reference, which is the
same algorithm, but a simpler reference here.
It's ok if terminal apply additional transformations, but we don't want
implementations passing through additional control codes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants