-
Notifications
You must be signed in to change notification settings - Fork 2
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
Capturing escape sequence sizing with categorized slices #9
Comments
Hi @ncatelli.
Is that sufficient for your use case? |
Hi Kurt, Unfortunately no, specifically I was looking for the best way to either:
That could be used, in conjunction with the |
I think you could use the fact that the For example, take the following: let x = format!("{}, {}!", "Hello".blue().on_green(), "world".red().on_yellow());
println!("{x:?}");
let [hello, comma, world, bang]: [v3::CategorisedSlice; 4] =
v3::categorise_text(&x).try_into().unwrap();
let hello_rng = 0..hello.end;
let comma_rng = hello.end..comma.end;
let world_rng = comma.end..world.end;
let bang_rng = world.end..bang.end;
dbg!(&x[hello_rng]);
dbg!(&x[comma_rng]);
dbg!(&x[world_rng]);
dbg!(&x[bang_rng]); It will print out:
Which captures the original escape code sequences. If you need a 'trailing' escape code sequence (say |
What would be the best way to derive the escape code by size of a give CategorizedSlice? Having this information would be extremely useful for tasks like text wrapping.
The text was updated successfully, but these errors were encountered: