jam1garner / owo-colors

A zero-allocation no_std-compatible zero-cost way to add color to your Rust terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting ANSI start and end sequence separated

dominikwilkowski opened this issue · comments

Is there a way to get the start and end ANSI sequence from owo_colors for a given rgb value (or any other parsed color I guess)?
I need it and before implementing a method to generate a color, split if and take each bit separately I thought I ask here.
In my mind it would be something like this:

println!("unstyled {} some styled text here {} unstyled",
  OwoColorize.rgb(70, 130, 180).start,
  OwoColorize.rgb(70, 130, 180).end
);

Or something like that?

This should be resolved by #55, although it hasn't been included in a release just yet. Within the next week I expect it to be on crates.io, planning on making a new minor release after #56

For cases where the color is statically determined, ANSI_FG from the Color trait exists currently. There's also runtime versions in DynColor but they're not easy to use due to being intended for fmt trait impls, so waiting for the Style API for this is likely preferable