luser / strip-ansi-escapes

Apache License 2.0
30 stars 13 forks source link

Wrapping ansi escapes? #1

Open joshtriplett opened 4 years ago

joshtriplett commented 4 years ago

Given that this library already recognizes ansi escape sequences, could it offer a function to split out ansi escape sequences rather than stripping them? For instance, an iterator that alternates between Escapes(&str) and NormalStr(&str)? That would enable use cases like wrapping escapes in a control sequence (such as \[ and \] for the bash prompt).

luser commented 4 years ago

I'm open to suggestions as to how to make this work without complicating the API for the existing use case. Honestly all the real hard work is done in the vte crate so it might be easier to just use that? This crate just ignores most of the callbacks it gets from vte: https://github.com/luser/strip-ansi-escapes/blob/44b5e0426b5a2c09f6a51e799f0725d3981a61b6/src/lib.rs#L129-L161