ratatui_toolkit/services/theme/app_theme/constructors/new.rs
1//! New constructor for [`AppTheme`].
2
3use ratatui::style::Color;
4
5use crate::services::theme::app_theme::AppTheme;
6use crate::services::theme::diff_colors::DiffColors;
7use crate::services::theme::markdown_colors::MarkdownColors;
8use crate::services::theme::syntax_colors::SyntaxColors;
9
10impl AppTheme {
11 /// Creates a new [`AppTheme`] with all colors specified.
12 ///
13 /// This is a low-level constructor that requires all colors to be provided.
14 /// For most use cases, prefer [`AppTheme::default()`] or [`AppTheme::from_json()`].
15 ///
16 /// # Arguments
17 ///
18 /// * `primary` - Primary UI color
19 /// * `secondary` - Secondary UI color
20 /// * `accent` - Accent color
21 /// * `error` - Error color
22 /// * `warning` - Warning color
23 /// * `success` - Success color
24 /// * `info` - Info color
25 /// * `text` - Primary text color
26 /// * `text_muted` - Muted text color
27 /// * `selected_text` - Selected text color
28 /// * `background` - Main background color
29 /// * `background_panel` - Panel background color
30 /// * `background_element` - Element background color
31 /// * `background_menu` - Menu background color
32 /// * `border` - Default border color
33 /// * `border_active` - Active border color
34 /// * `border_subtle` - Subtle border color
35 /// * `diff` - Diff colors
36 /// * `markdown` - Markdown colors
37 /// * `syntax` - Syntax colors
38 ///
39 /// # Returns
40 ///
41 /// A new `AppTheme` instance with all colors configured.
42 ///
43 /// # Example
44 ///
45 /// ```rust
46 /// use ratatui::style::Color;
47 /// use ratatui_toolkit::services::theme::{AppTheme, DiffColors, MarkdownColors, SyntaxColors};
48 ///
49 /// let theme = AppTheme::new(
50 /// Color::Blue, Color::Magenta, Color::Cyan,
51 /// Color::Red, Color::Yellow, Color::Green, Color::LightBlue,
52 /// Color::White, Color::Gray, Color::White,
53 /// Color::Black, Color::DarkGray, Color::DarkGray, Color::DarkGray,
54 /// Color::Gray, Color::White, Color::DarkGray,
55 /// DiffColors::default(),
56 /// MarkdownColors::default(),
57 /// SyntaxColors::default(),
58 /// );
59 /// ```
60 #[allow(clippy::too_many_arguments)]
61 pub fn new(
62 primary: Color,
63 secondary: Color,
64 accent: Color,
65 error: Color,
66 warning: Color,
67 success: Color,
68 info: Color,
69 text: Color,
70 text_muted: Color,
71 selected_text: Color,
72 background: Color,
73 background_panel: Color,
74 background_element: Color,
75 background_menu: Color,
76 border: Color,
77 border_active: Color,
78 border_subtle: Color,
79 diff: DiffColors,
80 markdown: MarkdownColors,
81 syntax: SyntaxColors,
82 ) -> Self {
83 Self {
84 primary,
85 secondary,
86 accent,
87 error,
88 warning,
89 success,
90 info,
91 text,
92 text_muted,
93 selected_text,
94 background,
95 background_panel,
96 background_element,
97 background_menu,
98 border,
99 border_active,
100 border_subtle,
101 diff,
102 markdown,
103 syntax,
104 }
105 }
106}