add spacer element to statusline (#3165)

* add spacer element to statusline

* docs
This commit is contained in:
Seth Bromberger 2022-07-26 03:07:59 +02:00 committed by GitHub
parent 742d16026e
commit bfdcfec8c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -78,6 +78,7 @@ ### `[editor.statusline]` Section
| `diagnostics` | The number of warnings and/or errors | | `diagnostics` | The number of warnings and/or errors |
| `selections` | The number of active selections | | `selections` | The number of active selections |
| `position` | The cursor position | | `position` | The cursor position |
| `spacer` | Inserts a space between elements (multiple/contiguous spacers may be specified) |
### `[editor.lsp]` Section ### `[editor.lsp]` Section

View File

@ -143,6 +143,7 @@ fn get_render_function<F>(element_id: StatusLineElementID) -> impl Fn(&mut Rende
helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics, helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics,
helix_view::editor::StatusLineElement::Selections => render_selections, helix_view::editor::StatusLineElement::Selections => render_selections,
helix_view::editor::StatusLineElement::Position => render_position, helix_view::editor::StatusLineElement::Position => render_position,
helix_view::editor::StatusLineElement::Spacer => render_spacer,
} }
} }
@ -334,3 +335,10 @@ fn render_file_name<F>(context: &mut RenderContext, write: F)
write(context, title, None); write(context, title, None);
} }
fn render_spacer<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
{
write(context, String::from(" "), None);
}

View File

@ -246,6 +246,9 @@ pub enum StatusLineElement {
/// The cursor position /// The cursor position
Position, Position,
/// A single space
Spacer,
} }
// Cursor shape is read and used on every rendered frame and so needs // Cursor shape is read and used on every rendered frame and so needs