panel_settings.rs

  1use gpui::Pixels;
  2use schemars::JsonSchema;
  3use serde::{Deserialize, Serialize};
  4use settings::{Settings, SettingsSources, SettingsUi};
  5use workspace::dock::DockPosition;
  6
  7#[derive(Deserialize, Debug)]
  8pub struct CollaborationPanelSettings {
  9    pub button: bool,
 10    pub dock: DockPosition,
 11    pub default_width: Pixels,
 12}
 13
 14#[derive(Clone, Copy, Default, Serialize, Deserialize, JsonSchema, Debug)]
 15#[serde(rename_all = "snake_case")]
 16pub enum ChatPanelButton {
 17    Never,
 18    Always,
 19    #[default]
 20    WhenInCall,
 21}
 22
 23#[derive(Deserialize, Debug)]
 24pub struct ChatPanelSettings {
 25    pub button: ChatPanelButton,
 26    pub dock: DockPosition,
 27    pub default_width: Pixels,
 28}
 29
 30#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi)]
 31pub struct ChatPanelSettingsContent {
 32    /// When to show the panel button in the status bar.
 33    ///
 34    /// Default: only when in a call
 35    pub button: Option<ChatPanelButton>,
 36    /// Where to dock the panel.
 37    ///
 38    /// Default: right
 39    pub dock: Option<DockPosition>,
 40    /// Default width of the panel in pixels.
 41    ///
 42    /// Default: 240
 43    pub default_width: Option<f32>,
 44}
 45
 46#[derive(Deserialize, Debug)]
 47pub struct NotificationPanelSettings {
 48    pub button: bool,
 49    pub dock: DockPosition,
 50    pub default_width: Pixels,
 51}
 52
 53#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi)]
 54pub struct PanelSettingsContent {
 55    /// Whether to show the panel button in the status bar.
 56    ///
 57    /// Default: true
 58    pub button: Option<bool>,
 59    /// Where to dock the panel.
 60    ///
 61    /// Default: left
 62    pub dock: Option<DockPosition>,
 63    /// Default width of the panel in pixels.
 64    ///
 65    /// Default: 240
 66    pub default_width: Option<f32>,
 67}
 68
 69#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug, SettingsUi)]
 70pub struct MessageEditorSettings {
 71    /// Whether to automatically replace emoji shortcodes with emoji characters.
 72    /// For example: typing `:wave:` gets replaced with `👋`.
 73    ///
 74    /// Default: false
 75    pub auto_replace_emoji_shortcode: Option<bool>,
 76}
 77
 78impl Settings for CollaborationPanelSettings {
 79    const KEY: Option<&'static str> = Some("collaboration_panel");
 80
 81    type FileContent = PanelSettingsContent;
 82
 83    fn load(
 84        sources: SettingsSources<Self::FileContent>,
 85        _: &mut gpui::App,
 86    ) -> anyhow::Result<Self> {
 87        sources.json_merge()
 88    }
 89
 90    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
 91}
 92
 93impl Settings for ChatPanelSettings {
 94    const KEY: Option<&'static str> = Some("chat_panel");
 95
 96    type FileContent = ChatPanelSettingsContent;
 97
 98    fn load(
 99        sources: SettingsSources<Self::FileContent>,
100        _: &mut gpui::App,
101    ) -> anyhow::Result<Self> {
102        sources.json_merge()
103    }
104
105    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
106}
107
108impl Settings for NotificationPanelSettings {
109    const KEY: Option<&'static str> = Some("notification_panel");
110
111    type FileContent = PanelSettingsContent;
112
113    fn load(
114        sources: SettingsSources<Self::FileContent>,
115        _: &mut gpui::App,
116    ) -> anyhow::Result<Self> {
117        sources.json_merge()
118    }
119
120    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
121}
122
123impl Settings for MessageEditorSettings {
124    const KEY: Option<&'static str> = Some("message_editor");
125
126    type FileContent = MessageEditorSettings;
127
128    fn load(
129        sources: SettingsSources<Self::FileContent>,
130        _: &mut gpui::App,
131    ) -> anyhow::Result<Self> {
132        sources.json_merge()
133    }
134
135    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
136}