From 1bc81111e842634d2d8b5925b20231053e612efb Mon Sep 17 00:00:00 2001 From: ayntgl Date: Mon, 10 Jan 2022 14:29:00 +0400 Subject: [PATCH] feat: add default navigation shortcut for guilds list --- config/mod.go | 8 +++++--- ui/handlers.go | 10 +++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/config/mod.go b/config/mod.go index 0fb394b..e7a31ec 100644 --- a/config/mod.go +++ b/config/mod.go @@ -13,6 +13,7 @@ type GeneralConfig struct { } type KeybindingsConfig struct { + FocusGuildsList []string `json:"focusGuildsList"` FocusChannelsTreeView []string `json:"focusChannelsTreeView"` FocusMessagesTextView []string `json:"focusMessagesTextView"` FocusMessageInputField []string `json:"focusMessageInputField"` @@ -41,9 +42,10 @@ func New() *Config { Notifications: true, }, Keybindings: KeybindingsConfig{ - FocusChannelsTreeView: []string{"Alt+Left"}, - FocusMessagesTextView: []string{"Alt+Right"}, - FocusMessageInputField: []string{"Alt+Down"}, + FocusGuildsList: []string{"Alt+Rune[g]"}, + FocusChannelsTreeView: []string{"Alt+Rune[t]"}, + FocusMessagesTextView: []string{"Alt+Rune[m]"}, + FocusMessageInputField: []string{"Alt+Rune[i]"}, SelectPreviousMessage: []string{"Up"}, SelectNextMessage: []string{"Down"}, diff --git a/ui/handlers.go b/ui/handlers.go index ec8e709..e561613 100644 --- a/ui/handlers.go +++ b/ui/handlers.go @@ -13,7 +13,10 @@ import ( ) func onAppInputCapture(app *App, e *tcell.EventKey) *tcell.EventKey { - if hasKeybinding(app.Config.Keybindings.FocusChannelsTreeView, e.Name()) { + if hasKeybinding(app.Config.Keybindings.FocusGuildsList, e.Name()) { + app.SetFocus(app.GuildsList) + return nil + } else if hasKeybinding(app.Config.Keybindings.FocusChannelsTreeView, e.Name()) { app.SetFocus(app.ChannelsTreeView) return nil } else if hasKeybinding(app.Config.Keybindings.FocusMessagesTextView, e.Name()) { @@ -239,6 +242,11 @@ func onMessagesTextViewInputCapture(app *App, e *tcell.EventKey) *tcell.EventKey } func onMessageInputFieldInputCapture(app *App, e *tcell.EventKey) *tcell.EventKey { + // The default global navigation shortcut for guilds list is Alt+. + if e.Modifiers() == tcell.ModAlt { + return nil + } + switch e.Key() { case tcell.KeyEnter: if app.SelectedChannel == nil {