Merge remote-tracking branch 'nikitarevenco/merge-statusline-cmdline'

This commit is contained in:
Kalle Carlbark 2025-02-25 22:16:59 +01:00
commit 544c8a9a70
3 changed files with 21 additions and 5 deletions

View file

@ -113,6 +113,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:

View file

@ -238,7 +238,7 @@ impl EditorView {
let mut context =
statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners);
statusline::render(&mut context, statusline_area, surface);
statusline::render(&mut context, statusline_area, surface)
}
pub fn render_rulers(
@ -1563,8 +1563,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);
}
@ -1626,9 +1633,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,
@ -1640,7 +1653,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,
);

View file

@ -489,6 +489,7 @@ pub struct StatusLineConfig {
pub right: Vec<StatusLineElement>,
pub separator: String,
pub mode: ModeConfig,
pub merge_with_commandline: bool,
}
impl Default for StatusLineConfig {
@ -513,6 +514,7 @@ impl Default for StatusLineConfig {
],
separator: String::from(""),
mode: ModeConfig::default(),
merge_with_commandline: false,
}
}
}