### Verify Opaline Installation Source: https://hyperb1iss.github.io/opaline/getting-started/installation.html A simple Rust program to load the default theme and print its name and type (dark/light). This confirms that Opaline is correctly installed and functional. ```rust use opaline::Theme; fn main() { let theme = Theme::default(); println!("Loaded: {} ({})", theme.meta.name, if theme.is_dark() { "dark" } else { "light" }); } ``` -------------------------------- ### Integrate Theme Selector into Ratatui App Source: https://hyperb1iss.github.io/opaline/guide/theme-selector.html A minimal integration example for a Ratatui app, demonstrating how to handle key presses to open, select, and cancel the theme picker. The original theme is automatically restored on cancel. ```rust use crossterm::event::{self, KeyCode}; use opaline::{ThemeSelector, ThemeSelectorAction, ThemeSelectorState}; struct App { theme_picker: Option, } impl App { fn handle_key(&mut self, key: crossterm::event::KeyEvent) { if let Some(picker) = &mut self.theme_picker { match picker.handle_key(key) { ThemeSelectorAction::Select(id) => { // Theme is already applied; persist the choice self.save_theme_preference(&id); self.theme_picker = None; } ThemeSelectorAction::Cancel => { // Original theme was restored automatically self.theme_picker = None; } _ => {} } } else if key.code == KeyCode::Char('t') { // Open theme picker self.theme_picker = Some( ThemeSelectorState::with_current_selected() ); } } fn render(&mut self, frame: &mut ratatui::Frame) { if let Some(state) = &mut self.theme_picker { frame.render_stateful_widget( ThemeSelector::new(), frame.area(), state, ); } } } ``` -------------------------------- ### Theme Discovery Directories Source: https://hyperb1iss.github.io/opaline/guide/custom-themes.html Shows how to get standard theme directories for your application and list available themes. Opaline can scan these directories to discover user-provided themes. ```rust // Get theme directories for your app let dirs = opaline::app_theme_dirs("myapp"); // → ~/.config/myapp/themes/ // List discoverable themes for a specific app let themes = opaline::builtins::list_available_themes_for_app("myapp"); // Scan all theme directories let dirs = opaline::theme_dirs(); ``` -------------------------------- ### Theme Discovery Directories Source: https://hyperb1iss.github.io/opaline/reference/api.html Requires the `discovery` feature. Get the default directories for application-specific themes or system-wide themes. ```rust use opaline::{app_theme_dirs, theme_dirs}; let dirs = app_theme_dirs("myapp"); // Vec let dirs = theme_dirs(); // Vec ``` -------------------------------- ### Render Themed Widgets in Ratatui Source: https://hyperb1iss.github.io/opaline/guide/ratatui.html Example of rendering a themed `Block` and `Paragraph` within a Ratatui render function, utilizing Opaline's styling. ```rust use opaline::{Theme, gradient_bar}; use ratatui::widgets::{Block, Borders, Paragraph}; fn render(frame: &mut ratatui::Frame, theme: &Theme) { let area = frame.area(); // Themed block: OpalineStyle works via Into