refactor(config)!: replace NavigationKeybinds with SelectionKeybinds (#802)
This commit is contained in:
parent
6eb4b56122
commit
5f72acbfeb
8 changed files with 55 additions and 77 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue