panel_settings.rs

  1use anyhow;
  2use gpui::Pixels;
  3use schemars::JsonSchema;
  4use serde_derive::{Deserialize, Serialize};
  5use settings::Settings;
  6use workspace::dock::DockPosition;
  7
  8#[derive(Deserialize, Debug)]
  9pub struct CollaborationPanelSettings {
 10    pub button: bool,
 11    pub dock: DockPosition,
 12    pub default_width: Pixels,
 13}
 14
 15#[derive(Deserialize, Debug)]
 16pub struct ChatPanelSettings {
 17    pub button: bool,
 18    pub dock: DockPosition,
 19    pub default_width: Pixels,
 20}
 21
 22#[derive(Deserialize, Debug)]
 23pub struct NotificationPanelSettings {
 24    pub button: bool,
 25    pub dock: DockPosition,
 26    pub default_width: Pixels,
 27}
 28
 29#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
 30pub struct PanelSettingsContent {
 31    /// Whether to show the panel button in the status bar.
 32    ///
 33    /// Default: true
 34    pub button: Option<bool>,
 35    /// Where to dock the panel.
 36    ///
 37    /// Default: left
 38    pub dock: Option<DockPosition>,
 39    /// Default width of the panel in pixels.
 40    ///
 41    /// Default: 240
 42    pub default_width: Option<f32>,
 43}
 44
 45#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
 46pub struct MessageEditorSettings {
 47    /// Whether to automatically replace emoji shortcodes with emoji characters.
 48    /// For example: typing `:wave:` gets replaced with `👋`.
 49    ///
 50    /// Default: false
 51    pub auto_replace_emoji_shortcode: Option<bool>,
 52}
 53
 54impl Settings for CollaborationPanelSettings {
 55    const KEY: Option<&'static str> = Some("collaboration_panel");
 56    type FileContent = PanelSettingsContent;
 57    fn load(
 58        default_value: &Self::FileContent,
 59        user_values: &[&Self::FileContent],
 60        _: &mut gpui::AppContext,
 61    ) -> anyhow::Result<Self> {
 62        Self::load_via_json_merge(default_value, user_values)
 63    }
 64}
 65
 66impl Settings for ChatPanelSettings {
 67    const KEY: Option<&'static str> = Some("chat_panel");
 68    type FileContent = PanelSettingsContent;
 69    fn load(
 70        default_value: &Self::FileContent,
 71        user_values: &[&Self::FileContent],
 72        _: &mut gpui::AppContext,
 73    ) -> anyhow::Result<Self> {
 74        Self::load_via_json_merge(default_value, user_values)
 75    }
 76}
 77
 78impl Settings for NotificationPanelSettings {
 79    const KEY: Option<&'static str> = Some("notification_panel");
 80    type FileContent = PanelSettingsContent;
 81    fn load(
 82        default_value: &Self::FileContent,
 83        user_values: &[&Self::FileContent],
 84        _: &mut gpui::AppContext,
 85    ) -> anyhow::Result<Self> {
 86        Self::load_via_json_merge(default_value, user_values)
 87    }
 88}
 89
 90impl Settings for MessageEditorSettings {
 91    const KEY: Option<&'static str> = Some("message_editor");
 92    type FileContent = MessageEditorSettings;
 93    fn load(
 94        default_value: &Self::FileContent,
 95        user_values: &[&Self::FileContent],
 96        _: &mut gpui::AppContext,
 97    ) -> anyhow::Result<Self> {
 98        Self::load_via_json_merge(default_value, user_values)
 99    }
100}