diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-01-17 17:14:28 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-01-17 17:14:28 -0500 |
| commit | b039cf83c33630396f245fbcba79383e0b2db383 (patch) | |
| tree | ef54c5ebad1f2d577676c571d5a8c505456b85cb /main.go | |
| parent | bd9bce9f1278743e961a18cab688fdb09876560c (diff) | |
| download | volute-b039cf83c33630396f245fbcba79383e0b2db383.zip | |
add output widget
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 38 |
1 files changed, 27 insertions, 11 deletions
@@ -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() { |