Documentation
¶
Overview ¶
Package webshell is an in-memory terminal and a small fake shell for the browser build of tuios, where there is no kernel pty and no process to exec.
A Pty stands in for xpty.Pty: the window writes keystrokes to it and reads the guest's output back, exactly as it would with a real pseudo-terminal. Start runs a Go program in place of the command the window asked for. The package is pure Go and has no build tags, so it is tested natively.
Index ¶
- Constants
- func SetEventSink(fn func(Event))
- func WriteConfig(theme, border, glyphs string)
- type Event
- type Program
- type Pty
- func (p *Pty) Close() error
- func (p *Pty) Fd() uintptr
- func (p *Pty) Name() string
- func (p *Pty) Read(b []byte) (int, error)
- func (p *Pty) Resize(cols, rows int) error
- func (p *Pty) Size() (int, int, error)
- func (p *Pty) Start(cmd *exec.Cmd) error
- func (p *Pty) Wait() error
- func (p *Pty) Write(b []byte) (int, error)
- type TTY
Constants ¶
const ( // EventCommandStart is a command line starting at the prompt. Data: // command, line, cwd. EventCommandStart = "shell.start" // EventCommand is a command line that finished. Data: command, line, cwd, // exitCode (an int). EventCommand = "shell.command" // EventCwd is the shell changing directory. Data: cwd. EventCwd = "shell.cwd" // EventAgentReport is the fake agent reporting its state, for tuios and // not for the page: the browser build turns it into app.AgentReportMsg. // Data: state, message, kind, harness. EventAgentReport = "agent.report" // EventTapePlay asks tuios to play a tape, from `tuios tape play`. The // browser build turns it into app.PlayTapeMsg. Data: name, script. EventTapePlay = "tape.play" )
The events guests emit.
const AgentHarness = "claude-code"
AgentHarness is the harness id the fake agent reports as.
const ConfigPath = Home + "/.config/tuios/config.toml"
ConfigPath is the fake tuios config file.
const Home = "/home/guest"
Home is the fake user's home directory.
const ProjectDir = Home + "/projects/hello"
ProjectDir is the tiny Go project, which is also the fake git repository.
Variables ¶
This section is empty.
Functions ¶
func SetEventSink ¶
func SetEventSink(fn func(Event))
SetEventSink installs the function guests report events to. The wasm entry point forwards them to the page.
func WriteConfig ¶
func WriteConfig(theme, border, glyphs string)
WriteConfig rewrites the config file to match the looks the tour is showing, so cat config.toml shows what the reader picked.
Types ¶
type Event ¶
type Event struct {
Type string `json:"type"`
WindowID string `json:"windowId,omitempty"`
Data map[string]any `json:"data,omitempty"`
}
Event is something a guest did that a guided tour may want to know about, such as a command the user ran at the fake shell.
type Pty ¶
type Pty struct {
// contains filtered or unexported fields
}
Pty is an in-memory pseudo-terminal. It satisfies xpty.Pty.
func (*Pty) Start ¶
Start runs the program cmd names in place of cmd. Anything unknown runs the shell, since the window asked for the user's shell.
type TTY ¶
type TTY struct {
In <-chan []byte
// contains filtered or unexported fields
}
TTY is what a guest program sees: input as chunks, output, and the size.
func (*TTY) Lay ¶ added in v0.10.1
Lay prints lines laid out for the pane width, each on a line of its own. When the pane changes width, the shell calls lay again to draw them for the new one, so lay must print nothing itself and give the same lines for the same width.