1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//! # Theme System Module
//!
//! Comprehensive theming system for the Quetty terminal user interface providing
//! dynamic theme loading, management, and runtime switching capabilities. This module
//! enables rich visual customization with support for multiple theme families and flavors.
//!
//! ## Architecture
//!
//! The theme system is built around several key components:
//!
//! - **[`ThemeManager`]** - Global theme management and runtime switching
//! - **[`ThemeLoader`]** - Dynamic theme discovery and loading from filesystem
//! - **[`ThemeConfig`]** - Configuration structure for theme selection
//! - **Theme Validation** - Comprehensive validation for theme files and structures
//!
//! ## Supported Theme Families
//!
//! The system supports multiple popular terminal theme families:
//!
//! ### Catppuccin
//! - **Latte** - Light, warm theme for daytime use
//! - **Frappé** - Medium contrast theme with balanced colors
//! - **Macchiato** - Darker theme with soft contrast
//! - **Mocha** - Deep dark theme for nighttime coding
//!
//! ### Nightfox
//! - **Nightfox** - Balanced dark theme with blue accents
//! - **Dayfox** - Light theme with warm tones
//! - **Carbonfox** - High contrast dark theme
//! - **Duskfox** - Muted dark theme with purple accents
//!
//! ### Quetty (Default)
//! - **Dark** - Application default dark theme
//! - **Light** - Application default light theme
//!
//! ## Basic Usage
//!
//! ### Initialization and Basic Operations
//! ```ignore
//! use quetty::theme::{ThemeManager, ThemeConfig};
//!
//! // Initialize at application startup
//! let config = ThemeConfig {
//! theme_name: "catppuccin".to_string(),
//! flavor_name: "mocha".to_string(),
//! };
//! ThemeManager::init_global(&config)?;
//!
//! // Access theme colors throughout the application
//! let primary_color = ThemeManager::primary_accent();
//! let text_color = ThemeManager::text_primary();
//! let surface_color = ThemeManager::surface();
//! ```
//!
//! ### Runtime Theme Switching
//! ```ignore
//! use quetty::theme::ThemeManager;
//!
//! // Switch to a different theme at runtime
//! {
//! let mut manager = ThemeManager::global().lock().unwrap();
//! manager.switch_theme("nightfox", "carbonfox")?;
//! }
//!
//! // Colors automatically update for all components
//! let new_accent = ThemeManager::primary_accent();
//! ```
//!
//! ### Theme Discovery
//! ```ignore
//! use quetty::theme::ThemeManager;
//!
//! // Discover available themes and flavors
//! let available_themes = ThemeManager::get_available_themes();
//! for (theme_name, flavors) in available_themes {
//! println!("Theme: {}", theme_name);
//! for (flavor_name, theme_icon, flavor_icon) in flavors {
//! println!(" Flavor: {} {} {}", flavor_name, theme_icon, flavor_icon);
//! }
//! }
//! ```
//!
//! ## Color Categories
//!
//! ### Core Colors
//! - **Text Colors** - Primary and muted text for readability
//! - **Surface Colors** - Background and container colors
//! - **Accent Colors** - Primary, title, and header accents
//!
//! ### Functional Colors
//! - **Selection Colors** - Highlighting and focus indicators
//! - **Status Colors** - Success, warning, error, info, and loading states
//! - **Message Colors** - Queue-specific colors for different message states
//!
//! ### Component-Specific Colors
//! - **Help System** - Shortcut keys and descriptions
//! - **Popups** - Modal backgrounds and text
//! - **Lists** - Namespace and item-specific styling
//!
//! ## Component Integration
//!
//! ### Using Colors in TUI Components
//! ```ignore
//! use quetty::theme::ThemeManager;
//! use tuirealm::props::{PropPayload, PropValue};
//!
//! // Set component colors from theme
//! component.attr(
//! PropName::ForegroundColor,
//! PropPayload::One(PropValue::Color(ThemeManager::text_primary())),
//! );
//!
//! component.attr(
//! PropName::BackgroundColor,
//! PropPayload::One(PropValue::Color(ThemeManager::surface())),
//! );
//! ```
//!
//! ### Dynamic Color Updates
//! ```ignore
//! use quetty::theme::ThemeManager;
//!
//! // Components can react to theme changes
//! pub fn update_colors(&mut self) {
//! self.primary_color = ThemeManager::primary_accent();
//! self.text_color = ThemeManager::text_primary();
//! self.background_color = ThemeManager::surface();
//! // Trigger component redraw...
//! }
//! ```
//!
//! ## Error Handling and Fallbacks
//!
//! The theme system provides graceful degradation:
//!
//! - **Missing Themes** - Falls back to default Quetty dark theme
//! - **Invalid Colors** - Uses fallback colors for invalid hex values
//! - **Loading Errors** - Continues with previously loaded theme or defaults
//! - **Thread Safety** - Handles concurrent access safely with mutex protection
//!
//! ## Theme File Structure
//!
//! Themes are loaded from `~/.config/quetty/themes/` directory:
//! ```text
//! themes/
//! ├── catppuccin/
//! │ ├── latte.toml
//! │ ├── frappe.toml
//! │ ├── macchiato.toml
//! └── nightfox/
//! ├── nightfox.toml
//! ├── dayfox.toml
//! └── carbonfox.toml
//! ```
pub use ThemeManager;
pub use ThemeConfig;