diff --git a/src/ui/formula_panel.rs b/src/ui/formula_panel.rs index eb66931..e7cb5c1 100644 --- a/src/ui/formula_panel.rs +++ b/src/ui/formula_panel.rs @@ -59,6 +59,14 @@ impl PanelContent for FormulaContent<'_> { buf.set_string(inner.x, inner.y + index as u16, &truncated, style); } + fn footer_height(&self) -> u16 { + if matches!(self.mode, AppMode::FormulaEdit { .. }) { + 1 + } else { + 0 + } + } + fn render_footer(&self, inner: Rect, buf: &mut Buffer) { if matches!(self.mode, AppMode::FormulaEdit { .. }) { let y = inner.y + inner.height.saturating_sub(1); diff --git a/src/ui/panel.rs b/src/ui/panel.rs index 29ee7e6..496d6c0 100644 --- a/src/ui/panel.rs +++ b/src/ui/panel.rs @@ -22,7 +22,11 @@ pub trait PanelContent { /// Render a single item at the given row index. /// `inner` is the full inner area of the panel; the item occupies row `index`. fn render_item(&self, index: usize, is_selected: bool, inner: Rect, buf: &mut Buffer); - /// Optional footer rendered below the items (e.g. inline hints). + /// Number of lines the footer occupies (used to reserve space). + fn footer_height(&self) -> u16 { + 0 + } + /// Optional footer rendered in the reserved space at the bottom. fn render_footer(&self, _inner: Rect, _buf: &mut Buffer) {} } @@ -69,8 +73,9 @@ impl Widget for Panel<'_, C> { return; } + let item_height = inner.height.saturating_sub(self.content.footer_height()); for i in 0..self.content.item_count() { - if i as u16 >= inner.height { + if i as u16 >= item_height { break; } let is_selected = i == self.cursor && is_active;