Help us shape the future of Go! Take the 2026 Go Developer Survey

internal

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 10 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 FileReader added in v1.34.1

type FileReader interface {
	io.Reader
	Fd() uintptr
}

type FileWriter added in v1.34.1

type FileWriter interface {
	io.Writer
	Fd() uintptr
}

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(writers ...io.Writer) *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

	// Use these variables if you want to do unit testing.
	Stdin  FileReader // Optional; defaults to os.Stdin when nil.
	Stdout FileWriter // Optional; defaults to os.Stdout when nil.
	Stderr io.Writer  // Optional; defaults to os.Stderr when nil.
}

type KeyPressEventArgs

type KeyPressEventArgs struct {
	Value     string
	Char      rune
	Key       rune
	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