separator

Horizontal rule atom with optional centered label.

struct Component

source

pub struct Component

A 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

source

pub fn rule(style: Style) -> Self

Create 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

source

pub fn labeled(label: impl Into<String>, style: Style) -> Self

Create 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

source

pub fn dashed(label: impl Into<String>, style: Style) -> Self

Create 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

source

pub fn width(self, width: usize) -> Self

Override 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.