ThemeManager

Struct ThemeManager 

Source
pub struct ThemeManager { /* private fields */ }
Expand description

Theme manager for runtime theme management and switching

Implementations§

Source§

impl ThemeManager

Source

pub fn new() -> Self

Create a new theme manager with default theme

Source

pub fn with_theme(theme: Theme) -> Self

Create a theme manager with a specific theme

Source

pub fn with_registry(registry: ThemeRegistry) -> Self

Create a theme manager with a custom registry

Source

pub fn current(&self) -> Result<Theme>

Get the current theme

Source

pub fn switch_by_name(&self, name: &str) -> Result<()>

Switch to a theme by name

Source

pub fn switch_to(&self, theme: Theme) -> Result<()>

Switch to a specific theme

Source

pub fn available_themes(&self) -> Vec<&'static str>

Get all available theme names

Source

pub fn current_name(&self) -> Result<String>

Get the current theme name

Source

pub fn load_from_config(&self, config: &TuiConfig) -> Result<()>

Load theme from config

Source

pub fn save_to_config(&self, config: &mut TuiConfig) -> Result<()>

Save current theme to config

Source

pub fn load_from_storage(&self) -> Result<()>

Load theme preference from storage

Source

pub fn save_to_storage(&self) -> Result<()>

Save current theme preference to storage

Source

pub fn load_custom_theme(&self, path: &Path) -> Result<()>

Load a custom theme from a file

Source

pub fn load_custom_themes_from_directory( &self, dir: &Path, ) -> Result<Vec<Theme>>

Load all custom themes from a directory

Source

pub fn load_and_register_custom_themes(&self, dir: &Path) -> Result<Vec<String>>

Load all custom themes from a directory and register them

Source

pub fn load_custom_themes_from_storage(&self) -> Result<Vec<String>>

Load all custom themes from storage and register them

Source

pub fn save_custom_theme(&self, path: &Path) -> Result<()>

Save current theme as a custom theme to storage

Source

pub fn save_custom_theme_to_storage(&self, theme_name: &str) -> Result<()>

Save current theme as a custom theme to storage by name

Source

pub fn save_theme_as_custom(&self, theme: &Theme, path: &Path) -> Result<()>

Save a specific theme as a custom theme

Source

pub fn save_theme_as_custom_to_storage( &self, theme: &Theme, theme_name: &str, ) -> Result<()>

Save a specific theme as a custom theme to storage by name

Source

pub fn delete_custom_theme(&self, name: &str, path: &Path) -> Result<()>

Delete a custom theme file and unregister it

Source

pub fn delete_custom_theme_from_storage(&self, theme_name: &str) -> Result<()>

Delete a custom theme from storage and unregister it

Source

pub fn custom_themes_directory() -> Result<PathBuf>

Get the default custom themes directory

Source

pub fn registry(&self) -> &ThemeRegistry

Get the theme registry

Source

pub fn list_all_themes(&self) -> Result<Vec<String>>

List all available themes (built-in and custom)

Source

pub fn list_builtin_themes(&self) -> Vec<String>

List all built-in themes

Source

pub fn list_custom_themes(&self) -> Result<Vec<String>>

List all custom themes

Source

pub fn register_theme(&self, theme: Theme) -> Result<()>

Register a custom theme in the registry

Source

pub fn unregister_theme(&self, name: &str) -> Result<()>

Unregister a custom theme from the registry

Source

pub fn theme_exists(&self, name: &str) -> bool

Check if a theme exists

Source

pub fn is_builtin_theme(&self, name: &str) -> bool

Check if a theme is built-in

Source

pub fn is_custom_theme(&self, name: &str) -> Result<bool>

Check if a theme is custom

Source

pub fn builtin_theme_count(&self) -> usize

Get the number of built-in themes

Source

pub fn custom_theme_count(&self) -> Result<usize>

Get the number of custom themes

Source

pub fn reset_colors(&self) -> Result<()>

Reset all colors in the current theme to their default values

Source

pub fn reset_theme(&self) -> Result<()>

Reset the current theme to its built-in default

Source

pub fn reset_color(&self, color_name: &str) -> Result<()>

Reset a specific color field in the current theme to its default value

Source

pub fn get_default_color(&self, color_name: &str) -> Result<Color>

Get the default color value for a specific color field in the current theme

Source

pub fn reset_manager(&self) -> &ThemeResetManager

Get the theme reset manager

Source

pub fn on_theme_changed<F>(&self, listener: F) -> Result<()>
where F: Fn(&Theme) + Send + 'static,

Register a listener for theme changes

Trait Implementations§

Source§

impl Clone for ThemeManager

Source§

fn clone(&self) -> ThemeManager

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 ThemeManager

Source§

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

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

impl Default for ThemeManager

Source§

fn default() -> Self

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

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more