Skip to main content

ui/
app.rs

1//! App-owned configuration.
2
3use gpui::App;
4
5/// Configuration carried by the application. Import as `use ui::AppExt as _;`.
6pub trait AppExt {
7    /// Reads the caption button style. Defaults to `Rectangular`.
8    fn caption_style(&self) -> crate::titlebar::CaptionStyle;
9
10    /// Sets the caption button style and refreshes windows.
11    fn set_caption_style(&mut self, style: crate::titlebar::CaptionStyle);
12
13    /// Reads caret blink.
14    fn caret_blink(&self) -> bool;
15
16    /// Enables blinking or holds carets solid, then refreshes windows.
17    fn set_caret_blink(&mut self, blink: bool);
18
19    /// Reads caret shape.
20    fn caret_shape(&self) -> crate::input::CaretShape;
21
22    /// Sets text caret shape and refreshes windows. Defaults to `Bar`.
23    fn set_caret_shape(&mut self, shape: crate::input::CaretShape);
24
25    /// Reads block caret height.
26    fn caret_height(&self) -> crate::input::CaretHeight;
27
28    /// Sets block caret height and refreshes windows. Defaults to `Line`.
29    fn set_caret_height(&mut self, height: crate::input::CaretHeight);
30
31    /// Reads scrollbar visibility.
32    fn scrollbar_visibility(&self) -> crate::scroll::Visibility;
33
34    /// Sets default scrollbar visibility and refreshes windows.
35    fn set_scrollbar_visibility(&mut self, value: crate::scroll::Visibility);
36
37    /// Reads the preset color set pickers offer.
38    fn color_swatches(&self) -> std::rc::Rc<[crate::color::Swatch]>;
39
40    /// Replaces the preset color set and refreshes windows. Defaults to
41    /// [`crate::color::default_swatches`].
42    fn set_color_swatches(&mut self, set: impl Into<std::rc::Rc<[crate::color::Swatch]>>);
43}
44
45impl AppExt for App {
46    fn caption_style(&self) -> crate::titlebar::CaptionStyle {
47        crate::titlebar::caption_style(self)
48    }
49
50    fn set_caption_style(&mut self, style: crate::titlebar::CaptionStyle) {
51        self.set_global(style);
52        self.refresh_windows();
53    }
54
55    fn caret_blink(&self) -> bool {
56        crate::input::caret_blink(self)
57    }
58
59    fn set_caret_blink(&mut self, blink: bool) {
60        crate::input::set_caret_blink(blink, self)
61    }
62
63    fn caret_shape(&self) -> crate::input::CaretShape {
64        crate::input::caret::caret_shape(self)
65    }
66
67    fn set_caret_shape(&mut self, shape: crate::input::CaretShape) {
68        crate::input::caret::set_caret_shape(shape, self)
69    }
70
71    fn caret_height(&self) -> crate::input::CaretHeight {
72        crate::input::caret::caret_height(self)
73    }
74
75    fn set_caret_height(&mut self, height: crate::input::CaretHeight) {
76        crate::input::caret::set_caret_height(height, self)
77    }
78
79    fn scrollbar_visibility(&self) -> crate::scroll::Visibility {
80        crate::scroll::overlay::visibility(self)
81    }
82
83    fn set_scrollbar_visibility(&mut self, value: crate::scroll::Visibility) {
84        crate::scroll::overlay::set_visibility(value, self)
85    }
86
87    fn color_swatches(&self) -> std::rc::Rc<[crate::color::Swatch]> {
88        crate::color::swatches(self)
89    }
90
91    fn set_color_swatches(&mut self, set: impl Into<std::rc::Rc<[crate::color::Swatch]>>) {
92        crate::color::set_swatches(set, self)
93    }
94}