From 13d2cd1293744b5b11a3942a34da9ef2884148a2 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:51:13 +0000 Subject: [PATCH 1/6] feat: option to Merge statusline and Command line into 1 line --- helix-term/src/ui/editor.rs | 26 +++++++++++++++++++++++--- helix-view/src/editor.rs | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 5179be4f4..ff449fdf1 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -241,7 +241,20 @@ impl EditorView { let mut context = statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners); - statusline::render(&mut context, statusline_area, surface); + let is_bottom_statusline = viewport.height - statusline_area.y == 1; + let has_editor_status = editor.status_msg.is_some(); + + // We always render the statusline, unless it meets all of these conditions: + // - It's at the bottom of the screen + // - There is a status message + // - We want to merge the statusline with the commandline + // + // In this case, the status message is overlaid on top of the statusline, and we do not render the statusline. + if is_bottom_statusline && has_editor_status && config.statusline.merge_with_commandline { + // do not render the statusline + } else { + statusline::render(&mut context, statusline_area, surface) + } } pub fn render_rulers( @@ -1487,8 +1500,15 @@ impl Component for EditorView { _ => false, }; - // -1 for commandline and -1 for bufferline - let mut editor_area = area.clip_bottom(1); + // If merge_with_commandline option is set, then status message renders on top of the statusline, in which case we will not show the statusline + // Otherwise, status message renders in a separate line, so we give it 1 line of vertical space + let mut editor_area = area.clip_bottom(if config.statusline.merge_with_commandline { + 0 + } else { + 1 + }); + + // Editor area decreases by 1, to give 1 line of vertical space for bufferline if use_bufferline { editor_area = editor_area.clip_top(1); } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index aa9a11533..201c79345 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -479,6 +479,7 @@ pub struct StatusLineConfig { pub right: Vec, pub separator: String, pub mode: ModeConfig, + pub merge_with_commandline: bool, } impl Default for StatusLineConfig { @@ -503,6 +504,7 @@ impl Default for StatusLineConfig { ], separator: String::from("│"), mode: ModeConfig::default(), + merge_with_commandline: true, } } } From f44be744358f1e343e89c9b11f69c419857f0bf8 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:14:25 +0000 Subject: [PATCH 2/6] feat: `merge-with-commandline` config option --- book/src/editor.md | 1 + 1 file changed, 1 insertion(+) diff --git a/book/src/editor.md b/book/src/editor.md index 624bdff23..211dbf21b 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -110,6 +110,7 @@ The `[editor.statusline]` key takes the following sub-keys: | `mode.normal` | The text shown in the `mode` element for normal mode | `"NOR"` | | `mode.insert` | The text shown in the `mode` element for insert mode | `"INS"` | | `mode.select` | The text shown in the `mode` element for select mode | `"SEL"` | +| `merge-with-commandline` | If set, the command line and statusline will merge into a single line. Status text will replace the statusline briefly | `false` | The following statusline elements can be configured: From 355402e2100a5e537c1bc3baedeb974621a38711 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Thu, 6 Feb 2025 16:57:49 +0000 Subject: [PATCH 3/6] fix: number indicators rendering on top of statusline --- helix-term/src/ui/editor.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index ff449fdf1..3ca5fd2d0 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1570,9 +1570,15 @@ impl Component for EditorView { } else { 0 }; + let y_offset = if config.statusline.merge_with_commandline { + // render macros and key sequences 1 line above + 1 + } else { + 0 + }; surface.set_string( area.x + area.width.saturating_sub(key_width + macro_width), - area.y + area.height.saturating_sub(1), + (area.y + area.height.saturating_sub(1)).saturating_sub(y_offset), disp.get(disp.len().saturating_sub(key_width as usize)..) .unwrap_or(&disp), style, @@ -1584,7 +1590,7 @@ impl Component for EditorView { .add_modifier(Modifier::BOLD); surface.set_string( area.x + area.width.saturating_sub(3), - area.y + area.height.saturating_sub(1), + (area.y + area.height.saturating_sub(1)).saturating_sub(y_offset), &disp, style, ); From df96f0c122d8d0c12bf850cf6d47bd5e4e85b1ab Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Thu, 6 Feb 2025 17:04:18 +0000 Subject: [PATCH 4/6] feat: merge-with-commandline `false` by default --- helix-view/src/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 201c79345..f9c087efb 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -504,7 +504,7 @@ impl Default for StatusLineConfig { ], separator: String::from("│"), mode: ModeConfig::default(), - merge_with_commandline: true, + merge_with_commandline: false, } } } From da577cf1acc5e968b933a278a0f02fc212a92eb9 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Fri, 7 Feb 2025 21:04:56 +0000 Subject: [PATCH 5/6] feat: always render the statusline --- helix-term/src/ui/editor.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 3ca5fd2d0..989de61b7 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -241,20 +241,7 @@ impl EditorView { let mut context = statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners); - let is_bottom_statusline = viewport.height - statusline_area.y == 1; - let has_editor_status = editor.status_msg.is_some(); - - // We always render the statusline, unless it meets all of these conditions: - // - It's at the bottom of the screen - // - There is a status message - // - We want to merge the statusline with the commandline - // - // In this case, the status message is overlaid on top of the statusline, and we do not render the statusline. - if is_bottom_statusline && has_editor_status && config.statusline.merge_with_commandline { - // do not render the statusline - } else { - statusline::render(&mut context, statusline_area, surface) - } + statusline::render(&mut context, statusline_area, surface) } pub fn render_rulers( From f506116b38e27f92990e52c716c33322d850e99a Mon Sep 17 00:00:00 2001 From: Nik Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Mon, 7 Apr 2025 22:04:28 +0100 Subject: [PATCH 6/6] fix: background color The statusline and the command mode prompt will now both have the same background when the editor.statusline.merge-with-commandline option is set --- helix-term/src/commands/typed.rs | 5 +++++ helix-term/src/ui/prompt.rs | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 49864abb6..b8219bc14 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -3253,6 +3253,11 @@ pub(super) fn command_mode(cx: &mut Context) { None }); + if cx.editor.config().statusline.merge_with_commandline { + // command line prompt has the same background as the statusline when + // the statusline and the command line are merged + prompt.background = Some(cx.editor.theme.get("ui.statusline")) + } // Calculate initial completion prompt.recalculate_completion(cx.editor); diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 1e443ce7f..d7e83d5ef 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -28,6 +28,7 @@ pub struct Prompt { prompt: Cow<'static, str>, line: String, cursor: usize, + pub background: Option, completion: Vec, selection: Option, history_register: Option, @@ -84,6 +85,7 @@ impl Prompt { selection: None, history_register, history_pos: None, + background: None, completion_fn: Box::new(completion_fn), callback_fn: Box::new(callback_fn), doc_fn: Box::new(|_| None), @@ -401,7 +403,9 @@ impl Prompt { let completion_color = theme.get("ui.menu"); let selected_color = theme.get("ui.menu.selected"); let suggestion_color = theme.get("ui.text.inactive"); - let background = theme.get("ui.background"); + let background = self + .background + .unwrap_or_else(|| theme.get("ui.background")); // completion let max_len = self