From 90c51de8a1c1bbffe4b6b3b1c382becf2025601d Mon Sep 17 00:00:00 2001 From: hermes Date: Fri, 2 Oct 2026 21:13:11 +0000 Subject: [PATCH] palette: scale popup with terminal size, key hints --- crates/hx-tui/src/picker.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/hx-tui/src/picker.rs b/crates/hx-tui/src/picker.rs index cbf4912..7fbabf2 100644 --- a/crates/hx-tui/src/picker.rs +++ b/crates/hx-tui/src/picker.rs @@ -132,11 +132,15 @@ impl Picker { pub fn draw(&self, f: &mut ratatui::Frame) { let th = theme::t(); let a = f.area(); - let w = a.width.saturating_sub(4).min(80); + // scales with the terminal: 60% of the width, 50..=110 cols, never wider than the screen + let w = (a.width * 6 / 10).clamp(50, 110).min(a.width.saturating_sub(4)); let ms = self.matches(); // borders + query line + spacer - let h = (ms.len() as u16 + 4).min(a.height.saturating_sub(2)).max(5); - let r = Rect::new(a.x + (a.width - w) / 2, a.y + 1, w, h); + let h = (ms.len() as u16 + 4) + .min((a.height * 6 / 10).max(8)) + .min(a.height.saturating_sub(2)) + .max(5); + let r = Rect::new(a.x + (a.width - w) / 2, a.y + a.height / 8, w, h); let rows = (h - 4) as usize; let top = self.sel.saturating_sub(rows.saturating_sub(1)); let lw = ms @@ -165,7 +169,8 @@ impl Picker { Paragraph::new(lines).block( Block::bordered() .border_style(th.dim()) - .title(Span::styled(" ctrl-p ", th.dim())), + .title(Span::styled(" ctrl-p ", th.dim())) + .title_bottom(Span::styled(" ↑↓ select · ⏎ run · esc close ", th.dim())), ), r, );