prompt

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blanked added in v0.4.0

func Blanked(src []byte) ([]byte, []byte)

Blanked displays nothing.

func CaretNotation

func CaretNotation(src []byte) ([]byte, []byte)

CaretNotation displays control characters in caret notation.

func Masked

func Masked(src []byte) ([]byte, []byte)

Masked displays all characters as asterisks.

Types

type SignalError

type SignalError syscall.Signal

SignalError indicates that the operation was interrupted by a signal.

func (SignalError) Error

func (se SignalError) Error() string

func (SignalError) Signal

func (se SignalError) Signal() int

Signal returns the signal number.

type Terminal added in v0.4.0

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

Terminal represents a terminal.

func NewTerminal added in v0.4.0

func NewTerminal() (*Terminal, error)

NewTerminal opens a terminal.

func (*Terminal) Close added in v0.4.0

func (t *Terminal) Close() error

Close closes the terminal.

func (*Terminal) ContextReader added in v0.5.0

func (t *Terminal) ContextReader(ctx context.Context) (io.ReadCloser, error)

ContextReader returns an io.ReadCloser that cancels the Read operation when context's Done channel is closed.

func (*Terminal) GetSize added in v0.5.0

func (t *Terminal) GetSize() (width, height int, err error)

GetSize returns the visible dimensions of the given terminal.

func (*Terminal) MakeRaw added in v0.4.0

func (t *Terminal) MakeRaw() error

MakeRaw puts the terminal into raw mode.

func (*Terminal) Read added in v0.4.0

func (t *Terminal) Read(p []byte) (int, error)

Read reads up to len(p) bytes from the terminal.

func (*Terminal) ReadCustom added in v0.5.0

func (t *Terminal) ReadCustom(ctx context.Context, prompt string, transform TransformFunc) ([]byte, error)

ReadCustom reads a line of input from the terminal with custom transform function.

func (*Terminal) ReadLine added in v0.5.0

func (t *Terminal) ReadLine(ctx context.Context, prompt string) ([]byte, error)

ReadLine reads a line of input from the terminal.

func (*Terminal) ReadNoEcho added in v0.4.0

func (t *Terminal) ReadNoEcho(ctx context.Context, prompt string) ([]byte, error)

ReadNoEcho reads a line of input from the terminal without local echo.

func (*Terminal) ReadPassword added in v0.4.0

func (t *Terminal) ReadPassword(ctx context.Context, prompt string) ([]byte, error)

ReadPassword reads a line of input from the terminal with masking.

func (*Terminal) Restore added in v0.4.0

func (t *Terminal) Restore() error

Restore restores the terminal to the state prior to calling MakeRaw.

func (*Terminal) Write added in v0.4.0

func (t *Terminal) Write(p []byte) (int, error)

Write writes len(p) bytes to the terminal.

type TransformFunc added in v0.4.0

type TransformFunc func(src []byte) (disp, bs []byte)

TransformFunc transforms src into its display form and a sequence of backspaces for deleting it.

Jump to

Keyboard shortcuts

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