pub struct AnsiDecoder { /* private fields */ }Expand description
Translates ANSI codes into styled Text. Mirrors rich.ansi.AnsiDecoder.
The decoder is stateful: a style set on one line persists to the next, just like a real terminal (and like upstream).
Implementations§
Source§impl AnsiDecoder
impl AnsiDecoder
pub fn new() -> Self
Sourcepub fn decode(&mut self, terminal_text: &str) -> Vec<Text>
pub fn decode(&mut self, terminal_text: &str) -> Vec<Text>
Decode a multi-line terminal string into one Text per line.
Sourcepub fn decode_split_newlines(&mut self, terminal_text: &str) -> Vec<Text>
pub fn decode_split_newlines(&mut self, terminal_text: &str) -> Vec<Text>
Decode as upstream 15.0.0’s AnsiDecoder.decode splits:
re.split(r"(?<=\n)", text) then line.rstrip("\n"). Only \n ends
a line (a \r before it is kept, so it resets the line), and text
ending in a newline, or empty text, yields a final empty line.
decode keeps the older splitlines behaviour that
existing callers rely on.
Sourcepub fn decode_line(&mut self, line: &str) -> Text
pub fn decode_line(&mut self, line: &str) -> Text
Decode a single line containing ANSI codes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AnsiDecoder
impl RefUnwindSafe for AnsiDecoder
impl Send for AnsiDecoder
impl Sync for AnsiDecoder
impl Unpin for AnsiDecoder
impl UnsafeUnpin for AnsiDecoder
impl UnwindSafe for AnsiDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more