mirror of https://github.com/helix-editor/helix
ui: picker: Render matches/total counts
parent
b635e35818
commit
f20dc1283d
|
@ -393,6 +393,8 @@ impl<T: 'static> Component for Picker<T> {
|
||||||
area
|
area
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let text_style = cx.editor.theme.get("ui.text");
|
||||||
|
|
||||||
// -- Render the frame:
|
// -- Render the frame:
|
||||||
// clear area
|
// clear area
|
||||||
let background = cx.editor.theme.get("ui.background");
|
let background = cx.editor.theme.get("ui.background");
|
||||||
|
@ -408,6 +410,15 @@ impl<T: 'static> Component for Picker<T> {
|
||||||
|
|
||||||
// -- Render the input bar:
|
// -- 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);
|
let area = Rect::new(inner.x + 1, inner.y, inner.width - 1, 1);
|
||||||
self.prompt.render(area, surface, cx);
|
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)
|
// 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 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 selected = Style::default().fg(Color::Rgb(255, 255, 255));
|
||||||
|
|
||||||
let rows = inner.height;
|
let rows = inner.height;
|
||||||
|
@ -448,7 +458,7 @@ impl<T: 'static> Component for Picker<T> {
|
||||||
if i == (self.cursor - offset) {
|
if i == (self.cursor - offset) {
|
||||||
selected
|
selected
|
||||||
} else {
|
} else {
|
||||||
style
|
text_style
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue