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

feat(stream): Initial support for auto-adapting streams #54

Merged
merged 5 commits into from
Mar 8, 2023
Merged

Conversation

epage
Copy link
Collaborator

@epage epage commented Mar 8, 2023

This is the first step of #5.
This is only supporting AlwaysAnsi and Never and only using TTY and wincon information.

Future work

  • Support wincon
  • Optionally support degrading from truecolor -> 256 color -> 16 color, depending on the terminal

Areas of uncertainty

  • Should we support all of the flags (nocolor, cli_colors, etc) or have users deal with that?
    • A part of me wants truecolor -> 256 color -> 16 adaption to be optional and have clap foist that on the palette chooser so we don't take that performance hit unnecessarily
  • Should always_ansi call windows::enable_ansi_colors? Probably but then we'd need to make sure it doesn't get called twice in a row
  • Do we need any kind of caching for our checks?

In doing this, I made println bypass one of the common pitfalls for CLI authors: the panic on broken pipe. This will instead let the application keep printing which is a better default.

Another CLI pitfall is the performance of using the non-locked version. This also means not having a println. I decided to go ahead and favor ergonomics and instead be very explicit in the documentation about this

This has more overhead as it has to track the UTF8 parse state to tell
UTF8 continuations from single-byte control codes.
This will be one of the building blocks for `Stream`.
@epage epage force-pushed the stream branch 3 times, most recently from c42d718 to ea3c0d1 Compare March 8, 2023 21:04
@epage epage merged commit fefa595 into main Mar 8, 2023
@epage epage deleted the stream branch March 8, 2023 21:12
@epage epage mentioned this pull request Mar 10, 2023
2 tasks
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