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 scrollbar visibility.
26    fn scrollbar_visibility(&self) -> crate::scroll::Visibility;
27
28    /// Sets default scrollbar visibility and refreshes windows.
29    fn set_scrollbar_visibility(&mut self, value: crate::scroll::Visibility);
30
31    /// Reads the preset color set pickers offer.
32    fn color_swatches(&self) -> std::rc::Rc<[crate::color::Swatch]>;
33
34    /// Replaces the preset color set and refreshes windows. Defaults to
35    /// [`crate::color::default_swatches`].
36    fn set_color_swatches(&mut self, set: impl Into<std::rc::Rc<[crate::color::Swatch]>>);
37}
38
39impl AppExt for App {
40    fn caption_style(&self) -> crate::titlebar::CaptionStyle {
41        crate::titlebar::caption_style(self)
42    }
43
44    fn set_caption_style(&mut self, style: crate::titlebar::CaptionStyle) {
45        self.set_global(style);
46        self.refresh_windows();
47    }
48
49    fn caret_blink(&self) -> bool {
50        crate::input::caret_blink(self)
51    }
52
53    fn set_caret_blink(&mut self, blink: bool) {
54        crate::input::set_caret_blink(blink, self)
55    }
56
57    fn caret_shape(&self) -> crate::input::CaretShape {
58        crate::input::caret::caret_shape(self)
59    }
60
61    fn set_caret_shape(&mut self, shape: crate::input::CaretShape) {
62        crate::input::caret::set_caret_shape(shape, self)
63    }
64
65    fn scrollbar_visibility(&self) -> crate::scroll::Visibility {
66        crate::scroll::overlay::visibility(self)
67    }
68
69    fn set_scrollbar_visibility(&mut self, value: crate::scroll::Visibility) {
70        crate::scroll::overlay::set_visibility(value, self)
71    }
72
73    fn color_swatches(&self) -> std::rc::Rc<[crate::color::Swatch]> {
74        crate::color::swatches(self)
75    }
76
77    fn set_color_swatches(&mut self, set: impl Into<std::rc::Rc<[crate::color::Swatch]>>) {
78        crate::color::set_swatches(set, self)
79    }
80}