Documentation
¶
Overview ¶
Terminal emulator interpreting xterm control sequences into a cell grid with scrollback, driving a program on a pty
Index ¶
- Constants
- func Descendants(pid int) []int
- func Editor() string
- func EditorCommand(ctx context.Context, editor, path string) *exec.Cmd
- func EditorWords(editor string) []string
- func Environ(base []string, version string) []string
- func OpenPty() (*os.File, *os.File, error)
- func Processes() map[int]int
- func StripANSI(text string) string
- type Changes
- type Command
- type Cursor
- type CursorShape
- type Emulator
- func (e *Emulator) AltScreen() bool
- func (e *Emulator) AltScroll() bool
- func (e *Emulator) Base() uint64
- func (e *Emulator) ClearScrollback()
- func (e *Emulator) Cursor() Cursor
- func (e *Emulator) Cwd() string
- func (e *Emulator) Draw(buf *uv.Buffer, v View)
- func (e *Emulator) Events() []Event
- func (e *Emulator) Find(query string) []Match
- func (e *Emulator) Focus(in bool) []byte
- func (e *Emulator) Generation() uint64
- func (e *Emulator) Key(k Key) []byte
- func (e *Emulator) LineAt(p Pos) (Pos, Pos)
- func (e *Emulator) Mouse(m Mouse) ([]byte, bool)
- func (e *Emulator) Paste(text string) []byte
- func (e *Emulator) Progress() (state, value int)
- func (e *Emulator) Prompt(from uint64, d int) (uint64, bool)
- func (e *Emulator) Refind(query string, old []Match, since uint64) ([]Match, int, uint64)
- func (e *Emulator) Reset()
- func (e *Emulator) Resize(w, h int)
- func (e *Emulator) Row(abs uint64) (Line, bool)
- func (e *Emulator) ScrollbackLen() int
- func (e *Emulator) Scrolled() uint64
- func (e *Emulator) SetDefaults(fg, bg, cursor color.Color)
- func (e *Emulator) SetScrollback(n int)
- func (e *Emulator) Size() (int, int)
- func (e *Emulator) Synchronized() bool
- func (e *Emulator) Take() Changes
- func (e *Emulator) Text(s Selection) string
- func (e *Emulator) Title() string
- func (e *Emulator) WordAt(p Pos) (Pos, Pos)
- func (e *Emulator) Write(p []byte) (int, error)
- func (e *Emulator) WriteString(s string) (int, error)
- type Event
- type EventKind
- type Exit
- type Key
- type Line
- type Match
- type Mouse
- type MouseKind
- type Options
- type Pos
- type Process
- type SelMode
- type Selection
- type Session
- func (s *Session) Bytes() int64
- func (s *Session) Close()
- func (s *Session) Command() Command
- func (s *Session) Cwd() string
- func (s *Session) Done() <-chan struct{}
- func (s *Session) Exit() Exit
- func (s *Session) Exited() bool
- func (s *Session) Input(b []byte)
- func (s *Session) Pid() int
- func (s *Session) Resize(cols, rows int)
- func (s *Session) Wake() <-chan struct{}
- func (s *Session) Write(b []byte) (int, error)
- type View
Constants ¶
const ( MarkPrompt uint8 = 1 << iota MarkInput MarkOutput MarkEnd )
Shell integration marks a row may carry, set through OSC 133
Variables ¶
This section is empty.
Functions ¶
func Descendants ¶
Every live descendant of pid, parents before their children, zombies left for their parent to reap
func Editor ¶
func Editor() string
Editor a person set in EDITOR or VISUAL, else the first of the usual ones found on this machine, empty when there is none. It looks through PATH, so the app calls it off the UI loop
func EditorCommand ¶
Command that runs the editor on the file with the words it was set with. The editor is the person's own, run in their terminal, so it starts with the environment of the terminal icebath was started in, which carries no profile's variables
func EditorWords ¶
Words of the editor a person set, its program first, so one set with flags, such as code -w, runs with them: as a shell splits them outside Windows, so a quoted path with spaces stays one word, as git and other programs read EDITOR, and at spaces on Windows, where a backslash separates folders
func Environ ¶
Environment a program on the terminal starts with, the terminal variables set over the given base
Types ¶
type Changes ¶
type Changes struct {
// Rows that ever scrolled above the screen, the dropped ones included
Scrolled uint64
// Rows the scrollback holds
Scrollback int
// Whether the alternate screen shows
Alt bool
// Progress the program reported through OSC 9;4, state zero when none is shown
Progress, Percent int
// Events queued since the last take
Events []Event
}
What a host reads once output arrived, taken under one hold of the lock
type Command ¶
Program to run on the terminal
func DefaultShell ¶
func DefaultShell() Command
Program a terminal starts when none is configured, the login shell of the user or the plain shell of the system. The first call looks for it on the disk, so the app asks for it off the UI loop
type Cursor ¶
Where the cursor is, whether it shows, its shape and blink, and the color the program gave it
type CursorShape ¶
type CursorShape int
Shape the program asked the cursor to take through DECSCUSR
const ( CursorBlock CursorShape = iota CursorUnderline CursorBar )
type Emulator ¶
type Emulator struct {
// contains filtered or unexported fields
}
Terminal emulator holding a main grid with scrollback and an alternate grid, safe for one writer and many readers
func (*Emulator) AltScroll ¶
Reports whether a wheel turn should reach the program as arrow keys, the alternate scroll of xterm
func (*Emulator) Base ¶
Absolute number of the top row of the screen, growing by one for every row pushed above it
func (*Emulator) ClearScrollback ¶
func (e *Emulator) ClearScrollback()
Forgets every row above the screen
func (*Emulator) Cwd ¶
Working directory the program reported through OSC 7, empty when it reported none or one on another host
func (*Emulator) Draw ¶
Paints the rows in view into the buffer, the scrollback above the screen when scrolled
func (*Emulator) Find ¶
Every place the text occurs, scrollback first, letters matched without regard to case when the query has no capitals
func (*Emulator) Focus ¶
Bytes the program receives when the terminal gains or loses focus, none unless it asked
func (*Emulator) Generation ¶
Counter that moves whenever output arrived, so a host knows when to draw again
func (*Emulator) Mouse ¶
Bytes the program receives for the pointer event, false when it does not track it and the host keeps the event
func (*Emulator) Paste ¶
Bytes the program receives for pasted text, bracketed when it asked for that
func (*Emulator) Progress ¶
Progress the program reported through OSC 9;4, state zero when none is shown
func (*Emulator) Prompt ¶
Absolute row of the nearest prompt mark above or below the row, false when there is none
func (*Emulator) Refind ¶
Matches of the query brought up to date with the output since they were found, the rows above since taken as unchanged as they had scrolled out by then: the old matches on rows still kept above the logical row holding since stay, the rows from there on are searched again, and past the most kept the oldest go. The old matches are reused for the new ones. Reports the matches, how many of the old ones went from the front and the top row of the screen, the since of the next call. A since of zero searches every row
func (*Emulator) Reset ¶
func (e *Emulator) Reset()
Returns everything to its starting state, keeping the scrollback
func (*Emulator) Resize ¶
Changes the grid to w by h, rewrapping the main screen and its scrollback to the new width
func (*Emulator) Row ¶
Copy of the row at an absolute number, false when it is gone or past the bottom
func (*Emulator) Scrolled ¶
Total rows that ever scrolled above the screen, the dropped ones included
func (*Emulator) SetDefaults ¶
Replaces the colors answered for the default text, background and cursor
func (*Emulator) SetScrollback ¶
Replaces the rows the scrollback keeps
func (*Emulator) Synchronized ¶
Reports whether a synchronized update holds the picture, which it may for a second at most
func (*Emulator) Take ¶
Takes the events queued since the last take with where the grid stands as they are taken
func (*Emulator) Text ¶
Text the selection covers, soft wrapped rows joined and trailing blanks of each row dropped
func (*Emulator) WordAt ¶
Start and end of the word under the position, crossing soft wraps, the position alone on a blank
type EventKind ¶
type EventKind int
Something the program did that the host shows or acts on outside the grid
type Key ¶
type Key struct {
Code rune
Shifted rune
Base rune
Text string
Mod uv.KeyMod
Repeat bool
Release bool
}
Key event from the host, codes as ultraviolet names them
type Line ¶
type Line struct {
Cells []uv.Cell
Wrapped bool
Marks uint8
// Exit code of the command that ended on this row when MarkEnd is set
Exit int
// contains filtered or unexported fields
}
Row of cells with whether it continues on the row below and the shell marks it carries
type Options ¶
type Options struct {
// Rows kept above the screen, none when zero
Scrollback int
// Receives every answer the program asked for, such as cursor position reports
Reply io.Writer
// Colors reported for the default text, background and cursor
Fg, Bg, Cursor color.Color
// Name and version answered to XTVERSION
Version string
}
Settings an emulator starts with
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Program running on a pseudo terminal
func (*Process) Close ¶
func (p *Process) Close()
Hangs up the terminal, then kills the program and everything under it when it lingers
func (*Process) Cwd ¶
Working directory of the program as the kernel knows it, empty where that cannot be read
type Session ¶
type Session struct {
Emu *Emulator
// contains filtered or unexported fields
}
Program on a pseudo terminal feeding an emulator, with a wake channel the host waits on for output
func Open ¶
Starts the command on a terminal of cols by rows that feeds a fresh emulator built with the options
func (*Session) Cwd ¶
Working directory of the program, what it announced over OSC 7, else what the kernel reports
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Channel closed once the program has ended
func (*Session) Input ¶
Queues bytes for the program without waiting, dropping them once it has ended
type View ¶
type View struct {
// Rows scrolled back into the scrollback, zero for the live screen
Scroll int
// Theme colors for the sixteen ANSI colors, a nil entry leaving the terminal default
Colors [16]color.Color
// Colors cells take when the program swaps them through reverse video or a selection covers them
Fg, Bg color.Color
// Highlight colors of selected cells
SelFg, SelBg color.Color
Selection *Selection
// Matches lit as search matches, in the order of their rows
Matches []Match
MatchFg color.Color
MatchBg color.Color
// Match lit as the current one
Current *Match
CurFg color.Color
CurBg color.Color
}
What a host paints the grid with