Skip to main content

editor/
handles.rs

1//! The glyphs the editor's handles paint: the block's gutter handle and a
2//! table's row and column handles. The app installs its own with
3//! [`crate::AppExt::set_handles`]; [`Handles::default`] until it does.
4
5use gpui::{App, Global};
6use ui::icons::{Icon, glyph};
7
8#[derive(Clone, Debug, PartialEq, Eq)]
9pub struct Handles {
10    pub block: Icon,
11    pub row: Icon,
12    pub column: Icon,
13}
14
15impl Default for Handles {
16    fn default() -> Self {
17        Self {
18            block: glyph::GripVertical.into(),
19            row: glyph::GripVertical.into(),
20            column: glyph::GripHorizontal.into(),
21        }
22    }
23}
24
25pub(crate) struct Installed(pub Handles);
26
27impl Global for Installed {}
28
29/// The glyphs the app installed, or [`Handles::default`].
30pub(crate) fn installed(cx: &App) -> Handles {
31    cx.try_global::<Installed>()
32        .map_or_else(Handles::default, |Installed(handles)| handles.clone())
33}