2024-10-31 06:37:50 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2024-11-06 08:03:25 +00:00
|
|
|
"github.com/alecthomas/colour"
|
|
|
|
|
2024-10-31 06:37:50 +00:00
|
|
|
"git.smsvc.net/pomodoro/ChronoTomato/cmd/client/helper"
|
|
|
|
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (a app) View() string {
|
|
|
|
var body string
|
2024-11-06 08:03:25 +00:00
|
|
|
var serverStatus string
|
2024-10-31 06:37:50 +00:00
|
|
|
|
2024-11-06 08:03:25 +00:00
|
|
|
body = "Waiting for server message..."
|
2024-10-31 06:37:50 +00:00
|
|
|
if a.pomodoro != (GoTomato.ServerMessage{}) {
|
|
|
|
body = helper.TerminalOutput(a.pomodoro)
|
|
|
|
helper.DesktopNotifications(a.pomodoro)
|
2024-11-06 08:03:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
serverStatus = colour.Sprintf("^D^1disconnected: %v^R\n", client.LastErr)
|
|
|
|
if client.Connected() {
|
|
|
|
serverStatus = colour.Sprintf("^D^2connected to %s^R\n", client.Server)
|
2024-10-31 06:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
helpView := a.help.View(a.keys)
|
2024-11-06 08:03:25 +00:00
|
|
|
height := 8 - strings.Count(body, "\n") - strings.Count(serverStatus, "\n") - strings.Count(helpView, "\n")
|
2024-10-31 06:37:50 +00:00
|
|
|
|
2024-11-06 08:03:25 +00:00
|
|
|
return body + strings.Repeat("\n", height) + serverStatus + helpView
|
2024-10-31 06:37:50 +00:00
|
|
|
}
|