ratatui_toolkit/widgets/markdown_widget/widget/constructors/
with_theme.rs

1//! Theme application constructor for MarkdownWidget.
2
3use crate::widgets::markdown_widget::widget::MarkdownWidget;
4
5impl<'a> MarkdownWidget<'a> {
6    /// Applies an application theme to the widget.
7    ///
8    /// When a theme is applied, the widget will use theme colors for:
9    /// - Statusline (mode colors, background, text)
10    /// - TOC (text, active, hover, background, border colors)
11    /// - Selection highlighting
12    ///
13    /// If no theme is set, the widget falls back to default hardcoded colors.
14    ///
15    /// # Arguments
16    ///
17    /// * `theme` - The application theme to use for styling
18    ///
19    /// # Returns
20    ///
21    /// Self for method chaining.
22    ///
23    /// # Example
24    ///
25    /// ```rust,no_run
26    /// use ratatui_toolkit::{MarkdownWidget, theme::AppTheme};
27    ///
28    /// let theme = AppTheme::default();
29    /// // let widget = MarkdownWidget::new(content, scroll, selection, double_click)
30    /// //     .with_theme(&theme);
31    /// ```
32    pub fn with_theme(mut self, theme: &'a crate::services::theme::AppTheme) -> Self {
33        self.app_theme = Some(theme);
34        // Apply theme colors to TOC config
35        self.toc_config = self.toc_config.with_theme(theme);
36        self
37    }
38}