diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-01-19 21:26:16 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-01-19 21:26:16 -0500 |
| commit | 39a3b948e525fe2b22b90e07df323ab77f6a81f6 (patch) | |
| tree | 2054a4b5da06685b27a8346326aa286e0bed3634 /main.go | |
| parent | b039cf83c33630396f245fbcba79383e0b2db383 (diff) | |
| download | volute-39a3b948e525fe2b22b90e07df323ab77f6a81f6.zip | |
keep track of focused widget
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -20,6 +20,7 @@ func run() { var ( displacementChan = make(chan uint) output = make(chan uint) + focus = NewFocus(2) displacement uint = 0 ) @@ -29,6 +30,7 @@ func run() { go widget.Input( displacementChan, r, + focus.widgets[0], mux.MakeEnv(), ) r = image.Rect( @@ -40,6 +42,19 @@ func run() { go widget.Label("cc", r, mux.MakeEnv()) r = image.Rect( + r.Max.X+pad, + r.Min.Y, + r.Max.X+pad+widget.TextWidth(6), + r.Max.Y, + ) + go widget.Input( + displacementChan, + r, + focus.widgets[1], + mux.MakeEnv(), + ) + + r = image.Rect( pad, r.Max.Y+pad, pad+widget.TextWidth(6), @@ -47,6 +62,8 @@ func run() { ) go widget.Output(output, r, mux.MakeEnv()) + focus.widgets[focus.i] <- true + Loop: for { select { @@ -60,8 +77,13 @@ Loop: case win.WiClose: break Loop case win.KbType: - if event.Rune == 'q' { + switch event.Rune { + case 'q': break Loop + case 'j', 'l': + focus.Next() + case 'k', 'h': + focus.Prev() } } } |