title
Styled title atom with optional truncation and column padding.
struct Component
pub struct ComponentA styled heading with optional truncation and padding.
| Field | Type | Description |
|---|---|---|
max_width |
Option<usize> | Display width above which the text is cut to max_width - 1 characters plus …; None never cuts. |
pad_to |
Option<usize> | Minimum visible width, filled with trailing spaces; None never pads. |
style |
Style | Style painted over the text. |
text |
String | Title text. |
Implements Display.
Component::new
pub fn new(text: impl Into<String>, style: Style) -> SelfCreate a new title with the given text and style.
| Parameter | Type | Description |
|---|---|---|
text |
impl Into<String> | the title text |
style |
Style | the style to paint it in |
| returns | Self | The title, with no truncation or padding. |
Component::max_width
pub fn max_width(self, width: usize) -> SelfTruncate the title to at most width visible characters, appending … if needed.
| Parameter | Type | Description |
|---|---|---|
width |
usize | the display width above which the title is cut to width - 1 characters plus …; wide characters can still exceed it |
| returns | Self | The title with the limit set. |
Component::pad_to
pub fn pad_to(self, width: usize) -> SelfRight-pad with spaces so the title occupies at least width visible columns.
| Parameter | Type | Description |
|---|---|---|
width |
usize | the minimum visible width |
| returns | Self | The title with the padding set. |