Documentation ¶
Index ¶
- Constants
- Variables
- func Done() tea.Msg
- func FontColor(str, color string) string
- func GenMask(l int) string
- func GenStr(l int, s string) string
- func Styler(attrs ...attribute) func(interface{}) string
- func VFDoNothing(_ string) error
- func VFNotBlank(s string) error
- type Confirm
- type ConfirmConfig
- type EchoMode
- type Model
Constants ¶
const ( DefaultErrorMsgPrefix = "✘" // DefaultGoodPrompt = "✔" //DefaultPrompt = "" DefaultConfirmPrompt = "?" )
const ( FGBold attribute FGFaint FGItalic FGUnderline )
Foreground weight/decoration attributes.
const ( FGBlack attribute = iota + 30 FGRed FGGreen FGYellow FGBlue FGMagenta FGCyan FGWhite )
Foreground color attributes
const ( BGBlack attribute = iota + 40 BGRed BGGreen BGYellow BGBlue BGMagenta BGCyan BGWhite )
Background color attributes
const ( //DefaultPrompt = "Please Input: " DefaultPrompt = "?" DefaultValidateOkPrefix = "✔" DefaultValidateErrPrefix = "✘" ColorPrompt = "2" )
const DONE = "DONE"
Variables ¶
var FuncMap = template.FuncMap{ "black": Styler(FGBlack), "red": Styler(FGRed), "green": Styler(FGGreen), "yellow": Styler(FGYellow), "blue": Styler(FGBlue), "magenta": Styler(FGMagenta), "cyan": Styler(FGCyan), "white": Styler(FGWhite), "bgBlack": Styler(BGBlack), "bgRed": Styler(BGRed), "bgGreen": Styler(BGGreen), "bgYellow": Styler(BGYellow), "bgBlue": Styler(BGBlue), "bgMagenta": Styler(BGMagenta), "bgCyan": Styler(BGCyan), "bgWhite": Styler(BGWhite), "bold": Styler(FGBold), "faint": Styler(FGFaint), "italic": Styler(FGItalic), "underline": Styler(FGUnderline), }
FuncMap defines template helpers for the output. It can be extended as a regular map.
var ResetCode = fmt.Sprintf("%s%dm", esc, reset)
ResetCode is the character code used to reset the terminal formatting
Functions ¶
func GenStr ¶
GenStr generate a string of the specified length, the string is composed of the given characters
func Styler ¶
func Styler(attrs ...attribute) func(interface{}) string
Styler returns a func that applies the attributes given in the Styler call to the provided string.
func VFDoNothing ¶
VFDoNothing is a verification function that does nothing
func VFNotBlank ¶
VFNotBlank is a verification function that checks whether the input is empty
Types ¶
type Confirm ¶
type Confirm struct { ConfirmConfig Message string Prompt string FuncMap template.FuncMap // Default is the initial value for the confirm Default bool // contains filtered or unexported fields }
Confirm is a regular text input that accept yes/no answers. Response type is a bool.
func NewDefaultConfirm ¶
type ConfirmConfig ¶
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