terminal

package
v0.0.0-...-db1d8bb Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Carrier

type Carrier interface {
	Send(context.Context, Event) error
	Recv(context.Context) (Event, error)
}

Carrier is implemented by WebSocket, TCP, stdio relay, or any other channel.

type Control

type Control interface {
	IsTerminal() bool
	Size() (cols, rows int)
	MakeRaw() (restore func(), err error)
	OnResize(func(cols, rows int)) func()
	Close() error
}

Control exposes optional terminal capabilities for a byte stream.

type Event

type Event struct {
	Type    EventType
	Data    []byte
	Cols    int
	Rows    int
	Message string
}

Event is the minimal frame shape for adapting arbitrary carriers.

type EventType

type EventType string

EventType is a transport-neutral terminal event.

const (
	EventData     EventType = "data"
	EventResize   EventType = "resize"
	EventRawEnter EventType = "raw.enter"
	EventRawExit  EventType = "raw.exit"
	EventClose    EventType = "close"
	EventError    EventType = "error"
)

type Remote

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

Remote owns a Terminal backed by a Carrier.

func NewRemote

func NewRemote(ctx context.Context, carrier Carrier, opts RemoteOptions) (*Remote, error)

NewRemote adapts any carrier into a Terminal.

func (*Remote) Close

func (r *Remote) Close() error

Close closes the remote terminal.

type RemoteOptions

type RemoteOptions struct {
	IsTerminal bool
	Cols       int
	Rows       int
}

RemoteOptions configures a carrier-backed terminal.

type StreamControl

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

StreamControl is a reusable in-memory terminal control implementation.

func NewControl

func NewControl(isTerminal bool, cols, rows int) *StreamControl

NewControl returns a mutable terminal control object.

func (*StreamControl) Close

func (c *StreamControl) Close() error

func (*StreamControl) IsTerminal

func (c *StreamControl) IsTerminal() bool

func (*StreamControl) MakeRaw

func (c *StreamControl) MakeRaw() (func(), error)

func (*StreamControl) OnResize

func (c *StreamControl) OnResize(fn func(int, int)) func()

func (*StreamControl) SetSize

func (c *StreamControl) SetSize(cols, rows int)

func (*StreamControl) Size

func (c *StreamControl) Size() (int, int)

type Terminal

type Terminal struct {
	In      io.Reader
	Out     io.Writer
	Err     io.Writer
	Control Control
}

Terminal is the transport-neutral IO boundary used by readline.

func Local

func Local() *Terminal

Local returns a Terminal backed by process stdin/stdout/stderr.

func Stream

func Stream(in io.Reader, out, err io.Writer, control Control) *Terminal

Stream returns a Terminal backed by arbitrary streams and optional control.

Jump to

Keyboard shortcuts

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