pub struct LineText<Line> { /* private fields */ }
Expand description
LineText
writes a custom text on a border.
§Example
use tabled::{Table, settings::style::LineText, settings::object::Rows};
let mut table = Table::new(["Hello World"]);
table.with(LineText::new("+-.table", Rows::first()));
assert_eq!(
table.to_string(),
"+-.table------+\n\
| &str |\n\
+-------------+\n\
| Hello World |\n\
+-------------+"
);
Implementations§
Source§impl<Line> LineText<Line>
impl<Line> LineText<Line>
Sourcepub fn new<S>(text: S, line: Line) -> Self
pub fn new<S>(text: S, line: Line) -> Self
Creates a LineText
instance.
Line can be a column or a row.
Lines are numbered from 0 to the count_rows
/count_columns
included:
(line >= 0 && line <= count_rows
)
(line >= 0 && line <= count_columns
).
use tabled::{Table, settings::style::LineText, settings::object::Columns};
let mut table = Table::new(["Hello World"]);
table.with(LineText::new("TABLE", Columns::one(0)));
table.with(LineText::new("TABLE", Columns::one(1)));
assert_eq!(
table.to_string(),
"T-------------T\n\
A &str A\n\
B-------------B\n\
L Hello World L\n\
E-------------E"
);
Sourcepub fn align(self, alignment: Alignment) -> Self
pub fn align(self, alignment: Alignment) -> Self
Set an offset from which the text will be started.
use tabled::Table;
use tabled::settings::{Alignment, style::LineText, object::Rows};
let mut table = Table::new(["Hello World"]);
table.with(LineText::new("TABLE", Rows::first()).align(Alignment::center()));
assert_eq!(
table.to_string(),
"+----TABLE----+\n\
| &str |\n\
+-------------+\n\
| Hello World |\n\
+-------------+"
);
Sourcepub fn offset(self, offset: impl Into<Offset>) -> Self
pub fn offset(self, offset: impl Into<Offset>) -> Self
Set an offset from which the text will be started.
use tabled::{Table, settings::style::LineText, settings::object::Rows};
let mut table = Table::new(["Hello World"]);
table.with(LineText::new("TABLE", Rows::first()).offset(3));
assert_eq!(
table.to_string(),
"+--TABLE------+\n\
| &str |\n\
+-------------+\n\
| Hello World |\n\
+-------------+"
);
Sourcepub fn color(self, color: Color) -> Self
pub fn color(self, color: Color) -> Self
Set a color of the text.
use tabled::Table;
use tabled::settings::{object::Rows, Color, style::LineText};
let mut table = Table::new(["Hello World"]);
table.with(LineText::new("TABLE", Rows::first()).color(Color::FG_BLUE));
assert_eq!(
table.to_string(),
"\u{1b}[34mT\u{1b}[39m\u{1b}[34mA\u{1b}[39m\u{1b}[34mB\u{1b}[39m\u{1b}[34mL\u{1b}[39m\u{1b}[34mE\u{1b}[39m---------+\n\
| &str |\n\
+-------------+\n\
| Hello World |\n\
+-------------+"
);
Trait Implementations§
Source§impl<R, D> TableOption<R, ColoredConfig, D> for LineText<Column>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
impl<R, D> TableOption<R, ColoredConfig, D> for LineText<Column>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl<R, D> TableOption<R, ColoredConfig, D> for LineText<FirstColumn>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
impl<R, D> TableOption<R, ColoredConfig, D> for LineText<FirstColumn>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl<R, D> TableOption<R, ColoredConfig, D> for LineText<FirstRow>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
impl<R, D> TableOption<R, ColoredConfig, D> for LineText<FirstRow>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastColumn>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastColumn>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastColumnOffset>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastColumnOffset>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastRow>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastRow>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastRowOffset>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastRowOffset>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl<R, D> TableOption<R, ColoredConfig, D> for LineText<Row>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
impl<R, D> TableOption<R, ColoredConfig, D> for LineText<Row>where
R: Records + ExactRecords,
for<'a> &'a R: Records,
for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreAuto Trait Implementations§
impl<Line> Freeze for LineText<Line>where
Line: Freeze,
impl<Line> RefUnwindSafe for LineText<Line>where
Line: RefUnwindSafe,
impl<Line> Send for LineText<Line>where
Line: Send,
impl<Line> Sync for LineText<Line>where
Line: Sync,
impl<Line> Unpin for LineText<Line>where
Line: Unpin,
impl<Line> UnwindSafe for LineText<Line>where
Line: UnwindSafe,
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
Mutably borrows from an owned value. Read more