aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorwes adams2022-11-12 17:31:09 +0000
committerGitHub2022-11-12 17:31:09 +0000
commitfd585c1ee4ae0ac541f99b5e69a40833f5e3246d (patch)
treefdc6975abf46a54ad257571a5bb6bb29de4d834b /helix-term/src
parent1f72d342493206b83ed82efd402aca712eaffbf8 (diff)
Statusline indicator to show number of selected chars (#4682)
Co-authored-by: wes adams <wadams@grayshift.com>
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/ui/statusline.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs
index b0e8ec5d..47bb1129 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<F>(context: &mut RenderContext, write: F)
+where
+ F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
+{
+ let tot_sel = context.doc.selection(context.view.id).primary().len();
+ write(
+ context,
+ format!(" {} char{} ", tot_sel, if tot_sel == 1 { "" } else { "s" }),
+ None,
+ );
+}
+
fn get_position(context: &RenderContext) -> Position {
coords_at_pos(
context.doc.text().slice(..),