Documentation
¶
Index ¶
- Variables
- type EchoMode
- type InputMode
- 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 InputMode) *InputModeldeprecated
- func (m InputModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m InputModel) UseKeyEnter() bool
- func (m InputModel) UseKeyQ() bool
- func (m InputModel) View() string
- func (m *InputModel) WithEchoMode(mode EchoMode) *InputModel
- func (m *InputModel) WithInputMode(mode InputMode) *InputModel
- func (m *InputModel) WithValidateFunc(vf ValidateFunc) *InputModel
- type InputOption
- type ListHandler
- type ListStyle
- type Prompt
- func (p *Prompt) Ask(message string) *Prompt
- func (p Prompt) Choose(choices []string, opts ...choose.Option) (string, error)
- func (p Prompt) Init() tea.Cmd
- func (p Prompt) Input(defaultValue string, opts ...InputOption) (string, error)
- func (p Prompt) InputWithLimit(defaultValue string, inputLimit InputMode) (string, error)deprecated
- func (p Prompt) MultiChoose(choices []string, opts ...multichoose.Option) ([]string, error)
- func (p *Prompt) Run(pm PromptModel) (PromptModel, error)
- func (p *Prompt) SetHelpVisible(visible bool) *Promptdeprecated
- func (p *Prompt) SetModel(pm PromptModel) *Prompt
- func (p Prompt) TextArea(defaultValue string) (string, error)
- func (p Prompt) Toggle(choices []string) (string, error)
- func (p Prompt) ToggleWithStyle(choices []string, style *ListStyle) (string, error)
- func (p Prompt) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (p Prompt) View() string
- func (p *Prompt) WithHelp(enable bool) *Prompt
- func (p *Prompt) WithProgramOptions(opts ...tea.ProgramOption) *Prompt
- func (p *Prompt) WithTestView(initView *string, finalView *string) *Prompt
- type PromptModel
- type TextAreaModel
- func (m TextAreaModel) Data() any
- func (m TextAreaModel) DataString() string
- func (m TextAreaModel) Init() tea.Cmd
- func (m TextAreaModel) KeyBindings() []key.Binding
- func (m TextAreaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m TextAreaModel) UseKeyEnter() bool
- func (m TextAreaModel) UseKeyQ() bool
- func (m TextAreaModel) View() string
- type ToggleModeldeprecated
- func (m ToggleModel) Data() any
- func (m ToggleModel) DataString() string
- func (m ToggleModel) Init() tea.Cmd
- func (m ToggleModel) KeyBindings() []key.Binding
- func (m ToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m ToggleModel) UseKeyEnter() bool
- func (m ToggleModel) UseKeyQ() bool
- func (m ToggleModel) View() string
- type ValidateFunc
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")) DefaultErrorPromptPrefixStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) DefaultNormalPromptSuffixStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("6")) DefaultFinishPromptSuffixStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("6")) DefaultNoteStyle = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{ Light: "#909090", Dark: "#626262", }) DefaultItemStyle = lipgloss.NewStyle() DefaultSelectedItemStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) DefaultChoiceStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) )
var WithChooseTheme = choose.WithTheme
Functions ¶
This section is empty.
Types ¶
type EchoMode ¶ added in v0.5.0
const ( // EchoNormal displays text as is. This is the default behavior. EchoNormal EchoMode = textinput.EchoNormal // EchoPassword displays the EchoCharacter mask instead of actual // characters. This is commonly used for password fields. EchoPassword EchoMode = textinput.EchoPassword // EchoNone displays nothing as characters are entered. This is commonly // seen for password fields on the command line. EchoNone EchoMode = textinput.EchoNone )
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
deprecated
func (m *InputModel) SetInputLimit(inputLimit InputMode) *InputModel
Deprecated: use InputModel.WithInputMode instead.
func (InputModel) UseKeyEnter ¶ added in v0.4.0
func (m InputModel) UseKeyEnter() bool
func (InputModel) UseKeyQ ¶ added in v0.3.1
func (m InputModel) UseKeyQ() bool
func (InputModel) View ¶
func (m InputModel) View() string
func (*InputModel) WithEchoMode ¶ added in v0.5.0
func (m *InputModel) WithEchoMode(mode EchoMode) *InputModel
func (*InputModel) WithInputMode ¶ added in v0.5.0
func (m *InputModel) WithInputMode(mode InputMode) *InputModel
func (*InputModel) WithValidateFunc ¶ added in v0.5.0
func (m *InputModel) WithValidateFunc(vf ValidateFunc) *InputModel
type InputOption ¶ added in v0.5.0
type InputOption func(*InputModel)
func WithEchoMode ¶ added in v0.5.0
func WithEchoMode(mode EchoMode) InputOption
func WithInputMode ¶ added in v0.5.0
func WithInputMode(mode InputMode) InputOption
func WithValidateFunc ¶ added in v0.5.0
func WithValidateFunc(vf ValidateFunc) InputOption
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 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) Input ¶
func (p Prompt) Input(defaultValue string, opts ...InputOption) (string, error)
Input asks the user to enter a string.
func (Prompt) MultiChoose ¶
MultiChoose lets the user choose multiples from the given choices.
func (*Prompt) Run ¶
func (p *Prompt) Run(pm PromptModel) (PromptModel, error)
Run runs the program using the given model, blocking until the user chooses or exits.
func (*Prompt) SetHelpVisible
deprecated
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 ¶
ToggleWithStyle lets the user choose one of the given choices. Appearance uses the given style.
func (*Prompt) WithProgramOptions ¶ added in v0.4.0
func (p *Prompt) WithProgramOptions(opts ...tea.ProgramOption) *Prompt
WithProgramOptions sets the `tea.ProgramOption` passed when calling `tea.NewProgram`. This function is mainly used for testing, usually you don't need to use this function.
type PromptModel ¶
type TextAreaModel ¶ added in v0.4.0
type TextAreaModel struct {
// contains filtered or unexported fields
}
func NewTextAreaModel ¶ added in v0.4.0
func NewTextAreaModel(defaultValue string) *TextAreaModel
func (TextAreaModel) Data ¶ added in v0.4.0
func (m TextAreaModel) Data() any
func (TextAreaModel) DataString ¶ added in v0.4.0
func (m TextAreaModel) DataString() string
func (TextAreaModel) Init ¶ added in v0.4.0
func (m TextAreaModel) Init() tea.Cmd
func (TextAreaModel) KeyBindings ¶ added in v0.4.0
func (m TextAreaModel) KeyBindings() []key.Binding
func (TextAreaModel) UseKeyEnter ¶ added in v0.4.0
func (m TextAreaModel) UseKeyEnter() bool
func (TextAreaModel) UseKeyQ ¶ added in v0.4.0
func (m TextAreaModel) UseKeyQ() bool
func (TextAreaModel) View ¶ added in v0.4.0
func (m TextAreaModel) View() string
type ToggleModel
deprecated
type ToggleModel struct {
ListHandler
// contains filtered or unexported fields
}
Deprecated: use Choose([]string{}, WithTheme(ChooseThemeLine)) instead.
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) UseKeyEnter ¶ added in v0.4.0
func (m ToggleModel) UseKeyEnter() bool
func (ToggleModel) UseKeyQ ¶ added in v0.3.1
func (m ToggleModel) UseKeyQ() bool
func (ToggleModel) View ¶
func (m ToggleModel) View() string
type ValidateFunc ¶ added in v0.5.0
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
choose
command
|
|
|
choose-theme-arrow
command
|
|
|
choose-theme-line
command
|
|
|
choose-with-help
command
|
|
|
input
command
|
|
|
input-echo-none
command
|
|
|
input-echo-password
command
|
|
|
input-integer-only
command
|
|
|
input-number-only
command
|
|
|
input-with-help
command
|
|
|
input-with-validation
command
|
|
|
multichoose
command
|
|
|
multichoose-theme-dot
command
|
|
|
multichoose-with-help
command
|
|
|
textarea
command
|
|
|
textarea-with-help
command
|
|
|
toggle
command
|
|
|
toggle-with-help
command
|
|











