Documentation
¶
Overview ¶
Package vt binds libghostty-vt, Ghostty's terminal emulator, through purego on native targets and an embedded WebAssembly module in a browser: no cgo. Native structs mirror its C ABI; the browser marshals the separate guest memory. Both validate the library's type manifest before use.
Nothing here is safe for concurrent use: callers serialize the calls on a Terminal and on what is made from it.
Index ¶
- Constants
- func EncodeFocus(gained bool) []byte
- func EncodePaste(text string, bracketed bool) []byte
- func Load(path string) error
- func Loaded() bool
- func PasteIsSafe(text string) bool
- type Cell
- type ClipboardAnswer
- type ClipboardRead
- type ClipboardReply
- type Color
- type Colors
- type Cursor
- type CursorStyle
- type DeferredClipboardRead
- type Dirty
- type Effects
- type Geometry
- type Gesture
- func (g *Gesture) Autoscroll(t *Terminal) int
- func (g *Gesture) Drag(t *Terminal, ref GridRef, x, y float64, geo Geometry, rect bool) (Selection, bool)
- func (g *Gesture) Dragged(t *Terminal) bool
- func (g *Gesture) Free(t *Terminal)
- func (g *Gesture) Press(t *Terminal, ref GridRef, x, y float64, ns uint64) (Selection, bool)
- func (g *Gesture) Release(t *Terminal, ref *GridRef)
- func (g *Gesture) Reset(t *Terminal)
- func (g *Gesture) Tick(t *Terminal, col, row int, x, y float64, geo Geometry, rect bool) (Selection, bool)
- type GridRef
- type Image
- type ImageFormat
- type Key
- type KeyAction
- type KeyEncoder
- type KeyEvent
- type Mode
- type Mods
- type MouseAction
- type MouseEncoder
- type Placement
- type RGB
- type RenderState
- func (r *RenderState) BeginUpdate(t *Terminal) error
- func (r *RenderState) CellGraphemes(x int, buf []rune) []rune
- func (r *RenderState) CellStyle(x int) Style
- func (r *RenderState) Clean()
- func (r *RenderState) Colors() Colors
- func (r *RenderState) Cursor() Cursor
- func (r *RenderState) Dirty() Dirty
- func (r *RenderState) EndUpdate()
- func (r *RenderState) Free()
- func (r *RenderState) NextRow() bool
- func (r *RenderState) RowCells() []Cell
- func (r *RenderState) RowDirty() bool
- func (r *RenderState) RowID() RowID
- func (r *RenderState) RowPrompt() RowPrompt
- func (r *RenderState) RowSelection() (start, end int, ok bool)
- func (r *RenderState) RowWrapped() bool
- func (r *RenderState) Rows()
- func (r *RenderState) Size() (cols, rows int)
- func (r *RenderState) Update(t *Terminal) error
- type Result
- type RowID
- type RowPrompt
- type Scrollbar
- type Search
- func (s *Search) Feed()
- func (s *Search) Free()
- func (s *Search) Select(back bool) bool
- func (s *Search) Selected() (int, bool)
- func (s *Search) SelectedMatch() (Selection, bool)
- func (s *Search) SetText(text string)
- func (s *Search) Status() SearchStatus
- func (s *Search) Tick() SearchStatus
- func (s *Search) Total() int
- func (s *Search) ViewportMatches(buf []Selection) []Selection
- type SearchStatus
- type Selection
- type Style
- type TermColors
- type Terminal
- func (t *Terminal) Activity() uint64
- func (t *Terminal) AltScreen() bool
- func (t *Terminal) AnswerClipboard(d *DeferredClipboardRead, allowed bool, contents map[string][]byte, ...)
- func (t *Terminal) AtBottom() bool
- func (t *Terminal) CellAt(x, y int) (GridRef, bool)
- func (t *Terminal) CellIsInput(ref GridRef) bool
- func (t *Terminal) CellWide(ref GridRef) Wide
- func (t *Terminal) Colors(defaults bool) TermColors
- func (t *Terminal) Compress() bool
- func (t *Terminal) Cursor() (x, y int)
- func (t *Terminal) CursorAtPrompt() bool
- func (t *Terminal) CursorInInput() bool
- func (t *Terminal) ExtendSelection(ref GridRef) bool
- func (t *Terminal) Free()
- func (t *Terminal) Hyperlink(ref GridRef) string
- func (t *Terminal) Image(id uint32) (Image, bool)
- func (t *Terminal) ImageGeneration(id uint32) uint64
- func (t *Terminal) KittyKeyboardFlags() int
- func (t *Terminal) Mode(m Mode) bool
- func (t *Terminal) ModifyOtherKeys() bool
- func (t *Terminal) MouseShape() int
- func (t *Terminal) MouseTracking() bool
- func (t *Terminal) PasteEvent(mimes []string) bool
- func (t *Terminal) Placements(fn func(Placement))
- func (t *Terminal) Pwd() string
- func (t *Terminal) Reset()
- func (t *Terminal) Resize(cols, rows, cellWidth, cellHeight int) error
- func (t *Terminal) Row(y int) (prompt RowPrompt, wrap bool)
- func (t *Terminal) RowText(y int) (text []rune, cols []int)
- func (t *Terminal) ScreenCellAt(x, y int) (GridRef, bool)
- func (t *Terminal) ScreenRow(ref *GridRef) (int, bool)
- func (t *Terminal) ScreenRowText(y int) (text []rune, cols []int)
- func (t *Terminal) ScreenRowWraps(y int) bool
- func (t *Terminal) ScrollBy(rows int)
- func (t *Terminal) ScrollToBottom()
- func (t *Terminal) ScrollToRow(row int)
- func (t *Terminal) ScrollToTop()
- func (t *Terminal) ScrollbackRows() int
- func (t *Terminal) Scrollbar() Scrollbar
- func (t *Terminal) SelectAll() (Selection, bool)
- func (t *Terminal) SelectionText() (string, bool)
- func (t *Terminal) SetColors(fg, bg RGB, cursor *RGB, palette *[256]RGB)
- func (t *Terminal) SetDefaultCursor(s CursorStyle, blink bool)
- func (t *Terminal) SetImageLimit(bytes uint64)
- func (t *Terminal) SetMode(m Mode, v bool)
- func (t *Terminal) SetModeDefault(m Mode, v bool)
- func (t *Terminal) SetResizePullBack(v bool)
- func (t *Terminal) SetScrollback(n int)
- func (t *Terminal) SetSelection(s *Selection)
- func (t *Terminal) SetTerminfoName(name string)
- func (t *Terminal) Size() (cols, rows int)
- func (t *Terminal) Text() string
- func (t *Terminal) Title() string
- func (t *Terminal) VT() []byte
- func (t *Terminal) ViewportPoint(ref *GridRef) (x, y int, shown bool)
- func (t *Terminal) Write(p []byte)
- type Wide
Constants ¶
const ( ButtonNone = 0 ButtonLeft = 1 ButtonRight = 2 ButtonMiddle = 3 WheelUp = 4 WheelDown = 5 WheelLeft = 6 WheelRight = 7 )
Mouse buttons: 1 left, 2 right, 3 middle, 4 and 5 the wheel up and down, 6 and 7 left and right.
const ( UnderlineNone = iota UnderlineSingle UnderlineDouble UnderlineCurly UnderlineDotted UnderlineDashed )
Underline styles.
const Supported = true
Supported reports whether the platform can load the library.
Variables ¶
This section is empty.
Functions ¶
func EncodeFocus ¶
EncodeFocus returns the report of the terminal gaining or losing the focus (mode 1004).
func EncodePaste ¶
EncodePaste returns text as the program reads a paste: bracketed (mode 2004), or with newlines as carriage returns, and without the control characters that could run commands.
func Load ¶
Load loads the library at path. Only the first call loads one: later calls report how it went, whatever their path.
func PasteIsSafe ¶
PasteIsSafe reports whether pasting text cannot run a command by itself.
Types ¶
type Cell ¶
type Cell struct {
// Codepoint is the first character, 0 for none. Grapheme reports a
// cluster; CellGraphemes returns the whole cluster, Codepoint included.
Codepoint rune
Grapheme bool
// Style identifies the cell's style (CellStyle) among the row's
// cells: 0 is the default.
Style uint16
Wide Wide
Hyperlink bool
// Background is the color of a cell without text whose background
// a program filled, when HasBackground; Palette tells that it is
// the palette's color of index Background.R.
Background RGB
HasBackground bool
Palette bool
}
Cell is a cell of a row.
type ClipboardAnswer ¶
type ClipboardAnswer int
ClipboardAnswer is how the ClipboardRead effect answers a program's read of the clipboard.
const ( // ClipboardRefused has the library refuse the read itself: an empty // OSC 52 reply, an EPERM status for the Kitty protocol's OSC 5522, // which the binding drops, as the read of a terminal that is not the // one to answer. It is the zero value. ClipboardRefused ClipboardAnswer = iota // ClipboardAnswered answers the read with ClipboardReply.Contents // now, which the library encodes as it returns. ClipboardAnswered // ClipboardDeferred holds the library's refusal back and answers the // read later with Terminal.AnswerClipboard, which needs a // ClipboardReply carrying a DeferredClipboardRead. ClipboardDeferred )
type ClipboardRead ¶
type ClipboardRead struct {
// Mimes are the types asked for, in order of preference; List asks
// for the types available.
Mimes []string
List bool
// Primary is the selection clipboard of X11.
Primary bool
// Granted tells that the program holds the terminal's permission, as
// when it reads what a paste offered it.
Granted bool
// CanRemember tells that the program asked with a password (the one
// a paste event gave it, with its name): a terminal that pasted
// knows it — Granted says so — and one that does not never can, and
// leaves the read to the one it is for.
CanRemember bool
}
ClipboardRead is a program's request to read the clipboard.
type ClipboardReply ¶
type ClipboardReply struct {
Contents map[string][]byte
Available []string
// Deferred is the read to answer later, with ClipboardDeferred.
Deferred *DeferredClipboardRead
}
ClipboardReply answers a ClipboardRead: Contents by MIME type, of the types asked for, and Available when the list was asked for. Without contents the read is refused. A deferred read carries Deferred instead.
type Color ¶
Color is the color of a style: none (the default), an index of the palette, or an RGB color.
type Colors ¶
type Colors struct {
Background, Foreground RGB
// Cursor is the cursor's color when HasCursor is set; it takes the
// text's otherwise.
Cursor RGB
HasCursor bool
Palette [256]RGB
}
Colors are the colors of a frame: those programs set, else the defaults.
type Cursor ¶
type Cursor struct {
// InView reports that the cursor is in the viewport, at column X of
// row Y; WideTail that it is on the second half of a wide character.
InView bool
X, Y int
WideTail bool
// Visible reports that programs show the cursor, Blinking that it
// blinks, Password that the program reads a password.
Visible, Blinking, Password bool
Style CursorStyle
}
Cursor is the cursor of a frame.
type CursorStyle ¶
type CursorStyle int32
CursorStyle is the shape of the cursor.
const ( CursorBar CursorStyle = iota CursorBlock CursorUnderline CursorBlockHollow )
type DeferredClipboardRead ¶
type DeferredClipboardRead struct {
// contains filtered or unexported fields
}
DeferredClipboardRead is a read the embedder answers after its effect returned (ClipboardDeferred). The binding fills it as the library writes the refusal it holds back: kitty tells that the read came by the Kitty clipboard protocol (OSC 5522) rather than OSC 52; for OSC 52, prefix is the reply's beginning ("\x1b]52;" with the selector and its ";") and terminator how the request ended; refusal is what the library wrote to refuse the read (the empty OSC 52 reply, or the EPERM packet), which a denial writes again; mimes, list and primary are what the program asked for, and id is the id of a Kitty protocol read, echoed in its answer. Pass it to Terminal.AnswerClipboard.
type Effects ¶
type Effects struct {
// WritePTY answers the program, as to a query of the cursor's
// position. p is only valid during the call.
WritePTY func(p []byte)
Bell func()
// TitleChanged and PwdChanged tell that Title or Pwd changed.
TitleChanged func()
PwdChanged func()
// RenderHold tells that the program started or ended a synchronized
// update (mode 2026), during which the screen should not show.
RenderHold func(held bool)
// Clipboard writes text to the clipboard (OSC 52), and reports
// whether it did. primary is the selection clipboard of X11.
Clipboard func(text string, primary bool) bool
// ClipboardRead answers a program's read of the clipboard (OSC 52
// with "?", the Kitty clipboard protocol's OSC 5522): the contents of
// the MIME types asked for, and the types available when the program
// asks for the list. ClipboardAnswered writes the reply, encoded, to
// WritePTY in one call as ClipboardRead returns; ClipboardRefused
// refuses it (an empty OSC 52 reply, EPERM for OSC 5522), and the
// EPERM is dropped, so that a terminal that is not the one to answer
// stays silent; ClipboardDeferred holds the refusal back and answers
// later through Terminal.AnswerClipboard, for a terminal that must
// ask the user first.
ClipboardRead func(req ClipboardRead) (reply ClipboardReply, answer ClipboardAnswer)
// Size reports the size of the screen in cells and of a cell in
// pixels, for size reports.
Size func() (cols, rows, cellWidth, cellHeight int)
// Dark reports whether the colors are dark, for color scheme reports.
Dark func() bool
// Notify shows a desktop notification (OSC 9, OSC 777).
Notify func(title, body string)
// Progress reports the progress of the program (OSC 9;4): state is
// 0 to remove it, 1 to set it to progress (0 to 100), 2 for an error,
// 3 for indeterminate progress and 4 paused.
Progress func(state, progress int)
}
Effects are what a terminal asks of its embedder while it processes output, all optional. They run during Terminal.Write, which they must not call.
type Geometry ¶
type Geometry struct {
Columns, CellWidth, PadLeft, Height int
}
Geometry is the grid in pixels, for drags.
type Gesture ¶
type Gesture struct {
// contains filtered or unexported fields
}
Gesture turns presses and drags of the pointer into selections as Ghostty does: a click and a drag select cells, a double click words and a triple click lines, and dragging past the top or the bottom asks to scroll.
func NewGesture ¶
NewGesture makes a gesture: repeated clicks count within interval nanoseconds of each other and distance pixels.
func (*Gesture) Autoscroll ¶
Autoscroll reports whether a drag past an edge asks to scroll up (-1) or down (1).
func (*Gesture) Drag ¶
func (g *Gesture) Drag(t *Terminal, ref GridRef, x, y float64, geo Geometry, rect bool) (Selection, bool)
Drag moves the pressed pointer to cell ref at x, y pixels, selecting a rectangle when rect is set.
func (*Gesture) Dragged ¶
Dragged reports whether the pointer moved to another cell since it was pressed.
func (*Gesture) Press ¶
Press presses the pointer on cell ref at x, y pixels, at time ns of a monotonic clock. A double or triple click selects at once.
type GridRef ¶
type GridRef struct {
// contains filtered or unexported fields
}
GridRef is a GhosttyGridRef: a cell of the terminal, valid until the terminal next changes.
type Image ¶
type Image struct {
ID uint32
Width, Height int
Format ImageFormat
// Pixels are the image's, decoded; Generation changes when they do.
Pixels []byte
Generation uint64
}
Image is an image of the Kitty graphics protocol.
type ImageFormat ¶
type ImageFormat int32
ImageFormat is how an image's pixels are laid out (GhosttyKittyImageFormat).
const ( ImageRGB ImageFormat = 0 ImageRGBA ImageFormat = 1 ImageGrayAlpha ImageFormat = 3 ImageGray ImageFormat = 4 )
Image formats: PNG is decoded to RGBA as an image arrives.
type Key ¶
type Key int32
Key is a GhosttyKey: a key by its place on the keyboard, as the W3C's KeyboardEvent.code names them.
const ( KeyUnidentified Key = iota KeyBackquote KeyBackslash KeyBracketLeft KeyBracketRight KeyComma KeyDigit0 KeyDigit1 KeyDigit2 KeyDigit3 KeyDigit4 KeyDigit5 KeyDigit6 KeyDigit7 KeyDigit8 KeyDigit9 KeyEqual KeyIntlBackslash KeyIntlRo KeyIntlYen KeyA KeyB KeyC KeyD KeyE KeyF KeyG KeyH KeyI KeyJ KeyK KeyL KeyM KeyN KeyO KeyP KeyQ KeyR KeyS KeyT KeyU KeyV KeyW KeyX KeyY KeyZ KeyMinus KeyPeriod KeyQuote KeySemicolon KeySlash KeyAltLeft KeyAltRight KeyBackspace KeyCapsLock KeyContextMenu KeyControlLeft KeyControlRight KeyEnter KeyMetaLeft KeyMetaRight KeyShiftLeft KeyShiftRight KeySpace KeyTab KeyConvert KeyKanaMode KeyNonConvert KeyDelete KeyEnd KeyHelp KeyHome KeyInsert KeyPageDown KeyPageUp KeyArrowDown KeyArrowLeft KeyArrowRight KeyArrowUp )
Keys, in the order of GhosttyKey.
const ( KeyEscape Key = KeyArrowUp + 1 + 41 + iota KeyF1 )
KeyEscape and the function keys follow the 41 keys of the numpad.
type KeyEncoder ¶
type KeyEncoder struct {
// contains filtered or unexported fields
}
KeyEncoder encodes keys as the terminal's modes ask: legacy sequences, xterm's modifyOtherKeys or the Kitty keyboard protocol.
func (*KeyEncoder) Encode ¶
func (e *KeyEncoder) Encode(k KeyEvent) []byte
Encode returns the bytes the program reads for k, valid until the next call; nil for keys that send nothing.
func (*KeyEncoder) Sync ¶
func (e *KeyEncoder) Sync(t *Terminal, optionAsAlt bool)
Sync takes the terminal's modes, and whether Option is Alt on macOS.
type KeyEvent ¶
type KeyEvent struct {
Action KeyAction
Key Key
Mods Mods
// Consumed are the modifiers that made Text, as Shift an "A".
Consumed Mods
// Text is what the key types, without what Ctrl or Alt change; empty
// for keys that type nothing.
Text string
// Unshifted is the character the key types without modifiers.
Unshifted rune
// Composing tells that an input method is composing.
Composing bool
}
KeyEvent is a key to encode for the program.
type Mode ¶
type Mode uint16
Mode is a GhosttyMode: a DEC private mode, or an ANSI one with bit 15.
const ( ModeCursorKeys Mode = 1 ModeCursorVisible Mode = 25 ModeFocusEvent Mode = 1004 ModeAltScroll Mode = 1007 ModeBracketedPaste Mode = 2004 // ModePasteEvents has a paste tell the program what the clipboard // holds, which it reads itself (the Kitty clipboard protocol). ModePasteEvents Mode = 5522 ModeSyncOutput Mode = 2026 ModeGraphemes Mode = 2027 // ModeColorScheme has the terminal tell the program when its colors // go from light to dark or back (CSI ? 997 ; 1 n for dark, 2 light). ModeColorScheme Mode = 2031 )
Modes.
type MouseAction ¶
type MouseAction int32
MouseAction is what the pointer did.
const ( MousePress MouseAction = iota MouseRelease MouseMotion )
type MouseEncoder ¶
type MouseEncoder struct {
// contains filtered or unexported fields
}
MouseEncoder encodes pointer events in the format and for the events the program asked for.
func NewMouseEncoder ¶
func NewMouseEncoder() (*MouseEncoder, error)
NewMouseEncoder makes a mouse encoder.
func (*MouseEncoder) Encode ¶
func (m *MouseEncoder) Encode(action MouseAction, button int, mods Mods, x, y float32) []byte
Encode returns the bytes the program reads for a pointer event at x, y pixels, valid until the next call; nil when it asked for no such event.
type Placement ¶
type Placement struct {
ImageID, ID uint32
// Virtual tells that the placement shows through the cells of Unicode
// placeholders rather than where it is placed.
Virtual bool
// Col and Row are its top left cell on the screen, Row negative when
// its top scrolled off; Visible tells that some of it shows.
Col, Row int
Visible bool
// XOffset and YOffset place it within its first cell, in pixels;
// Width and Height are the pixels it takes on the screen, Cols and Rows
// the cells.
XOffset, YOffset int
Width, Height int
Cols, Rows int
// SrcX, SrcY, SrcW and SrcH are the part of the image it shows, in the
// image's pixels.
SrcX, SrcY, SrcW, SrcH int
// Z orders it: below the cells' backgrounds when below -1<<30, below
// the text when negative, above it otherwise.
Z int32
// Params are the placement as a program asked for it: offsets, the
// part of the image and the cells, 0 for what the image gives.
ParamCols, ParamRows int
ParamSrcX, ParamSrcY, ParamSrcW, ParamSrcH int
}
Placement is where a program placed an image (Kitty graphics), as the screen shows it now.
type RenderState ¶
type RenderState struct {
// contains filtered or unexported fields
}
RenderState is a GhosttyRenderState: what a frame draws of a terminal, copied from it by an update, with the rows that changed since the last frame marked dirty.
func NewRenderState ¶
func NewRenderState() (*RenderState, error)
NewRenderState makes an empty render state.
func (*RenderState) BeginUpdate ¶
func (r *RenderState) BeginUpdate(t *Terminal) error
BeginUpdate copies the terminal's state, the only step that needs the terminal; EndUpdate finishes the update without it.
func (*RenderState) CellGraphemes ¶
func (r *RenderState) CellGraphemes(x int, buf []rune) []rune
CellGraphemes appends the codepoints of cell x of the row RowCells read to buf.
func (*RenderState) CellStyle ¶
func (r *RenderState) CellStyle(x int) Style
CellStyle returns the style of cell x of the row RowCells read.
func (*RenderState) Colors ¶
func (r *RenderState) Colors() Colors
Colors returns the colors of the frame.
func (*RenderState) Cursor ¶
func (r *RenderState) Cursor() Cursor
Cursor returns the cursor of the frame.
func (*RenderState) Dirty ¶
func (r *RenderState) Dirty() Dirty
Dirty reports how much changed since the last Clean.
func (*RenderState) EndUpdate ¶
func (r *RenderState) EndUpdate()
EndUpdate finishes the update BeginUpdate started.
func (*RenderState) NextRow ¶
func (r *RenderState) NextRow() bool
NextRow moves to the next row, and reports whether there is one.
func (*RenderState) RowCells ¶
func (r *RenderState) RowCells() []Cell
RowCells returns the cells of the row, valid until the next update.
func (*RenderState) RowDirty ¶
func (r *RenderState) RowDirty() bool
RowDirty reports whether the row changed since the last Clean.
func (*RenderState) RowID ¶
func (r *RenderState) RowID() RowID
RowID returns the identity of the row, which it keeps as it scrolls.
func (*RenderState) RowPrompt ¶
func (r *RenderState) RowPrompt() RowPrompt
RowPrompt returns how the row belongs to a shell's prompt.
func (*RenderState) RowSelection ¶
func (r *RenderState) RowSelection() (start, end int, ok bool)
RowSelection returns the selected columns of the row, from start to end inclusive.
func (*RenderState) RowWrapped ¶
func (r *RenderState) RowWrapped() bool
RowWrapped reports whether the row soft-wraps into the next.
func (*RenderState) Rows ¶
func (r *RenderState) Rows()
Rows starts going through the rows of the frame, top to bottom, with NextRow.
func (*RenderState) Size ¶
func (r *RenderState) Size() (cols, rows int)
Size returns the size of the viewport in cells.
func (*RenderState) Update ¶
func (r *RenderState) Update(t *Terminal) error
Update updates the render state from the terminal in one step.
type RowID ¶
type RowID struct {
// contains filtered or unexported fields
}
RowID identifies a row across render state updates (a GhosttyRenderStateRowId).
type RowPrompt ¶
type RowPrompt int32
RowPrompt is how a row belongs to a shell's prompt, which the shell marks with OSC 133 (shell integration).
type Scrollbar ¶
type Scrollbar struct {
Total, Offset, Len uint64
}
Scrollbar is a GhosttyTerminalScrollbar: the rows of the screen and its scrollback, the first row of the viewport and how many rows it shows.
type Search ¶
type Search struct {
// contains filtered or unexported fields
}
Search searches a terminal, its scrollback included, for text, as Ghostty's find does: matches follow the screen as it changes, and the screens as programs switch them. Matching is exact but for ASCII letters, whose case it ignores.
func NewSearch ¶
NewSearch makes a search of t, which looks for nothing until SetText. Selecting a match scrolls nothing: the caller shows it where it likes.
func (*Search) Feed ¶
func (s *Search) Feed()
Feed reads what changed of the terminal, a bounded amount at a time.
func (*Search) Select ¶
Select selects the next match toward older output, or toward newer output when back, wrapping around. It reports whether there was a match.
func (*Search) Selected ¶
Selected returns the index of the selected match, 0 the newest, and reports whether one is.
func (*Search) SelectedMatch ¶
SelectedMatch returns the selected match.
func (*Search) SetText ¶
SetText searches for text from scratch, or keeps the matches when it is the text searched already; "" searches for nothing.
func (*Search) Status ¶
func (s *Search) Status() SearchStatus
Status returns how far the search went.
func (*Search) Tick ¶
func (s *Search) Tick() SearchStatus
Tick makes a bounded amount of progress, without the terminal.
func (*Search) ViewportMatches ¶
ViewportMatches returns the matches on the pages the viewport shows, as of the last Feed, in buf's memory when it has room.
type SearchStatus ¶
type SearchStatus int32
SearchStatus is how far a search went (GhosttySearchStatus).
const ( // SearchRunning: Tick makes progress. SearchRunning SearchStatus = iota // SearchFeedRequired: Feed must read the terminal first. SearchFeedRequired // SearchComplete: the search caught up with the terminal as of the // last Feed. SearchComplete )
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
Selection is a GhosttySelection: two cells of the terminal, inclusive, valid until the terminal next changes.
type Style ¶
type Style struct {
FG, BG, UnderlineColor Color
Bold, Italic, Faint, Blink, Inverse, Invisible, Strikethrough, Overline bool
Underline int
}
Style is how a cell's text shows.
type TermColors ¶
type TermColors struct {
Foreground, Background, Cursor RGB
HasForeground, HasBackground, HasCursor bool
Palette [256]RGB
}
TermColors are a terminal's colors; a color neither a program set nor a default gave is not Has.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal is a GhosttyTerminal: the screen, its scrollback, the cursor and the modes, which the output of programs changes.
func NewTerminal ¶
NewTerminal makes a terminal of cols columns and rows rows.
func (*Terminal) AltScreen ¶
AltScreen reports whether the alternate screen shows, as in full-screen programs.
func (*Terminal) AnswerClipboard ¶
func (t *Terminal) AnswerClipboard(d *DeferredClipboardRead, allowed bool, contents map[string][]byte, available []string)
AnswerClipboard answers a read that the ClipboardRead effect deferred (ClipboardDeferred): allowed serves contents by MIME type, and available for the types listing (OSC 5522's "."), while denied writes the refusal the library wrote for the read and the binding held back. It is safe from any goroutine, and contents and available are not retained after it returns.
func (*Terminal) AtBottom ¶
AtBottom reports whether the viewport follows the active screen, rather than showing the scrollback.
func (*Terminal) CellIsInput ¶
CellIsInput reports whether OSC 133 marks a cell as shell input.
func (*Terminal) CellWide ¶
CellWide reports whether ref holds a character or a wide-character spacer.
func (*Terminal) Colors ¶
func (t *Terminal) Colors(defaults bool) TermColors
Colors returns the colors programs see: those they set (OSC 4, 10, 11, 12) over the defaults, or with defaults the defaults alone.
func (*Terminal) Compress ¶
Compress compresses some of the scrollback, as when the terminal is idle, and reports whether more is left to compress.
func (*Terminal) Cursor ¶
Cursor returns the cursor's column and row in the active screen, the bottom of the scrollback.
func (*Terminal) CursorAtPrompt ¶
CursorAtPrompt reports whether OSC 133 places the cursor in the current shell prompt or input. Alternate-screen programs never qualify.
func (*Terminal) CursorInInput ¶
CursorInInput reports an active OSC 133 command-input phase at the cursor.
func (*Terminal) ExtendSelection ¶
ExtendSelection moves the selection's logical end to ref, keeping its original anchor even for a reversed selection. Read a fresh snapshot: grid references cannot be kept across output, scrolling or resizing.
func (*Terminal) Image ¶
Image returns an image, its pixels copied; false when there is no such image or its pixels have yet to arrive.
func (*Terminal) ImageGeneration ¶
ImageGeneration returns the generation of an image, 0 when there is no such image or its pixels have yet to arrive.
func (*Terminal) KittyKeyboardFlags ¶
KittyKeyboardFlags returns the flags of the kitty keyboard protocol programs set.
func (*Terminal) ModifyOtherKeys ¶
ModifyOtherKeys reports whether xterm's modifyOtherKeys mode 2 is on (CSI > 4 ; 2 m). The library tells it in no GhosttyTerminalData, but a key encoder takes it from the terminal with the other modes: without the Kitty keyboard protocol, Ctrl+P is CSI 27 ; 5 ; 112 ~ in mode 2, and ^P otherwise.
func (*Terminal) MouseShape ¶
MouseShape returns the pointer shape a program asked for (OSC 22), a GhosttyMouseShape.
func (*Terminal) MouseTracking ¶
MouseTracking reports whether a program asked for mouse events.
func (*Terminal) PasteEvent ¶
PasteEvent tells the program what the clipboard offers a paste, by the MIME types, for it to read what it wants (mode 5522, the Kitty clipboard protocol); the program's reads come to Effects.ClipboardRead, granted. The event goes to the program through Effects.WritePTY. It reports whether the event was sent: it is not when the mode is not set or the terminal has no ClipboardRead, when the paste is the embedder's to encode (EncodePaste).
func (*Terminal) Placements ¶
Placements calls fn with each placement of the screen that shows.
func (*Terminal) Pwd ¶
Pwd returns the working directory the shell reported (OSC 7), as it reported it: a file URL, or a path.
func (*Terminal) Row ¶
Row returns how row y of the viewport belongs to a shell's prompt, and whether it soft-wraps into the next.
func (*Terminal) RowText ¶
RowText returns the text of row y of the viewport, and the column of each of its runes.
func (*Terminal) ScreenCellAt ¶
ScreenCellAt is CellAt in the rows of the screen and its scrollback, 0 the oldest, as ScreenRow numbers them.
func (*Terminal) ScreenRow ¶
ScreenRow returns the row of a cell among those of the screen and its scrollback, 0 the oldest, as ScrollToRow takes it.
func (*Terminal) ScreenRowText ¶
ScreenRowText is RowText for a row of the screen and its scrollback.
func (*Terminal) ScreenRowWraps ¶
ScreenRowWraps reports whether row y of the screen and its scrollback soft-wraps into the next.
func (*Terminal) ScrollToBottom ¶
func (t *Terminal) ScrollToBottom()
func (*Terminal) ScrollToRow ¶
func (*Terminal) ScrollToTop ¶
func (t *Terminal) ScrollToTop()
ScrollToTop, ScrollToBottom, ScrollBy and ScrollToRow move the viewport: to the top of the scrollback, to the active screen, by rows (negative up), or to show row first.
func (*Terminal) ScrollbackRows ¶
ScrollbackRows returns how many rows the scrollback holds.
func (*Terminal) SelectionText ¶
SelectionText returns the text of the selection, with soft-wrapped lines joined and trailing spaces trimmed, as Ghostty copies it.
func (*Terminal) SetColors ¶
SetColors sets the default colors, which programs may change: the foreground, the background, the cursor's (nil for the text's) and the palette of 256 colors (nil for Ghostty's).
func (*Terminal) SetDefaultCursor ¶
func (t *Terminal) SetDefaultCursor(s CursorStyle, blink bool)
SetDefaultCursor sets the cursor that programs reset to (DECSCUSR 0).
func (*Terminal) SetImageLimit ¶
SetImageLimit sets how many bytes the images of the Kitty graphics protocol may take, zero refusing them (and deleting those there are).
func (*Terminal) SetModeDefault ¶
SetModeDefault sets a mode, and the value a reset restores.
func (*Terminal) SetResizePullBack ¶
SetResizePullBack sets whether growing the screen pulls rows back from the scrollback, which a pseudo-terminal keeping its own screen, as Windows' ConPTY, cannot follow.
func (*Terminal) SetScrollback ¶
SetScrollback limits the scrollback to about n bytes.
func (*Terminal) SetSelection ¶
SetSelection selects s, or nothing when s is nil.
func (*Terminal) SetTerminfoName ¶
SetTerminfoName sets the name of the terminfo entry the terminal reports (XTGETTCAP TN).
func (*Terminal) Text ¶
Text returns the text of the screen and its scrollback, with soft-wrapped lines joined and trailing spaces trimmed.
func (*Terminal) VT ¶
VT returns the terminal's state as escape sequences, which restore it in a terminal of the same size: the scrollback and the screen with their styles and hyperlinks, then the modes, the scrolling region, the tab stops, the working directory, the keyboard's flags and the cursor. The palette is left out, as the terminal it restores in has colors of its own.
func (*Terminal) ViewportPoint ¶
ViewportPoint returns the column and the row of the viewport of a cell, and reports whether the viewport shows it.