From 3cbbce6aebb7dd3ea581836a1cf28f6cd35d8bbf Mon Sep 17 00:00:00 2001 From: ayn2op Date: Thu, 4 Jun 2026 17:41:19 -0400 Subject: [PATCH] refactor(chat): drive guilds tree navigation through tree keybinds --- go.mod | 4 ++-- go.sum | 8 ++++---- internal/ui/chat/guilds_tree.go | 25 ++++++++----------------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 721a8a5..fd166cb 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/alecthomas/chroma/v2 v2.26.1 github.com/andybalholm/brotli v1.2.1 github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97 - github.com/ayn2op/tview v0.0.0-20260603033754-03ce043930ff + github.com/ayn2op/tview v0.0.0-20260604212409-7075d4e3251a github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb github.com/diamondburned/arikawa/v3 v3.6.1-0.20260518050745-b430932b3ee1 github.com/diamondburned/ningen/v3 v3.0.1-0.20260306213430-5a08d3a709b4 @@ -54,7 +54,7 @@ require ( github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect github.com/twmb/murmur3 v1.1.8 // indirect go4.org v0.0.0-20260112195520-a5071408f32f // indirect - golang.org/x/exp/shiny v0.0.0-20260529124908-c761662dc8c9 // indirect + golang.org/x/exp/shiny v0.0.0-20260603202125-055de637280b // indirect golang.org/x/image v0.41.0 // indirect golang.org/x/mobile v0.0.0-20260602190626-68735029466e // indirect golang.org/x/sys v0.45.0 // indirect diff --git a/go.sum b/go.sum index e98c97c..781872f 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/andybalholm/brotli v1.2.1 h1:R+f5xP285VArJDRgowrfb9DqL18yVK0gKAW/F+eT github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97 h1:WujETUV+v0DEJyZgjeLzQvihWyL80c0Tg4qf0dDo+Io= github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97/go.mod h1:3kFnpNCa3dF6WryzOMCDao7PfZ7DTCh+pievlfuwV80= -github.com/ayn2op/tview v0.0.0-20260603033754-03ce043930ff h1:847J26ULcb5dimVXU3ymJXdlmWUY/I/hLpQ5FMiGJOY= -github.com/ayn2op/tview v0.0.0-20260603033754-03ce043930ff/go.mod h1:W0lZFznN+hDXma+CT27czLM8/zbNOda6vsfVgHI1Sew= +github.com/ayn2op/tview v0.0.0-20260604212409-7075d4e3251a h1:mJ6+hfFcQrzFy/rUZLJgkHQzIXuVIeXxiUtU/OQiJF4= +github.com/ayn2op/tview v0.0.0-20260604212409-7075d4e3251a/go.mod h1:W0lZFznN+hDXma+CT27czLM8/zbNOda6vsfVgHI1Sew= github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8= github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0= github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= @@ -117,8 +117,8 @@ go4.org v0.0.0-20260112195520-a5071408f32f h1:ziUVAjmTPwQMBmYR1tbdRFJPtTcQUI12fH go4.org v0.0.0-20260112195520-a5071408f32f/go.mod h1:ZRJnO5ZI4zAwMFp+dS1+V6J6MSyAowhRqAE+DPa1Xp0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp/shiny v0.0.0-20260529124908-c761662dc8c9 h1:cSx0wquXV+TIgifO2PIB7NQ9DHFH6cGqE+U3OGSGDgw= -golang.org/x/exp/shiny v0.0.0-20260529124908-c761662dc8c9/go.mod h1:eQWld7Ucl0GVwFfFJYfSLmTbCJG2XEQrz+PGjltJgck= +golang.org/x/exp/shiny v0.0.0-20260603202125-055de637280b h1:9Z1UbVACNfxuIPSvQKzNSsFc8ItxDuAkgmYtBJD0O0Y= +golang.org/x/exp/shiny v0.0.0-20260603202125-055de637280b/go.mod h1:eQWld7Ucl0GVwFfFJYfSLmTbCJG2XEQrz+PGjltJgck= golang.org/x/image v0.41.0 h1:8wS72eGJMJaBxK6okTzd4WaXumUlTVlb753MlsSvTCo= golang.org/x/image v0.41.0/go.mod h1:uIc348UZMSvS5Z65CVZ7iDPaNobNFEPeJ4kbqTOszmA= golang.org/x/mobile v0.0.0-20260602190626-68735029466e h1:YxPXu/HWDTcSSrzSX+sCltsfcNCa/ZYVG43oslMouNU= diff --git a/internal/ui/chat/guilds_tree.go b/internal/ui/chat/guilds_tree.go index cb86e17..c4a8646 100644 --- a/internal/ui/chat/guilds_tree.go +++ b/internal/ui/chat/guilds_tree.go @@ -55,6 +55,14 @@ func newGuildsTree(cfg *config.Config, chat *Model) *guildsTree { SetGraphics(cfg.Theme.GuildsTree.Graphics). SetGraphicsColor(tcell.GetColor(cfg.Theme.GuildsTree.GraphicsColor)). SetTitle("Guilds") + gt.SetKeybinds(tree.Keybinds{ + Up: cfg.Keybinds.GuildsTree.Up.Keybind, + Down: cfg.Keybinds.GuildsTree.Down.Keybind, + Top: cfg.Keybinds.GuildsTree.Top.Keybind, + Bottom: cfg.Keybinds.GuildsTree.Bottom.Keybind, + MoveToParent: cfg.Keybinds.GuildsTree.MoveToParentNode.Keybind, + Select: cfg.Keybinds.GuildsTree.SelectCurrent.Keybind, + }) return gt } @@ -327,7 +335,6 @@ func (gt *guildsTree) Update(msg tview.Msg) tview.Cmd { case tree.SelectedMsg: return gt.onSelected(msg.Node) case tview.KeyMsg: - handler := gt.Model.Update switch { case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.CollapseAll.Keybind): for _, node := range gt.GetRoot().GetChildren() { @@ -337,25 +344,9 @@ func (gt *guildsTree) Update(msg tview.Msg) tview.Cmd { case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.CollapseParentNode.Keybind): gt.collapseParentNode(gt.GetCurrentNode()) return nil - case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.MoveToParentNode.Keybind): - return handler(tcell.NewEventKey(tcell.KeyRune, "K", tcell.ModNone)) - case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.Up.Keybind): - return handler(tcell.NewEventKey(tcell.KeyUp, "", tcell.ModNone)) - case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.Down.Keybind): - return handler(tcell.NewEventKey(tcell.KeyDown, "", tcell.ModNone)) - case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.Top.Keybind): - gt.Move(gt.GetRowCount() * -1) - return nil - case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.Bottom.Keybind): - gt.Move(gt.GetRowCount()) - return nil - case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.SelectCurrent.Keybind): - return handler(tcell.NewEventKey(tcell.KeyEnter, "", tcell.ModNone)) case keybind.Matches(msg, gt.cfg.Keybinds.GuildsTree.YankID.Keybind): return gt.yankID() } - // Do not fall through to defaults for unmatched keys. - return nil } return gt.Model.Update(msg) }