aboutsummaryrefslogtreecommitdiff
path: root/src/pomo
diff options
context:
space:
mode:
Diffstat (limited to 'src/pomo')
-rw-r--r--src/pomo/state.rs51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/pomo/state.rs b/src/pomo/state.rs
index f4a7a5e..64ceca7 100644
--- a/src/pomo/state.rs
+++ b/src/pomo/state.rs
@@ -9,6 +9,12 @@ pub enum SessionMode {
LongBreak,
}
+pub enum InputMode {
+ Normal,
+ Insert,
+ Edit,
+}
+
impl SessionMode {
pub fn get_color(&self) -> Color {
match self {
@@ -26,10 +32,16 @@ pub struct Task {
pub struct Pomo {
pub mode: SessionMode,
+ pub work_time: Duration,
+ pub short_break_time: Duration,
+ pub long_break_time: Duration,
pub time_remaining: Duration,
pub is_running: bool,
+ pub break_count: u32,
pub tasks: Vec<Task>,
pub task_state: ListState,
+ pub input_mode: InputMode,
+ pub input_buffer: String,
pub should_quit: bool,
pub show_help: bool
}
@@ -48,31 +60,46 @@ impl Pomo {
Self {
mode: SessionMode::Work,
- time_remaining: Duration::from_secs(25 * 60),
+ work_time: work,
+ short_break_time: Duration::from_secs(5 * 60),
+ long_break_time: Duration::from_secs(15 * 60),
+ time_remaining: work,
is_running: false,
- tasks: dummy_tasks,
+ break_count: 0,
+ tasks: Vec::new(),
task_state: ListState::default(),
+ input_mode: InputMode::Normal,
+ input_buffer: String::new(),
should_quit: false,
- show_help: false
+ show_help: false,
}
}
pub fn tick(&mut self) {
if self.is_running && self.time_remaining.as_secs() > 0 {
- self.time_remaining -= std::time::Duration::from_secs(1);
+ self.time_remaining -= Duration::from_secs(1);
} else if self.is_running && self.time_remaining.as_secs() == 0 {
self.is_running = false;
- // Simple rotation: Work -> ShortBreak -> Work
- match self.mode {
- SessionMode::Work => {
+ self.transition_next_session();
+ }
+ }
+
+ fn transition_next_session(&mut self) {
+ match self.mode {
+ SessionMode::Work => {
+ self.break_count += 1;
+ if self.break_count % 4 == 0 {
+ self.mode = SessionMode::LongBreak;
+ self.time_remaining = self.long_break_time;
+ } else {
self.mode = SessionMode::ShortBreak;
- self.time_remaining = std::time::Duration::from_secs(5 * 60);
- }
- _ => {
- self.mode = SessionMode::Work;
- self.time_remaining = std::time::Duration::from_secs(25 * 60);
+ self.time_remaining = self.short_break_time;
}
}
+ _ => {
+ self.mode = SessionMode::Work;
+ self.time_remaining = self.work_time;
+ }
}
}