diff options
| author | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-01-18 22:03:38 +0530 |
|---|---|---|
| committer | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-01-18 22:03:38 +0530 |
| commit | 2a40c1bc7a1869f921c3428546f81f3f1cb26e07 (patch) | |
| tree | dda8359dd96770f39d5dceb6039dc61aaaeafb72 /src/pomo/ui.rs | |
| parent | 614805fc637a4cfeac4f8c62b8b04717a7daae96 (diff) | |
| download | pomoru-2a40c1bc7a1869f921c3428546f81f3f1cb26e07.tar.xz pomoru-2a40c1bc7a1869f921c3428546f81f3f1cb26e07.zip | |
add a dynamic help menu
Diffstat (limited to 'src/pomo/ui.rs')
| -rw-r--r-- | src/pomo/ui.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pomo/ui.rs b/src/pomo/ui.rs index e1f1f5d..1a7fb49 100644 --- a/src/pomo/ui.rs +++ b/src/pomo/ui.rs @@ -51,6 +51,33 @@ pub fn render(f: &mut Frame, app: &mut Pomo) { .highlight_symbol(" "); f.render_stateful_widget(list, chunks[1], &mut app.task_state); + + if app.show_help { + let help_area = centered_rect(30, 30, f.area()); // Smaller popup + + // Clear the area underneath so the main UI doesn't interfere + f.render_widget(Clear, help_area); + + let help_block = Block::default() + .title(" Help / Controls ") + .borders(Borders::ALL) + .border_type(BorderType::Rounded) + .border_style(Style::default().fg(accent_color)); + + let commands = app.get_commands(); + let help_text: Vec<ListItem> = commands + .iter() + .map(|c| { + ListItem::new(Line::from(vec![ + Span::styled(format!("{:<7}", c.key), Style::default().fg(accent_color).add_modifier(Modifier::BOLD)), + Span::raw(c.desc), + ])) + }) + .collect(); + + let help_list = List::new(help_text).block(help_block); + f.render_widget(help_list, help_area); + } } fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect { |