1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use settings::Settings;
4
5#[derive(Deserialize)]
6pub struct WorkspaceSettings {
7 pub active_pane_magnification: f32,
8 pub confirm_quit: bool,
9 pub show_call_status_icon: bool,
10 pub autosave: AutosaveSetting,
11}
12
13#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
14pub struct WorkspaceSettingsContent {
15 /// Scale by which to zoom the active pane.
16 /// When set to 1.0, the active pane has the same size as others,
17 /// but when set to a larger value, the active pane takes up more space.
18 ///
19 /// Default: `1.0`
20 pub active_pane_magnification: Option<f32>,
21 /// Whether or not to prompt the user to confirm before closing the application.
22 ///
23 /// Default: false
24 pub confirm_quit: Option<bool>,
25 /// Whether or not to show the call status icon in the status bar.
26 ///
27 /// Default: true
28 pub show_call_status_icon: Option<bool>,
29 /// When to automatically save edited buffers.
30 ///
31 /// Default: off
32 pub autosave: Option<AutosaveSetting>,
33}
34
35#[derive(Deserialize)]
36pub struct TabBarSettings {
37 pub show_nav_history_buttons: bool,
38}
39
40#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
41pub struct TabBarSettingsContent {
42 /// Whether or not to show the navigation history buttons in the tab bar.
43 ///
44 /// Default: true
45 pub show_nav_history_buttons: Option<bool>,
46}
47
48#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
49#[serde(rename_all = "snake_case")]
50pub enum AutosaveSetting {
51 /// Disable autosave.
52 Off,
53 /// Save after inactivity period of `milliseconds`.
54 AfterDelay { milliseconds: u64 },
55 /// Autosave when focus changes.
56 OnFocusChange,
57 /// Autosave when the active window changes.
58 OnWindowChange,
59}
60
61impl Settings for WorkspaceSettings {
62 const KEY: Option<&'static str> = None;
63
64 type FileContent = WorkspaceSettingsContent;
65
66 fn load(
67 default_value: &Self::FileContent,
68 user_values: &[&Self::FileContent],
69 _: &mut gpui::AppContext,
70 ) -> anyhow::Result<Self> {
71 Self::load_via_json_merge(default_value, user_values)
72 }
73}
74
75impl Settings for TabBarSettings {
76 const KEY: Option<&'static str> = Some("tab_bar");
77
78 type FileContent = TabBarSettingsContent;
79
80 fn load(
81 default_value: &Self::FileContent,
82 user_values: &[&Self::FileContent],
83 _: &mut gpui::AppContext,
84 ) -> anyhow::Result<Self> {
85 Self::load_via_json_merge(default_value, user_values)
86 }
87}