Documentation
¶
Overview ¶
Terminal emulator interpreting xterm control sequences into a cell grid with scrollback, driving a program on a pty
Index ¶
- Constants
- func Environ(base []string, version string) []string
- 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) BracketedPaste() bool
- 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) FocusEvents() bool
- func (e *Emulator) Generation() uint64
- func (e *Emulator) Key(k Key) []byte
- func (e *Emulator) KittyFlags() int
- func (e *Emulator) LineAt(p Pos) (Pos, Pos)
- func (e *Emulator) Mouse(m Mouse) ([]byte, bool)
- func (e *Emulator) MouseTracking() 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) 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) 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 Span
- 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 ¶
Types ¶
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
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) BracketedPaste ¶
Reports whether the program asked for bracketed paste
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) FocusEvents ¶
Reports whether the program asked to hear about focus changes
func (*Emulator) Generation ¶
Counter that moves whenever output arrived, so a host knows when to draw again
func (*Emulator) KittyFlags ¶
Kitty keyboard flags in force on the shown screen
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) MouseTracking ¶
Reports whether the program tracks the mouse in any mode
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) 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) 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
// Spans lit as search matches, by absolute row
Matches map[uint64][]Span
MatchFg color.Color
MatchBg color.Color
// Span lit as the current match
Current *Match
CurFg color.Color
CurBg color.Color
}
What a host paints the grid with