package frontend import ( "atomicgo.dev/keyboard" "atomicgo.dev/keyboard/keys" "git.smsvc.net/pomodoro/ChronoTomato/internal/websocket" ChronoTomato "git.smsvc.net/pomodoro/ChronoTomato/pkg/models" GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models" ws "github.com/gorilla/websocket" ) func keyhandler(conn *ws.Conn, config ChronoTomato.Config, message *GoTomato.ServerMessage, quit chan bool) { keyboard.Listen(func(key keys.Key) (stop bool, err error) { select { case <-websocket.Done: quit <- true return true, nil default: switch key.String() { case "space": if !message.Ongoing { websocket.SendCmd(conn, config.Password, "start") return false, nil } if message.Paused { websocket.SendCmd(conn, config.Password, "resume") return false, nil } else { websocket.SendCmd(conn, config.Password, "pause") return false, nil } case "s": websocket.SendCmd(conn, config.Password, "stop") return false, nil case "r": if config.PomodoroConfig != (GoTomato.GoTomatoPomodoroConfig{}) { websocket.Send_updateSettings(conn, config.Password, config.PomodoroConfig) } return false, nil case "q": quit <- true return true, nil } } return false, nil }) }