ChronoTomato/internal/notifications/terminal.go
Sebastian Mark 98013780da feat: refactor to use local pointer for ServerMessage
- replace `shared.ServerMessage` with local pomodoro pointer
- update conditions to use `pomodoro` instead of `shared.ServerMessage`

🤖
2024-10-23 17:45:18 +02:00

44 lines
892 B
Go

package notifications
import (
"ChronoTomato/internal/shared"
"fmt"
"strings"
)
func TerminalOutput() {
var timerOutput string
pomodoro := &shared.ServerMessage
fmt.Print("\033[H\033[2J") // Clears the screen
fmt.Printf("Work: %d | Break: %d | Longbreak: %d\n",
pomodoro.PomodoroSettings.Work/60,
pomodoro.PomodoroSettings.ShortBreak/60,
pomodoro.PomodoroSettings.LongBreak/60,
)
fmt.Printf("Session: %d/%d\n",
pomodoro.Session,
pomodoro.PomodoroSettings.Sessions,
)
fmt.Printf("▶ %s\n",
pomodoro.Mode,
)
switch pomodoro.Mode {
case "Idle":
timerOutput = ""
default:
minutes := pomodoro.TimeLeft / 60
seconds := pomodoro.TimeLeft % 60
timerOutput = fmt.Sprintf("⏳ %02d:%02d", minutes, seconds)
}
fmt.Printf(timerOutput)
//footer
fmt.Printf(strings.Repeat("\n", 3))
fmt.Printf("s: start • space: pause/resume • r: stop • q: quit")
}