mirror of
https://github.com/charmbracelet/gum
synced 2024-06-08 08:42:16 +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":
|
case "enter":
|
||||||
m.quitting = true
|
m.quitting = true
|
||||||
// Select the item on which they've hit enter if it falls within
|
// If the user hasn't selected any items in a multi-select.
|
||||||
// the limit.
|
// Then we select the item that they have pressed enter on. If they
|
||||||
if m.numSelected < m.limit {
|
// have selected items, then we simply return them.
|
||||||
|
if m.numSelected < 1 {
|
||||||
m.items[m.index].selected = true
|
m.items[m.index].selected = true
|
||||||
}
|
}
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
|
|
|
@ -10,9 +10,9 @@ type Options struct {
|
||||||
NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"`
|
NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"`
|
||||||
Height int `help:"Height of the list" default:"10"`
|
Height int `help:"Height of the list" default:"10"`
|
||||||
Cursor string `help:"Prefix to show on item that corresponds to the cursor position" default:"> "`
|
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:"• "`
|
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:"✕ "`
|
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:" "`
|
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"`
|
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"`
|
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"`
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"github.com/muesli/termenv"
|
"github.com/muesli/termenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var bubbleGumPink = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
lipgloss.SetColorProfile(termenv.ANSI256)
|
lipgloss.SetColorProfile(termenv.ANSI256)
|
||||||
gum := &Gum{}
|
gum := &Gum{}
|
||||||
ctx := kong.Parse(
|
ctx := kong.Parse(
|
||||||
gum,
|
gum,
|
||||||
kong.Name("gum"),
|
kong.Description(fmt.Sprintf("Tasty bubble %s for your shell.", bubbleGumPink.Render("gum"))),
|
||||||
kong.Description("Tasty Bubble Gum for your shell."),
|
|
||||||
kong.UsageOnError(),
|
kong.UsageOnError(),
|
||||||
kong.ConfigureHelp(kong.HelpOptions{
|
kong.ConfigureHelp(kong.HelpOptions{
|
||||||
Compact: true,
|
Compact: true,
|
||||||
|
|
Loading…
Reference in a new issue