Selaa lähdekoodia

feat(config)!: add additional selection keys to keys.mentions_list (#720)

Ayyan 3 kuukautta sitten
vanhempi
sitoutus
d700548d02
3 muutettua tiedostoa jossa 33 lisäystä ja 25 poistoa
  1. 4 2
      internal/config/config.toml
  2. 18 19
      internal/config/keys.go
  3. 11 4
      internal/ui/chat/message_input.go

+ 4 - 2
internal/config/config.toml

@@ -113,8 +113,10 @@ open_editor = "Ctrl+E"
 open_file_picker = "Ctrl+Rune[\\]"
 
 [keys.mentions_list]
-up = "Ctrl+P"
-down = "Ctrl+N"
+select_previous = "Ctrl+P"
+select_next = "Ctrl+N"
+select_first = "Home"
+select_last = "End"
 
 # style = { foreground = "", background = "", attributes = "" or [""] }
 [theme.title]

+ 18 - 19
internal/config/keys.go

@@ -8,23 +8,6 @@ type (
 		SelectLast     string `toml:"select_last"`
 	}
 
-	Keys struct {
-		FocusGuildsTree   string `toml:"focus_guilds_tree"`
-		FocusMessagesList string `toml:"focus_messages_list"`
-		FocusMessageInput string `toml:"focus_message_input"`
-		FocusPrevious     string `toml:"focus_previous"`
-		FocusNext         string `toml:"focus_next"`
-		ToggleGuildsTree  string `toml:"toggle_guilds_tree"`
-
-		GuildsTree   GuildsTreeKeys   `toml:"guilds_tree"`
-		MessagesList MessagesListKeys `toml:"messages_list"`
-		MessageInput MessageInputKeys `toml:"message_input"`
-		MentionsList MentionsListKeys `toml:"mentions_list"`
-
-		Logout string `toml:"logout"`
-		Quit   string `toml:"quit"`
-	}
-
 	GuildsTreeKeys struct {
 		SelectionKeys
 		SelectCurrent string `toml:"select_current"`
@@ -67,7 +50,23 @@ type (
 	}
 
 	MentionsListKeys struct {
-		Up   string `toml:"up"`
-		Down string `toml:"down"`
+		SelectionKeys
+	}
+
+	Keys struct {
+		FocusGuildsTree   string `toml:"focus_guilds_tree"`
+		FocusMessagesList string `toml:"focus_messages_list"`
+		FocusMessageInput string `toml:"focus_message_input"`
+		FocusPrevious     string `toml:"focus_previous"`
+		FocusNext         string `toml:"focus_next"`
+		ToggleGuildsTree  string `toml:"toggle_guilds_tree"`
+
+		GuildsTree   GuildsTreeKeys   `toml:"guilds_tree"`
+		MessagesList MessagesListKeys `toml:"messages_list"`
+		MessageInput MessageInputKeys `toml:"message_input"`
+		MentionsList MentionsListKeys `toml:"mentions_list"`
+
+		Logout string `toml:"logout"`
+		Quit   string `toml:"quit"`
 	}
 )

+ 11 - 4
internal/ui/chat/message_input.go

@@ -149,12 +149,19 @@ func (mi *messageInput) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
 
 	if mi.cfg.AutocompleteLimit > 0 {
 		if mi.chatView.GetVisibile(mentionsListPageName) {
+			handler := mi.mentionsList.InputHandler()
 			switch event.Name() {
-			case mi.cfg.Keys.MentionsList.Up:
-				mi.mentionsList.InputHandler()(tcell.NewEventKey(tcell.KeyUp, "", tcell.ModNone), nil)
+			case mi.cfg.Keys.MentionsList.SelectPrevious:
+				handler(tcell.NewEventKey(tcell.KeyUp, "", tcell.ModNone), nil)
 				return nil
-			case mi.cfg.Keys.MentionsList.Down:
-				mi.mentionsList.InputHandler()(tcell.NewEventKey(tcell.KeyDown, "", tcell.ModNone), nil)
+			case mi.cfg.Keys.MentionsList.SelectNext:
+				handler(tcell.NewEventKey(tcell.KeyDown, "", tcell.ModNone), nil)
+				return nil
+			case mi.cfg.Keys.MentionsList.SelectFirst:
+				handler(tcell.NewEventKey(tcell.KeyHome, "", tcell.ModNone), nil)
+				return nil
+			case mi.cfg.Keys.MentionsList.SelectLast:
+				handler(tcell.NewEventKey(tcell.KeyEnd, "", tcell.ModNone), nil)
 				return nil
 			}
 		}