Skip to main content

WidgetStyle

Struct WidgetStyle 

Source
pub struct WidgetStyle {
Show 18 fields pub content: Style, pub secondary: Style, pub muted: Style, pub info: Style, pub success: Style, pub warning: Style, pub danger: Style, pub page: Style, pub section: Style, pub subsection: Style, pub action: Style, pub filled: Style, pub sunken: Style, pub focus: Modifier, pub meter_cells: u16, pub meter_full: char, pub meter_empty: char, pub required_marker: &'static str,
}
Expand description

The colours and marks the drawings below use.

TableStyle’s shape, for its reasons: an ungated struct of styles with a Default, plus a from_theme that is what a consumer holding a loaded theme should reach for first. A consumer painting bevels and nothing else should not have to supply text tones it never uses, and gating the whole module on theme would make these unreachable to anyone hand-picking colours.

The default is the one that survives a terminal with no colour at all: modifiers only, no foreground anywhere. That is not a placeholder. A two-colour terminal is the case where a Style carrying a foreground is a foreground that will not land, and bold-and-reversed is what is left.

Fields§

§content: Style

Ordinary content, and what Tone::Neutral reads as.

§secondary: Style

Content one step back: a field’s label, a quoted run.

§muted: Style

Content two steps back: a caption, a hint, a meter’s reading.

§info: Style

Something worth knowing and nothing to do about it.

§success: Style

Something finished and it worked.

§warning: Style

Something the user should look at.

§danger: Style

Something broken, or about to be destroyed.

§page: Style

A page title.

§section: Style

A section title.

§subsection: Style

A subsection title.

§action: Style

Text that goes somewhere, and a control’s label.

§filled: Style

A control filled with the action colour, for the one on a screen that is the thing to press. A form’s submit is the case that has it.

§sunken: Style

A surface set back from the one it sits on, by colour and nothing else. What a code run takes, since every cell is monospace and the thing a webview says with a typeface cannot be said that way here.

§focus: Modifier

What “you are on this one” adds to whatever it lands on.

Reversed video by default, which is the affordance a cell has left once colour is spent on tone and bold on weight. A webview says it with an outline; a terminal has no outline that is not four more cells.

§meter_cells: u16

How many cells meter spends on its bar.

§meter_full: char

The filled part of a bar.

§meter_empty: char

The empty part of a bar.

§required_marker: &'static str

What marks a compulsory field, appended to its label.

A knob for makeover-immediate’s reason: it is the one piece of copy here, and copy is not a renderer’s call.

Implementations§

Source§

impl WidgetStyle

Source

pub const fn tone(&self, tone: Tone) -> Style

The style a tone reads as.

Tone is closed and stays closed, so this is total and needs no fallback arm.

Source

pub const fn heading(&self, level: Heading) -> Style

The style a heading reads as.

Source

pub fn focused(&self, focused: bool, style: Style) -> Style

style, plus the mark that says the user is on this one.

Takes the flag rather than being called behind an if, because every caller has a bool in hand and the branch is the part that gets forgotten.

Trait Implementations§

Source§

impl Clone for WidgetStyle

Source§

fn clone(&self) -> WidgetStyle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for WidgetStyle

Source§

impl Debug for WidgetStyle

Source§

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

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

impl Default for WidgetStyle

Source§

fn default() -> Self

Modifiers only, no foreground: what survives a terminal with two colours.

Source§

impl Eq for WidgetStyle

Source§

impl PartialEq for WidgetStyle

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WidgetStyle

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.