aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-01-17 17:14:28 -0500
committerSam Anthony <sam@samanthony.xyz>2024-01-17 17:14:28 -0500
commitb039cf83c33630396f245fbcba79383e0b2db383 (patch)
treeef54c5ebad1f2d577676c571d5a8c505456b85cb /main.go
parentbd9bce9f1278743e961a18cab688fdb09876560c (diff)
downloadvolute-b039cf83c33630396f245fbcba79383e0b2db383.zip
add output widget
Diffstat (limited to 'main.go')
-rw-r--r--main.go38
1 files changed, 27 insertions, 11 deletions
diff --git a/main.go b/main.go
index eb2e094..a173fd4 100644
--- a/main.go
+++ b/main.go
@@ -18,7 +18,10 @@ func run() {
mux, env := gui.NewMux(w)
var (
- displacementChan = make(chan float64)
+ displacementChan = make(chan uint)
+ output = make(chan uint)
+
+ displacement uint = 0
)
pad := 10
@@ -36,23 +39,36 @@ func run() {
)
go widget.Label("cc", r, mux.MakeEnv())
+ r = image.Rect(
+ pad,
+ r.Max.Y+pad,
+ pad+widget.TextWidth(6),
+ r.Max.Y+pad+widget.TextHeight(),
+ )
+ go widget.Output(output, r, mux.MakeEnv())
+
Loop:
- for event := range env.Events() {
- switch event := event.(type) {
- case win.WiClose:
- break Loop
- case win.KbType:
- if event.Rune == 'q' {
+ for {
+ select {
+ case displacement = <-displacementChan:
+ output <- displacement
+ case event, ok := <-env.Events():
+ if !ok { // channel closed
break Loop
}
- }
- select {
- case _ = <-displacementChan:
- default:
+ switch event := event.(type) {
+ case win.WiClose:
+ break Loop
+ case win.KbType:
+ if event.Rune == 'q' {
+ break Loop
+ }
+ }
}
}
close(env.Draw())
close(displacementChan)
+ close(output)
}
func main() {