From be1647b685b005ef5b66678e52bd21c51b45be01 Mon Sep 17 00:00:00 2001 From: wes adams Date: Wed, 9 Nov 2022 13:11:35 -0500 Subject: [PATCH] Statusline element that shows number of chars in primary selection Feature request: #4624 --- book/src/configuration.md | 1 + helix-term/src/ui/statusline.rs | 15 +++++++++++++++ helix-view/src/editor.rs | 3 +++ 3 files changed, 19 insertions(+) diff --git a/book/src/configuration.md b/book/src/configuration.md index 20abeba5a216..8713c3ffe85d 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -103,6 +103,7 @@ The following statusline elements can be configured: | `file-type` | The type of the opened file | | `diagnostics` | The number of warnings and/or errors | | `selections` | The number of active selections | +| `primary-selection-length` | The number of characters currently in primary selection | | `position` | The cursor position | | `position-percentage` | The cursor position as a percentage of the total number of lines | | `separator` | The string defined in `editor.statusline.separator` (defaults to `"│"`) | diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs index b0e8ec5d2546..47bb11290a3c 100644 --- a/helix-term/src/ui/statusline.rs +++ b/helix-term/src/ui/statusline.rs @@ -142,6 +142,9 @@ where helix_view::editor::StatusLineElement::FileType => render_file_type, helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics, helix_view::editor::StatusLineElement::Selections => render_selections, + helix_view::editor::StatusLineElement::PrimarySelectionLength => { + render_primary_selection_length + } helix_view::editor::StatusLineElement::Position => render_position, helix_view::editor::StatusLineElement::PositionPercentage => render_position_percentage, helix_view::editor::StatusLineElement::TotalLineNumbers => render_total_line_numbers, @@ -254,6 +257,18 @@ where ); } +fn render_primary_selection_length(context: &mut RenderContext, write: F) +where + F: Fn(&mut RenderContext, String, Option