ui

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultValidateOkPrefix  = "✔"
	DefaultValidateErrPrefix = "✘"
	DefaultTextAreaMaxHeight = 5
	DefaultTextAreaHeight    = 2
	DefaultSelectWidth       = 20
	DefaultSelectHeight      = 12

	ColorPrompt = "2"
)
View Source
const (
	DefaultInputWidth = 20
)

Variables

This section is empty.

Functions

func DefaultValidateFunc

func DefaultValidateFunc(_ string) error

DefaultValidateFunc is a verification function that does nothing

func FontColor

func FontColor(text, color string) string

func GenMask

func GenMask(l int) string

GenMask generate a mask string of the specified length

func GenStr

func GenStr(l int, s string) string

GenStr generate a string of the specified length, the string is composed of the given characters

func Run added in v1.0.0

func Run(model tea.Model, noTTY bool) (tea.Model, error)

Types

type Choice

type Choice string

func (Choice) FilterValue

func (i Choice) FilterValue() string

type Choices

type Choices []Choice

type EchoMode

type EchoMode textinput.EchoMode

EchoMode sets the input behavior of the text input field. EchoMode is an alias for the textinput.EchoMode.

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 InputModel

type InputModel struct {
	// contains filtered or unexported fields
}

func NewInput

func NewInput(label string) *InputModel

func (*InputModel) Canceled

func (m *InputModel) Canceled() bool

Canceled determine whether the operation is cancelled

func (*InputModel) EchoMode

func (m *InputModel) EchoMode() textinput.EchoMode

EchoMode return the input EchoMode

func (*InputModel) Init

func (m *InputModel) Init() tea.Cmd

func (*InputModel) Update

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

func (*InputModel) Value

func (m *InputModel) Value() string

Value return the input string

func (*InputModel) View

func (m *InputModel) View() string

func (*InputModel) WithEchoMode

func (m *InputModel) WithEchoMode(mode EchoMode) *InputModel

func (*InputModel) WithPlaceholder

func (m *InputModel) WithPlaceholder(placeholder string) *InputModel

func (*InputModel) WithValidateErrPrefix

func (m *InputModel) WithValidateErrPrefix(prefix string) *InputModel

func (*InputModel) WithValidateFunc

func (m *InputModel) WithValidateFunc(fn func(string) error) *InputModel

func (*InputModel) WithValidateOkPrefix

func (m *InputModel) WithValidateOkPrefix(prefix string) *InputModel

func (*InputModel) WithWidth

func (m *InputModel) WithWidth(width int) *InputModel

type Model

type Model interface {
	tea.Model

	Value() string
	Canceled() bool
}

Model is an alias for the tea.Model.

type SelectModel

type SelectModel struct {
	// contains filtered or unexported fields
}

func NewSelect

func NewSelect(label string, choices Choices) *SelectModel

func (*SelectModel) Canceled

func (m *SelectModel) Canceled() bool

func (*SelectModel) Init

func (m *SelectModel) Init() tea.Cmd

func (*SelectModel) Update

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

func (*SelectModel) Value

func (m *SelectModel) Value() string

func (*SelectModel) View

func (m *SelectModel) View() string

func (*SelectModel) WithHeight

func (m *SelectModel) WithHeight(height int) *SelectModel

func (*SelectModel) WithWidth

func (m *SelectModel) WithWidth(width int) *SelectModel

type TextAreaModel

type TextAreaModel struct {
	// contains filtered or unexported fields
}

func NewTextArea

func NewTextArea(label string) *TextAreaModel

func (*TextAreaModel) Canceled

func (m *TextAreaModel) Canceled() bool

Canceled determine whether the operation is cancelled

func (*TextAreaModel) Init

func (m *TextAreaModel) Init() tea.Cmd

func (*TextAreaModel) Update

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

func (*TextAreaModel) Value

func (m *TextAreaModel) Value() string

Value return the input string

func (*TextAreaModel) View

func (m *TextAreaModel) View() string

func (*TextAreaModel) WithHeight

func (m *TextAreaModel) WithHeight(height int) *TextAreaModel

func (*TextAreaModel) WithMaxHeight

func (m *TextAreaModel) WithMaxHeight(height int) *TextAreaModel

func (*TextAreaModel) WithPlaceholder

func (m *TextAreaModel) WithPlaceholder(placeholder string) *TextAreaModel

func (*TextAreaModel) WithValidateErrPrefix

func (m *TextAreaModel) WithValidateErrPrefix(prefix string) *TextAreaModel

func (*TextAreaModel) WithValidateFunc

func (m *TextAreaModel) WithValidateFunc(fn func(string) error) *TextAreaModel

func (*TextAreaModel) WithValidateOkPrefix

func (m *TextAreaModel) WithValidateOkPrefix(prefix string) *TextAreaModel

func (*TextAreaModel) WithWidth

func (m *TextAreaModel) WithWidth(width int) *TextAreaModel

Jump to

Keyboard shortcuts

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