text

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(i *Text)

func WithBackgroundStyle

func WithBackgroundStyle(style *style.Style) Option

WithBackgroundStyle set the background style

func WithBlinkSpeed

func WithBlinkSpeed(blinkSpeed time.Duration) Option

WithBlinkSpeed set the blink speed

func WithCharLimit

func WithCharLimit(charLimit int) Option

WithCharLimit is the maximum amount of characters this input element will accept. If 0 or less, there's no limit.

func WithCursorStyle

func WithCursorStyle(style *style.Style) Option

WithCursorStyle set the cursor style

func WithDefaultValue

func WithDefaultValue(s string) Option

WithDefaultValue set the default value

func WithDefaultValueStyle

func WithDefaultValueStyle(style *style.Style) Option

WithDefaultValueStyle set the default value style

func WithDisableOutputResult

func WithDisableOutputResult() Option

WithDisableOutputResult disable output result

func WithEchoNone

func WithEchoNone() Option

WithEchoNone set echoMode use components.EchoNone. displays nothing as characters are entered

func WithEchoPassword

func WithEchoPassword(maskedSymbol ...rune) Option

WithEchoPassword set echoMode use components.EchoPassword. if maskedSymbol is not empty, then set EchoCharacter use maskedSymbol[0]

func WithFocusInterval

func WithFocusInterval(s string) Option

WithFocusInterval default is theme.DefaultTheme#FocusInterval

func WithFocusIntervalStyle

func WithFocusIntervalStyle(s *style.Style) Option

WithFocusIntervalStyle default is theme.DefaultTheme#FocusIntervalStyle

func WithFocusSymbol

func WithFocusSymbol(s string) Option

WithFocusSymbol default is theme.DefaultTheme#FocusSymbol

func WithFocusSymbolStyle

func WithFocusSymbolStyle(s *style.Style) Option

WithFocusSymbolStyle default is theme.DefaultTheme#FocusSymbolStyle

func WithKeyMap

func WithKeyMap(keymap components.InputKeyMap) Option

WithKeyMap replace keymap

components.InputDefaultKeyMap

func WithPrompt

func WithPrompt(prompt string) Option

WithPrompt set the prompt

func WithPromptStyle

func WithPromptStyle(style *style.Style) Option

WithPromptStyle set the prompt style

func WithPure

func WithPure() Option

WithPure do not use any beautification features, any options you customize will be cleared

func WithRequired

func WithRequired() Option

WithRequired must input some words.

func WithRequiredMsg

func WithRequiredMsg(msg string) Option

WithRequiredMsg if there is no input, the `msg` will be prompted

components.InputDefaultRequiredMsg

func WithRequiredMsgKeepAliveTime

func WithRequiredMsgKeepAliveTime(keepaliveTime time.Duration) Option

WithRequiredMsgKeepAliveTime set `requiredMsg` keep alive time.

components.InputDefaultRequiredMsgKeepTime

func WithTextStyle

func WithTextStyle(style *style.Style) Option

WithTextStyle set the text style

func WithUnFocusInterval

func WithUnFocusInterval(s string) Option

WithUnFocusInterval default is theme.DefaultTheme#UnFocusInterval

func WithUnFocusIntervalStyle

func WithUnFocusIntervalStyle(s *style.Style) Option

WithUnFocusIntervalStyle default is theme.DefaultTheme#UnFocusIntervalStyle

func WithUnFocusSymbol

func WithUnFocusSymbol(s string) Option

WithUnFocusSymbol default is theme.DefaultTheme#UnFocusSymbol

func WithUnFocusSymbolStyle

func WithUnFocusSymbolStyle(s *style.Style) Option

WithUnFocusSymbolStyle default is theme.DefaultTheme#UnFocusIntervalStyle

type Text

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

func New

func New(ops ...Option) *Text

func (*Text) Apply

func (i *Text) Apply(ops ...Option) *Text

Apply options on Text

func (i *Text) Blink() bool

Blink returns whether or not to draw the cursor.

func (*Text) Blur

func (i *Text) Blur()

Blur removes the Focus state on the model. When the model is blurred it can not receive keyboard input and the cursor will be hidden.

func (*Text) Cursor

func (i *Text) Cursor() int

Cursor returns the cursor position.

func (*Text) CursorEnd

func (i *Text) CursorEnd()

CursorEnd moves the cursor to the end of the input field.

func (*Text) CursorMode

func (i *Text) CursorMode() components.CursorMode

CursorMode returns the model's cursor mode. For available cursor modes, see type CursorMode.

func (*Text) CursorStart

func (i *Text) CursorStart()

CursorStart moves the cursor to the start of the input field.

func (*Text) Display

func (i *Text) Display() (string, error)

func (*Text) Focus

func (i *Text) Focus()

Focus sets the Focus state on the model. When the model is in Focus it can receive keyboard input and the cursor will be hidden.

func (*Text) Focused

func (i *Text) Focused() bool

Focused returns the focus state on the model.

func (*Text) Reset

func (i *Text) Reset()

Reset sets the input to its default state with no input. Returns whether or not the cursor blink should reset.

func (*Text) SetCursor

func (i *Text) SetCursor(pos int)

SetCursor 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 (*Text) SetCursorMode

func (i *Text) SetCursorMode(model components.CursorMode)

SetCursorMode sets the model's cursor mode. This method returns a command.

For available cursor modes, see type CursorMode.

func (*Text) Value

func (i *Text) 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