textinput

package
v0.7.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blink() tea.Msg

Blink is a command used to initialize cursor blinking.

func Paste

func Paste() tea.Msg

Paste is a command for pasting from the clipboard into the text input.

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 Model

type Model struct {
	Err error

	// General settings
	Prompt           string
	Placeholder      string
	Cursor           string
	BlinkSpeed       time.Duration
	TextColor        string
	BackgroundColor  string
	PlaceholderColor string
	CursorColor      string
	EchoMode         EchoMode
	EchoCharacter    rune

	// 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 NewModel

func NewModel() Model

NewModel creates a new model with default settings.

func (*Model) Blur

func (m *Model) Blur()

Blur removes the focus state on the model.

func (*Model) CursorEnd

func (m *Model) CursorEnd() bool

CursorEnd moves the cursor to the end of the field. Returns whether or not the cursor blink should be reset.

func (*Model) CursorStart

func (m *Model) CursorStart() bool

CursorStart moves the cursor to the start of the field. Returns whether or not the curosr blink should be reset.

func (*Model) Focus

func (m *Model) Focus()

Focus sets the focus state on the model.

func (Model) Focused

func (m Model) Focused() bool

Focused returns the focus state on the model.

func (*Model) Reset

func (m *Model) Reset() bool

Reset sets the input to its default state with no input. Returns whether or not the cursor blink should reset.

func (*Model) SetCursor

func (m *Model) SetCursor(pos int) bool

SetCursor start 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. Returns whether or nor the cursor timer should be reset.

func (*Model) SetValue

func (m *Model) SetValue(s string)

SetValue sets the value of the text input.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update is the Bubble Tea update loop.

func (Model) Value

func (m Model) Value() string

Value returns the value of the text input.

func (Model) View

func (m Model) View() string

View renders the textinput in its current state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL