Sebastian Mark
f1071f33c6
- remove dependency on atomicgo.dev/keyboard
- add dependency on github.com/eiannone/keyboard
- include keyhandling as non-blocking in frondend/main
- refactor keyhandler()
🤖
32 lines
727 B
Go
32 lines
727 B
Go
package frontend
|
|
|
|
import (
|
|
"github.com/eiannone/keyboard"
|
|
ws "github.com/gorilla/websocket"
|
|
|
|
"git.smsvc.net/pomodoro/ChronoTomato/internal/websocket"
|
|
|
|
ChronoTomato "git.smsvc.net/pomodoro/ChronoTomato/pkg/models"
|
|
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
|
)
|
|
|
|
func UpdateLoop(conn *ws.Conn, config ChronoTomato.Config, channel <-chan GoTomato.ServerMessage) {
|
|
var message GoTomato.ServerMessage
|
|
|
|
keysEvents, _ := keyboard.GetKeys(1)
|
|
defer keyboard.Close()
|
|
|
|
for {
|
|
select {
|
|
case message = <-channel:
|
|
desktopNotifications(message)
|
|
terminalOutput(message)
|
|
case keypress := <-keysEvents:
|
|
if !keyhandler(keypress, conn, config, message) {
|
|
return
|
|
}
|
|
case <-websocket.Done:
|
|
return
|
|
}
|
|
}
|
|
}
|