Commit
Author: Kevin Schoon [kevinschoon@gmail.com]
Committer: GitHub [noreply@github.com] Wed, 01 Jun 2022 14:00:46 +0000
Hash: 309277a1154fb1660a276982a00363261474794b
Timestamp: Wed, 01 Jun 2022 14:00:46 +0000 (2 years ago)

+26 -11 +/-3 browse
Merge pull request #62 from sboysel/feature/ui-task-message
Merge pull request #62 from sboysel/feature/ui-task-message

Display current task message while running or paused
1diff --git a/pkg/internal/runner.go b/pkg/internal/runner.go
2index 46a802c..81b4c24 100644
3--- a/pkg/internal/runner.go
4+++ b/pkg/internal/runner.go
5 @@ -192,6 +192,8 @@ func (t *TaskRunner) Pause() {
6
7 func (t *TaskRunner) Status() *Status {
8 return &Status{
9+ TaskID: t.taskID,
10+ TaskMessage: t.taskMessage,
11 State: t.state,
12 Count: t.count,
13 NPomodoros: t.nPomodoros,
14 diff --git a/pkg/internal/types.go b/pkg/internal/types.go
15index 4485493..6fd19c5 100644
16--- a/pkg/internal/types.go
17+++ b/pkg/internal/types.go
18 @@ -105,6 +105,8 @@ func (p Pomodoro) Duration() time.Duration {
19 // Status is used to communicate the state
20 // of a running Pomodoro session
21 type Status struct {
22+ TaskID int `json:"task_id"`
23+ TaskMessage string `json:"task_message"`
24 State State `json:"state"`
25 Remaining time.Duration `json:"remaining"`
26 Pauseduration time.Duration `json:"pauseduration"`
27 diff --git a/pkg/internal/ui.go b/pkg/internal/ui.go
28index 787f749..27c7add 100644
29--- a/pkg/internal/ui.go
30+++ b/pkg/internal/ui.go
31 @@ -14,6 +14,8 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) {
32 par.Text = fmt.Sprintf(
33 `[%d/%d] Pomodoros completed
34
35+ Current Task: %s
36+
37 %s %s remaining
38
39
40 @@ -21,6 +23,7 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) {
41 `,
42 status.Count,
43 status.NPomodoros,
44+ status.TaskMessage,
45 wheel,
46 status.Remaining,
47 )
48 @@ -41,13 +44,17 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) {
49 status.Pauseduration,
50 )
51 case PAUSED:
52- par.Text = `Pomo is suspended.
53-
54- Press [p] to continue.
55-
56-
57- [q] - quit [p] - unpause
58- `
59+ par.Text = fmt.Sprintf(`Pomo is suspended.
60+
61+ Current Task: %s
62+
63+ Press [p] to continue.
64+
65+
66+ [q] - quit [p] - unpause
67+ `,
68+ status.TaskMessage,
69+ )
70 case COMPLETE:
71 par.Text = `This session has concluded.
72
73 @@ -82,16 +89,20 @@ func StartUI(runner *TaskRunner) {
74 resize := func() {
75 termWidth, termHeight := ui.TerminalDimensions()
76
77+ // for RUNNING and PAUSED states
78 x1 := (termWidth - 50) / 2
79 x2 := x1 + 50
80
81- y1 := (termHeight - 8) / 2
82- y2 := y1 + 8
83+ y1 := (termHeight - 10) / 2
84+ y2 := y1 + 10
85
86 switch runner.state {
87 case BREAKING:
88- y1 = (termHeight - 12) / 2
89- y2 = y1 + 12
90+ y1 = (termHeight - 11) / 2
91+ y2 = y1 + 11
92+ case COMPLETE:
93+ y1 = (termHeight - 8) / 2
94+ y2 = y1 + 8
95 }
96
97 par.SetRect(x1, y1, x2, y2)