Skip to content

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

/// 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.
@eezstreet
Copy link

What items are needed to move this forward?

@sunfishcode
Copy link
Member Author

The next steps are:

  • Review the design and determine whether it seems viable.
  • Implement it, and report back in how it went.
  • Identify real-world use cases (not just applications that use terminal features, but applications that use terminal features and that need to be compiled to Wasm).

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.

3 participants