Skip to main content

AnsiLineAssembler

Struct AnsiLineAssembler 

Source
pub struct AnsiLineAssembler { /* private fields */ }
Expand description

Feeds a byte stream into AnsiParser one line at a time, carrying SGR state across line breaks and holding back incomplete input.

Since turbo-vision 2.2, Attr carries a style bitset alongside fg/bg, so ANSI bold, dim, italic, underline, reverse, and strikethrough survive parsing and are re-emitted by attr_to_sgr to carry across line breaks — plank’s dim-italic thinking style now arrives italic, not just as its grey. (ANSI bold still also brightens the foreground; that is AnsiParser’s own behavior.) Deliberate, not a bug: the ERASE_LINE repaint marker (\r\x1b[0K) is detected as a literal 4-byte match anywhere it appears in pending, with no surrounding context check. Content that happens to quote that exact byte sequence (a fenced code block showing raw ANSI, a pasted terminal transcript) would have everything before it on the line silently discarded, same as a real repaint. This mirrors AnsiParser’s own no-erase-in-line design and is not worth adding machinery to disambiguate.

Implementations§

Source§

impl AnsiLineAssembler

Source

pub fn new() -> Self

Source

pub fn push(&mut self, bytes: &[u8])

Accepts more stream bytes, cutting any complete lines.

Source

pub fn take_complete_lines(&mut self) -> Vec<Vec<Cell>>

Removes and returns every line cut so far.

Source

pub fn partial_line(&self) -> Vec<Cell>

The line currently being assembled, rendered as far as it has arrived.

A trailing incomplete escape sequence is withheld, so a half-received \x1b[3 never appears on screen as literal [3.

Source

pub fn flush(&mut self) -> Option<Vec<Cell>>

Emits the in-progress line as final, if there is one. Used when a stream ends without a trailing newline.

Trait Implementations§

Source§

impl Debug for AnsiLineAssembler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AnsiLineAssembler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more