Struct tabled::settings::themes::Theme

source ·
pub struct Theme { /* private fields */ }
Available on crate feature std only.
Expand description

A raw style data, which can be produced safely from Style.

It can be useful in order to not have a generics and be able to use it as a variable more conveniently.

Implementations§

source§

impl Theme

source

pub const fn from_style<T, B, L, R, H, V, const HS: usize, const VS: usize>( style: Style<T, B, L, R, H, V, HS, VS> ) -> Self

Build a theme out of a style builder.

source§

impl Theme

source

pub const fn new() -> Self

Creates a new empty style.

It’s quite an analog of Style::empty

source§

impl Theme

source

pub fn set_border_top(&mut self, c: char)

Set a border character top .

source

pub fn set_border_bottom(&mut self, c: char)

Set a border character bottom .

source

pub fn set_border_left(&mut self, c: char)

Set a border character left .

source

pub fn set_border_right(&mut self, c: char)

Set a border character right .

source

pub fn set_border_corner_top_left(&mut self, c: char)

Set a border character top left corner .

source

pub fn set_border_corner_top_right(&mut self, c: char)

Set a border character top right corner .

source

pub fn set_border_corner_bottom_left(&mut self, c: char)

Set a border character bottom left corner .

source

pub fn set_border_corner_bottom_right(&mut self, c: char)

Set a border character bottom right corner .

source

pub fn set_border_intersection_top(&mut self, c: char)

Set a border character top intersection with a vertical line .

source

pub fn set_border_intersection_bottom(&mut self, c: char)

Set a border character bottom intersection with a vertical line .

source

pub fn set_border_intersection_left(&mut self, c: char)

Set a border character left intersection with a horizontal line .

source

pub fn set_border_intersection_right(&mut self, c: char)

Set a border character right intersection with a horizontal line .

source

pub fn set_border_intersection(&mut self, c: char)

Set a border character intersection of horizontal and vertical line .

source

pub fn set_border_horizontal(&mut self, c: char)

Set a border character horizontal .

source

pub fn set_border_vertical(&mut self, c: char)

Set a border character vertical .

source§

impl Theme

source

pub const fn get_border_top(&self) -> Option<char>

Get a border character top .

source

pub const fn get_border_bottom(&self) -> Option<char>

Get a border character bottom .

source

pub const fn get_border_left(&self) -> Option<char>

Get a border character left .

source

pub const fn get_border_right(&self) -> Option<char>

Get a border character right .

source

pub const fn get_border_corner_top_left(&self) -> Option<char>

Get a border character top left corner .

source

pub const fn get_border_corner_top_right(&self) -> Option<char>

Get a border character top right corner .

source

pub const fn get_border_corner_bottom_left(&self) -> Option<char>

Get a border character bottom left corner .

source

pub const fn get_border_corner_bottom_right(&self) -> Option<char>

Get a border character bottom right corner .

source

pub const fn get_border_intersection_top(&self) -> Option<char>

Get a border character top intersection with a vertical line .

source

pub const fn get_border_intersection_bottom(&self) -> Option<char>

Get a border character bottom intersection with a vertical line .

source

pub const fn get_border_intersection_left(&self) -> Option<char>

Get a border character left intersection with a horizontal line .

source

pub const fn get_border_intersection_right(&self) -> Option<char>

Get a border character right intersection with a horizontal line .

source

pub const fn get_border_intersection(&self) -> Option<char>

Get a border character intersection of horizontal and vertical line .

source

pub const fn get_border_horizontal(&self) -> Option<char>

Get a border character horizontal .

source

pub const fn get_border_vertical(&self) -> Option<char>

Get a border character vertical .

source§

impl Theme

source

pub fn remove_border_top(&mut self)

Remove a border character top .

source

pub fn remove_border_bottom(&mut self)

Remove a border character bottom .

source

pub fn remove_border_left(&mut self)

Remove a border character left .

source

pub fn remove_border_right(&mut self)

Remove a border character right .

source

pub fn remove_border_corner_top_left(&mut self)

Remove a border character top left corner .

source

pub fn remove_border_corner_top_right(&mut self)

Remove a border character top right corner .

source

pub fn remove_border_corner_bottom_left(&mut self)

Remove a border character bottom left corner .

source

pub fn remove_border_corner_bottom_right(&mut self)

Remove a border character bottom right corner .

source

pub fn remove_border_intersection_top(&mut self)

Remove a border character top intersection with a vertical line .

source

pub fn remove_border_intersection_bottom(&mut self)

Remove a border character bottom intersection with a vertical line .

source

pub fn remove_border_intersection_left(&mut self)

Remove a border character left intersection with a horizontal line .

source

pub fn remove_border_intersection_right(&mut self)

Remove a border character right intersection with a horizontal line .

source

pub fn remove_border_intersection(&mut self)

Remove a border character intersection of horizontal and vertical line .

source

pub fn remove_border_horizontal(&mut self)

Remove a border character horizontal .

source

pub fn remove_border_vertical(&mut self)

Remove a border character vertical .

source§

impl Theme

source

pub fn set_border_color_top(&mut self, color: Color)

Set a border color top .

source

pub fn set_border_color_bottom(&mut self, color: Color)

Set a border color bottom .

source

pub fn set_border_color_left(&mut self, color: Color)

Set a border color left .

source

pub fn set_border_color_right(&mut self, color: Color)

Set a border color right .

source

pub fn set_border_color_corner_top_left(&mut self, color: Color)

Set a border color top left corner .

source

pub fn set_border_color_corner_top_right(&mut self, color: Color)

Set a border color top right corner .

source

pub fn set_border_color_corner_bottom_left(&mut self, color: Color)

Set a border color bottom left corner .

source

pub fn set_border_color_corner_bottom_right(&mut self, color: Color)

Set a border color bottom right corner .

source

pub fn set_border_color_intersection_top(&mut self, color: Color)

Set a border color top intersection with a vertical line .

source

pub fn set_border_color_intersection_bottom(&mut self, color: Color)

Set a border color bottom intersection with a vertical line .

source

pub fn set_border_color_intersection_left(&mut self, color: Color)

Set a border color left intersection with a horizontal line .

source

pub fn set_border_color_intersection_right(&mut self, color: Color)

Set a border color right intersection with a horizontal line .

source

pub fn set_border_color_intersection(&mut self, color: Color)

Set a border color intersection of horizontal and vertical line .

source

pub fn set_border_color_horizontal(&mut self, color: Color)

Set a border color horizontal .

source

pub fn set_border_color_vertical(&mut self, color: Color)

Set a border color vertical .

source§

impl Theme

source

pub fn remove_border_color_top(&mut self)

Remove a border color top .

source

pub fn remove_border_color_bottom(&mut self)

Remove a border color bottom .

source

pub fn remove_border_color_left(&mut self)

Remove a border color left .

source

pub fn remove_border_color_right(&mut self)

Remove a border color right .

source

pub fn remove_border_color_corner_top_left(&mut self)

Remove a border color top left corner .

source

pub fn remove_border_color_corner_top_right(&mut self)

Remove a border color top right corner .

source

pub fn remove_border_color_corner_bottom_left(&mut self)

Remove a border color bottom left corner .

source

pub fn remove_border_color_corner_bottom_right(&mut self)

Remove a border color bottom right corner .

source

pub fn remove_border_color_intersection_top(&mut self)

Remove a border color top intersection with a vertical line .

source

pub fn remove_border_color_intersection_bottom(&mut self)

Remove a border color bottom intersection with a vertical line .

source

pub fn remove_border_color_intersection_left(&mut self)

Remove a border color left intersection with a horizontal line .

source

pub fn remove_border_color_intersection_right(&mut self)

Remove a border color right intersection with a horizontal line .

source

pub fn remove_border_color_intersection(&mut self)

Remove a border color intersection of horizontal and vertical line .

source

pub fn remove_border_color_horizontal(&mut self)

Remove a border color horizontal .

source

pub fn remove_border_color_vertical(&mut self)

Remove a border color vertical .

source§

impl Theme

source

pub fn get_border_color_top(&self) -> Option<&Color>

Get a border color top .

source

pub fn get_border_color_bottom(&self) -> Option<&Color>

Get a border color bottom .

source

pub fn get_border_color_left(&self) -> Option<&Color>

Get a border color left .

source

pub fn get_border_color_right(&self) -> Option<&Color>

Get a border color right .

source

pub fn get_border_color_corner_top_left(&self) -> Option<&Color>

Get a border color top left corner .

source

pub fn get_border_color_corner_top_right(&self) -> Option<&Color>

Get a border color top right corner .

source

pub fn get_border_color_corner_bottom_left(&self) -> Option<&Color>

Get a border color bottom left corner .

source

pub fn get_border_color_corner_bottom_right(&self) -> Option<&Color>

Get a border color bottom right corner .

source

pub fn get_border_color_intersection_top(&self) -> Option<&Color>

Get a border color top intersection with a vertical line .

source

pub fn get_border_color_intersection_bottom(&self) -> Option<&Color>

Get a border color bottom intersection with a vertical line .

source

pub fn get_border_color_intersection_left(&self) -> Option<&Color>

Get a border color left intersection with a horizontal line .

source

pub fn get_border_color_intersection_right(&self) -> Option<&Color>

Get a border color right intersection with a horizontal line .

source

pub fn get_border_color_intersection(&self) -> Option<&Color>

Get a border color intersection of horizontal and vertical line .

source

pub fn get_border_color_horizontal(&self) -> Option<&Color>

Get a border color horizontal .

source

pub fn get_border_color_vertical(&self) -> Option<&Color>

Get a border color vertical .

source§

impl Theme

source

pub fn set_border_frame(&mut self, frame: Border<char>)

Returns an outer border of the style.

source

pub fn set_border_color_frame(&mut self, frame: Border<Color>)

Returns an outer border of the style.

source

pub fn set_border(&mut self, borders: Borders<char>)

Set borders structure.

source

pub fn set_border_color(&mut self, borders: Borders<Color>)

Set borders structure.

source

pub const fn get_border_frame(&self) -> Border<char>

Set an outer border.

source

pub const fn get_border_color_frame(&self) -> Border<&Color>

Set an outer border.

source§

impl Theme

source

pub fn set_lines_horizontal( &mut self, lines: HashMap<usize, HorizontalLine<char>> )

Set horizontal border lines.

Example
use std::collections::HashMap;
use tabled::{Table, settings::style::{Style, HorizontalLine}, settings::themes::Theme};

let mut style = Theme::from(Style::re_structured_text());

let mut lines = HashMap::new();
lines.insert(1, HorizontalLine::inherit(Style::extended()).into());

style.set_lines_horizontal(lines);

let data = (0..3).map(|i| ("Hello", i));
let table = Table::new(data).with(style).to_string();

assert_eq!(
    table,
    concat!(
        " ======= ===== \n",
        "  &str    i32  \n",
        "╠═══════╬═════╣\n",
        "  Hello   0    \n",
        "  Hello   1    \n",
        "  Hello   2    \n",
        " ======= ===== ",
    ),
)
source

pub fn set_lines_vertical(&mut self, lines: HashMap<usize, VerticalLine<char>>)

Set vertical border lines.

Example
use std::collections::HashMap;
use tabled::{
    Table,
    settings::style::{Style, HorizontalLine},
    settings::themes::Theme,
};


let mut style = Theme::from_style(Style::re_structured_text());

let mut lines = HashMap::new();
lines.insert(1, HorizontalLine::inherit(Style::extended()).into());

style.set_lines_vertical(lines);

let data = (0..3).map(|i| ("Hello", i));
let table = Table::new(data).with(style).to_string();

assert_eq!(
    table,
    concat!(
        "=======╠=====\n",
        " &str  ═ i32 \n",
        "======= =====\n",
        " Hello ═ 0   \n",
        " Hello ═ 1   \n",
        " Hello ═ 2   \n",
        "=======╣=====",
    ),
)
source

pub fn insert_line_vertical( &mut self, line: usize, vertical: VerticalLine<char> )

Insert a vertical line into specific column location.

source

pub fn insert_line_horizontal( &mut self, line: usize, horizontal: HorizontalLine<char> )

Insert a horizontal line to a specific row location.

source

pub fn get_line_vertical(&self, column: usize) -> Option<VerticalLine<char>>

Get a vertical line at the row if any set.

source

pub fn get_line_horizontal(&self, row: usize) -> Option<HorizontalLine<char>>

Get a horizontal line at the row if any set.

source§

impl Theme

source

pub fn reverse_rows(&mut self, reverse: bool)

Reverse rows.

source

pub fn reverse_columns(&mut self, reverse: bool)

Reverse columns.

Set a footer.

Copy columns names to an apposite side of a table.

source

pub fn align_columns(&mut self, position: Alignment)

Set column alignment

Trait Implementations§

source§

impl Clone for Theme

source§

fn clone(&self) -> Theme

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Theme

source§

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

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

impl Default for Theme

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<Borders<char>> for Theme

source§

fn from(borders: Borders<char>) -> Self

Converts to this type from the input type.
source§

impl From<ColoredConfig> for Theme

source§

fn from(cfg: ColoredConfig) -> Self

Converts to this type from the input type.
source§

impl<T, B, L, R, H, V, const HSIZE: usize, const VSIZE: usize> From<Style<T, B, L, R, H, V, HSIZE, VSIZE>> for Theme

source§

fn from(style: Style<T, B, L, R, H, V, HSIZE, VSIZE>) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Theme

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<R, D> TableOption<R, ColoredConfig, D> for Theme

source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, _: &mut D)

The function modificaties of records and a grid configuration.
source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
source§

impl<R, D> TableOption<R, CompactConfig, D> for Theme

source§

fn change(self, _: &mut R, cfg: &mut CompactConfig, _: &mut D)

The function modificaties of records and a grid configuration.
source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
source§

impl<R, D> TableOption<R, CompactMultilineConfig, D> for Theme

source§

fn change(self, _: &mut R, cfg: &mut CompactMultilineConfig, _: &mut D)

The function modificaties of records and a grid configuration.
source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
source§

impl Eq for Theme

source§

impl StructuralEq for Theme

source§

impl StructuralPartialEq for Theme

Auto Trait Implementations§

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnwindSafe for Theme

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> 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,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.