fix: choose prefixes and pink gum text

This commit is contained in:
Maas Lalani 2022-07-14 10:37:22 -04:00
parent 0f4b98c2ad
commit 5a1195dda5
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000
3 changed files with 12 additions and 8 deletions

View file

@ -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

View file

@ -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"`

View file

@ -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,