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: StyledTextPrimary content rendered when ordinary layout is selected.
right_content: StyledTextOptional 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: AlignHorizontal alignment applied to primary content.
margin_left: u16Requested transparent left margin width in terminal columns.
layout_block may clamp this so each row has at least one content
column.
margin_right: u16Requested 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
impl StyledBlock
Sourcepub fn new(content: impl Into<StyledText>) -> StyledBlock
pub fn new(content: impl Into<StyledText>) -> StyledBlock
Creates a left-aligned block with no margins or background.
Sourcepub fn is_empty(&self) -> bool
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.
Sourcepub fn bg(self, color: Color) -> StyledBlock
pub fn bg(self, color: Color) -> StyledBlock
Returns this block with a content-area background color.
Sourcepub fn align(self, align: Align) -> StyledBlock
pub fn align(self, align: Align) -> StyledBlock
Returns this block with the requested content alignment.
Sourcepub fn right_content(self, content: impl Into<StyledText>) -> StyledBlock
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.
Sourcepub fn two_line_elision(self, elision: TwoLineElision) -> StyledBlock
pub fn two_line_elision(self, elision: TwoLineElision) -> StyledBlock
Returns this block with width-adaptive two-row excerpt layout.
Sourcepub fn priority_line(self, line: PriorityLine) -> StyledBlock
pub fn priority_line(self, line: PriorityLine) -> StyledBlock
Returns this block with priority-based single-line content.
Sourcepub fn priority_line_body(self, body: impl Into<StyledText>) -> StyledBlock
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.
Sourcepub fn priority_line_content(&self) -> Option<&PriorityLine>
pub fn priority_line_content(&self) -> Option<&PriorityLine>
Returns priority-line content when this block uses priority layout.
Sourcepub fn priority_line_body_content(&self) -> Option<&StyledText>
pub fn priority_line_body_content(&self) -> Option<&StyledText>
Returns the body owned by this block’s priority layout, if selected.
Sourcepub fn margin_left(self, n: u16) -> StyledBlock
pub fn margin_left(self, n: u16) -> StyledBlock
Returns this block with a requested transparent left margin.
The margin may be clamped during layout.
Sourcepub fn margin_right(self, n: u16) -> StyledBlock
pub fn margin_right(self, n: u16) -> StyledBlock
Returns this block with a requested transparent right margin.
The margin may be clamped during layout.
Sourcepub fn margins(self, left: u16, right: u16) -> StyledBlock
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
impl Clone for StyledBlock
Source§fn clone(&self) -> StyledBlock
fn clone(&self) -> StyledBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more