terminal

package
v0.0.0-...-7e3db83 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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