pub struct Highlight<O> { /* private fields */ }
Expand description
Highlight modifies a table style by changing a border of a target Table
segment.
It basically highlights outer border of a given segment.
§Example
use tabled::{
Table,
settings::{
Highlight, Border, Style,
object::{Segment, Object}
}
};
let data = [
("ELF", "Extensible Linking Format", true),
("DWARF", "", true),
("PE", "Portable Executable", false),
];
let table = Table::new(data.iter().enumerate())
.with(Style::markdown())
.with(Highlight::outline(Segment::all().not((0,0).and((1, 0)).and((0, 1)).and((0, 3))), '*'))
.to_string();
assert_eq!(
table,
concat!(
" ***************************** \n",
"| usize | &str * &str * bool |\n",
"|-------*********---------------------------*********\n",
"| 0 * ELF | Extensible Linking Format | true *\n",
"********* *\n",
"* 1 | DWARF | | true *\n",
"* *\n",
"* 2 | PE | Portable Executable | false *\n",
"*****************************************************",
),
);
Implementations§
Source§impl<O> Highlight<O>
impl<O> Highlight<O>
Sourcepub const fn new(target: O) -> Self
pub const fn new(target: O) -> Self
Build a new instance of Highlight
with ‘*’ char being used as changer.
BE AWARE: if target exceeds boundaries it may panic.
Sourcepub const fn outline(target: O, c: char) -> Self
pub const fn outline(target: O, c: char) -> Self
Build a new instance of Highlight
,
highlighting by a character.
BE AWARE: if target exceeds boundaries it may panic.
Sourcepub fn colored(target: O, color: Color) -> Self
pub fn colored(target: O, color: Color) -> Self
Build a new instance of Highlight
,
highlighting by a color and a given character for a border.
BE AWARE: if target exceeds boundaries it may panic.
Sourcepub fn border<T, B, L, R>(self, border: ConstBorder<T, B, L, R>) -> Self
pub fn border<T, B, L, R>(self, border: ConstBorder<T, B, L, R>) -> Self
Set a border for a Highlight
.
Sourcepub fn color(self, border: BorderColor) -> Self
pub fn color(self, border: BorderColor) -> Self
Set a border color for a Highlight
.
Trait Implementations§
Source§impl<O, R, D> TableOption<R, ColoredConfig, D> for Highlight<O>
impl<O, R, D> TableOption<R, ColoredConfig, D> for Highlight<O>
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, _: &mut D)
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>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreAuto Trait Implementations§
impl<O> Freeze for Highlight<O>where
O: Freeze,
impl<O> RefUnwindSafe for Highlight<O>where
O: RefUnwindSafe,
impl<O> Send for Highlight<O>where
O: Send,
impl<O> Sync for Highlight<O>where
O: Sync,
impl<O> Unpin for Highlight<O>where
O: Unpin,
impl<O> UnwindSafe for Highlight<O>where
O: 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