Skip to main content

Box

Struct Box 

Source
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_right

Fields§

§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: bool

Whether the box draws in ASCII only (upstream’s ascii= flag): an ASCII-only terminal keeps it rather than substituting ASCII.

Implementations§

Source§

impl Box

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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§

Source§

impl Clone for Box

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Box

Source§

impl Debug for Box

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Box

Source§

impl PartialEq for Box

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.