textinput

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 6 Imported by: 902

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blink(model Model) tea.Cmd

Blink is a command used to time the cursor blinking.

func View

func View(model tea.Model) string

View renders the textinput in its current state.

Types

type BlinkMsg

type BlinkMsg struct{}

BlinkMsg is sent when the cursor should alternate it's blinking state.

type ErrMsg

type ErrMsg error

ErrMsg indicates there's been an error. We don't handle errors in the this package; we're expecting errors to be handle in the program that implements this text input.

type Model

type Model struct {
	Err              error
	Prompt           string
	Cursor           string
	BlinkSpeed       time.Duration
	Placeholder      string
	TextColor        string
	BackgroundColor  string
	PlaceholderColor string
	CursorColor      string

	// 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 Tea model for this text input element.

func NewModel

func NewModel() Model

NewModel creates a new model with default settings.

func Update

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

Update is the Tea update loop.

func (*Model) Blur

func (m *Model) Blur()

Blur removes the focus state on the model.

func (*Model) CursorEnd

func (m *Model) CursorEnd()

CursorEnd moves the cursor to the end of the field.

func (*Model) CursorStart

func (m *Model) CursorStart()

CursorStart moves the cursor to the start of the field.

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()

Reset sets the input to its default state with no input.

func (*Model) SetCursor

func (m *Model) SetCursor(pos int)

Cursor 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.

func (*Model) SetValue

func (m *Model) SetValue(s string)

SetValue sets the value of the text input.

func (Model) Value

func (m Model) Value() string

Value returns the value of the text input.

Jump to

Keyboard shortcuts

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