feat(config): add keybinds to cycle focus between widgets (#613)
Co-authored-by: Ayyan <ayn2op@gmail.com>
This commit is contained in:
parent
746d8b8505
commit
2af722b283
3 changed files with 33 additions and 0 deletions
|
|
@ -137,6 +137,34 @@ func (a *application) onPagesInputCapture(event *tcell.EventKey) *tcell.EventKey
|
|||
case a.cfg.Keys.FocusMessageInput:
|
||||
a.SetFocus(a.messageInput)
|
||||
return nil
|
||||
case a.cfg.Keys.FocusPrevious:
|
||||
switch a.GetFocus() {
|
||||
case a.guildsTree:
|
||||
a.SetFocus(a.messageInput)
|
||||
case a.messageInput:
|
||||
a.SetFocus(a.messagesList)
|
||||
default: // Handle both a.messagesList and a.flex as well as other edge cases (if there is).
|
||||
if a.flex.GetItemCount() == 2 {
|
||||
a.SetFocus(a.guildsTree)
|
||||
} else { // If there is no guild tree, the correct previous page is message input.
|
||||
a.SetFocus(a.messageInput)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case a.cfg.Keys.FocusNext:
|
||||
switch a.GetFocus() {
|
||||
case a.guildsTree:
|
||||
a.SetFocus(a.messagesList)
|
||||
case a.messagesList:
|
||||
a.SetFocus(a.messageInput)
|
||||
default: // Handle both a.messageInput and a.flex as well as other edge cases (if there is).
|
||||
if a.flex.GetItemCount() == 2 {
|
||||
a.SetFocus(a.guildsTree)
|
||||
} else { // If there is no guild tree, the correct next page is message input.
|
||||
a.SetFocus(a.messagesList)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case a.cfg.Keys.Logout:
|
||||
a.quit()
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ only_on_ping = true
|
|||
focus_guilds_tree = "Ctrl+G"
|
||||
focus_messages_list = "Ctrl+T"
|
||||
focus_message_input = "Ctrl+Space"
|
||||
# Cycle focus between the widgets.
|
||||
focus_previous = "Ctrl+H"
|
||||
focus_next = "Ctrl+L"
|
||||
# Hide/show the guilds tree.
|
||||
toggle_guilds_tree = "Ctrl+B"
|
||||
quit = "Ctrl+C"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ type (
|
|||
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"`
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue