ratatui_toolkit/widgets/code_diff/foundation/diff_config/constructors/new.rs
1use ratatui::style::Color;
2
3use crate::widgets::code_diff::diff_config::DiffConfig;
4use crate::widgets::code_diff::enums::DiffStyle;
5
6impl DiffConfig {
7 /// Creates a new diff configuration with default values.
8 ///
9 /// Default colors are chosen to work well on both light and dark terminals:
10 /// - Added lines: dark green background, bright green foreground
11 /// - Removed lines: dark red background, bright red foreground
12 /// - Hunk headers: gray background, cyan foreground
13 ///
14 /// # Returns
15 ///
16 /// A new `DiffConfig` with default settings
17 ///
18 /// # Example
19 ///
20 /// ```rust
21 /// use ratatui_toolkit::code_diff::DiffConfig;
22 ///
23 /// let config = DiffConfig::new();
24 /// assert!(config.show_line_numbers);
25 /// ```
26 pub fn new() -> Self {
27 Self {
28 added_bg: Color::Rgb(0, 60, 0),
29 added_fg: Color::Rgb(80, 200, 80),
30 removed_bg: Color::Rgb(60, 0, 0),
31 removed_fg: Color::Rgb(200, 80, 80),
32 hunk_header_bg: Color::Rgb(40, 40, 40),
33 hunk_header_fg: Color::Cyan,
34 line_number_fg: Color::DarkGray,
35 show_line_numbers: true,
36 context_lines: 3,
37 style: DiffStyle::SideBySide,
38 gutter_width: 2,
39 line_number_width: 4,
40 sidebar_enabled: false,
41 sidebar_default_width: 25,
42 sidebar_min_width: 10,
43 sidebar_max_width: 50,
44 }
45 }
46}
47
48impl Default for DiffConfig {
49 fn default() -> Self {
50 Self::new()
51 }
52}