Struct Style

Source
pub struct Style {
    pub fg: Option<Color>,
    pub bg: Option<Color>,
    pub attributes: Attributes,
}
Expand description

The style for a cell in a [crate::Buffer] A style is applied to ever single cell in a [crate::Buffer].

Styles do not cascade (and don’t behave like CSS). So giving a style to a parent widget does not automatically apply it to the child.

The following template would draw a red border with white text inside:

border [foreground: red]:
    text: "hi"

In the following example, if the condition is ever true, and then false the text is_false will be rendered with a red foreground.

The way to reset the foreground is to apply Color::Reset to the text.

if [cond: {{ is_true }}]:
    text [foreground: red]: "is true"
else:
    text: "is false"

Fields§

§fg: Option<Color>

Foreground colour.

§bg: Option<Color>

Background colour.

§attributes: Attributes

Attributes.

Implementations§

Source§

impl Style

Source

pub const fn new() -> Self

Create a new instance of a Style:

Source

pub fn from_cell_attribs(attributes: &Attributes<'_>) -> Self

Create an instance of Style from CellAttributes.

Source

pub fn set_fg(&mut self, fg: Color)

Set the foreground colour

Source

pub fn set_bg(&mut self, bg: Color)

Set the background colour

Source

pub fn set_bold(&mut self, bold: bool)

Set the style to bold

Source

pub fn set_italic(&mut self, italic: bool)

Set the style to italic

Source

pub fn set_dim(&mut self, dim: bool)

Make the cell dim

Source

pub fn set_underlined(&mut self, underlined: bool)

Make the cell underlined as long as it’s supported

Source

pub fn set_overlined(&mut self, overlined: bool)

Make the cell overlined as long as it’s supported

Source

pub fn set_crossed_out(&mut self, crossed_out: bool)

Make the cell crossed out as long as it’s supported

Source

pub fn set_reversed(&mut self, inverse: bool)

Invert the foreground and background

Source

pub fn reset() -> Self

Reset the style

Source

pub fn merge(&mut self, other: Style)

Merge two styles: if self has no foreground the foreground from the other style is copied to self. if self has no background the background from the other style is copied to self.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Style

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Style

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Style

Source§

fn eq(&self, other: &Style) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Style

Source§

impl Eq for Style

Source§

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 UnwindSafe for Style

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.