summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2021-06-20 20:49:52 -0400
committerJeff Zhao <jeff.no.zhao@gmail.com>2021-06-20 20:49:52 -0400
commitda053083045a0e0fb6532554234c0679d286b1c5 (patch)
treee704b94db5dc02bc098b7da7af96acd29cff6974
parent68a6bf78cfe6d0a46f15f2e80e917ffb69b8c963 (diff)
fix menu not drawing correctly
-rw-r--r--src/ui/widgets/tui_menu.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/ui/widgets/tui_menu.rs b/src/ui/widgets/tui_menu.rs
index 2634662..0cee287 100644
--- a/src/ui/widgets/tui_menu.rs
+++ b/src/ui/widgets/tui_menu.rs
@@ -19,18 +19,18 @@ impl<'a> TuiMenu<'a> {
impl<'a> Widget for TuiMenu<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
- let text_iter = self.options.iter().chain(&[" "]);
let style = Style::default().fg(Color::Reset).bg(Color::Reset);
- let area_x = area.x + 1;
- let area_y = area.y + 1;
Block::default()
.style(style)
.borders(Borders::TOP)
.render(area, buf);
- for (i, text) in text_iter.enumerate() {
- buf.set_string(area_x, area_y + i as u16, text, style);
+ let text_iter = self.options.iter().chain(&[" "]);
+ let area_x = area.x + 1;
+
+ for (y, text) in (area.y + 1..area.y + area.height).zip(text_iter) {
+ buf.set_string(area_x, y, text, style);
}
}
}