anstyle icon indicating copy to clipboard operation
anstyle copied to clipboard

Provide stream API with implicit conversions

Open epage opened this issue 3 years ago • 2 comments

Most term styling crates require the format-site to know the capabilities of the intended output stream. This complicates things when the the format-site and outputting are decoupled.

The idea for this is that people choose the ansi styling crate of their choice and a special set of stdout/stderr streams then handle the conversion of ansi styling to what the terminal is capable of.

Conversions

  • Graceful degration to lower colors or no colors
  • Convert to wincon api

epage avatar Jun 10 '22 14:06 epage

See https://crates.io/crates/fwdansi/

epage avatar Jun 10 '22 14:06 epage

https://crates.io/crates/strip-ansi-cli

epage avatar Jun 22 '22 00:06 epage

How rich handles color conversion

  • https://github.comTextualize/rich/blob/master/rich/_palettes.py
  • https://github.com/Textualize/rich/blob/0bdbe550c4bdc68058ca285f20bc3d57aa0a0ba7/rich/color.py#L548

MIT

epage avatar Sep 23 '22 21:09 epage

https://crates.io/crates/rgb2ansi256 LGPL https://crates.io/crates/ansi_colours LGPL

epage avatar Sep 23 '22 22:09 epage