Documentation
¶
Index ¶
- type AnswerbackTerminal
- type Attributes
- type Cell
- type Color
- type Connection
- type Connector
- type Cursor
- type CursorMatcherSpec
- type Key
- type KeyEncoder
- type KeyModifier
- type KeyPress
- type LineMatcherSpec
- type MatcherSpec
- type ModifiedKeyEncoder
- type Screen
- type ScreenMatcher
- type ScreenMatcherFunc
- type Server
- type Session
- func (s *Session) Close() error
- func (s *Session) Done() <-chan struct{}
- func (s *Session) Err() error
- func (s *Session) Events(ctx context.Context) <-chan TerminalEvent
- func (s *Session) ID() uint64
- func (s *Session) Press(key Key, modifiers ...KeyModifier) error
- func (s *Session) Resize(width, height int) error
- func (s *Session) Screen() Screen
- func (s *Session) Screens(ctx context.Context) <-chan Screen
- func (s *Session) Send(data []byte) error
- func (s *Session) WaitFor(ctx context.Context, matcher ScreenMatcher) (Screen, error)
- func (s *Session) WaitForIdle(ctx context.Context, quietPeriod time.Duration) (Screen, error)
- func (s *Session) WaitForStable(ctx context.Context, matcher ScreenMatcher, quietPeriod time.Duration) (Screen, error)
- type SessionOpener
- type SessionRequest
- type SessionStream
- type Terminal
- type TerminalEvent
- type TerminalEventDrainer
- type TerminalEventType
- type TerminalProfile
- type WaitError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnswerbackTerminal ¶
AnswerbackTerminal configures the response sent when the host transmits ENQ.
type Attributes ¶
type Attributes uint16
Attributes describes a cell's graphic rendition.
const ( Bold Attributes = 1 << iota Underline Blink Reverse Conceal )
func (Attributes) Has ¶
func (a Attributes) Has(attributes Attributes) bool
Has reports whether all requested attributes are set.
type Cell ¶
type Cell struct {
Text string
Width int
Foreground Color
Background Color
Attributes Attributes
}
Cell is one terminal screen cell. Text is normally one character. Width is one for a normal cell, two for a wide character, and zero for its continuation.
type Color ¶
type Color int16
Color is a terminal palette index. DefaultColor selects the terminal's configured default foreground or background.
const (
DefaultColor Color = -1
)
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a server-managed connection to a remote terminal server.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close closes every session and then the underlying connection. It is idempotent.
func (*Connection) ID ¶
func (c *Connection) ID() uint64
ID returns the connection's server-unique identifier.
func (*Connection) NewSession ¶
NewSession opens and starts an interactive session on the connection.
type Connector ¶
type Connector interface {
Connect(context.Context) (SessionOpener, error)
}
Connector establishes a connection capable of opening terminal sessions.
type CursorMatcherSpec ¶ added in v0.1.0
CursorMatcherSpec describes CursorAt.
type Key ¶
type Key string
Key identifies a named terminal key or one printable character.
const ( KeyEnter Key = "Enter" KeyTab Key = "Tab" KeyBackspace Key = "Backspace" KeyEscape Key = "Escape" KeyUp Key = "ArrowUp" KeyDown Key = "ArrowDown" KeyRight Key = "ArrowRight" KeyLeft Key = "ArrowLeft" KeyHome Key = "Home" KeyEnd Key = "End" KeyInsert Key = "Insert" KeyDelete Key = "Delete" KeyPageUp Key = "PageUp" KeyPageDown Key = "PageDown" KeyF1 Key = "F1" KeyF2 Key = "F2" KeyF3 Key = "F3" KeyF4 Key = "F4" KeyF5 Key = "F5" KeyF6 Key = "F6" KeyF7 Key = "F7" KeyF8 Key = "F8" KeyF9 Key = "F9" KeyF10 Key = "F10" KeyF11 Key = "F11" KeyF12 Key = "F12" )
type KeyEncoder ¶
KeyEncoder converts named keys to the byte sequence expected by a terminal profile. Terminal implementations may satisfy this in addition to Terminal.
type KeyModifier ¶
type KeyModifier uint8
KeyModifier identifies modifiers applied to a key press. Alt and Meta are aliases because ANSI terminals conventionally encode both as an Escape prefix or the same CSI modifier bit.
const ( ModifierShift KeyModifier = 1 << iota ModifierAlt ModifierControl ModifierMeta = ModifierAlt )
type KeyPress ¶
type KeyPress struct {
Key Key
Modifiers KeyModifier
}
KeyPress describes one key and its combined modifiers.
func NewKeyPress ¶
func NewKeyPress(key Key, modifiers ...KeyModifier) (KeyPress, error)
NewKeyPress combines modifiers into one key press.
type LineMatcherSpec ¶ added in v0.1.0
LineMatcherSpec describes ScreenLineEquals.
type MatcherSpec ¶ added in v0.1.0
type MatcherSpec struct {
Contains *string `json:"contains,omitempty"`
Line *LineMatcherSpec `json:"line,omitempty"`
Cursor *CursorMatcherSpec `json:"cursor,omitempty"`
All []MatcherSpec `json:"all,omitempty"`
Any []MatcherSpec `json:"any,omitempty"`
Not *MatcherSpec `json:"not,omitempty"`
}
MatcherSpec is a serializable screen expectation used by the driver protocol, MCP tools, and recorded workflows. Exactly one field must be set.
func (MatcherSpec) ScreenMatcher ¶ added in v0.1.0
func (s MatcherSpec) ScreenMatcher() (ScreenMatcher, error)
ScreenMatcher builds the matcher described by s.
type ModifiedKeyEncoder ¶
ModifiedKeyEncoder converts key presses with modifiers to the byte sequence expected by a terminal profile.
type Screen ¶
Screen is a detached, row-major terminal snapshot. The Cells slice belongs to the snapshot and is never reused by the terminal that produced it.
type ScreenMatcher ¶
ScreenMatcher determines whether a screen has reached an expected state.
func AllOf ¶
func AllOf(matchers ...ScreenMatcher) ScreenMatcher
AllOf matches when every matcher succeeds. An empty AllOf matches every screen.
func AnyOf ¶
func AnyOf(matchers ...ScreenMatcher) ScreenMatcher
AnyOf matches when at least one matcher succeeds. An empty AnyOf never matches.
func CursorAt ¶
func CursorAt(column, row int) ScreenMatcher
CursorAt matches the cursor's zero-based position.
func ScreenContains ¶
func ScreenContains(text string) ScreenMatcher
ScreenContains matches when the exact screen text contains text.
func ScreenLineEquals ¶
func ScreenLineEquals(row int, text string) ScreenMatcher
ScreenLineEquals matches when row contains exactly text, including trailing spaces. Rows are zero-based.
type ScreenMatcherFunc ¶
ScreenMatcherFunc adapts a function into a ScreenMatcher.
func (ScreenMatcherFunc) Match ¶
func (f ScreenMatcherFunc) Match(screen Screen) bool
Match calls the adapted function.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns terminal connection and session lifecycles.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session coordinates one transport stream with one terminal.
func (*Session) Close ¶
Close closes the stream and waits for its read loop to stop. It is idempotent.
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Done is closed when the remote session ends or Close completes.
func (*Session) Events ¶
func (s *Session) Events(ctx context.Context) <-chan TerminalEvent
Events observes BELL, ENQ, and future non-screen terminal events. Each event has a session-monotonic sequence. A subscriber that cannot keep up is closed rather than blocking terminal processing.
func (*Session) Press ¶
func (s *Session) Press(key Key, modifiers ...KeyModifier) error
Press sends the terminal-profile sequence for a named or printable key with optional modifiers.
func (*Session) Screens ¶
Screens observes detached snapshots. It sends the current snapshot first, then the latest snapshot after each visible screen revision. A slow observer may skip intermediate revisions. The channel closes when ctx or the session ends.
func (*Session) Send ¶
Send writes input to the remote terminal session. Concurrent sends are serialized so their byte streams cannot interleave.
func (*Session) WaitFor ¶
WaitFor waits until matcher accepts a screen, the context expires, or the session ends.
func (*Session) WaitForIdle ¶
WaitForIdle waits until no host output arrives for quietPeriod. Host bytes that do not visibly change the screen still reset the quiet period.
func (*Session) WaitForStable ¶
func (s *Session) WaitForStable(ctx context.Context, matcher ScreenMatcher, quietPeriod time.Duration) (Screen, error)
WaitForStable waits until matcher succeeds and no host output arrives for quietPeriod. The matcher is checked again after the quiet period.
type SessionOpener ¶
type SessionOpener interface {
OpenSession(context.Context, SessionRequest) (SessionStream, error)
Close() error
}
SessionOpener is the transport-specific side of a Connection.
type SessionRequest ¶
SessionRequest describes the terminal requested from a remote server.
type SessionStream ¶
type SessionStream interface {
io.ReadWriteCloser
Resize(width, height int) error
}
SessionStream carries one interactive terminal session. Close must unblock any pending Read so session shutdown can complete.
type Terminal ¶
type Terminal interface {
io.Writer
Profile() TerminalProfile
Resize(width, height int) error
Snapshot() Screen
}
Terminal consumes bytes received from a host and maintains terminal state. Implementations return detached snapshots that remain stable as more bytes are processed.
type TerminalEvent ¶
type TerminalEvent struct {
Sequence uint64
Type TerminalEventType
Data string
}
TerminalEvent reports a terminal control event. Sequence is assigned by the session; Data contains the configured answerback for an enquiry.
type TerminalEventDrainer ¶
type TerminalEventDrainer interface {
DrainEvents() []TerminalEvent
}
TerminalEventDrainer exposes events produced synchronously by Terminal.Write. The session drains events after each host-output write.
type TerminalEventType ¶
type TerminalEventType string
TerminalEventType identifies a non-screen event emitted while processing host output.
const ( EventBell TerminalEventType = "bell" EventEnquiry TerminalEventType = "enquiry" )
type TerminalProfile ¶
type TerminalProfile string
TerminalProfile identifies the behavior emulated by a terminal.
const ( // ProfileVT220 identifies the DEC VT220 terminal profile. ProfileVT220 TerminalProfile = "vt220" // ProfileXTerm identifies the xterm terminal profile with 256-color support. ProfileXTerm TerminalProfile = "xterm-256color" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ansi provides shared ANSI/DEC terminal emulation for concrete terminal profiles.
|
Package ansi provides shared ANSI/DEC terminal emulation for concrete terminal profiles. |
|
cmd
|
|
|
reference-tui
command
|
|
|
tuicast-driver
command
|
|
|
tuicast-mcp
command
|
|
|
Package driver exposes TUICast through a language-neutral JSON-RPC protocol.
|
Package driver exposes TUICast through a language-neutral JSON-RPC protocol. |
|
Package driverui provides the read-only TUICast Inspector HTTP application.
|
Package driverui provides the read-only TUICast Inspector HTTP application. |
|
Package mcpserver exposes TUICast terminal automation as MCP tools.
|
Package mcpserver exposes TUICast terminal automation as MCP tools. |
|
Package memory provides an in-memory transport for automation and tests.
|
Package memory provides an in-memory transport for automation and tests. |
|
Package parsing converts a terminal byte stream into ANSI/DEC parser events.
|
Package parsing converts a terminal byte stream into ANSI/DEC parser events. |
|
Package reference implements the deterministic TUI used to exercise TUICast automation and terminal emulation.
|
Package reference implements the deterministic TUI used to exercise TUICast automation and terminal emulation. |
|
ssh
Package ssh serves the reference TUI over SSH.
|
Package ssh serves the reference TUI over SSH. |
|
telnet
Package telnet serves the reference TUI over Telnet.
|
Package telnet serves the reference TUI over Telnet. |
|
sdk
|
|
|
go
module
|
|
|
Package ssh implements SSH transport using golang.org/x/crypto/ssh.
|
Package ssh implements SSH transport using golang.org/x/crypto/ssh. |
|
Package telnet implements Telnet transport and option negotiation.
|
Package telnet implements Telnet transport and option negotiation. |
|
Package vt220 implements the TUICast DEC VT220 terminal profile.
|
Package vt220 implements the TUICast DEC VT220 terminal profile. |
|
Package workbench records and replays language-neutral terminal workflows.
|
Package workbench records and replays language-neutral terminal workflows. |
|
Package xterm implements the TUICast xterm terminal profile.
|
Package xterm implements the TUICast xterm terminal profile. |