Documentation
¶
Index ¶
- Variables
- type BackgroundBuffer
- func (b *BackgroundBuffer) ClearFullRebuild()
- func (b *BackgroundBuffer) NeedsFullRebuild() bool
- func (b *BackgroundBuffer) Render(f graphics.Frame)
- func (b *BackgroundBuffer) Resize(cols, rows int)
- func (b *BackgroundBuffer) SetLayout(originX, originY, padX, padY, cellW, cellH float32)
- func (b *BackgroundBuffer) UpdateAll(grid *Grid, bgDefault color.Color)
- func (b *BackgroundBuffer) UpdateCell(x, y, width int, bg color.Color)
- func (b *BackgroundBuffer) UpdateCellTransparent(x, y, width int)
- func (b *BackgroundBuffer) UpdateDirty(grid *Grid, bgDefault color.Color)
- type Cell
- type ColorScheme
- type DirtyRegion
- type EmulatorReader
- type Grid
- func (g *Grid) CellAt(x, y int) *Cell
- func (g *Grid) ClearDirty()
- func (g *Grid) CursorPosition() (x, y int)
- func (g *Grid) DirtyCount() int
- func (g *Grid) GetDirtyRegions() []DirtyRegion
- func (g *Grid) IsDirty(x, y int) bool
- func (g *Grid) IterateAll(fn func(x, y int, cell *Cell))
- func (g *Grid) IterateDirty(fn func(x, y int, cell *Cell))
- func (g *Grid) MarkAllDirty()
- func (g *Grid) MarkDirty(x, y int)
- func (g *Grid) ResetStats()
- func (g *Grid) Resize(cols, rows int)
- func (g *Grid) SetCell(x, y int, content string, width int, fg, bg color.Color, attrs uint8) bool
- func (g *Grid) Size() (cols, rows int)
- func (g *Grid) Stats() GridStats
- func (g *Grid) UpdateCursor(newX, newY int)
- type GridStats
- type Hooks
- type Point
- type Terminal
- type VTCell
- type View
- func (v *View) ClearSelection()
- func (v *View) Close() error
- func (v *View) Grid() *Grid
- func (v *View) Read(p []byte) (int, error)
- func (v *View) SetColorScheme(scheme ColorScheme)
- func (v *View) SetInsets(left, top, right, bottom float32)
- func (v *View) SetPendingEvents(events []window.InputEvent)
- func (v *View) Step(f graphics.Frame, hooks Hooks) error
- func (v *View) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ErrWindowClosed = errors.New("window closed by user")
Functions ¶
This section is empty.
Types ¶
type BackgroundBuffer ¶
type BackgroundBuffer struct {
// contains filtered or unexported fields
}
BackgroundBuffer manages a persistent vertex buffer for terminal cell backgrounds. It supports efficient partial updates for dirty cells, reducing GPU draw calls from O(cells) to O(1).
func NewBackgroundBuffer ¶
func NewBackgroundBuffer(win graphics.Window, tex graphics.Texture, cols, rows int) (*BackgroundBuffer, error)
NewBackgroundBuffer creates a new background buffer for the given grid dimensions.
func (*BackgroundBuffer) ClearFullRebuild ¶
func (b *BackgroundBuffer) ClearFullRebuild()
ClearFullRebuild clears the full rebuild flag after a rebuild.
func (*BackgroundBuffer) NeedsFullRebuild ¶
func (b *BackgroundBuffer) NeedsFullRebuild() bool
NeedsFullRebuild returns true if a full buffer rebuild is required.
func (*BackgroundBuffer) Render ¶
func (b *BackgroundBuffer) Render(f graphics.Frame)
Render draws all backgrounds in a single draw call.
func (*BackgroundBuffer) Resize ¶
func (b *BackgroundBuffer) Resize(cols, rows int)
Resize changes the buffer capacity to match new grid dimensions.
func (*BackgroundBuffer) SetLayout ¶
func (b *BackgroundBuffer) SetLayout(originX, originY, padX, padY, cellW, cellH float32)
SetLayout updates the layout parameters used to calculate vertex positions.
func (*BackgroundBuffer) UpdateAll ¶
func (b *BackgroundBuffer) UpdateAll(grid *Grid, bgDefault color.Color)
UpdateAll rebuilds all vertices and uploads to GPU. Call this after SetLayout or Resize.
func (*BackgroundBuffer) UpdateCell ¶
func (b *BackgroundBuffer) UpdateCell(x, y, width int, bg color.Color)
UpdateCell updates the vertices for a single cell.
func (*BackgroundBuffer) UpdateCellTransparent ¶
func (b *BackgroundBuffer) UpdateCellTransparent(x, y, width int)
UpdateCellTransparent sets a cell to fully transparent (alpha=0). Used for cells with the default background color.
func (*BackgroundBuffer) UpdateDirty ¶
func (b *BackgroundBuffer) UpdateDirty(grid *Grid, bgDefault color.Color)
UpdateDirty updates vertices for all dirty cells in the grid.
type ColorScheme ¶ added in v0.0.2
type ColorScheme struct {
// Foreground is the default text color.
Foreground color.RGBA
// Background is the default background color.
Background color.RGBA
// Cursor is the cursor color.
Cursor color.RGBA
// Selection is the selection highlight color.
Selection color.RGBA
// Palette is the 16-color ANSI palette (0-7 normal, 8-15 bright).
Palette []color.RGBA
}
ColorScheme defines the color palette for the terminal.
func DefaultColorScheme ¶ added in v0.0.2
func DefaultColorScheme() ColorScheme
DefaultColorScheme returns the default Tokyo Night color scheme.
func LightColorScheme ¶ added in v0.0.2
func LightColorScheme() ColorScheme
LightColorScheme returns a light color scheme with purple accents.
type DirtyRegion ¶
DirtyRegion represents a rectangular region of dirty cells.
type EmulatorReader ¶
type EmulatorReader interface {
Width() int
Height() int
CellAt(x, y int) interface {
GetContent() string
GetWidth() int
GetFg() color.Color
GetBg() color.Color
GetAttrs() uint8
}
CursorPosition() struct{ X, Y int }
}
EmulatorReader provides read access to VT emulator cell data.
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid manages a grid of terminal cells with dirty tracking for incremental updates.
func (*Grid) CursorPosition ¶
CursorPosition returns the current cursor position.
func (*Grid) DirtyCount ¶
DirtyCount returns the number of dirty cells.
func (*Grid) GetDirtyRegions ¶
func (g *Grid) GetDirtyRegions() []DirtyRegion
GetDirtyRegions returns a list of dirty regions for batch processing. Adjacent dirty cells are merged into larger regions to reduce draw calls.
func (*Grid) IterateAll ¶
IterateAll calls fn for each cell regardless of dirty state.
func (*Grid) IterateDirty ¶
IterateDirty calls fn for each dirty cell with its coordinates. This is useful for incremental rendering.
func (*Grid) MarkAllDirty ¶
func (g *Grid) MarkAllDirty()
MarkAllDirty marks all cells as dirty (for full redraw).
func (*Grid) SetCell ¶
SetCell updates a cell and marks it dirty if it changed. Returns true if the cell was actually modified.
func (*Grid) UpdateCursor ¶
UpdateCursor marks old and new cursor positions as dirty.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal is a convenience wrapper that owns its own window and renders a View into it.
type VTCell ¶
type VTCell struct {
Content string
Width int
Style struct {
Fg color.Color
Bg color.Color
Attrs uint8
}
}
VTCell wraps the charmbracelet/vt Cell type for our interface.
func (*VTCell) GetContent ¶
type View ¶
type View struct {
// contains filtered or unexported fields
}
View is an embeddable terminal view that can be rendered inside an existing graphics.Window loop. It also implements io.Reader/io.Writer for wiring to a guest console.
func (*View) ClearSelection ¶
func (v *View) ClearSelection()
ClearSelection clears the current selection.
func (*View) SetColorScheme ¶ added in v0.0.2
func (v *View) SetColorScheme(scheme ColorScheme)
SetColorScheme sets the terminal color scheme.
func (*View) SetInsets ¶
SetInsets configures pixel insets for rendering and sizing the terminal grid. The terminal will render within the content rect: [left, top] → [windowWidth-right, windowHeight-bottom].
func (*View) SetPendingEvents ¶ added in v0.0.2
func (v *View) SetPendingEvents(events []window.InputEvent)
SetPendingEvents sets events to process in the next Step() call. When set, Step() uses these events instead of calling DrainInputEvents(). The events are cleared after being processed.