aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/listener.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/listener.rs')
-rw-r--r--src/client/listener.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/client/listener.rs b/src/client/listener.rs
index 0b403b2..e70c2b3 100644
--- a/src/client/listener.rs
+++ b/src/client/listener.rs
@@ -69,8 +69,8 @@ pub fn start_listener() {
}
}
-// TODO: show remaining time, not time elapsed
-fn format_time(secs: u16) -> String {
+fn format_time(elapsed_secs: u16, total_secs: u16) -> String {
+ let secs = total_secs - elapsed_secs;
format!("{:02}:{:02}", secs / 60, secs % 60)
}
@@ -93,8 +93,13 @@ fn pretty_print(f: &Format, p: Pomo) {
State::LongBreakIdle => &f.format_long_break_idle,
};
+ let total_secs: u16 = match p.current_state {
+ State::WorkIdle | State::Work | State::WorkPaused => p.work_duration,
+ State::BreakIdle | State::Break | State::BreakPaused => p.break_duration,
+ State::LongBreakIdle | State::LongBreak | State::LongBreakPaused => p.long_break_duration,
+ };
println!("{}", format
- .replace("{time}", format_time(p.secs_elapsed).as_str())
+ .replace("{time}", format_time(p.secs_elapsed, total_secs).as_str())
.replace("{counter}", format!("{}", p.counter).as_str()));
}