on master help sign in
ui: picker: Render matches/total counts
commitf20dc1283d2368aa9d052d46588a09599f901294 authorBlaž Hrastnik <blaz@mxxn.io> dateFri 13 Aug 2021, 17:56 (5 years ago) parentb635e35
1 file changed+12−2
helix-term/src/ui/picker.rs+12−2
helix-term/src/ui/picker.rs+12−2
@@ -393,6 +393,8 @@ impl<T: 'static> Component for Picker<T> {
393393 area
394394 };
395395
396+ let text_style = cx.editor.theme.get("ui.text");
397+
396398 // -- Render the frame:
397399 // clear area
398400 let background = cx.editor.theme.get("ui.background");
@@ -408,6 +410,15 @@ impl<T: 'static> Component for Picker<T> {
408410
409411 // -- Render the input bar:
410412
413+ let count = format!("{}/{}", self.matches.len(), self.options.len());
414+ surface.set_stringn(
415+ (area.x + area.width).saturating_sub(count.len() as u16 + 1),
416+ area.y,
417+ &count,
418+ (count.len()).min(area.width as usize),
419+ text_style,
420+ );
421+
411422 let area = Rect::new(inner.x + 1, inner.y, inner.width - 1, 1);
412423 self.prompt.render(area, surface, cx);
413424
@@ -425,7 +436,6 @@ impl<T: 'static> Component for Picker<T> {
425436 // subtract the area of the prompt (-2) and current item marker " > " (-3)
426437 let inner = Rect::new(inner.x + 3, inner.y + 2, inner.width - 3, inner.height - 2);
427438
428− let style = cx.editor.theme.get("ui.text");
429439 let selected = Style::default().fg(Color::Rgb(255, 255, 255));
430440
431441 let rows = inner.height;
@@ -448,7 +458,7 @@ impl<T: 'static> Component for Picker<T> {
448458 if i == (self.cursor - offset) {
449459 selected
450460 } else {
451− style
461+ text_style
452462 },
453463 true,
454464 );