internal

package
v0.0.0-...-408228c Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCancelled = errors.New("cancelled by user")

Functions

This section is empty.

Types

type Cursor

type Cursor interface {
	MoveCursorUp(lines int)
	MoveCursorDown(lines int)
	MoveCursorLeft(columns int)
	MoveCursorRight(columns int)
	MoveCursorToStartOfLine()
	HideCursor()
	ShowCursor()
}

Cursor is a base component for UX components that require cursor manipulation.

func NewCursor

func NewCursor(writer io.Writer) Cursor

type Input

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

Input is a base component for UX components that require user input.

func NewInput

func NewInput() *Input

NewInput creates a new Input instance.

func (*Input) ReadInput

func (i *Input) ReadInput(ctx context.Context, config *InputConfig, handler KeyPressEventHandler) error

ReadInput reads user input from the keyboard.

func (*Input) ResetValue

func (i *Input) ResetValue()

ResetValue resets the value of the input.

type InputConfig

type InputConfig struct {
	InitialValue   string
	IgnoreHintKeys bool
}

type KeyPressEventArgs

type KeyPressEventArgs struct {
	Value     string
	Char      rune
	Key       keyboard.Key
	Hint      bool
	Cancelled bool
}

type KeyPressEventHandler

type KeyPressEventHandler func(args *KeyPressEventArgs) (bool, error)

KeyPressEventHandler is a function type that handles key press events. Return true to continue listening for key presses, false to stop.

Jump to

Keyboard shortcuts

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