diff options
author | Blaž Hrastnik | 2021-08-13 08:56:37 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-08-13 08:56:37 +0000 |
commit | f20dc1283d2368aa9d052d46588a09599f901294 (patch) | |
tree | 5bff54b5c469b96baafa20c17eab8df0d0840e1b | |
parent | b635e35818b96ff357ceeeac68451836da69aec4 (diff) |
ui: picker: Render matches/total counts
-rw-r--r-- | helix-term/src/ui/picker.rs | 14 |
1 files changed, 12 insertions, 2 deletions
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<T: 'static> Component for Picker<T> { 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<T: 'static> Component for Picker<T> { // -- 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<T: 'static> Component for Picker<T> { // 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<T: 'static> Component for Picker<T> { if i == (self.cursor - offset) { selected } else { - style + text_style }, true, ); |