Documentation
¶
Index ¶
- Variables
- type Completer
- type Handler
- func (ib *Handler) AppendHistory(item string)
- func (ib *Handler) Clear()
- func (ib *Handler) ClearHighlight()
- func (ib *Handler) ClearHistory()
- func (ib *Handler) Cursor() (term.Coordinates, term.CursorStyle, bool)
- func (ib *Handler) Dimensions() (int, int)
- func (ib *Handler) Draw(w term.Writer)
- func (ib *Handler) Handle(ev term.Event) (exit, handled bool)
- func (ib *Handler) Height(width int) int
- func (ib *Handler) Reset()
- func (ib *Handler) Resize(width, height int)
- func (ib *Handler) Result() (string, error)
- func (ib *Handler) Selection() (string, bool)
- func (ib *Handler) SetAttr(attr term.Attributes) (ret term.Attributes)
- func (ib *Handler) SetHighlight(start, end int, attr term.Attributes)
- func (ib *Handler) SetHistory(items []string)
- func (ib *Handler) Text() string
- type Option
- func WithAttributes(attr term.Attributes) Option
- func WithCompleter(c Completer) Option
- func WithCtrlCAborts() Option
- func WithHistory(items []string) Option
- func WithPlaceholder(text string, cfg component.StringResponsiveConfig) Option
- func WithPlaceholderText(text string) Option
- func WithPrompt(prompt string) Option
- func WithRedact(redact bool) Option
- func WithRedactRune(r rune) Option
- func WithTabStyle(style TabStyle) Option
- func WithText(text string) Option
- func WithWordCompleter(c WordCompleter) Option
- type TabStyle
- type WordCompleter
Constants ¶
This section is empty.
Variables ¶
var ErrAborted = errors.New("aborted")
ErrAborted is returned by Result when input was cancelled via Ctrl+C.
Functions ¶
This section is empty.
Types ¶
type Completer ¶ added in v0.0.24
Completer returns completions for the entire line. It receives the line and returns the head (portion before completions), the candidates, and the tail (portion after completions).
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements a multi-line text input handler with wrapping, text selection, word-wise cursor movement, history navigation, reverse search, and tab completion. Note that text selection is limited by your terminal's ability to handle shift+arrow keys.
func (*Handler) AppendHistory ¶ added in v0.0.24
AppendHistory adds an item to the history.
func (*Handler) ClearHighlight ¶ added in v0.0.27
func (ib *Handler) ClearHighlight()
ClearHighlight removes any active highlight range.
func (*Handler) ClearHistory ¶ added in v0.0.24
func (ib *Handler) ClearHistory()
ClearHistory removes all history entries.
func (*Handler) Cursor ¶
func (ib *Handler) Cursor() (term.Coordinates, term.CursorStyle, bool)
Cursor satisfies tui.Handler
func (*Handler) Dimensions ¶ added in v0.0.35
Dimensions satisfies component.Floating. It returns the width needed to render the entire input box content on a single line (height is always 1).
func (*Handler) Height ¶
Height satisfies Responsive. Returns the number of lines needed to display all text content and cursor given the specified width.
func (*Handler) Reset ¶ added in v0.0.24
func (ib *Handler) Reset()
Reset clears the exit state for the next prompt.
func (*Handler) Result ¶ added in v0.0.24
Result returns the input text or an error if input was aborted or reached EOF.
func (*Handler) SetAttr ¶
func (ib *Handler) SetAttr(attr term.Attributes) (ret term.Attributes)
SetAttr satisfies WithAttributes.
func (*Handler) SetHighlight ¶ added in v0.0.27
func (ib *Handler) SetHighlight(start, end int, attr term.Attributes)
SetHighlight applies attr to the text range [start, end). The prompt and characters outside the range are unaffected.
func (*Handler) SetHistory ¶ added in v0.0.24
SetHistory replaces the history with items.
type Option ¶ added in v0.0.9
type Option func(*Handler)
Option configures a Handler.
func WithAttributes ¶ added in v0.0.9
func WithAttributes(attr term.Attributes) Option
WithAttributes defines the default input text attributes.
func WithCompleter ¶ added in v0.0.24
WithCompleter sets a line completer for tab completion.
func WithCtrlCAborts ¶ added in v0.0.24
func WithCtrlCAborts() Option
WithCtrlCAborts makes Ctrl+C abort the input (returning ErrAborted) instead of clearing the line.
func WithHistory ¶ added in v0.0.24
WithHistory pre-populates the history.
func WithPlaceholder ¶ added in v0.0.9
func WithPlaceholder(text string, cfg component.StringResponsiveConfig) Option
WithPlaceholder adds a placeholder when there's no text in the input box. The placeholder uses the provided StringResponsiveConfig for styling.
func WithPlaceholderText ¶ added in v0.0.9
WithPlaceholderText adds a placeholder with default gray styling.
func WithPrompt ¶ added in v0.0.24
WithPrompt sets the prompt string displayed before the input text on the first line.
func WithRedact ¶ added in v0.0.71
WithRedact enables redacted rendering: each character of the buffer is drawn as the default redaction glyph ('*'). The underlying buffer is kept intact: Text(), Result() and Selection() still return the real content. Useful for password / secret prompts.
Use WithRedactRune to override the glyph.
func WithRedactRune ¶ added in v0.0.71
WithRedactRune sets the rune used when redact rendering is enabled. Implies WithRedact(true). The zero rune resets to the default ('*').
func WithTabStyle ¶ added in v0.0.24
WithTabStyle sets the tab completion style.
func WithText ¶ added in v0.0.24
WithText pre-populates the input text and places the cursor at the end.
func WithWordCompleter ¶ added in v0.0.24
func WithWordCompleter(c WordCompleter) Option
WithWordCompleter sets a word completer for tab completion.