From 5f72acbfeb45ab726f4a715e26a4d8c2a26750fd Mon Sep 17 00:00:00 2001 From: ayn2op Date: Wed, 10 Jun 2026 21:22:21 -0400 Subject: [PATCH] refactor(config)!: replace NavigationKeybinds with SelectionKeybinds (#802) --- internal/config/config.toml | 24 +++++------ internal/config/keybinds.go | 60 ++++++++------------------ internal/ui/chat/attachments_picker.go | 4 +- internal/ui/chat/channels_picker.go | 4 +- internal/ui/chat/composer.go | 12 +++--- internal/ui/chat/guilds_tree.go | 12 +++--- internal/ui/chat/mentions_list.go | 8 ++-- internal/ui/chat/util.go | 8 ++-- 8 files changed, 55 insertions(+), 77 deletions(-) diff --git a/internal/config/config.toml b/internal/config/config.toml index d0717e0..159e28d 100644 --- a/internal/config/config.toml +++ b/internal/config/config.toml @@ -115,18 +115,18 @@ quit = "ctrl+c" [keybinds.picker] cancel = "esc" -up = "ctrl+p" -down = "ctrl+n" -top = "home" -bottom = "end" +select_up = "ctrl+p" +select_down = "ctrl+n" +select_top = "home" +select_bottom = "end" select = "enter" # Only while focusing on the guilds tree [keybinds.guilds_tree] -up = "k" -down = "j" -top = "g" -bottom = "G" +select_up = "k" +select_down = "j" +select_top = "g" +select_bottom = "G" # Select the currently highlighted text-based channel or expand a guild or channel. select_current = "enter" yank_id = "i" @@ -180,10 +180,10 @@ open_editor = "ctrl+e" open_file_picker = "ctrl+\\" [keybinds.mentions_list] -up = "ctrl+p" -down = "ctrl+n" -top = "home" -bottom = "end" +select_up = "ctrl+p" +select_down = "ctrl+n" +select_top = "home" +select_bottom = "end" # style = { foreground = "", background = "", attributes = "" or ["",""], underline = "", underline_color = "" } [theme.title] diff --git a/internal/config/keybinds.go b/internal/config/keybinds.go index f8c8654..3d13423 100644 --- a/internal/config/keybinds.go +++ b/internal/config/keybinds.go @@ -38,13 +38,6 @@ func desc(s string) Keybind { } } -type NavigationKeybinds struct { - Up Keybind `toml:"up"` - Down Keybind `toml:"down"` - Top Keybind `toml:"top"` - Bottom Keybind `toml:"bottom"` -} - type ScrollKeybinds struct { ScrollUp Keybind `toml:"scroll_up"` ScrollDown Keybind `toml:"scroll_down"` @@ -60,13 +53,13 @@ type SelectionKeybinds struct { } type PickerKeybinds struct { - NavigationKeybinds + SelectionKeybinds Select Keybind `toml:"select"` Cancel Keybind `toml:"cancel"` } type GuildsTreeKeybinds struct { - NavigationKeybinds + SelectionKeybinds SelectCurrent Keybind `toml:"select_current"` YankID Keybind `toml:"yank_id"` @@ -107,7 +100,7 @@ type ComposerKeybinds struct { } type MentionsListKeybinds struct { - NavigationKeybinds + SelectionKeybinds } type Keybinds struct { @@ -133,33 +126,28 @@ type Keybinds struct { Quit Keybind `toml:"quit"` } -func defaultPickerKeybinds() PickerKeybinds { - return PickerKeybinds{ - NavigationKeybinds: NavigationKeybinds{ - Up: desc("up"), - Down: desc("down"), - Top: desc("top"), - Bottom: desc("btm"), - }, - Cancel: desc("cancel"), - Select: desc("sel"), +func defaultSelectionKeybinds() SelectionKeybinds { + return SelectionKeybinds{ + SelectUp: desc("up"), + SelectDown: desc("down"), + SelectTop: desc("top"), + SelectBottom: desc("btm"), } } -func defaultNavigationKeybinds() NavigationKeybinds { - return NavigationKeybinds{ - Up: desc("up"), - Down: desc("down"), - Top: desc("top"), - Bottom: desc("btm"), +func defaultPickerKeybinds() PickerKeybinds { + return PickerKeybinds{ + SelectionKeybinds: defaultSelectionKeybinds(), + Cancel: desc("cancel"), + Select: desc("sel"), } } func defaultGuildsTreeKeybinds() GuildsTreeKeybinds { return GuildsTreeKeybinds{ - NavigationKeybinds: defaultNavigationKeybinds(), - SelectCurrent: desc("select"), - YankID: desc("copy id"), + SelectionKeybinds: defaultSelectionKeybinds(), + SelectCurrent: desc("select"), + YankID: desc("copy id"), CollapseAll: desc("collapse all"), CollapseParentNode: desc("collapse parent"), @@ -169,12 +157,7 @@ func defaultGuildsTreeKeybinds() GuildsTreeKeybinds { func defaultMessagesListKeybinds() MessagesListKeybinds { return MessagesListKeybinds{ - SelectionKeybinds: SelectionKeybinds{ - SelectUp: desc("up"), - SelectDown: desc("down"), - SelectTop: desc("top"), - SelectBottom: desc("btm"), - }, + SelectionKeybinds: defaultSelectionKeybinds(), ScrollKeybinds: ScrollKeybinds{ ScrollUp: desc("scr up"), ScrollDown: desc("scr down"), @@ -210,12 +193,7 @@ func defaultComposerKeybinds() ComposerKeybinds { func defaultMentionsListKeybinds() MentionsListKeybinds { return MentionsListKeybinds{ - NavigationKeybinds: NavigationKeybinds{ - Up: desc("up"), - Down: desc("down"), - Top: desc("top"), - Bottom: desc("btm"), - }, + SelectionKeybinds: defaultSelectionKeybinds(), } } diff --git a/internal/ui/chat/attachments_picker.go b/internal/ui/chat/attachments_picker.go index 74216d0..b659827 100644 --- a/internal/ui/chat/attachments_picker.go +++ b/internal/ui/chat/attachments_picker.go @@ -67,13 +67,13 @@ func (ap *attachmentsPicker) Update(msg tview.Msg) tview.Cmd { func (ap *attachmentsPicker) ShortHelp() []keybind.Keybind { cfg := ap.cfg.Keybinds.Picker - return []keybind.Keybind{cfg.Up.Keybind, cfg.Down.Keybind, cfg.Select.Keybind, cfg.Cancel.Keybind} + return []keybind.Keybind{cfg.SelectUp.Keybind, cfg.SelectDown.Keybind, cfg.Select.Keybind, cfg.Cancel.Keybind} } func (ap *attachmentsPicker) FullHelp() [][]keybind.Keybind { cfg := ap.cfg.Keybinds.Picker return [][]keybind.Keybind{ - {cfg.Up.Keybind, cfg.Down.Keybind, cfg.Top.Keybind, cfg.Bottom.Keybind}, + {cfg.SelectUp.Keybind, cfg.SelectDown.Keybind, cfg.SelectTop.Keybind, cfg.SelectBottom.Keybind}, {cfg.Select.Keybind, cfg.Cancel.Keybind}, } } diff --git a/internal/ui/chat/channels_picker.go b/internal/ui/chat/channels_picker.go index 78cf893..ecf3d59 100644 --- a/internal/ui/chat/channels_picker.go +++ b/internal/ui/chat/channels_picker.go @@ -113,13 +113,13 @@ func (cp *channelsPicker) channelItem(guild *discord.Guild, channel discord.Chan func (cp *channelsPicker) ShortHelp() []keybind.Keybind { cfg := cp.cfg.Keybinds.Picker - return []keybind.Keybind{cfg.Up.Keybind, cfg.Down.Keybind, cfg.Select.Keybind, cfg.Cancel.Keybind} + return []keybind.Keybind{cfg.SelectUp.Keybind, cfg.SelectDown.Keybind, cfg.Select.Keybind, cfg.Cancel.Keybind} } func (cp *channelsPicker) FullHelp() [][]keybind.Keybind { cfg := cp.cfg.Keybinds.Picker return [][]keybind.Keybind{ - {cfg.Up.Keybind, cfg.Down.Keybind, cfg.Top.Keybind, cfg.Bottom.Keybind}, + {cfg.SelectUp.Keybind, cfg.SelectDown.Keybind, cfg.SelectTop.Keybind, cfg.SelectBottom.Keybind}, {cfg.Select.Keybind, cfg.Cancel.Keybind}, } } diff --git a/internal/ui/chat/composer.go b/internal/ui/chat/composer.go index 7299c6a..6096b96 100644 --- a/internal/ui/chat/composer.go +++ b/internal/ui/chat/composer.go @@ -229,10 +229,10 @@ func (c *composer) Update(msg tview.Msg) tview.Cmd { if c.cfg.AutocompleteLimit > 0 { if c.chat.GetVisible(mentionsListLayerName) { keybinds := c.cfg.Keybinds.MentionsList - if keybind.Matches(msg, keybinds.Up.Keybind) || - keybind.Matches(msg, keybinds.Down.Keybind) || - keybind.Matches(msg, keybinds.Top.Keybind) || - keybind.Matches(msg, keybinds.Bottom.Keybind) { + if keybind.Matches(msg, keybinds.SelectUp.Keybind) || + keybind.Matches(msg, keybinds.SelectDown.Keybind) || + keybind.Matches(msg, keybinds.SelectTop.Keybind) || + keybind.Matches(msg, keybinds.SelectBottom.Keybind) { return tview.Batch(typingCmd, c.mentionsList.Update(msg)) } } @@ -823,7 +823,7 @@ func (c *composer) ShortHelp() []keybind.Keybind { if c.chat.GetVisible(mentionsListLayerName) { cfg := c.cfg.Keybinds.MentionsList ccfg := c.cfg.Keybinds.Composer - short := []keybind.Keybind{cfg.Up.Keybind, cfg.Down.Keybind, ccfg.Cancel.Keybind} + short := []keybind.Keybind{cfg.SelectUp.Keybind, cfg.SelectDown.Keybind, ccfg.Cancel.Keybind} if c.canAttachFiles() { short = append(short, ccfg.OpenFilePicker.Keybind) } @@ -843,7 +843,7 @@ func (c *composer) FullHelp() [][]keybind.Keybind { mcfg := c.cfg.Keybinds.MentionsList ccfg := c.cfg.Keybinds.Composer return [][]keybind.Keybind{ - {mcfg.Up.Keybind, mcfg.Down.Keybind, mcfg.Top.Keybind, mcfg.Bottom.Keybind}, + {mcfg.SelectUp.Keybind, mcfg.SelectDown.Keybind, mcfg.SelectTop.Keybind, mcfg.SelectBottom.Keybind}, {ccfg.TabComplete.Keybind, ccfg.Cancel.Keybind}, } } diff --git a/internal/ui/chat/guilds_tree.go b/internal/ui/chat/guilds_tree.go index f9034ec..64539b2 100644 --- a/internal/ui/chat/guilds_tree.go +++ b/internal/ui/chat/guilds_tree.go @@ -56,10 +56,10 @@ func newGuildsTree(cfg *config.Config, chat *Model) *guildsTree { 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, + Up: cfg.Keybinds.GuildsTree.SelectUp.Keybind, + Down: cfg.Keybinds.GuildsTree.SelectDown.Keybind, + Top: cfg.Keybinds.GuildsTree.SelectTop.Keybind, + Bottom: cfg.Keybinds.GuildsTree.SelectBottom.Keybind, MoveToParent: cfg.Keybinds.GuildsTree.MoveToParentNode.Keybind, Select: cfg.Keybinds.GuildsTree.SelectCurrent.Keybind, }) @@ -450,7 +450,7 @@ func (gt *guildsTree) selectCurrentKeybind() keybind.Keybind { func (gt *guildsTree) ShortHelp() []keybind.Keybind { cfg := gt.cfg.Keybinds.GuildsTree - shortHelp := []keybind.Keybind{cfg.Up.Keybind, cfg.Down.Keybind, gt.selectCurrentKeybind()} + shortHelp := []keybind.Keybind{cfg.SelectUp.Keybind, cfg.SelectDown.Keybind, gt.selectCurrentKeybind()} if gt.canCollapseParent(gt.GetCurrentNode()) { shortHelp = append(shortHelp, cfg.CollapseParentNode.Keybind) } @@ -463,7 +463,7 @@ func (gt *guildsTree) FullHelp() [][]keybind.Keybind { selectGroup = append(selectGroup, gt.collapseKeybinds()...) return [][]keybind.Keybind{ - {cfg.Up.Keybind, cfg.Down.Keybind, cfg.Top.Keybind, cfg.Bottom.Keybind}, + {cfg.SelectUp.Keybind, cfg.SelectDown.Keybind, cfg.SelectTop.Keybind, cfg.SelectBottom.Keybind}, selectGroup, {cfg.YankID.Keybind}, } diff --git a/internal/ui/chat/mentions_list.go b/internal/ui/chat/mentions_list.go index 8d3f3b3..ca8cae7 100644 --- a/internal/ui/chat/mentions_list.go +++ b/internal/ui/chat/mentions_list.go @@ -26,10 +26,10 @@ func newMentionsList(cfg *config.Config) *mentionsList { } m.SetSelectedStyle(tcell.StyleDefault.Reverse(true)) m.SetKeybinds(list.Keybinds{ - SelectUp: cfg.Keybinds.MentionsList.Up.Keybind, - SelectDown: cfg.Keybinds.MentionsList.Down.Keybind, - SelectTop: cfg.Keybinds.MentionsList.Top.Keybind, - SelectBottom: cfg.Keybinds.MentionsList.Bottom.Keybind, + SelectUp: cfg.Keybinds.MentionsList.SelectUp.Keybind, + SelectDown: cfg.Keybinds.MentionsList.SelectDown.Keybind, + SelectTop: cfg.Keybinds.MentionsList.SelectTop.Keybind, + SelectBottom: cfg.Keybinds.MentionsList.SelectBottom.Keybind, }) m.Box = ui.ConfigureBox(m.Box, &cfg.Theme) diff --git a/internal/ui/chat/util.go b/internal/ui/chat/util.go index e64b0a5..c956ff1 100644 --- a/internal/ui/chat/util.go +++ b/internal/ui/chat/util.go @@ -32,10 +32,10 @@ func ConfigurePicker(model *picker.Model, cfg *config.Config, title string) { model.SetKeybinds(picker.Keybinds{ Cancel: cfg.Keybinds.Picker.Cancel.Keybind, Keybinds: list.Keybinds{ - SelectUp: cfg.Keybinds.Picker.Up.Keybind, - SelectDown: cfg.Keybinds.Picker.Down.Keybind, - SelectTop: cfg.Keybinds.Picker.Top.Keybind, - SelectBottom: cfg.Keybinds.Picker.Bottom.Keybind, + SelectUp: cfg.Keybinds.Picker.SelectUp.Keybind, + SelectDown: cfg.Keybinds.Picker.SelectDown.Keybind, + SelectTop: cfg.Keybinds.Picker.SelectTop.Keybind, + SelectBottom: cfg.Keybinds.Picker.SelectBottom.Keybind, }, Select: cfg.Keybinds.Picker.Select.Keybind, })