Compare commits

...

2 Commits

Author SHA1 Message Date
Erasin Wang
7c405d7fb4
Merge 2ffb5eaf85 into b8313da5a8 2024-11-20 17:56:41 -06:00
Erasin
2ffb5eaf85 Add commandline = false
Hide commandline
2024-07-18 20:08:16 +08:00
4 changed files with 21 additions and 10 deletions

View File

@ -44,6 +44,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` | `[]` |

View File

@ -235,7 +235,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);
@ -1486,11 +1486,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);
@ -1514,6 +1516,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();
@ -1526,7 +1531,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,
);
@ -1551,7 +1556,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,
@ -1563,7 +1568,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,
);

View File

@ -138,6 +138,8 @@ pub fn raw_regex_prompt(
doc.set_selection(view.id, snapshot.clone());
doc.set_view_offset(view.id, 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);

View File

@ -321,6 +321,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`.
@ -971,6 +973,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 {
@ -1165,7 +1168,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,