diff --git a/book/src/editor.md b/book/src/editor.md index 82d5f8461..378f56db1 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -43,6 +43,7 @@ ### `[editor]` Section | `undercurl` | Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative | `false` | | `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` | | `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` | +| `commandline` | CommandLine Display. | `true` | | `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` | | `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set | `80` | | `workspace-lsp-roots` | Directories relative to the workspace root that are treated as LSP roots. Should only be set in `.helix/config.toml` | `[]` | diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index c151a7dd5..2ba381924 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -233,7 +233,7 @@ pub fn render_view( let statusline_area = view .area .clip_top(view.area.height.saturating_sub(1)) - .clip_bottom(1); // -1 from bottom to remove commandline + .clip_bottom(config.commandline as u16); // -1 from bottom to remove commandline let mut context = statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners); @@ -1481,11 +1481,13 @@ fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { _ => false, }; - // -1 for commandline and -1 for bufferline - let mut editor_area = area.clip_bottom(1); - if use_bufferline { - editor_area = editor_area.clip_top(1); + let editor_area = if use_bufferline { + // -1 for bufferline + area.clip_top(1) + } else { + area } + .clip_bottom(config.commandline as u16); // -1 for commandline // if the terminal size suddenly changed, we need to trigger a resize cx.editor.resize(editor_area); @@ -1509,6 +1511,9 @@ fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { let key_width = 15u16; // for showing pending keys let mut status_msg_width = 0; + // commandline + let commandline_msg_pos = if config.commandline { 1 } else { 2 }; + // render status msg if let Some((status_msg, severity)) = &cx.editor.status_msg { status_msg_width = status_msg.width(); @@ -1521,7 +1526,7 @@ fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { surface.set_string( area.x, - area.y + area.height.saturating_sub(1), + area.y + area.height.saturating_sub(commandline_msg_pos), status_msg, style, ); @@ -1546,7 +1551,7 @@ fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { }; 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(commandline_msg_pos), disp.get(disp.len().saturating_sub(key_width as usize)..) .unwrap_or(&disp), style, @@ -1558,7 +1563,7 @@ fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { .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(commandline_msg_pos), &disp, style, ); diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 10f4104ab..4cc08223f 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -138,6 +138,8 @@ pub fn raw_regex_prompt( doc.set_selection(view.id, snapshot.clone()); view.offset = offset_snapshot; + let commandline = config.commandline as usize; + if event == PromptEvent::Validate { let callback = async move { let call: job::Callback = Callback::EditorCompositor(Box::new( @@ -146,7 +148,7 @@ pub fn raw_regex_prompt( let size = compositor.size(); let popup = Popup::new("invalid-regex", contents) .position(Some(helix_core::Position::new( - size.height as usize - 2, // 2 = statusline + commandline + size.height as usize - 1 - commandline, // = statusline + commandline 0, ))) .auto_close(true); diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index cead30d7c..a95cae4a2 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -320,6 +320,8 @@ pub struct Config { pub whitespace: WhitespaceConfig, /// Persistently display open buffers along the top pub bufferline: BufferLine, + /// Commandline display, Default true. + pub commandline: bool, /// Vertical indent width guides. pub indent_guides: IndentGuidesConfig, /// Whether to color modes with different colors. Defaults to `false`. @@ -964,6 +966,7 @@ fn default() -> Self { rulers: Vec::new(), whitespace: WhitespaceConfig::default(), bufferline: BufferLine::default(), + commandline: true, indent_guides: IndentGuidesConfig::default(), color_modes: false, soft_wrap: SoftWrap { @@ -1157,7 +1160,7 @@ pub fn new( let auto_pairs = (&conf.auto_pairs).into(); // HAXX: offset the render area height by 1 to account for prompt/commandline - area.height -= 1; + area.height -= conf.commandline as u16; Self { mode: Mode::Normal,