ChronoTomato/internal/notifications/terminal.go

48 lines
952 B
Go
Raw Normal View History

2024-10-22 11:13:41 +00:00
package notifications
import (
"ChronoTomato/internal/shared"
2024-10-23 11:58:17 +00:00
"atomicgo.dev/cursor"
2024-10-22 11:13:41 +00:00
"fmt"
"github.com/fatih/color"
"strings"
2024-10-22 11:13:41 +00:00
)
func TerminalOutput() {
2024-10-22 11:13:41 +00:00
var timerOutput string
pomodoro := &shared.ServerMessage
2024-10-23 11:58:17 +00:00
cursor.Hide()
2024-10-22 11:13:41 +00:00
fmt.Print("\033[H\033[2J") // Clears the screen
color.Blue("Work: %d | Break: %d | Longbreak: %d\n\n",
pomodoro.PomodoroSettings.Work/60,
pomodoro.PomodoroSettings.ShortBreak/60,
pomodoro.PomodoroSettings.LongBreak/60,
2024-10-22 11:13:41 +00:00
)
fmt.Printf("Session: %d/%d\n",
pomodoro.Session,
pomodoro.PomodoroSettings.Sessions,
2024-10-22 11:13:41 +00:00
)
fmt.Printf("▶ %s\n",
pomodoro.Mode,
2024-10-22 11:13:41 +00:00
)
switch pomodoro.Mode {
2024-10-22 11:13:41 +00:00
case "Idle":
timerOutput = ""
default:
minutes := pomodoro.TimeLeft / 60
seconds := pomodoro.TimeLeft % 60
2024-10-22 11:13:41 +00:00
timerOutput = fmt.Sprintf("⏳ %02d:%02d", minutes, seconds)
}
fmt.Printf(timerOutput)
//footer
fmt.Printf(strings.Repeat("\n", 3))
2024-10-23 12:21:36 +00:00
color.White("space: start/pause/resume • r: stop • q: quit")
2024-10-22 11:13:41 +00:00
}