prompt

package
v0.0.0-...-cb7a572 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultPrompt            = "Please Input: "
	DefaultValidateOkPrefix  = "✔"
	DefaultValidateErrPrefix = "✘"

	ColorPrompt = "2"
)

Variables

This section is empty.

Functions

func VFDoNothing

func VFDoNothing(_ string) error

VFDoNothing is a verification function that does nothing

func VFNotBlank

func VFNotBlank(s string) error

VFNotBlank is a verification function that checks whether the input is empty

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
)

copy from textinput.Model

type Model

type Model struct {
	// 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

	// Prompt is the prefix of the prompt library, the user needs to define
	// the format(including spaces)
	Prompt string

	// ValidateFunc is a "real-time verification" function, which verifies
	// whether the terminal input data is legal in real time
	ValidateFunc func(string) error

	// ValidateOkPrefix is the prompt prefix when the validation fails
	ValidateOkPrefix string

	// ValidateErrPrefix is the prompt prefix when the verification is successful
	ValidateErrPrefix string

	// EchoMode sets the input behavior of the text input field.
	EchoMode EchoMode
	// contains filtered or unexported fields
}

Model is a data container used to store TUI status information, the ui rendering success style is as follows:

✔ Please Input: aaaa

func (Model) Canceled

func (m Model) Canceled() bool

Canceled determine whether the operation is cancelled

func (*Model) Update

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

Update method responds to various events and modifies the data model according to the corresponding events

func (Model) Value

func (m Model) Value() string

Value return the input string

func (Model) View

func (m Model) View() string

View reads the data state of the data model for rendering

Jump to

Keyboard shortcuts

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