pub struct Box {Show 30 fields
pub top_left: char,
pub top: char,
pub top_divider: char,
pub top_right: char,
pub head_left: char,
pub head_vertical: char,
pub head_right: char,
pub head_row_left: char,
pub head_row_horizontal: char,
pub head_row_cross: char,
pub head_row_right: char,
pub mid_left: char,
pub mid_vertical: char,
pub mid_right: char,
pub row_left: char,
pub row_horizontal: char,
pub row_cross: char,
pub row_right: char,
pub foot_row_left: char,
pub foot_row_horizontal: char,
pub foot_row_cross: char,
pub foot_row_right: char,
pub foot_left: char,
pub foot_vertical: char,
pub foot_right: char,
pub bottom_left: char,
pub bottom: char,
pub bottom_divider: char,
pub bottom_right: char,
pub ascii: bool,
}Expand description
A set of box-drawing characters. Mirrors rich.box.Box.
The field names match upstream’s 8×4 grid:
top_left top top_divider top_right
head_left (space) head_vertical head_right
head_row_left head_row_horizontal head_row_cross head_row_right
mid_left (space) mid_vertical mid_right
row_left row_horizontal row_cross row_right
foot_row_left foot_row_horizontal foot_row_cross foot_row_right
foot_left (space) foot_vertical foot_right
bottom_left bottom bottom_divider bottom_rightFields§
§top_left: char§top: char§top_divider: char§top_right: char§head_left: char§head_vertical: char§head_right: char§head_row_left: char§head_row_horizontal: char§head_row_cross: char§head_row_right: char§mid_left: char§mid_vertical: char§mid_right: char§row_left: char§row_horizontal: char§row_cross: char§row_right: char§foot_row_left: char§foot_row_horizontal: char§foot_row_cross: char§foot_row_right: char§foot_left: char§foot_vertical: char§foot_right: char§bottom_left: char§bottom: char§bottom_divider: char§bottom_right: char§ascii: boolWhether the box draws in ASCII only (upstream’s ascii= flag): an
ASCII-only terminal keeps it rather than substituting ASCII.
Implementations§
Source§impl Box
impl Box
Sourcepub fn new(template: &str, ascii: bool) -> Option<Box>
pub fn new(template: &str, ascii: bool) -> Option<Box>
Parse a box from the 8-line, 4-column template (as upstream does).
Panics at const-eval time if the template is malformed, so the built-in
constants are validated when the crate compiles.
A custom box from its 8-line template, as upstream’s Box(box, ascii=…): each of the first eight lines must hold exactly four
characters, else None (upstream raises ValueError). ascii says
the glyphs are all ASCII, so substitute keeps
the box on an ASCII-only terminal.
Sourcepub fn get_top(&self, widths: &[usize], edge: bool) -> String
pub fn get_top(&self, widths: &[usize], edge: bool) -> String
The top border for the given column widths. Port of Box.get_top.
edge controls whether the left/right corner glyphs are drawn.
Sourcepub fn get_row(&self, widths: &[usize], level: RowLevel, edge: bool) -> String
pub fn get_row(&self, widths: &[usize], level: RowLevel, edge: bool) -> String
A horizontal divider row between columns at a given level. Port of
Box.get_row. edge controls whether the left/right glyphs are drawn.
Sourcepub fn substitute(
&self,
legacy_windows: bool,
safe: bool,
ascii_only: bool,
) -> Box
pub fn substitute( &self, legacy_windows: bool, safe: bool, ascii_only: bool, ) -> Box
Return a version of this box safe for the target terminal. Port of
Box.substitute.
On a legacy Windows console (legacy_windows + safe), the boxes
that legacy code pages can’t draw fall back, as upstream’s
LEGACY_WINDOWS_SUBSTITUTIONS: ROUNDED, HEAVY, HEAVY_EDGE and
HEAVY_HEAD to SQUARE, MINIMAL_HEAVY_HEAD to MINIMAL and
SIMPLE_HEAVY to SIMPLE. On a non-UTF-8 terminal (ascii_only), a
box not flagged ascii becomes ASCII.
Sourcepub fn substitute_for(&self, options: &ConsoleOptions, safe: bool) -> Box
pub fn substitute_for(&self, options: &ConsoleOptions, safe: bool) -> Box
substitute under render options, as upstream’s
Box.substitute(options, safe=True): options.legacy_windows and
options.ascii_only.
Sourcepub fn is_ascii(&self) -> bool
pub fn is_ascii(&self) -> bool
Whether the box is flagged as ASCII-only. Upstream passes ascii=True
to exactly the built-in boxes drawn in ASCII (ASCII, ASCII2,
ASCII_DOUBLE_HEAD, MARKDOWN), which substitute keeps on an
ASCII-only terminal; a custom box carries the flag it was made with
(Box::new).
Sourcepub fn get_plain_headed_box(&self) -> Box
pub fn get_plain_headed_box(&self) -> Box
If this box draws its header border with special characters, the most
similar box that does not; otherwise the box itself. Port of
Box.get_plain_headed_box: a table without a header draws with it.
Sourcepub fn get_bottom(&self, widths: &[usize], edge: bool) -> String
pub fn get_bottom(&self, widths: &[usize], edge: bool) -> String
The bottom border for the given column widths. Port of Box.get_bottom.
edge controls whether the left/right corner glyphs are drawn.
Trait Implementations§
impl Copy for Box
impl Eq for Box
impl StructuralPartialEq for Box
Auto Trait Implementations§
impl Freeze for Box
impl RefUnwindSafe for Box
impl Send for Box
impl Sync for Box
impl Unpin for Box
impl UnsafeUnpin for Box
impl UnwindSafe for Box
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.