pub struct Line { /* private fields */ }Expand description
A single line of styled terminal output, composed of Spans.
ANSI escape codes are emitted only when to_ansi_string
is called, keeping the data model free of formatting concerns.
Implementations§
Source§impl Line
impl Line
pub fn new(s: impl Into<String>) -> Self
pub fn styled(text: impl Into<String>, color: Color) -> Self
pub fn with_style(text: impl Into<String>, style: Style) -> Self
pub fn spans(&self) -> &[Span]
pub fn is_empty(&self) -> bool
pub fn prepend(self, text: impl Into<String>) -> Self
pub fn push_text(&mut self, text: impl Into<String>)
pub fn push_styled(&mut self, text: impl Into<String>, color: Color)
pub fn push_with_style(&mut self, text: impl Into<String>, style: Style)
pub fn push_span(&mut self, span: Span)
pub fn append_line(&mut self, other: &Line)
pub fn extend_bg_to_width(&mut self, target_width: usize)
pub fn to_ansi_string(&self) -> String
Sourcepub fn display_width(&self) -> usize
pub fn display_width(&self) -> usize
Display width in terminal columns (accounts for unicode widths).
Sourcepub fn soft_wrap(&self, width: u16) -> Vec<Line>
pub fn soft_wrap(&self, width: u16) -> Vec<Line>
Soft-wrap this line to fit within width columns.
pub fn plain_text(&self) -> String
Trait Implementations§
impl Eq for Line
impl StructuralPartialEq for Line
Auto Trait Implementations§
impl Freeze for Line
impl RefUnwindSafe for Line
impl Send for Line
impl Sync for Line
impl Unpin for Line
impl UnsafeUnpin for Line
impl UnwindSafe for Line
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more