Skip to content

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

Merged
epage merged 5 commits into
mainfrom
stream
Mar 8, 2023
Merged

feat(stream): Initial support for auto-adapting streams#54
epage merged 5 commits into
mainfrom
stream

Conversation

@epage
Copy link
Copy Markdown
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

epage added 5 commits March 6, 2023 23:05
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`.
Comment thread crates/anstyle-stream/src/lib.rs
@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
epage added a commit that referenced this pull request May 1, 2026
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