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