pub struct PriorityLine { /* private fields */ }Expand description
A single line that progressively hides lower-importance styled items.
Items retain insertion order and styling within each alignment group; all retained left items render before all retained right items. Normally, adjacent items within a group receive one separator cell; explicitly attached fragments do not. Retained left and right groups receive at least one padding cell between them. Layout hides larger priorities first until the line fits. For equal priorities, later inserted items hide first. Empty content passed to any push method is ignored.
After every lower-importance item is discarded, a highest-importance
survivor that cannot fit is also hidden. The result stays empty rather than
resurrecting a less-important smaller item, wrapping, or clipping content.
Attach the line through crate::StyledBlock::priority_line so block
layout can recompute retention for the current terminal width.
Truncatable items first reserve their configured minimum representation.
If all item minima do not fit, whole items disappear by the same priority
rule as non-truncatable items. Remaining columns then grow retained
truncatable items toward their configured maxima in ascending priority and
insertion order. This makes competition deterministic while retaining as
many useful elements as their minima permit. Truncation preserves complete
Unicode grapheme clusters and terminal display width, using exactly ┄
between the retained prefix and suffix.
Callers may mark an essential priority band with Self::require_through.
If any accepted item in that band cannot survive, the line becomes empty
instead of presenting only part of the essential meaning.
Implementations§
Source§impl PriorityLine
impl PriorityLine
Sourcepub fn new() -> PriorityLine
pub fn new() -> PriorityLine
Creates an empty priority line.
Sourcepub fn require_through(&mut self, priority: PriorityLinePriority)
pub fn require_through(&mut self, priority: PriorityLinePriority)
Requires every accepted item at or above priority to survive layout.
If the terminal cannot fit those items at their minimum representations, layout returns a fill-only row instead of presenting an incomplete essential set. Items with larger numeric priorities keep their normal independent truncation and hiding behavior.
Sourcepub fn set_separator_style(&mut self, style: Style)
pub fn set_separator_style(&mut self, style: Style)
Sets the style for one-column separators between ordinary items.
Sourcepub fn push(
&mut self,
priority: PriorityLinePriority,
alignment: PriorityLineAlignment,
content: impl Into<StyledText>,
)
pub fn push( &mut self, priority: PriorityLinePriority, alignment: PriorityLineAlignment, content: impl Into<StyledText>, )
Appends one independently hideable item to an edge group.
Sourcepub fn push_truncated(
&mut self,
priority: PriorityLinePriority,
alignment: PriorityLineAlignment,
content: impl Into<StyledText>,
truncation: PriorityLineTruncation,
)
pub fn push_truncated( &mut self, priority: PriorityLinePriority, alignment: PriorityLineAlignment, content: impl Into<StyledText>, truncation: PriorityLineTruncation, )
Appends one middle-truncatable item to an edge group.
The item stays whole when it fits within truncation.max_width();
otherwise layout retains a prefix and suffix around the exact ┄
marker. It may disappear by priority when even all retained items’
minimum representations and separators cannot fit.
Sourcepub fn push_attached(
&mut self,
priority: PriorityLinePriority,
alignment: PriorityLineAlignment,
content: impl Into<StyledText>,
)
pub fn push_attached( &mut self, priority: PriorityLinePriority, alignment: PriorityLineAlignment, content: impl Into<StyledText>, )
Appends one item without a separator from its retained predecessor.
This is for independently prioritized fragments that form one visual token, such as a status label followed by optional details beginning with punctuation.
Sourcepub fn push_truncated_attached(
&mut self,
priority: PriorityLinePriority,
alignment: PriorityLineAlignment,
content: impl Into<StyledText>,
truncation: PriorityLineTruncation,
)
pub fn push_truncated_attached( &mut self, priority: PriorityLinePriority, alignment: PriorityLineAlignment, content: impl Into<StyledText>, truncation: PriorityLineTruncation, )
Appends one middle-truncatable item without a preceding separator.
The truncation and disappearance rules match Self::push_truncated.
Trait Implementations§
Source§impl Clone for PriorityLine
impl Clone for PriorityLine
Source§fn clone(&self) -> PriorityLine
fn clone(&self) -> PriorityLine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more