summaryrefslogtreecommitdiff
path: root/helix-term/src/ui/menu.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-08 08:00:32 +0000
committerBlaž Hrastnik2021-03-08 08:00:32 +0000
commit5ea610c41d58c8e63178200db7b723d016318f67 (patch)
treec76d8b76d5cda802ca9a0fc36137e5ddbed281b5 /helix-term/src/ui/menu.rs
parent05aa0d6991820625189c7e367a6d033682ef4e4e (diff)
ui: Move terminal into compositor, redo required_size hints.
Diffstat (limited to 'helix-term/src/ui/menu.rs')
-rw-r--r--helix-term/src/ui/menu.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs
index 9f0e79be..c129420d 100644
--- a/helix-term/src/ui/menu.rs
+++ b/helix-term/src/ui/menu.rs
@@ -149,16 +149,21 @@ impl<T> Component for Menu<T> {
EventResult::Ignored
}
- fn size_hint(&self, area: Rect) -> Option<(usize, usize)> {
+ fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
+ let width = std::cmp::min(30, viewport.0);
+
const MAX: usize = 5;
let height = std::cmp::min(self.options.len(), MAX);
- Some((30, height))
+ let height = std::cmp::min(height, viewport.1 as usize);
+
+ Some((width as u16, height as u16))
}
fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
let style = Style::default().fg(Color::Rgb(164, 160, 232)); // lavender
let selected = Style::default().fg(Color::Rgb(255, 255, 255));
+ // TODO: instead of a cell, all these numbers should be precomputed in handle_event + init
let mut scroll = self.scroll.get();
let len = self.options.len();