2024-10-27 09:41:31 +00:00
|
|
|
package frontend
|
2024-10-22 11:13:41 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-10-23 11:57:24 +00:00
|
|
|
"github.com/fatih/color"
|
2024-10-23 11:51:19 +00:00
|
|
|
"strings"
|
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-27 09:41:31 +00:00
|
|
|
func terminalOutput(pomodoro GoTomato.ServerMessage) {
|
2024-10-27 20:32:57 +00:00
|
|
|
var (
|
|
|
|
modePrefix string
|
|
|
|
timerOutput string
|
|
|
|
)
|
2024-10-22 11:13:41 +00:00
|
|
|
|
|
|
|
fmt.Print("\033[H\033[2J") // Clears the screen
|
|
|
|
|
2024-10-24 17:16:57 +00:00
|
|
|
// header
|
2024-10-23 13:49:50 +00:00
|
|
|
color.Blue("Work: %d ◊ Break: %d ◊ Longbreak: %d\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-24 17:16:57 +00:00
|
|
|
fmt.Printf("Session: %d/%d\n",
|
|
|
|
pomodoro.Session,
|
2024-10-28 06:56:37 +00:00
|
|
|
pomodoro.Settings.Sessions,
|
2024-10-24 17:16:57 +00:00
|
|
|
)
|
|
|
|
fmt.Printf("%s %s\n", modePrefix, pomodoro.Mode)
|
2024-10-22 11:13:41 +00:00
|
|
|
fmt.Printf(timerOutput)
|
2024-10-23 11:51:19 +00:00
|
|
|
|
|
|
|
//footer
|
|
|
|
fmt.Printf(strings.Repeat("\n", 3))
|
2024-10-23 15:42:33 +00:00
|
|
|
color.White("space: start/pause/resume • s: stop • r: reset pomodoro • q: quit")
|
2024-10-22 11:13:41 +00:00
|
|
|
}
|