pub struct Style {
pub fg: Colour,
pub bg: Colour,
pub attrs: Attrs,
}Expand description
How a cell paints: foreground, background, attributes.
Fields§
§fg: Colour§bg: Colour§attrs: AttrsImplementations§
Source§impl Style
impl Style
pub const fn new() -> Self
Sourcepub const fn fg(colour: Colour) -> Self
pub const fn fg(colour: Colour) -> Self
A style with this foreground.
Examples found in repository?
More examples
examples/clock_card.rs (line 43)
32 fn frame(&mut self, frame: &Frame) {
33 let second = frame.now_ms() / 1000;
34 if self.shown != Some(second) {
35 self.shown = Some(second);
36 let (cols, _) = self.card.size();
37 let time = format!(
38 "{:02}:{:02}:{:02}",
39 second / 3600 % 24,
40 second / 60 % 60,
41 second % 60
42 );
43 self.card.text(0, 0, &time, Style::fg(Colour::FG).bold());
44 let fraction = (second % 60) as f32 / 60.0;
45 let track = Style::fg(Colour::RECEDE_FG);
46 self.card.bar(
47 Area::new(0, 1, cols, 1),
48 fraction,
49 Style::fg(Colour::ACCENT),
50 track,
51 );
52 // Publishes only the cells that changed.
53 let _ = self.card.commit();
54 }
55 // The next second boundary: an idle viewer wakes once a second.
56 frame.wake_at((second + 1) * 1000);
57 }pub const fn with_fg(self, colour: Colour) -> Self
pub const fn with_bg(self, colour: Colour) -> Self
pub const fn with_attrs(self, attrs: Attrs) -> Self
Sourcepub const fn bold(self) -> Self
pub const fn bold(self) -> Self
Examples found in repository?
examples/clock_card.rs (line 43)
32 fn frame(&mut self, frame: &Frame) {
33 let second = frame.now_ms() / 1000;
34 if self.shown != Some(second) {
35 self.shown = Some(second);
36 let (cols, _) = self.card.size();
37 let time = format!(
38 "{:02}:{:02}:{:02}",
39 second / 3600 % 24,
40 second / 60 % 60,
41 second % 60
42 );
43 self.card.text(0, 0, &time, Style::fg(Colour::FG).bold());
44 let fraction = (second % 60) as f32 / 60.0;
45 let track = Style::fg(Colour::RECEDE_FG);
46 self.card.bar(
47 Area::new(0, 1, cols, 1),
48 fraction,
49 Style::fg(Colour::ACCENT),
50 track,
51 );
52 // Publishes only the cells that changed.
53 let _ = self.card.commit();
54 }
55 // The next second boundary: an idle viewer wakes once a second.
56 frame.wake_at((second + 1) * 1000);
57 }pub const fn dim(self) -> Self
pub const fn italic(self) -> Self
Trait Implementations§
impl Copy for Style
impl Eq for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
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