Documentation
¶
Index ¶
- Variables
- func Blink() tea.Msg
- func Paste() tea.Msg
- type CursorMode
- type EchoMode
- type Model
- func (m Model) Blink() bool
- func (m *Model) Blur()
- func (m Model) Cursor() int
- func (m *Model) CursorEnd()
- func (m Model) CursorMode() CursorMode
- func (m *Model) CursorStart()
- func (m *Model) Focus() tea.Cmd
- func (m Model) Focused() bool
- func (m *Model) Reset() bool
- func (m *Model) SetCursor(pos int)
- func (m *Model) SetCursorMode(mode CursorMode) tea.Cmd
- func (m *Model) SetValue(s string)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) Value() string
- func (m Model) View() string
Constants ¶
This section is empty.
Variables ¶
var NewModel = New
NewModel creates a new model with default settings.
Deprecated. Use New instead.
Functions ¶
Types ¶
type CursorMode ¶ added in v0.8.0
type CursorMode int
CursorMode describes the behavior of the cursor.
const ( CursorBlink CursorMode = iota CursorStatic CursorHide )
Available cursor modes.
func (CursorMode) String ¶ added in v0.8.0
func (c CursorMode) String() string
String returns a the cursor mode in a human-readable format. This method is provisional and for informational purposes only.
type EchoMode ¶ added in v0.7.1
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 Model ¶
type Model struct {
Err error
// General settings.
Prompt string
Placeholder string
BlinkSpeed time.Duration
EchoMode EchoMode
EchoCharacter rune
// 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
BackgroundStyle lipgloss.Style
PlaceholderStyle lipgloss.Style
CursorStyle lipgloss.Style
// CharLimit is the maximum amount of characters this input element will
// accept. If 0 or less, there's no limit.
CharLimit int
// Width is the maximum number of characters that can be displayed at once.
// It essentially treats the text field like a horizontally scrolling
// viewport. If 0 or less this setting is ignored.
Width int
// contains filtered or unexported fields
}
Model is the Bubble Tea model for this text input element.
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) CursorEnd ¶
func (m *Model) CursorEnd()
CursorEnd moves the cursor to the end of the input field.
func (Model) CursorMode ¶ added in v0.8.0
func (m Model) CursorMode() CursorMode
CursorMode returns the model's cursor mode. For available cursor modes, see type CursorMode.
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 hidden.
func (*Model) Reset ¶
Reset sets the input to its default state with no input. Returns whether or not the cursor blink should reset.
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) SetCursorMode ¶ added in v0.8.0
func (m *Model) SetCursorMode(mode CursorMode) tea.Cmd
CursorMode sets the model's cursor mode. This method returns a command.
For available cursor modes, see type CursorMode.