From 8113c0a9331cde3fbc971812c3736f0cf0bbc6b1 Mon Sep 17 00:00:00 2001 From: Sam Boysel Date: Tue, 31 May 2022 23:00:34 -0700 Subject: [PATCH] display current task message while running or paused --- pkg/internal/runner.go | 2 ++ pkg/internal/types.go | 2 ++ pkg/internal/ui.go | 31 +++++++++++++++++++++---------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/pkg/internal/runner.go b/pkg/internal/runner.go index 46a802c..81b4c24 100644 --- a/pkg/internal/runner.go +++ b/pkg/internal/runner.go @@ -192,6 +192,8 @@ func (t *TaskRunner) Pause() { func (t *TaskRunner) Status() *Status { return &Status{ + TaskID: t.taskID, + TaskMessage: t.taskMessage, State: t.state, Count: t.count, NPomodoros: t.nPomodoros, diff --git a/pkg/internal/types.go b/pkg/internal/types.go index 4485493..6fd19c5 100644 --- a/pkg/internal/types.go +++ b/pkg/internal/types.go @@ -105,6 +105,8 @@ func (p Pomodoro) Duration() time.Duration { // Status is used to communicate the state // of a running Pomodoro session type Status struct { + TaskID int `json:"task_id"` + TaskMessage string `json:"task_message"` State State `json:"state"` Remaining time.Duration `json:"remaining"` Pauseduration time.Duration `json:"pauseduration"` diff --git a/pkg/internal/ui.go b/pkg/internal/ui.go index 787f749..27c7add 100644 --- a/pkg/internal/ui.go +++ b/pkg/internal/ui.go @@ -14,6 +14,8 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) { par.Text = fmt.Sprintf( `[%d/%d] Pomodoros completed + Current Task: %s + %s %s remaining @@ -21,6 +23,7 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) { `, status.Count, status.NPomodoros, + status.TaskMessage, wheel, status.Remaining, ) @@ -41,13 +44,17 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) { status.Pauseduration, ) case PAUSED: - par.Text = `Pomo is suspended. + par.Text = fmt.Sprintf(`Pomo is suspended. + + Current Task: %s - Press [p] to continue. - - - [q] - quit [p] - unpause - ` + Press [p] to continue. + + + [q] - quit [p] - unpause + `, + status.TaskMessage, + ) case COMPLETE: par.Text = `This session has concluded. @@ -82,16 +89,20 @@ func StartUI(runner *TaskRunner) { resize := func() { termWidth, termHeight := ui.TerminalDimensions() + // for RUNNING and PAUSED states x1 := (termWidth - 50) / 2 x2 := x1 + 50 - y1 := (termHeight - 8) / 2 - y2 := y1 + 8 + y1 := (termHeight - 10) / 2 + y2 := y1 + 10 switch runner.state { case BREAKING: - y1 = (termHeight - 12) / 2 - y2 = y1 + 12 + y1 = (termHeight - 11) / 2 + y2 = y1 + 11 + case COMPLETE: + y1 = (termHeight - 8) / 2 + y2 = y1 + 8 } par.SetRect(x1, y1, x2, y2)