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. Port
of AnsiDecoder.decode: 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.
rich 12 split with splitlines instead; for that, decode
text.lines() one at a time with decode_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>
The same as decode, which it was the only form of
before 0.0.22.
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