display current task message while running or paused

This commit is contained in:
Sam Boysel 2022-05-31 23:00:34 -07:00
parent e6aa45152c
commit 8113c0a933
3 changed files with 25 additions and 10 deletions

View File

@ -192,6 +192,8 @@ func (t *TaskRunner) Pause() {
func (t *TaskRunner) Status() *Status { func (t *TaskRunner) Status() *Status {
return &Status{ return &Status{
TaskID: t.taskID,
TaskMessage: t.taskMessage,
State: t.state, State: t.state,
Count: t.count, Count: t.count,
NPomodoros: t.nPomodoros, NPomodoros: t.nPomodoros,

View File

@ -105,6 +105,8 @@ func (p Pomodoro) Duration() time.Duration {
// Status is used to communicate the state // Status is used to communicate the state
// of a running Pomodoro session // of a running Pomodoro session
type Status struct { type Status struct {
TaskID int `json:"task_id"`
TaskMessage string `json:"task_message"`
State State `json:"state"` State State `json:"state"`
Remaining time.Duration `json:"remaining"` Remaining time.Duration `json:"remaining"`
Pauseduration time.Duration `json:"pauseduration"` Pauseduration time.Duration `json:"pauseduration"`

View File

@ -14,6 +14,8 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) {
par.Text = fmt.Sprintf( par.Text = fmt.Sprintf(
`[%d/%d] Pomodoros completed `[%d/%d] Pomodoros completed
Current Task: %s
%s %s remaining %s %s remaining
@ -21,6 +23,7 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) {
`, `,
status.Count, status.Count,
status.NPomodoros, status.NPomodoros,
status.TaskMessage,
wheel, wheel,
status.Remaining, status.Remaining,
) )
@ -41,13 +44,17 @@ func setContent(wheel *Wheel, status *Status, par *widgets.Paragraph) {
status.Pauseduration, status.Pauseduration,
) )
case PAUSED: case PAUSED:
par.Text = `Pomo is suspended. par.Text = fmt.Sprintf(`Pomo is suspended.
Current Task: %s
Press [p] to continue. Press [p] to continue.
[q] - quit [p] - unpause [q] - quit [p] - unpause
` `,
status.TaskMessage,
)
case COMPLETE: case COMPLETE:
par.Text = `This session has concluded. par.Text = `This session has concluded.
@ -82,16 +89,20 @@ func StartUI(runner *TaskRunner) {
resize := func() { resize := func() {
termWidth, termHeight := ui.TerminalDimensions() termWidth, termHeight := ui.TerminalDimensions()
// for RUNNING and PAUSED states
x1 := (termWidth - 50) / 2 x1 := (termWidth - 50) / 2
x2 := x1 + 50 x2 := x1 + 50
y1 := (termHeight - 8) / 2 y1 := (termHeight - 10) / 2
y2 := y1 + 8 y2 := y1 + 10
switch runner.state { switch runner.state {
case BREAKING: case BREAKING:
y1 = (termHeight - 12) / 2 y1 = (termHeight - 11) / 2
y2 = y1 + 12 y2 = y1 + 11
case COMPLETE:
y1 = (termHeight - 8) / 2
y2 = y1 + 8
} }
par.SetRect(x1, y1, x2, y2) par.SetRect(x1, y1, x2, y2)