diff options
Diffstat (limited to 'internal/switcher/keys.go')
-rw-r--r-- | internal/switcher/keys.go | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/internal/switcher/keys.go b/internal/switcher/keys.go index e019ba1..215a8e2 100644 --- a/internal/switcher/keys.go +++ b/internal/switcher/keys.go @@ -3,7 +3,7 @@ package switcher import "github.com/charmbracelet/bubbles/key" type keybinds struct { - next, prev, cpHex, cpRgb, cpHsl, cpCmyk, quit key.Binding + next, prev, cpHex, cpRgb, cpHsl, cpCmyk, help, quit key.Binding } func newKeybinds() keybinds { @@ -14,23 +14,27 @@ func newKeybinds() keybinds { ), prev: key.NewBinding( key.WithKeys("shift+tab"), - key.WithHelp("shift+tab", "previous picker"), + key.WithHelp("shift+tab", "prev. picker"), ), cpHex: key.NewBinding( key.WithKeys("x"), - key.WithHelp("x", "yank/copy hex value"), + key.WithHelp("x", "copy hex"), ), cpRgb: key.NewBinding( key.WithKeys("r"), - key.WithHelp("r", "yank/copy RGB value"), + key.WithHelp("r", "copy rgb"), ), cpHsl: key.NewBinding( key.WithKeys("s"), - key.WithHelp("s", "yank/copy HSL value"), + key.WithHelp("s", "copy hsl"), ), cpCmyk: key.NewBinding( key.WithKeys("c"), - key.WithHelp("c", "yank/copy CMYK value"), + key.WithHelp("c", "copy cmyk"), + ), + help: key.NewBinding( + key.WithKeys("?"), + key.WithHelp("?", "help"), ), quit: key.NewBinding( key.WithKeys("q", "ctrl+c"), @@ -41,9 +45,27 @@ func newKeybinds() keybinds { func Keys() []key.Binding { k := newKeybinds() - return []key.Binding{k.next, k.prev, k.cpHex, k.cpRgb, k.cpHsl, k.cpCmyk, k.quit} + return []key.Binding{k.next, k.prev, k.cpHex, k.cpRgb, k.cpHsl, k.cpCmyk, k.help, k.quit} +} + +func shortKeys() [][]key.Binding { + keys := make([][]key.Binding, 2) + rows := 2 + cRow := 0 + for i := 0; i < len(Keys()); i++ { + keys[cRow] = append(keys[cRow], Keys()[i]) + cRow++ + if cRow == rows { + cRow = 0 + } + } + return keys } -func (m Model) AllKeys() []key.Binding { - return append(Keys(), m.pickers[m.active].AllKeys()...) +func (m Model) AllKeys() [][]key.Binding { + keys := make([][]key.Binding, len(m.pickers[m.active].AllKeys())+1) + keys[0] = Keys() + copy(keys[1:], m.pickers[m.active].AllKeys()) + return keys + // return append(m.pickers[m.active].AllKeys(), Keys()) } |