diff options
| author | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-01-19 01:23:29 +0530 |
|---|---|---|
| committer | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-01-19 01:23:29 +0530 |
| commit | 2e1032f34c3180720289d264869655206a3548a8 (patch) | |
| tree | 8a245e121695ef738f47efb8dd30d5ba078e7ec0 /src/pomo/state.rs | |
| parent | a77a5fccd060c608f3539bcb0eee6fd008e4d1f1 (diff) | |
| download | pomoru-2e1032f34c3180720289d264869655206a3548a8.tar.xz pomoru-2e1032f34c3180720289d264869655206a3548a8.zip | |
add timer editing and smart quitting using q
q now doesn't close the app, instead it closes the current screen opened and only closes the app when on main timer screen
Diffstat (limited to 'src/pomo/state.rs')
| -rw-r--r-- | src/pomo/state.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/pomo/state.rs b/src/pomo/state.rs index fe74473..305a300 100644 --- a/src/pomo/state.rs +++ b/src/pomo/state.rs @@ -8,7 +8,7 @@ pub enum SessionMode { Work, ShortBreak, LongBreak } pub enum AppScreen { Timer, Tasks } #[derive(PartialEq, Clone, Copy)] -pub enum InputMode { Normal, Insert, Edit } +pub enum InputMode { Normal, Insert, Edit, TimerEdit } pub struct Task { pub title: String, @@ -84,9 +84,12 @@ impl Pomo { } } - pub fn get_progress(&self) -> f64 { - if self.total_duration.as_secs() == 0 { return 0.0; } - let elapsed = self.total_duration.as_secs_f64() - self.time_remaining.as_secs_f64(); - (elapsed / self.total_duration.as_secs_f64()).clamp(0.0, 1.0) + pub fn reset_timer_to_mode(&mut self) { + self.time_remaining = match self.mode { + SessionMode::Work => self.work_time, + SessionMode::ShortBreak => self.short_break_time, + SessionMode::LongBreak => self.long_break_time, + }; + self.total_duration = self.time_remaining; } } |