Skip to main content

Theme

Struct Theme 

Source
pub struct Theme { /* private fields */ }

Implementations§

Source§

impl Theme

Source

pub fn new() -> Self

Creates an empty theme.

Source

pub fn from_styles(styles: BTreeMap<String, Style>) -> Self

Creates a theme from a style map after normalizing capture names.

Source

pub fn from_parts( styles: BTreeMap<String, Style>, ui: BTreeMap<String, Style>, ) -> Self

Creates a theme from syntax-style and UI-role maps after normalization.

Source

pub fn insert( &mut self, capture_name: impl AsRef<str>, style: Style, ) -> Option<Style>

Inserts or replaces a style for a capture name.

Capture names are normalized (trimmed, lowercased, optional @ removed). Returns the previously associated style, if any.

Source

pub fn styles(&self) -> &BTreeMap<String, Style>

Returns the internal normalized style map.

Source

pub fn insert_ui( &mut self, role_name: impl AsRef<str>, style: Style, ) -> Option<Style>

Inserts or replaces a UI role style.

Role names are normalized like capture names. Returns the previously associated style, if any.

Source

pub fn ui_styles(&self) -> &BTreeMap<String, Style>

Returns the internal normalized UI role map.

Source

pub fn get_exact(&self, capture_name: &str) -> Option<&Style>

Returns the exact style for a capture after normalization.

Source

pub fn get_ui_exact(&self, role_name: &str) -> Option<&Style>

Returns the exact UI role style after normalization.

Source

pub fn resolve(&self, capture_name: &str) -> Option<&Style>

Resolves a style using dotted-name fallback and finally normal.

For example, comment.documentation falls back to comment before attempting normal.

Source

pub fn resolve_ui(&self, role_name: &str) -> Option<Style>

Resolves a UI role from explicit UI map entries with compatibility fallbacks.

This method first checks the dedicated ui map, then falls back to legacy entries in styles for compatibility with older themes.

Source

pub fn resolve_ui_role(&self, role: UiRole) -> Option<Style>

Resolves a typed UI role from explicit UI entries and fallbacks.

Source

pub fn default_terminal_colors(&self) -> (Option<Rgb>, Option<Rgb>)

Returns the theme default terminal foreground/background colors.

Values are resolved from UI roles first (default_fg, default_bg), then from styles.normal.

Source

pub fn from_json_str(input: &str) -> Result<Self, ThemeError>

Parses a theme from JSON.

Both wrapped ({ "styles": { ... } }) and flat style documents are accepted.

§Errors

Returns an error if the JSON cannot be parsed.

Source

pub fn from_toml_str(input: &str) -> Result<Self, ThemeError>

Parses a theme from TOML.

§Errors

Returns an error if the TOML cannot be parsed.

Source

pub fn from_builtin(theme: BuiltinTheme) -> Result<Self, ThemeError>

Loads a built-in theme from embedded JSON.

§Errors

Returns an error if embedded theme JSON fails to parse.

Source

pub fn from_builtin_name(name: &str) -> Result<Self, ThemeError>

Loads a built-in theme from a name or alias.

§Errors

Returns ThemeError::UnknownBuiltinTheme for unknown names.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

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 Theme

Source§

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

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

impl Default for Theme

Source§

fn default() -> Theme

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Theme

Source§

fn eq(&self, other: &Theme) -> 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 Eq for Theme

Source§

impl StructuralPartialEq for Theme

Auto Trait Implementations§

§

impl Freeze for Theme

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

§

impl UnwindSafe for Theme

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

Checks if this value is equivalent to the given key. 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> 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.