Merge pull request #62 from sboysel/feature/ui-task-message
Display current task message while running or paused
This commit is contained in:
commit
309277a115
|
@ -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,
|
||||||
|
|
|
@ -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"`
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
Press [p] to continue.
|
Current Task: %s
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue