mirror of
https://github.com/charmbracelet/gum
synced 2024-06-08 00:32:17 +02:00
fix: choose prefixes and pink gum
text
This commit is contained in:
parent
0f4b98c2ad
commit
5a1195dda5
|
@ -87,9 +87,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
}
|
||||
case "enter":
|
||||
m.quitting = true
|
||||
// Select the item on which they've hit enter if it falls within
|
||||
// the limit.
|
||||
if m.numSelected < m.limit {
|
||||
// If the user hasn't selected any items in a multi-select.
|
||||
// Then we select the item that they have pressed enter on. If they
|
||||
// have selected items, then we simply return them.
|
||||
if m.numSelected < 1 {
|
||||
m.items[m.index].selected = true
|
||||
}
|
||||
return m, tea.Quit
|
||||
|
|
|
@ -10,9 +10,9 @@ type Options struct {
|
|||
NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"`
|
||||
Height int `help:"Height of the list" default:"10"`
|
||||
Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> "`
|
||||
CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"• "`
|
||||
SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"✕ "`
|
||||
UnselectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:" "`
|
||||
CursorPrefix string `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"[•] "`
|
||||
SelectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"[✕] "`
|
||||
UnselectedPrefix string `help:"Prefix to show on selected items (hidden if limit is 1)" default:"[ ] "`
|
||||
CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" set:"name=indicator"`
|
||||
ItemStyle style.Styles `embed:"" prefix:"item." hidden:"" set:"defaultForeground=255" set:"name=item"`
|
||||
SelectedItemStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" set:"name=selected item"`
|
||||
|
|
7
main.go
7
main.go
|
@ -1,18 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/alecthomas/kong"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/muesli/termenv"
|
||||
)
|
||||
|
||||
var bubbleGumPink = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
|
||||
|
||||
func main() {
|
||||
lipgloss.SetColorProfile(termenv.ANSI256)
|
||||
gum := &Gum{}
|
||||
ctx := kong.Parse(
|
||||
gum,
|
||||
kong.Name("gum"),
|
||||
kong.Description("Tasty Bubble Gum for your shell."),
|
||||
kong.Description(fmt.Sprintf("Tasty bubble %s for your shell.", bubbleGumPink.Render("gum"))),
|
||||
kong.UsageOnError(),
|
||||
kong.ConfigureHelp(kong.HelpOptions{
|
||||
Compact: true,
|
||||
|
|
Loading…
Reference in a new issue