ChronoTomato/internal/frontend/terminal.go

52 lines
1.1 KiB
Go
Raw Normal View History

package frontend
2024-10-22 11:13:41 +00:00
import (
"fmt"
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
"github.com/fatih/color"
"strings"
2024-10-22 11:13:41 +00:00
)
func terminalOutput(pomodoro GoTomato.ServerMessage) {
var (
modePrefix string
timerOutput string
)
2024-10-22 11:13:41 +00:00
fmt.Print("\033[H\033[2J") // Clears the screen
// header
2024-10-23 13:49:50 +00:00
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
)
//body
switch pomodoro.Mode {
2024-10-22 11:13:41 +00:00
case "Idle":
modePrefix = " "
2024-10-22 11:13:41 +00:00
timerOutput = ""
default:
modePrefix = " "
if pomodoro.Paused {
modePrefix = " "
}
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("Session: %d/%d\n",
pomodoro.Session,
pomodoro.PomodoroSettings.Sessions,
)
fmt.Printf("%s %s\n", modePrefix, pomodoro.Mode)
2024-10-22 11:13:41 +00:00
fmt.Printf(timerOutput)
//footer
fmt.Printf(strings.Repeat("\n", 3))
color.White("space: start/pause/resume • s: stop • r: reset pomodoro • q: quit")
2024-10-22 11:13:41 +00:00
}