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/5] 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 5179be4f..ff449fdf 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 aa9a1153..201c7934 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -479,6 +479,7 @@ pub struct StatusLineConfig { pub right: Vec<StatusLineElement>, 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/5] 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 624bdff2..211dbf21 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/5] 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 ff449fdf..3ca5fd2d 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/5] 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 201c7934..f9c087ef 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/5] 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 3ca5fd2d..989de61b 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(