pub struct Theme { /* private fields */ }Implementations§
Source§impl Theme
impl Theme
Sourcepub fn from_styles(styles: BTreeMap<String, Style>) -> Self
pub fn from_styles(styles: BTreeMap<String, Style>) -> Self
Creates a theme from a style map after normalizing capture names.
Sourcepub fn from_parts(
styles: BTreeMap<String, Style>,
ui: BTreeMap<String, Style>,
) -> Self
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.
Sourcepub fn insert(
&mut self,
capture_name: impl AsRef<str>,
style: Style,
) -> Option<Style>
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.
Sourcepub fn insert_ui(
&mut self,
role_name: impl AsRef<str>,
style: Style,
) -> Option<Style>
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.
Sourcepub fn ui_styles(&self) -> &BTreeMap<String, Style>
pub fn ui_styles(&self) -> &BTreeMap<String, Style>
Returns the internal normalized UI role map.
Sourcepub fn get_exact(&self, capture_name: &str) -> Option<&Style>
pub fn get_exact(&self, capture_name: &str) -> Option<&Style>
Returns the exact style for a capture after normalization.
Sourcepub fn get_ui_exact(&self, role_name: &str) -> Option<&Style>
pub fn get_ui_exact(&self, role_name: &str) -> Option<&Style>
Returns the exact UI role style after normalization.
Sourcepub fn resolve(&self, capture_name: &str) -> Option<&Style>
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.
Sourcepub fn resolve_ui(&self, role_name: &str) -> Option<Style>
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.
Sourcepub fn resolve_ui_role(&self, role: UiRole) -> Option<Style>
pub fn resolve_ui_role(&self, role: UiRole) -> Option<Style>
Resolves a typed UI role from explicit UI entries and fallbacks.
Sourcepub fn default_terminal_colors(&self) -> (Option<Rgb>, Option<Rgb>)
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.
Sourcepub fn from_json_str(input: &str) -> Result<Self, ThemeError>
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.
Sourcepub fn from_toml_str(input: &str) -> Result<Self, ThemeError>
pub fn from_toml_str(input: &str) -> Result<Self, ThemeError>
Sourcepub fn from_builtin(theme: BuiltinTheme) -> Result<Self, ThemeError>
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.
Sourcepub fn from_builtin_name(name: &str) -> Result<Self, ThemeError>
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§
impl Eq for Theme
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.