Documentation
¶
Index ¶
- Variables
- type ChooseModel
- type InputLimit
- type InputModel
- func (m InputModel) Data() any
- func (m InputModel) DataString() string
- func (m InputModel) Init() tea.Cmd
- func (m InputModel) KeyBindings() []key.Binding
- func (m *InputModel) SetInputLimit(inputLimit InputLimit) *InputModel
- func (m InputModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m InputModel) UseKeyQ() bool
- func (m InputModel) View() string
- type ListHandler
- type ListStyle
- type MultiChooseModel
- func (m MultiChooseModel) Data() any
- func (m MultiChooseModel) DataString() string
- func (m MultiChooseModel) Init() tea.Cmd
- func (m MultiChooseModel) KeyBindings() []key.Binding
- func (m MultiChooseModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m MultiChooseModel) UseKeyQ() bool
- func (m MultiChooseModel) View() string
- type Prompt
- func (p *Prompt) Ask(message string) *Prompt
- func (p Prompt) Choose(choices []string, opts ...tea.ProgramOption) (string, error)
- func (p Prompt) ChooseWithStyle(choices []string, style *ListStyle, opts ...tea.ProgramOption) (string, error)
- func (p Prompt) Init() tea.Cmd
- func (p Prompt) Input(defaultValue string, opts ...tea.ProgramOption) (string, error)
- func (p Prompt) InputWithLimit(defaultValue string, inputLimit InputLimit, opts ...tea.ProgramOption) (string, error)
- func (p Prompt) MultiChoose(choices []string, opts ...tea.ProgramOption) ([]string, error)
- func (p Prompt) MultiChooseWithStyle(choices []string, style *ListStyle, opts ...tea.ProgramOption) ([]string, error)
- func (p *Prompt) Run(pm PromptModel, opts ...tea.ProgramOption) (PromptModel, error)
- func (p *Prompt) SetHelpVisible(visible bool) *Prompt
- func (p *Prompt) SetModel(pm PromptModel) *Prompt
- func (p Prompt) Toggle(choices []string, opts ...tea.ProgramOption) (string, error)
- func (p Prompt) ToggleWithStyle(choices []string, style *ListStyle, opts ...tea.ProgramOption) (string, error)
- func (p Prompt) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (p Prompt) View() string
- type PromptModel
- type ToggleModel
Constants ¶
This section is empty.
Variables ¶
var ( ErrModelConversion = errors.New("model conversion failed") ErrUserQuit = errors.New("user quit prompt") )
var ( DefaultNormalPromptPrefix = "?" DefaultFinishPromptPrefix = "✔" DefaultNormalPromptSuffix = "›" DefaultFinishPromptSuffix = "…" DefaultNormalPromptPrefixStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) DefaultFinishPromptPrefixStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("10")) DefaultNormalPromptSuffixStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("6")) DefaultFinishPromptSuffixStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("6")) DefaultItemStyle = lipgloss.NewStyle() DefaultSelectedItemStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) DefaultChoiceStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) )
Functions ¶
This section is empty.
Types ¶
type ChooseModel ¶
type ChooseModel struct {
ListHandler
// contains filtered or unexported fields
}
func NewChooseModel ¶
func NewChooseModel(choices []string) *ChooseModel
func NewChooseModelWithStyle ¶
func NewChooseModelWithStyle(choices []string, style *ListStyle) *ChooseModel
func (ChooseModel) Data ¶
func (m ChooseModel) Data() any
func (ChooseModel) DataString ¶
func (m ChooseModel) DataString() string
func (ChooseModel) Init ¶
func (m ChooseModel) Init() tea.Cmd
func (ChooseModel) KeyBindings ¶
func (m ChooseModel) KeyBindings() []key.Binding
func (ChooseModel) UseKeyQ ¶ added in v0.3.1
func (m ChooseModel) UseKeyQ() bool
func (ChooseModel) View ¶
func (m ChooseModel) View() string
type InputLimit ¶
type InputLimit int
const ( InputAll InputLimit = iota // allow any input. InputInteger // only integers can be entered. InputNumber // only integers and decimals can be entered. )
type InputModel ¶
type InputModel struct {
ItemStyle lipgloss.Style
SelectedItemStyle lipgloss.Style
ChoiceStyle lipgloss.Style
// contains filtered or unexported fields
}
func NewInputModel ¶
func NewInputModel(defaultValue string) *InputModel
func (InputModel) Data ¶
func (m InputModel) Data() any
func (InputModel) DataString ¶
func (m InputModel) DataString() string
func (InputModel) Init ¶
func (m InputModel) Init() tea.Cmd
func (InputModel) KeyBindings ¶
func (m InputModel) KeyBindings() []key.Binding
func (*InputModel) SetInputLimit ¶
func (m *InputModel) SetInputLimit(inputLimit InputLimit) *InputModel
func (InputModel) UseKeyQ ¶ added in v0.3.1
func (m InputModel) UseKeyQ() bool
func (InputModel) View ¶
func (m InputModel) View() string
type ListHandler ¶
type ListHandler struct {
// contains filtered or unexported fields
}
func NewListHandler ¶
func NewListHandler(choiceCount int, style *ListStyle) *ListHandler
func (ListHandler) Cursor ¶
func (h ListHandler) Cursor() int
func (*ListHandler) MoveNext ¶
func (h *ListHandler) MoveNext()
func (*ListHandler) MovePrev ¶
func (h *ListHandler) MovePrev()
func (ListHandler) Style ¶
func (h ListHandler) Style() *ListStyle
type ListStyle ¶
type ListStyle struct {
ItemStyle lipgloss.Style
SelectedItemStyle lipgloss.Style
ChoiceStyle lipgloss.Style
}
func NewListStyle ¶
func NewListStyle() *ListStyle
type MultiChooseModel ¶
type MultiChooseModel struct {
ListHandler
// contains filtered or unexported fields
}
func NewMultiChooseModel ¶
func NewMultiChooseModel(choices []string) *MultiChooseModel
func NewMultiChooseModelWithStyle ¶
func NewMultiChooseModelWithStyle(choices []string, style *ListStyle) *MultiChooseModel
func (MultiChooseModel) Data ¶
func (m MultiChooseModel) Data() any
func (MultiChooseModel) DataString ¶
func (m MultiChooseModel) DataString() string
func (MultiChooseModel) Init ¶
func (m MultiChooseModel) Init() tea.Cmd
func (MultiChooseModel) KeyBindings ¶
func (m MultiChooseModel) KeyBindings() []key.Binding
func (MultiChooseModel) UseKeyQ ¶ added in v0.3.1
func (m MultiChooseModel) UseKeyQ() bool
func (MultiChooseModel) View ¶
func (m MultiChooseModel) View() string
type Prompt ¶
type Prompt struct {
// Style
Message string
NormalPrefix string
FinishPrefix string
NormalSuffix string
FinishSuffix string
PrefixStyle lipgloss.Style
FinishPrefixStyle lipgloss.Style
SuffixStyle lipgloss.Style
FinishSuffixStyle lipgloss.Style
// contains filtered or unexported fields
}
func (Prompt) Choose ¶
Choose lets the user choose one of the given choices. Appearance uses the default style.
func (Prompt) ChooseWithStyle ¶
func (p Prompt) ChooseWithStyle(choices []string, style *ListStyle, opts ...tea.ProgramOption) (string, error)
ChooseWithStyle lets the user choose one of the given choices. Appearance uses the given style.
func (Prompt) Input ¶
Input asks the user to enter a string. You can use InputWithLimit to limit what the user can enter.
func (Prompt) InputWithLimit ¶
func (p Prompt) InputWithLimit(defaultValue string, inputLimit InputLimit, opts ...tea.ProgramOption) (string, error)
Input asks the user to enter a string. It restricts the types of characters the user can enter.
func (Prompt) MultiChoose ¶
MultiChoose lets the user choose multiples from the given choices. Appearance uses the default style.
func (Prompt) MultiChooseWithStyle ¶
func (p Prompt) MultiChooseWithStyle(choices []string, style *ListStyle, opts ...tea.ProgramOption) ([]string, error)
MultiChooseWithStyle lets the user choose one of the given choices. Appearance uses the given style.
func (*Prompt) Run ¶
func (p *Prompt) Run(pm PromptModel, opts ...tea.ProgramOption) (PromptModel, error)
Run runs the program using the given model, blocking until the user chooses or exits.
func (*Prompt) SetHelpVisible ¶
SetHelpVisible sets whether the help of the keymap is visible
func (*Prompt) SetModel ¶
func (p *Prompt) SetModel(pm PromptModel) *Prompt
SetModel sets the model used by the prompt. In most cases you won't need to use this.
func (Prompt) Toggle ¶
Toggle lets the user choose one of the given choices. Appearance uses the default style.
func (Prompt) ToggleWithStyle ¶
func (p Prompt) ToggleWithStyle(choices []string, style *ListStyle, opts ...tea.ProgramOption) (string, error)
ToggleWithStyle lets the user choose one of the given choices. Appearance uses the given style.
type PromptModel ¶
type ToggleModel ¶
type ToggleModel struct {
ListHandler
// contains filtered or unexported fields
}
func NewToggleModel ¶
func NewToggleModel(choices []string) *ToggleModel
func NewToggleModelWithStyle ¶
func NewToggleModelWithStyle(choices []string, style *ListStyle) *ToggleModel
func (ToggleModel) Data ¶
func (m ToggleModel) Data() any
func (ToggleModel) DataString ¶
func (m ToggleModel) DataString() string
func (ToggleModel) Init ¶
func (m ToggleModel) Init() tea.Cmd
func (ToggleModel) KeyBindings ¶
func (m ToggleModel) KeyBindings() []key.Binding
func (ToggleModel) UseKeyQ ¶ added in v0.3.1
func (m ToggleModel) UseKeyQ() bool
func (ToggleModel) View ¶
func (m ToggleModel) View() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
choose
command
|
|
|
choose-with-help
command
|
|
|
input
command
|
|
|
input-with-help
command
|
|
|
multichoose
command
|
|
|
multichoose-with-help
command
|
|
|
toggle
command
|
|
|
toggle-with-help
command
|




