Documentation ¶
Index ¶
- func Blink() tea.Msg
- func Paste() tea.Msg
- type EchoMode
- type KeyMap
- type Model
- func (m *Model) AvailableSuggestions() []string
- func (m *Model) Blur()
- func (m *Model) CurrentSuggestion() string
- func (m *Model) CurrentSuggestionIndex() int
- func (m *Model) CursorEnd()
- func (m *Model) CursorStart()
- func (m *Model) Focus() tea.Cmd
- func (m Model) Focused() bool
- func (m *Model) MatchedSuggestions() []string
- func (m Model) Position() int
- func (m *Model) Reset()
- func (m *Model) SetCursor(pos int)
- func (m *Model) SetSuggestions(suggestions []string)
- func (m *Model) SetValue(s string)
- func (m *Model) SetWidth(w int)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) Value() string
- func (m Model) View() string
- func (m Model) Width() int
- type ValidateFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EchoMode ¶
type EchoMode int
EchoMode sets the input behavior of the text input field.
const ( // EchoNormal displays text as is. This is the default behavior. EchoNormal EchoMode = iota // EchoPassword displays the EchoCharacter mask instead of actual // characters. This is commonly used for password fields. EchoPassword // EchoNone displays nothing as characters are entered. This is commonly // seen for password fields on the command line. EchoNone )
type KeyMap ¶
type KeyMap struct { CharacterForward key.Binding CharacterBackward key.Binding WordForward key.Binding WordBackward key.Binding DeleteWordBackward key.Binding DeleteWordForward key.Binding DeleteAfterCursor key.Binding DeleteBeforeCursor key.Binding DeleteCharacterBackward key.Binding DeleteCharacterForward key.Binding LineStart key.Binding LineEnd key.Binding Paste key.Binding AcceptSuggestion key.Binding NextSuggestion key.Binding PrevSuggestion key.Binding }
KeyMap is the key bindings for different actions within the textinput.
func DefaultKeyMap ¶
func DefaultKeyMap() KeyMap
DefaultKeyMap is the default set of key bindings for navigating and acting upon the textinput.
type Model ¶
type Model struct { Err error // General settings. Prompt string Placeholder string EchoMode EchoMode EchoCharacter rune Cursor cursor.Model // Styles. These will be applied as inline styles. // // For an introduction to styling with Lip Gloss see: // https://github.com/charmbracelet/lipgloss PromptStyle lipgloss.Style TextStyle lipgloss.Style PlaceholderStyle lipgloss.Style CompletionStyle lipgloss.Style // CharLimit is the maximum amount of characters this input element will // accept. If 0 or less, there's no limit. CharLimit int // KeyMap encodes the keybindings recognized by the widget. KeyMap KeyMap // Validate is a function that checks whether or not the text within the // input is valid. If it is not valid, the `Err` field will be set to the // error returned by the function. If the function is not defined, all // input is considered valid. Validate ValidateFunc // Should the input suggest to complete ShowSuggestions bool // contains filtered or unexported fields }
Model is the Bubble Tea model for this text input element.
func (*Model) AvailableSuggestions ¶
AvailableSuggestions returns the list of available suggestions.
func (*Model) Blur ¶
func (m *Model) Blur()
Blur removes the focus state on the model. When the model is blurred it can not receive keyboard input and the cursor will be hidden.
func (*Model) CurrentSuggestion ¶
CurrentSuggestion returns the currently selected suggestion.
func (*Model) CurrentSuggestionIndex ¶
CurrentSuggestion returns the currently selected suggestion index.
func (*Model) CursorEnd ¶
func (m *Model) CursorEnd()
CursorEnd moves the cursor to the end of the input field.
func (*Model) CursorStart ¶
func (m *Model) CursorStart()
CursorStart moves the cursor to the start of the input field.
func (*Model) Focus ¶
Focus sets the focus state on the model. When the model is in focus it can receive keyboard input and the cursor will be shown.
func (*Model) MatchedSuggestions ¶
MatchedSuggestions returns the list of matched suggestions.
func (*Model) Reset ¶
func (m *Model) Reset()
Reset sets the input to its default state with no input.
func (*Model) SetCursor ¶
SetCursor moves the cursor to the given position. If the position is out of bounds the cursor will be moved to the start or end accordingly.
func (*Model) SetSuggestions ¶
SetSuggestions sets the suggestions for the input.
type ValidateFunc ¶
ValidateFunc is a function that returns an error if the input is invalid.