x-backend #2

Merged
sashakoshka merged 34 commits from x-backend into main 2022-11-14 21:40:25 -07:00
4 changed files with 15 additions and 11 deletions
Showing only changes of commit 1d71df180d - Show all commits

View File

@ -42,7 +42,9 @@ func (backend *Backend) handleButtonPress (
event xevent.ButtonPressEvent,
) {
buttonEvent := *event.ButtonPressEvent
backend.channel <- stone.EventPress(buttonEvent.Detail)
backend.channel <- stone.EventPress {
Button: stone.Button(buttonEvent.Detail),
}
}
func (backend *Backend) handleButtonRelease (
@ -50,7 +52,9 @@ func (backend *Backend) handleButtonRelease (
event xevent.ButtonReleaseEvent,
) {
buttonEvent := *event.ButtonReleaseEvent
backend.channel <- stone.EventRelease(buttonEvent.Detail)
backend.channel <- stone.EventRelease {
Button: stone.Button(buttonEvent.Detail),
}
}
func (backend *Backend) handleKeyPress (
@ -59,7 +63,7 @@ func (backend *Backend) handleKeyPress (
) {
keyEvent := *event.KeyPressEvent
button := backend.keycodeToButton(keyEvent.Detail, keyEvent.State)
backend.channel <- stone.EventPress(button)
backend.channel <- stone.EventPress { Button: button }
}
func (backend *Backend) handleKeyRelease (
@ -68,7 +72,7 @@ func (backend *Backend) handleKeyRelease (
) {
keyEvent := *event.KeyReleaseEvent
button := backend.keycodeToButton(keyEvent.Detail, keyEvent.State)
backend.channel <- stone.EventRelease(button)
backend.channel <- stone.EventRelease { Button: button }
}
func (backend *Backend) handleMotionNotify (

View File

@ -3,8 +3,8 @@ package stone
type Event interface { }
type EventQuit struct { }
type EventPress Button
type EventRelease Button
type EventPress struct { Button }
type EventRelease struct { Button }
type EventResize struct { }
type EventMouseMove struct {
X int

View File

@ -38,16 +38,16 @@ func main () {
os.Exit(0)
case stone.EventPress:
event := event.(stone.EventPress)
if stone.Button(event) == stone.MouseButtonLeft {
button := event.(stone.EventPress).Button
if button == stone.MouseButtonLeft {
mousePressed = true
application.SetRune(0, 0, '+')
application.Draw()
}
case stone.EventRelease:
event := event.(stone.EventRelease)
if stone.Button(event) == stone.MouseButtonLeft {
button := event.(stone.EventRelease).Button
if button == stone.MouseButtonLeft {
mousePressed = false
application.SetRune(0, 0, 0)
application.Draw()

View File

@ -38,7 +38,7 @@ func main () {
os.Exit(0)
case stone.EventPress:
button := stone.Button(event.(stone.EventPress))
button := event.(stone.EventPress).Button
if button.Printable() {
application.SetRune(caret, 0, rune(button))
caret ++