pub struct StyleOpt {
pub fg: Option<Fg>,
pub bg: Option<Bg>,
pub sgr: Option<Sgr>,
}Expand description
A struct providing optional customization of the foreground color, background color, and text style of a GridPrinter column.
Fields§
§fg: Option<Fg>§bg: Option<Bg>§sgr: Option<Sgr>Implementations§
Source§impl StyleOpt
impl StyleOpt
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new StyleOpt with no specified style options.
Examples found in repository?
examples/colors.rs (line 17)
5fn main() -> Result<(), Box<dyn Error>> {
6
7 let grid = vec![
8 vec![1, 2, 3, 4, ],
9 vec![5, 6, 7, 8, ],
10 vec![9, 10, 11, 12, ],
11 ];
12
13 let rows = grid.len();
14 let cols = grid[0].len();
15
16 let printer = GridPrinter::builder(rows, cols)
17 .col_style(0, StyleOpt::new().fg(Fg::Magenta))?
18 .col_style(1, StyleOpt::new().fg(Fg::Black).bg(Bg::BrightYellow))?
19 .col_style(2, StyleOpt::new().sgr(Sgr::StrikeThrough))?
20 .col_style(3, StyleOpt::new().fg(Fg::Cyan))?
21 .build();
22 printer.print(&grid);
23
24 Ok(())
25}Sourcepub fn fg(self, fg: Fg) -> Self
pub fn fg(self, fg: Fg) -> Self
Set the foreground color.
Examples found in repository?
examples/colors.rs (line 17)
5fn main() -> Result<(), Box<dyn Error>> {
6
7 let grid = vec![
8 vec![1, 2, 3, 4, ],
9 vec![5, 6, 7, 8, ],
10 vec![9, 10, 11, 12, ],
11 ];
12
13 let rows = grid.len();
14 let cols = grid[0].len();
15
16 let printer = GridPrinter::builder(rows, cols)
17 .col_style(0, StyleOpt::new().fg(Fg::Magenta))?
18 .col_style(1, StyleOpt::new().fg(Fg::Black).bg(Bg::BrightYellow))?
19 .col_style(2, StyleOpt::new().sgr(Sgr::StrikeThrough))?
20 .col_style(3, StyleOpt::new().fg(Fg::Cyan))?
21 .build();
22 printer.print(&grid);
23
24 Ok(())
25}Sourcepub fn bg(self, bg: Bg) -> Self
pub fn bg(self, bg: Bg) -> Self
Set the background color.
Examples found in repository?
examples/colors.rs (line 18)
5fn main() -> Result<(), Box<dyn Error>> {
6
7 let grid = vec![
8 vec![1, 2, 3, 4, ],
9 vec![5, 6, 7, 8, ],
10 vec![9, 10, 11, 12, ],
11 ];
12
13 let rows = grid.len();
14 let cols = grid[0].len();
15
16 let printer = GridPrinter::builder(rows, cols)
17 .col_style(0, StyleOpt::new().fg(Fg::Magenta))?
18 .col_style(1, StyleOpt::new().fg(Fg::Black).bg(Bg::BrightYellow))?
19 .col_style(2, StyleOpt::new().sgr(Sgr::StrikeThrough))?
20 .col_style(3, StyleOpt::new().fg(Fg::Cyan))?
21 .build();
22 printer.print(&grid);
23
24 Ok(())
25}Sourcepub fn sgr(self, sgr: Sgr) -> Self
pub fn sgr(self, sgr: Sgr) -> Self
Set the Select Graphic Rendition.
Examples found in repository?
examples/colors.rs (line 19)
5fn main() -> Result<(), Box<dyn Error>> {
6
7 let grid = vec![
8 vec![1, 2, 3, 4, ],
9 vec![5, 6, 7, 8, ],
10 vec![9, 10, 11, 12, ],
11 ];
12
13 let rows = grid.len();
14 let cols = grid[0].len();
15
16 let printer = GridPrinter::builder(rows, cols)
17 .col_style(0, StyleOpt::new().fg(Fg::Magenta))?
18 .col_style(1, StyleOpt::new().fg(Fg::Black).bg(Bg::BrightYellow))?
19 .col_style(2, StyleOpt::new().sgr(Sgr::StrikeThrough))?
20 .col_style(3, StyleOpt::new().fg(Fg::Cyan))?
21 .build();
22 printer.print(&grid);
23
24 Ok(())
25}Trait Implementations§
impl StructuralPartialEq for StyleOpt
Auto Trait Implementations§
impl Freeze for StyleOpt
impl RefUnwindSafe for StyleOpt
impl Send for StyleOpt
impl Sync for StyleOpt
impl Unpin for StyleOpt
impl UnwindSafe for StyleOpt
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