Documentation
¶
Overview ¶
Package widget provides configurable prompt types used with [inquire.Query].
Configure widgets in the more callback passed to inquire.Session methods:
inquire.Query().Input(&name, "your name", func(w *widget.Input) {
w.Valid(func(s string) string { ... })
})
Conditional prompts use Base.When with WhenEqual predicates.
Index ¶
- func CompleteFrom(candidates []string) func(prefix string) []string
- func PollKey(ctx context.Context, scr *termui.Screen, band *termui.Band, repaint func()) (termui.Event, error)
- func WhenEqual[T comparable](ptr *T, want T) func() bool
- type AnyKey
- type Base
- type Editor
- func (e *Editor) Backspace()
- func (e *Editor) CursorCol(startX int) int
- func (e *Editor) DeleteForward()
- func (e *Editor) Draw(band *termui.Band, y, startX int)
- func (e *Editor) End()
- func (e *Editor) Home()
- func (e *Editor) Insert(r rune)
- func (e *Editor) KillToEnd()
- func (e *Editor) KillWordBackward()
- func (e *Editor) Left()
- func (e *Editor) Right()
- func (e *Editor) SetMask(ch rune)
- func (e *Editor) SetString(s string)
- func (e *Editor) String() string
- type Input
- func (w *Input) Complete(fn func(prefix string) []string) *Input
- func (w *Input) Hint(h string) *Input
- func (w *Input) MaskInput(ch ...rune) *Input
- func (w *Input) Run(ctx context.Context, scr *termui.Screen) error
- func (w *Input) Valid(fn func(string) string) *Input
- func (w *Input) When(fn func() bool) *Input
- type Menu
- type Note
- type Runner
- type Select
- type YesNo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompleteFrom ¶ added in v2.1.0
CompleteFrom returns a prefix matcher over fixed candidates (case-insensitive).
func PollKey ¶
func PollKey(ctx context.Context, scr *termui.Screen, band *termui.Band, repaint func()) (termui.Event, error)
PollKey waits for a key event, repainting the band after terminal resize.
func WhenEqual ¶
func WhenEqual[T comparable](ptr *T, want T) func() bool
WhenEqual returns a predicate that is true when *ptr equals want. Use with Base.When or widget When methods:
w.When(WhenEqual(&quest, "nuts"))
Types ¶
type AnyKey ¶
type AnyKey struct {
Base
// contains filtered or unexported fields
}
AnyKey waits for any key before continuing.
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base holds shared widget configuration.
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor is a rune-safe single-line text editor.
func (*Editor) Backspace ¶
func (e *Editor) Backspace()
Backspace removes the rune before the cursor.
func (*Editor) DeleteForward ¶
func (e *Editor) DeleteForward()
DeleteForward removes the rune at the cursor.
func (*Editor) KillToEnd ¶
func (e *Editor) KillToEnd()
KillToEnd removes text from the cursor through the end of the line.
func (*Editor) KillWordBackward ¶
func (e *Editor) KillWordBackward()
KillWordBackward removes the word (readline-style) before the cursor.
type Input ¶
type Input struct {
Base
// contains filtered or unexported fields
}
Input is a single-line text prompt.
func (*Input) Complete ¶ added in v2.1.0
Complete registers tab-completion candidates for the text before the cursor. Ignored when MaskInput is set. Use CompleteFrom for a static candidate list.
type Menu ¶
type Menu struct {
Base
// contains filtered or unexported fields
}
Menu is a vertical single-select prompt.
type Note ¶
type Note struct {
Base
// contains filtered or unexported fields
}
Note is a non-interactive message printed before the next prompt.
func NewNote ¶
NewNote constructs a Note with the given text. Use embedded newlines for multiple lines.
type Select ¶
type Select struct {
Base
// contains filtered or unexported fields
}
Select is a vertical multi-select checkbox prompt.
type YesNo ¶
type YesNo struct {
Base
// contains filtered or unexported fields
}
YesNo is a yes/no toggle prompt.