From f20dc1283d2368aa9d052d46588a09599f901294 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 13 Aug 2021 17:56:37 +0900 Subject: ui: picker: Render matches/total counts --- helix-term/src/ui/picker.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 9c6b328f..c3567d27 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -393,6 +393,8 @@ impl Component for Picker { area }; + let text_style = cx.editor.theme.get("ui.text"); + // -- Render the frame: // clear area let background = cx.editor.theme.get("ui.background"); @@ -408,6 +410,15 @@ impl Component for Picker { // -- Render the input bar: + let count = format!("{}/{}", self.matches.len(), self.options.len()); + surface.set_stringn( + (area.x + area.width).saturating_sub(count.len() as u16 + 1), + area.y, + &count, + (count.len()).min(area.width as usize), + text_style, + ); + let area = Rect::new(inner.x + 1, inner.y, inner.width - 1, 1); self.prompt.render(area, surface, cx); @@ -425,7 +436,6 @@ impl Component for Picker { // subtract the area of the prompt (-2) and current item marker " > " (-3) let inner = Rect::new(inner.x + 3, inner.y + 2, inner.width - 3, inner.height - 2); - let style = cx.editor.theme.get("ui.text"); let selected = Style::default().fg(Color::Rgb(255, 255, 255)); let rows = inner.height; @@ -448,7 +458,7 @@ impl Component for Picker { if i == (self.cursor - offset) { selected } else { - style + text_style }, true, ); -- cgit v1.2.3-70-g09d2