Skip to main content

StyledBlock

Struct StyledBlock 

Source
pub struct StyledBlock {
    pub content: StyledText,
    pub right_content: StyledText,
    pub bg: Option<Color>,
    pub align: Align,
    pub margin_left: u16,
    pub margin_right: u16,
    /* private fields */
}
Expand description

A unit of layout: styled content with background, alignment, and margins.

When rendered, the block’s content is wrapped at the available terminal-column width (after subtracting margins), aligned within that space, and the block’s background color fills remaining content-area cells.

Fields§

§content: StyledText

Primary content rendered when ordinary layout is selected.

§right_content: StyledText

Optional right-aligned adornment for ordinary single-row blocks.

layout_block renders this only when Self::align is Align::Left, primary content lays out to one row, and both sides fit with separator padding.

§bg: Option<Color>

Optional background color for the content area and its padding.

§align: Align

Horizontal alignment applied to primary content.

§margin_left: u16

Requested transparent left margin width in terminal columns.

layout_block may clamp this so each row has at least one content column.

§margin_right: u16

Requested transparent right margin width in terminal columns.

layout_block may clamp this so each row has at least one content column.

Implementations§

Source§

impl StyledBlock

Source

pub fn new(content: impl Into<StyledText>) -> StyledBlock

Creates a left-aligned block with no margins or background.

Source

pub fn is_empty(&self) -> bool

Returns true when the selected layout’s effective primary content is empty.

A priority line supersedes ordinary primary content. Right content remains an adornment and is excluded from this primary-content predicate.

Source

pub fn bg(self, color: Color) -> StyledBlock

Returns this block with a content-area background color.

Source

pub fn align(self, align: Align) -> StyledBlock

Returns this block with the requested content alignment.

Source

pub fn right_content(self, content: impl Into<StyledText>) -> StyledBlock

Returns this block with right-side adornment content.

The adornment is rendered only for left-aligned, single-row primary content when both sides fit with separator padding.

Source

pub fn two_line_elision(self, elision: TwoLineElision) -> StyledBlock

Returns this block with width-adaptive two-row excerpt layout.

Source

pub fn priority_line(self, line: PriorityLine) -> StyledBlock

Returns this block with priority-based single-line content.

Source

pub fn priority_line_body(self, body: impl Into<StyledText>) -> StyledBlock

Returns this block with ordinary body content below its priority line.

The body has no effect unless Self::priority_line is present, and it remains hidden whenever that line’s essential band fails closed.

Source

pub fn priority_line_content(&self) -> Option<&PriorityLine>

Returns priority-line content when this block uses priority layout.

Source

pub fn priority_line_body_content(&self) -> Option<&StyledText>

Returns the body owned by this block’s priority layout, if selected.

Source

pub fn margin_left(self, n: u16) -> StyledBlock

Returns this block with a requested transparent left margin.

The margin may be clamped during layout.

Source

pub fn margin_right(self, n: u16) -> StyledBlock

Returns this block with a requested transparent right margin.

The margin may be clamped during layout.

Source

pub fn margins(self, left: u16, right: u16) -> StyledBlock

Returns this block with requested transparent left and right margins.

The margins may be clamped during layout.

Trait Implementations§

Source§

impl Clone for StyledBlock

Source§

fn clone(&self) -> StyledBlock

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StyledBlock

Source§

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

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

impl Eq for StyledBlock

Source§

impl From<&str> for StyledBlock

Source§

fn from(s: &str) -> StyledBlock

Converts to this type from the input type.
Source§

impl From<String> for StyledBlock

Source§

fn from(s: String) -> StyledBlock

Converts to this type from the input type.
Source§

impl From<StyledText> for StyledBlock

Source§

fn from(text: StyledText) -> StyledBlock

Converts to this type from the input type.
Source§

impl PartialEq for StyledBlock

Source§

fn eq(&self, other: &StyledBlock) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for StyledBlock

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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