Эх сурвалжийг харах

feat: add default navigation shortcut for guilds list

ayntgl 4 жил өмнө
parent
commit
1bc81111e8
2 өөрчлөгдсөн 14 нэмэгдсэн , 4 устгасан
  1. 5 3
      config/mod.go
  2. 9 1
      ui/handlers.go

+ 5 - 3
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"},

+ 9 - 1
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+<rune>.
+	if e.Modifiers() == tcell.ModAlt {
+		return nil
+	}
+
 	switch e.Key() {
 	case tcell.KeyEnter:
 		if app.SelectedChannel == nil {