Struct comfy_table::Cell
source · pub struct Cell { /* private fields */ }
Expand description
A stylable table cell with content.
Implementations§
source§impl Cell
impl Cell
sourcepub fn set_delimiter(self, delimiter: char) -> Self
pub fn set_delimiter(self, delimiter: char) -> Self
Set the delimiter used to split text for this cell.
Normal text uses spaces (
) as delimiters. This is necessary to help comfy-table
understand the concept of words.
sourcepub fn set_alignment(self, alignment: CellAlignment) -> Self
pub fn set_alignment(self, alignment: CellAlignment) -> Self
Set the alignment of content for this cell.
Setting this overwrites alignment settings of the Column for this specific cell.
use comfy_table::CellAlignment;
use comfy_table::Cell;
let mut cell = Cell::new("Some content")
.set_alignment(CellAlignment::Center);
sourcepub fn fg(self, color: Color) -> Self
pub fn fg(self, color: Color) -> Self
Set the foreground text color for this cell.
comfy-table uses Crossterm Colors. Look at their documentation for all possible Colors.
use comfy_table::Color;
use comfy_table::Cell;
let mut cell = Cell::new("Some content")
.fg(Color::Red);
sourcepub fn bg(self, color: Color) -> Self
pub fn bg(self, color: Color) -> Self
Set the background color for this cell.
comfy-table uses Crossterm Colors. Look at their documentation for all possible Colors.
use comfy_table::Color;
use comfy_table::Cell;
let mut cell = Cell::new("Some content")
.bg(Color::Red);
sourcepub fn add_attribute(self, attribute: Attribute) -> Self
pub fn add_attribute(self, attribute: Attribute) -> Self
Add a styling attribute to the content cell.
Those can be bold, italic, blinking and many more.
comfy-table uses Crossterm Attributes. Look at their documentation for all possible Attributes.
use comfy_table::Attribute;
use comfy_table::Cell;
let mut cell = Cell::new("Some content")
.add_attribute(Attribute::Bold);
sourcepub fn add_attributes(self, attribute: Vec<Attribute>) -> Self
pub fn add_attributes(self, attribute: Vec<Attribute>) -> Self
Same as add_attribute, but you can pass a vector of Attributes