Documentation
¶
Overview ¶
Package term embeds a PTY-backed shell pane inside nook.
The Pane spawns $SHELL (or sh) inside a PTY, reads stdout, and renders a scrollback buffer with a cursor on the last line. Input is forwarded to the PTY when the pane is focused. The renderer is intentionally simple: it preserves bytes verbatim (so colors, prompt sequences, and bell pass through) and tracks a flat scrollback of decoded lines.
Not a terminal emulator. We don't interpret cursor-positioning, scrollback regions, or alternate-screen mode. Commands that need a full emulator (vim, htop, less) will still draw, but layout assumptions may break. For nook's MVP this is acceptable: it covers `git push`, `go test`, `npm run`, REPLs, file operations.
Index ¶
- type CancelMsg
- type ExitMsg
- type OutputMsg
- type Pane
- func (p Pane) Append(b []byte) Pane
- func (p Pane) Blur() Pane
- func (p Pane) Focus() Pane
- func (p Pane) Focused() bool
- func (p Pane) Lines() []string
- func (p Pane) MarkExit(err error) Pane
- func (p Pane) Session() *Session
- func (p Pane) Start() (Pane, error)
- func (p Pane) Stop() Pane
- func (p Pane) Update(msg tea.Msg) (Pane, tea.Cmd)
- func (p Pane) View() string
- func (p Pane) WithSize(w, h int) Pane
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OutputMsg ¶
type OutputMsg struct {
Data []byte
}
OutputMsg carries a chunk of bytes from the PTY.
type Pane ¶
type Pane struct {
// contains filtered or unexported fields
}
Pane is the terminal UI model.
func (Pane) Append ¶
Append decodes bytes from the PTY into scrollback. Strips most ANSI escapes for the MVP renderer; future versions can preserve color/style.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a live PTY-backed shell. Use New to construct; call Close to terminate.
func New ¶
New spawns a shell in a PTY rooted at cwd. The caller owns the returned Session and must Close it on exit.
func (*Session) ReadLoop ¶
ReadLoop pumps bytes from the PTY into a channel until ctx is cancelled or the process exits. Closes the channel on exit. Suitable for wrapping into a recursive tea.Cmd via Program.Send.