diff --git a/assets/settings/default.json b/assets/settings/default.json index 5d195f4bcd275796d942aac69f5a3cde40f9709d..83019f09a917d8f73272ba4f7c2b84517b10abe5 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1401,8 +1401,8 @@ // 4. A box drawn around the following character // "hollow" // - // Default: not set, defaults to "block" - "cursor_shape": null, + // Default: "block" + "cursor_shape": "block", // Set whether Alternate Scroll mode (code: ?1007) is active by default. // Alternate Scroll mode converts mouse scroll events into up / down key // presses when in the alternate screen (e.g. when running applications diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rs index dba842bf94b9e372fe08e17273e158270145e294..8079c4c82c1cf9e50feae04374ba47de3237a098 100644 --- a/crates/project/src/terminals.rs +++ b/crates/project/src/terminals.rs @@ -235,7 +235,7 @@ impl Project { task_state, shell, env, - settings.cursor_shape.unwrap_or_default(), + settings.cursor_shape, settings.alternate_scroll, settings.max_scroll_history_lines, is_via_remote, @@ -365,7 +365,7 @@ impl Project { None, shell, env, - settings.cursor_shape.unwrap_or_default(), + settings.cursor_shape, settings.alternate_scroll, settings.max_scroll_history_lines, is_via_remote, diff --git a/crates/settings/src/settings_content/terminal.rs b/crates/settings/src/settings_content/terminal.rs index 9a848d767cbcb023f0035b522cd4101e4cb624c3..6fbae5f43d125f85c2bc412aeee7c7aa7ee0041e 100644 --- a/crates/settings/src/settings_content/terminal.rs +++ b/crates/settings/src/settings_content/terminal.rs @@ -53,7 +53,7 @@ pub struct TerminalSettingsContent { /// Default cursor shape for the terminal. /// Can be "bar", "block", "underline", or "hollow". /// - /// Default: None + /// Default: "block" pub cursor_shape: Option, /// Sets the cursor blinking behavior in the terminal. /// @@ -226,7 +226,18 @@ pub enum ShowScrollbar { } #[derive( - Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom, + Clone, + Copy, + Debug, + Default, + Serialize, + Deserialize, + PartialEq, + Eq, + JsonSchema, + MergeFrom, + strum::VariantArray, + strum::VariantNames, )] #[serde(rename_all = "snake_case")] // todo() -> combine with CursorShape diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 5ad88833cf118db1808819b37f25e57af94c7122..0cc86825b707ed81a065f8df06bb6640251e2a22 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -2831,6 +2831,26 @@ pub(crate) fn user_settings_data() -> Vec { }), metadata: None, }), + SettingsPageItem::SettingItem(SettingItem { + title: "Cursor Shape", + description: "Default cursor shape for the terminal", + field: Box::new(SettingField { + pick: |settings_content| { + if let Some(terminal) = &settings_content.terminal { + &terminal.cursor_shape + } else { + &None + } + }, + pick_mut: |settings_content| { + &mut settings_content + .terminal + .get_or_insert_default() + .cursor_shape + }, + }), + metadata: None, + }), SettingsPageItem::SettingItem(SettingItem { title: "Alternate Scroll", description: "Sets whether Alternate Scroll mode is active by default", diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index e363a36518bd8e6bb8db4c155a7cc79ec693f49c..55588ca4ad000585851a179a47ad1d080182e429 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -427,6 +427,9 @@ fn init_renderers(cx: &mut App) { }) .add_renderer::(|settings_field, file, _, window, cx| { render_dropdown(*settings_field, file, window, cx) + }) + .add_renderer::(|settings_field, file, _, window, cx| { + render_dropdown(*settings_field, file, window, cx) }); // todo(settings_ui): Figure out how we want to handle discriminant unions diff --git a/crates/terminal/src/terminal_settings.rs b/crates/terminal/src/terminal_settings.rs index 91a65f386fdb21556ea7fac8c2c3d26187f162c8..8c72b87e589eabd190fceaa063d8a3fac4faee8b 100644 --- a/crates/terminal/src/terminal_settings.rs +++ b/crates/terminal/src/terminal_settings.rs @@ -30,7 +30,7 @@ pub struct TerminalSettings { pub font_weight: Option, pub line_height: TerminalLineHeight, pub env: HashMap, - pub cursor_shape: Option, + pub cursor_shape: CursorShape, pub blinking: TerminalBlink, pub alternate_scroll: AlternateScroll, pub option_as_meta: bool, @@ -91,7 +91,7 @@ impl settings::Settings for TerminalSettings { font_weight: content.font_weight.map(FontWeight), line_height: content.line_height.unwrap(), env: content.env.unwrap(), - cursor_shape: content.cursor_shape.map(Into::into), + cursor_shape: content.cursor_shape.map(Into::into).unwrap_or_default(), blinking: content.blinking.unwrap(), alternate_scroll: content.alternate_scroll.unwrap(), option_as_meta: content.option_as_meta.unwrap(), diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index cbb3ad92c58ae980698f135b7fa10bb9f68a4dd1..0f4f745b877bd6871fadd78c2c6136a268e51ded 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -234,9 +234,7 @@ impl TerminalView { terminal_view.focus_out(window, cx); }, ); - let cursor_shape = TerminalSettings::get_global(cx) - .cursor_shape - .unwrap_or_default(); + let cursor_shape = TerminalSettings::get_global(cx).cursor_shape; let scroll_handle = TerminalScrollHandle::new(terminal.read(cx)); @@ -427,7 +425,7 @@ impl TerminalView { let breadcrumb_visibility_changed = self.show_breadcrumbs != settings.toolbar.breadcrumbs; self.show_breadcrumbs = settings.toolbar.breadcrumbs; - let new_cursor_shape = settings.cursor_shape.unwrap_or_default(); + let new_cursor_shape = settings.cursor_shape; let old_cursor_shape = self.cursor_shape; if old_cursor_shape != new_cursor_shape { self.cursor_shape = new_cursor_shape;