feat: update keyboard handling to use new library
- remove dependency on atomicgo.dev/keyboard
- add dependency on github.com/eiannone/keyboard
- include keyhandling as non-blocking in frondend/main
- refactor keyhandler()
🤖
This commit is contained in:
parent
5f65b9aa56
commit
f1071f33c6
4 changed files with 33 additions and 87 deletions
|
@ -1,24 +1,31 @@
|
|||
package frontend
|
||||
|
||||
import (
|
||||
"github.com/gorilla/websocket"
|
||||
"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 *websocket.Conn, config ChronoTomato.Config, channel <-chan GoTomato.ServerMessage) {
|
||||
func UpdateLoop(conn *ws.Conn, config ChronoTomato.Config, channel <-chan GoTomato.ServerMessage) {
|
||||
var message GoTomato.ServerMessage
|
||||
|
||||
keyhandler_quit := make(chan bool, 1)
|
||||
go keyhandler(conn, config, &message, keyhandler_quit)
|
||||
keysEvents, _ := keyboard.GetKeys(1)
|
||||
defer keyboard.Close()
|
||||
|
||||
for {
|
||||
select {
|
||||
case message = <-channel:
|
||||
desktopNotifications(message)
|
||||
terminalOutput(message)
|
||||
case <-keyhandler_quit:
|
||||
case keypress := <-keysEvents:
|
||||
if !keyhandler(keypress, conn, config, message) {
|
||||
return
|
||||
}
|
||||
case <-websocket.Done:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue