separator
Horizontal rule atom with optional centered label.
struct Component
pub struct ComponentA horizontal separator line with optional centered label.
| Field | Type | Description |
|---|---|---|
ch |
char | Glyph repeated to draw the line: ─ for solid, ╌ for dashed. |
label |
Option<String> | Text centred in the line, with a space on each side. |
style |
Style | Style painted over the line and its label. |
width |
Option<usize> | Total width in columns, with the label measured in bytes; None uses row::terminal_width. |
Implements Display.
Component::rule
pub fn rule(style: Style) -> SelfCreate a solid rule separator.
| Parameter | Type | Description |
|---|---|---|
style |
Style | the style of the line |
| returns | Self | A solid, unlabeled separator as wide as the terminal. |
Component::labeled
pub fn labeled(label: impl Into<String>, style: Style) -> SelfCreate a solid separator with a centered label.
| Parameter | Type | Description |
|---|---|---|
label |
impl Into<String> | the text in the middle of the line |
style |
Style | the style of the line and the label |
| returns | Self | A solid, labeled separator as wide as the terminal. |
Component::dashed
pub fn dashed(label: impl Into<String>, style: Style) -> SelfCreate a dashed separator with a centered label.
| Parameter | Type | Description |
|---|---|---|
label |
impl Into<String> | the text in the middle of the line |
style |
Style | the style of the line and the label |
| returns | Self | A dashed, labeled separator as wide as the terminal. |
Component::width
pub fn width(self, width: usize) -> SelfOverride the separator width (defaults to the full terminal width).
| Parameter | Type | Description |
|---|---|---|
width |
usize | the total width in columns, label included |
| returns | Self | The separator with the fixed width. |