diff --git a/book/src/configuration.md b/book/src/configuration.md index c7334af4f..5372b9f03 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -78,6 +78,7 @@ ### `[editor.statusline]` Section | `diagnostics` | The number of warnings and/or errors | | `selections` | The number of active selections | | `position` | The cursor position | +| `position-percentage` | The cursor position as a percentage of the total number of lines | | `spacer` | Inserts a space between elements (multiple/contiguous spacers may be specified) | ### `[editor.lsp]` Section diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index e9e478bff..df6d48000 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -1,4 +1,4 @@ -use helix_core::{coords_at_pos, encoding}; +use helix_core::{coords_at_pos, encoding, Position}; use helix_view::{ document::{Mode, SCRATCH_BUFFER_NAME}, graphics::Rect, @@ -143,6 +143,7 @@ fn get_render_function(element_id: StatusLineElementID) -> impl Fn(&mut Rende helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics, helix_view::editor::StatusLineElement::Selections => render_selections, helix_view::editor::StatusLineElement::Position => render_position, + helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage, helix_view::editor::StatusLineElement::Spacer => render_spacer, } } @@ -251,19 +252,22 @@ fn render_selections(context: &mut RenderContext, write: F) ); } -fn render_position(context: &mut RenderContext, write: F) -where - F: Fn(&mut RenderContext, String, Option