text

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QuitTextStyle = lipgloss.NewStyle().Margin(1, 0, 2, 4)
)

Functions

This section is empty.

Types

type Model

type Model struct {
	// Style configures the style applied to all rendering for the prompt. This can be used to apply padding and borders.
	Style lipgloss.Style

	// ErrStyle configures the style applied to error messages.
	ErrStyle lipgloss.Style

	// Quitting indicates whether the prompt has been canceled.
	Quitting bool
	// contains filtered or unexported fields
}

Model is text model for bubble tea.

func NewTextModel

func NewTextModel(prompt string, options TextModelOptions) Model

NewTextModel creates a new Model struct with a textinput field, a prompt string, and options for the textinput field such as placeholder and echo mode, and sets the default style and error style for the Model.

func (Model) GetValue

func (m Model) GetValue() string

GetValue returns the input from the user, or the default value if the user did not enter anything.

func (Model) Init

func (m Model) Init() tea.Cmd

Init returns initial tea command for text input.

func (Model) Update

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

Update handles user input and errors, and returns a Model and a Cmd. It handles KeyEnter, KeyCtrlC, and KeyEsc, and sets the valueEntered and Quitting flags accordingly. It also handles errors by setting the err field in the Model.

func (Model) View

func (m Model) View() string

View renders a view with user selected value.

type TextModelOptions

type TextModelOptions struct {
	// Default sets a default value for the user input.
	Default string

	// Placeholder sets a placeholder for the user input.
	Placeholder string

	// Validate defines a validator for the user input.
	Validate func(string) error

	// EchoMode indicates the input behavior of the text input field (e.g. password).
	EchoMode textinput.EchoMode
}

TextModelOptions contains options for the text model.

Jump to

Keyboard shortcuts

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