pub struct Segment {
pub text: String,
pub style: Option<Style>,
pub control: Option<ControlCode>,
}Expand description
A piece of text with an associated style.
Segments are produced during rendering and ultimately converted to strings for terminal output.
Fields§
§text: String§style: Option<Style>§control: Option<ControlCode>Implementations§
Source§impl Segment
impl Segment
Sourcepub fn styled(text: impl Into<String>, style: Style) -> Self
pub fn styled(text: impl Into<String>, style: Style) -> Self
Create a segment with text and style.
Sourcepub fn control(code: ControlCode) -> Self
pub fn control(code: ControlCode) -> Self
Create a control-only segment.
Sourcepub fn cell_length(&self) -> usize
pub fn cell_length(&self) -> usize
Get the cell length of this segment’s text (using Unicode width).
Trait Implementations§
Source§impl From<Segment> for RenderItem
impl From<Segment> for RenderItem
impl StructuralPartialEq for Segment
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnsafeUnpin for Segment
impl UnwindSafe for Segment
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