fix: select all keybinding (#639)

* fix: select all keybinding

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* chore(deps): update gum

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2024-07-25 15:45:13 -04:00 committed by GitHub
parent 046a4d361e
commit 9db5c7fbba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 8 deletions

View File

@ -44,6 +44,9 @@ func (o Options) Run() error {
theme.Focused.SelectedPrefix = o.SelectedItemStyle.ToLipgloss().SetString(o.SelectedPrefix)
theme.Focused.UnselectedPrefix = o.ItemStyle.ToLipgloss().SetString(o.UnselectedPrefix)
keymap := huh.NewDefaultKeyMap()
keymap.MultiSelect.ToggleAll.SetKeys("a", "ctrl+a")
for _, s := range o.Selected {
for i, opt := range options {
if s == opt.Key || s == opt.Value {
@ -52,15 +55,15 @@ func (o Options) Run() error {
}
}
if o.NoLimit {
o.Limit = len(o.Options)
}
width := max(widest(o.Options)+
max(lipgloss.Width(o.SelectedPrefix)+lipgloss.Width(o.UnselectedPrefix))+
lipgloss.Width(o.Cursor)+1, lipgloss.Width(o.Header)+widthBuffer)
if o.Limit > 1 {
if o.NoLimit {
o.Limit = 0
}
if o.Limit > 1 || o.NoLimit {
var choices []string
field := huh.NewMultiSelect[string]().

2
go.mod
View File

@ -8,7 +8,7 @@ require (
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105
github.com/charmbracelet/glamour v0.7.0
github.com/charmbracelet/huh v0.5.2
github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04
github.com/charmbracelet/lipgloss v0.12.1
github.com/charmbracelet/log v0.4.0
github.com/charmbracelet/x/ansi v0.1.4

4
go.sum
View File

@ -22,8 +22,8 @@ github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105 h1:ye4X
github.com/charmbracelet/bubbletea v0.26.7-0.20240716165615-7d708384a105/go.mod h1:gw7FxN8J9u7IAlwc1ab1GnbfOMGExC9iI0e1t2SHs6I=
github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng=
github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps=
github.com/charmbracelet/huh v0.5.2 h1:ofeNkJ4iaFnzv46Njhx896DzLUe/j0L2QAf8znwzX4c=
github.com/charmbracelet/huh v0.5.2/go.mod h1:Sf7dY0oAn6N/e3sXJFtFX9hdQLrUdO3z7AYollG9bAM=
github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04 h1:4gl2RNDqRh0x5vGO0EPKOLXH+iEyHwq+36KNeuQ1/YI=
github.com/charmbracelet/huh v0.5.3-0.20240725170654-1926040ccf04/go.mod h1:Sf7dY0oAn6N/e3sXJFtFX9hdQLrUdO3z7AYollG9bAM=
github.com/charmbracelet/lipgloss v0.12.1 h1:/gmzszl+pedQpjCOH+wFkZr/N90Snz40J/NR7A0zQcs=
github.com/charmbracelet/lipgloss v0.12.1/go.mod h1:V2CiwIuhx9S1S1ZlADfOj9HmxeMAORuz5izHb0zGbB8=
github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM=