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/mod.rs | |
| parent | 614805fc637a4cfeac4f8c62b8b04717a7daae96 (diff) | |
| download | pomoru-2a40c1bc7a1869f921c3428546f81f3f1cb26e07.tar.xz pomoru-2a40c1bc7a1869f921c3428546f81f3f1cb26e07.zip | |
add a dynamic help menu
Diffstat (limited to 'src/pomo/mod.rs')
| -rw-r--r-- | src/pomo/mod.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index a47d138..9c02653 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -9,7 +9,8 @@ use crossterm::{ }; use ratatui::prelude::*; use std::io; -use std::time::{Duration, Instant}; // Fixed: Added Instant here +use std::time::{Duration, Instant}; +use crossterm::event::KeyModifiers; impl Pomo { pub fn run(&mut self) -> io::Result<()> { @@ -33,10 +34,18 @@ impl Pomo { if let Event::Key(key) = event::read()? { match key.code { KeyCode::Char('q') => self.should_quit = true, - KeyCode::Char(' ') => self.toggle_timer(), - KeyCode::Char('j') | KeyCode::Down => self.next_task(), - KeyCode::Char('k') | KeyCode::Up => self.previous_task(), - KeyCode::Enter => self.toggle_task(), + KeyCode::Char('?') => self.show_help = !self.show_help, + KeyCode::Char('h') if key.modifiers.contains(KeyModifiers::CONTROL) => { + self.show_help = !self.show_help + }, + // Only allow other inputs if help isn't showing (to keep it clean) + _ if !self.show_help => match key.code { + KeyCode::Char(' ') => self.toggle_timer(), + KeyCode::Char('j') | KeyCode::Down => self.next_task(), + KeyCode::Char('k') | KeyCode::Up => self.previous_task(), + KeyCode::Enter => self.toggle_task(), + _ => {} + }, _ => {} } } |