2024-10-31 06:37:50 +00:00
|
|
|
package helper
|
2024-10-22 11:13:41 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-10-31 06:37:50 +00:00
|
|
|
|
|
|
|
"github.com/alecthomas/colour"
|
2024-10-27 20:34:53 +00:00
|
|
|
|
|
|
|
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
2024-10-22 11:13:41 +00:00
|
|
|
)
|
|
|
|
|
2024-10-31 06:37:50 +00:00
|
|
|
// Return terminal output based on the passed ServerMessage
|
|
|
|
func TerminalOutput(pomodoro GoTomato.ServerMessage) string {
|
2024-10-27 20:32:57 +00:00
|
|
|
var (
|
2024-10-31 06:37:50 +00:00
|
|
|
output string
|
|
|
|
|
2024-10-27 20:32:57 +00:00
|
|
|
modePrefix string
|
|
|
|
timerOutput string
|
|
|
|
)
|
2024-10-22 11:13:41 +00:00
|
|
|
|
2024-10-24 17:16:57 +00:00
|
|
|
// header
|
2024-10-31 06:37:50 +00:00
|
|
|
output += colour.Sprintf("^D^4Work: %d ◊ Break: %d ◊ Longbreak: %d^R\n\n",
|
2024-10-28 06:56:37 +00:00
|
|
|
pomodoro.Settings.Work/60,
|
|
|
|
pomodoro.Settings.ShortBreak/60,
|
|
|
|
pomodoro.Settings.LongBreak/60,
|
2024-10-22 11:13:41 +00:00
|
|
|
)
|
|
|
|
|
2024-10-24 17:16:57 +00:00
|
|
|
//body
|
2024-10-23 11:48:16 +00:00
|
|
|
switch pomodoro.Mode {
|
2024-10-22 11:13:41 +00:00
|
|
|
case "Idle":
|
2024-10-24 17:16:57 +00:00
|
|
|
modePrefix = " "
|
2024-10-22 11:13:41 +00:00
|
|
|
timerOutput = ""
|
|
|
|
default:
|
2024-10-24 17:16:57 +00:00
|
|
|
modePrefix = " "
|
|
|
|
if pomodoro.Paused {
|
|
|
|
modePrefix = " "
|
|
|
|
}
|
2024-10-23 11:48:16 +00:00
|
|
|
minutes := pomodoro.TimeLeft / 60
|
|
|
|
seconds := pomodoro.TimeLeft % 60
|
2024-10-22 11:13:41 +00:00
|
|
|
|
|
|
|
timerOutput = fmt.Sprintf("⏳ %02d:%02d", minutes, seconds)
|
|
|
|
}
|
|
|
|
|
2024-10-31 06:37:50 +00:00
|
|
|
output += fmt.Sprintf("Session: %d/%d\n",
|
2024-10-24 17:16:57 +00:00
|
|
|
pomodoro.Session,
|
2024-10-28 06:56:37 +00:00
|
|
|
pomodoro.Settings.Sessions,
|
2024-10-24 17:16:57 +00:00
|
|
|
)
|
2024-10-31 06:37:50 +00:00
|
|
|
output += fmt.Sprintf("%s %s\n", modePrefix, pomodoro.Mode)
|
|
|
|
output += fmt.Sprintf(timerOutput)
|
2024-10-23 11:51:19 +00:00
|
|
|
|
2024-10-31 06:37:50 +00:00
|
|
|
return output
|
2024-10-22 11:13:41 +00:00
|
|
|
}
|