Help us shape the future of Go! Take the 2026 Go Developer Survey

term

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package term is the integrated terminal panel: the user's shell on a PTY, screen state kept by a VT100 emulator (vt10x), rendered on demand. The app learns about new output via Notify (listen-cmd pattern, like lsp.Manager).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Term

type Term struct {
	Label string // panel chip text; "" = numbered shell instance
	// contains filtered or unexported fields
}

func New

func New(dir string, argv []string, cols, rows int, env ...string) (*Term, error)

New starts argv (default: $SHELL, fallback /bin/sh) in dir on a cols×rows PTY. env entries ("K=V") are added to the inherited environment.

func (*Term) Close

func (t *Term) Close()

Close tears the PTY down and kills the shell.

func (*Term) Drag added in v0.6.1

func (t *Term) Drag(x, y int)

Drag extends the selection while the left button is held.

func (*Term) Notify

func (t *Term) Notify() <-chan struct{}

Notify yields once per burst of output; closed when the shell exits.

func (*Term) Paste added in v0.16.0

func (t *Term) Paste(s string)

Wheel handles one wheel step at cell (x, y) of the panel. Apps that asked for mouse reporting get a mouse code; alt-screen apps get arrow keys (xterm's alternate-scroll convention — how less/vim/htop scroll in real terminals); otherwise the view moves through Cove's scrollback. Paste writes s to the child as pasted input, the way a real terminal would: newlines become CR (what Enter sends), and if the child enabled bracketed paste (DECSET 2004) the text is wrapped in ESC[200~ / ESC[201~ so the app takes it as one block. Without the wrap, apps that rely on it (Claude Code, readline-based shells) see 1 KB chunks of "typed" text arriving through the PTY queue and mishandle every chunk but the last.

func (*Term) Press added in v0.6.1

func (t *Term) Press(x, y int)

Press handles a left press at panel cell (x, y).

func (*Term) Release added in v0.6.1

func (t *Term) Release(x, y int) string

Release ends the drag and returns the selected text; "" means a plain click (or the child app owns the mouse). The highlight stays until the next press.

func (*Term) Resize

func (t *Term) Resize(cols, rows int)

func (*Term) Scroll

func (t *Term) Scroll(delta int)

Scroll moves the view into scrollback: positive = older lines, negative = toward the live screen. Clamped to available history.

func (*Term) Scrolled

func (t *Term) Scrolled() int

Scrolled reports how many rows back the view currently sits.

func (*Term) Send

func (t *Term) Send(k tea.KeyMsg)

Send encodes a key press as terminal input bytes and writes it to the PTY. Typing snaps the view back to the live screen.

func (*Term) View

func (t *Term) View(focused bool) string

View renders the visible window as styled rows: the live screen, shifted up into scrollback when the user has scrolled. When focused and live, the cursor cell is drawn reversed.

func (*Term) Wheel added in v0.5.0

func (t *Term) Wheel(up bool, x, y int)

Directories

Path Synopsis
Vendored from github.com/hinshun/vt10x (MIT, see LICENSE) with one Cove patch: primary-screen scrollback (history field in State, capture in scrollUp, HistoryLen/HistoryCell accessors, View interface additions).
Vendored from github.com/hinshun/vt10x (MIT, see LICENSE) with one Cove patch: primary-screen scrollback (history field in State, capture in scrollUp, HistoryLen/HistoryCell accessors, View interface additions).

Jump to

Keyboard shortcuts

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