Documentation
¶
Index ¶
- Constants
- func StyleToANSI(s Style) string
- func StyleToDeltaANSI(prev, next Style) string
- type Cell
- type Color
- type ColorType
- type Parser
- type ResponseWriter
- type Style
- type VTerm
- func (v *VTerm) ClearDirty()
- func (v *VTerm) ClearDirtyWithCursor(showCursor bool)
- func (v *VTerm) ClearSelection()
- func (v *VTerm) DirtyLines() ([]bool, bool)
- func (v *VTerm) GetAllLines() []string
- func (v *VTerm) GetScrollInfo() (int, int)
- func (v *VTerm) GetSelectedText(startX, startY, endX, endY int) string
- func (v *VTerm) GetTextRange(startX, startLine, endX, endLine int) string
- func (v *VTerm) IsInSelection(x, y int) bool
- func (v *VTerm) IsScrolled() bool
- func (v *VTerm) LastCursorHidden() bool
- func (v *VTerm) LastCursorX() int
- func (v *VTerm) LastCursorY() int
- func (v *VTerm) LastShowCursor() bool
- func (v *VTerm) LineCells(line int) []Cell
- func (v *VTerm) MaxViewOffset() int
- func (v *VTerm) Render() string
- func (v *VTerm) RenderBuffers() ([][]Cell, int)
- func (v *VTerm) Resize(width, height int)
- func (v *VTerm) ScrollToLine(lineIdx int)
- func (v *VTerm) ScrollView(delta int)
- func (v *VTerm) ScrollViewTo(offset int)
- func (v *VTerm) ScrollViewToBottom()
- func (v *VTerm) ScrollViewToTop()
- func (v *VTerm) Search(query string) []int
- func (v *VTerm) SelActive() bool
- func (v *VTerm) SelEndX() int
- func (v *VTerm) SelEndY() int
- func (v *VTerm) SelStartX() int
- func (v *VTerm) SelStartY() int
- func (v *VTerm) SetResponseWriter(w ResponseWriter)
- func (v *VTerm) SetSelection(startX, startY, endX, endY int, active bool, rect bool)
- func (v *VTerm) SyncActive() bool
- func (v *VTerm) TotalLines() int
- func (v *VTerm) Version() uint64
- func (v *VTerm) VisibleLineRange() (start, end, total int)
- func (v *VTerm) VisibleScreen() [][]Cell
- func (v *VTerm) VisibleScreenWithSelection() [][]Cell
- func (v *VTerm) Write(data []byte)
Constants ¶
const MaxScrollback = 10000
Variables ¶
This section is empty.
Functions ¶
func StyleToANSI ¶
StyleToANSI converts a Style to ANSI escape codes. Optimized to avoid allocations using strings.Builder.
func StyleToDeltaANSI ¶
StyleToDeltaANSI returns the minimal SGR escape sequence to transition from prev to next style. This avoids the overhead of always emitting a full reset. Optimized to avoid allocations using strings.Builder.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser handles ANSI escape sequence parsing
type ResponseWriter ¶
type ResponseWriter func([]byte)
ResponseWriter is called when the terminal needs to send a response back to the PTY
type Style ¶
type Style struct {
Fg Color
Bg Color
Bold bool
Dim bool
Italic bool
Underline bool
Blink bool
Reverse bool
Hidden bool
Strike bool
}
Style holds text styling attributes
type VTerm ¶
type VTerm struct {
// Screen buffer (visible area)
Screen [][]Cell
// Scrollback buffer (oldest at index 0)
Scrollback [][]Cell
// Cursor position (0-indexed)
CursorX, CursorY int
// Dimensions
Width, Height int
// Scroll viewing position (0 = live, >0 = lines scrolled up)
ViewOffset int
// Alt screen mode (full-screen TUI applications).
AltScreen bool
// Scrolling region (for DECSTBM)
ScrollTop int
ScrollBottom int
// Origin mode (DECOM) - cursor positions are relative to scroll region.
OriginMode bool
// Current style for new characters
CurrentStyle Style
// Saved cursor state (for DECSC/DECRC)
SavedCursorX int
SavedCursorY int
SavedStyle Style
// Cursor visibility (controlled externally when pane is focused)
ShowCursor bool
// CursorHidden tracks if terminal app hid cursor via DECTCEM (mode 25)
CursorHidden bool
// contains filtered or unexported fields
}
VTerm is a virtual terminal emulator with scrollback support
func (*VTerm) ClearDirty ¶
func (v *VTerm) ClearDirty()
ClearDirty resets dirty tracking state after a render.
func (*VTerm) ClearDirtyWithCursor ¶
ClearDirtyWithCursor resets dirty tracking state and updates cursor tracking. This should be called after snapshotting to track cursor position changes.
func (*VTerm) ClearSelection ¶
func (v *VTerm) ClearSelection()
ClearSelection clears the current selection
func (*VTerm) DirtyLines ¶
DirtyLines returns the dirty line flags and whether all lines are dirty. This is used by VTermLayer for optimized rendering.
func (*VTerm) GetAllLines ¶
GetAllLines returns all content (scrollback + screen) as lines for search
func (*VTerm) GetScrollInfo ¶
GetScrollInfo returns (current offset, max offset)
func (*VTerm) GetSelectedText ¶
GetSelectedText extracts text from the selection range. startX, startY, endX, endY are in visible screen coordinates (0-indexed). This handles scrollback by converting visible Y to absolute line numbers.
func (*VTerm) GetTextRange ¶
GetTextRange extracts text from a range in the combined scrollback+screen buffer. Coordinates are absolute line indices (0-based) and columns.
func (*VTerm) IsInSelection ¶
IsInSelection checks if coordinate (x, y) is within the selection
func (*VTerm) IsScrolled ¶
IsScrolled returns true if viewing scrollback
func (*VTerm) LastCursorHidden ¶
LastCursorHidden returns the DECTCEM cursor hidden state from the previous render frame.
func (*VTerm) LastCursorX ¶
LastCursorX returns the cursor X position from the previous render frame. Used to detect cursor movement and mark dirty lines.
func (*VTerm) LastCursorY ¶
LastCursorY returns the cursor Y position from the previous render frame. Used to detect cursor movement and mark old cursor line dirty.
func (*VTerm) LastShowCursor ¶
LastShowCursor returns the cursor visibility from the previous render frame.
func (*VTerm) LineCells ¶
LineCells returns the cell slice for an absolute line index in scrollback+screen.
func (*VTerm) MaxViewOffset ¶
MaxViewOffset returns the maximum scrollback offset for the current buffers.
func (*VTerm) RenderBuffers ¶
RenderBuffers returns the current screen buffer and scrollback length. During synchronized output, it returns the frozen snapshot.
func (*VTerm) ScrollToLine ¶
ScrollToLine scrolls view to show the given line index (in combined buffer)
func (*VTerm) ScrollView ¶
ScrollView scrolls the view by delta lines (positive = up into history)
func (*VTerm) ScrollViewTo ¶
ScrollViewTo sets absolute scroll position
func (*VTerm) ScrollViewToBottom ¶
func (v *VTerm) ScrollViewToBottom()
ScrollViewToBottom returns to live view
func (*VTerm) ScrollViewToTop ¶
func (v *VTerm) ScrollViewToTop()
ScrollViewToTop scrolls to oldest content
func (*VTerm) SetResponseWriter ¶
func (v *VTerm) SetResponseWriter(w ResponseWriter)
SetResponseWriter sets the callback for terminal query responses
func (*VTerm) SetSelection ¶
SetSelection stores selection coordinates for rendering with highlight.
func (*VTerm) SyncActive ¶
SyncActive reports whether synchronized output is currently active.
func (*VTerm) TotalLines ¶
TotalLines returns the total number of lines in scrollback+screen.
func (*VTerm) Version ¶
Version returns the current version counter. This increments whenever visible content changes.
func (*VTerm) VisibleLineRange ¶
VisibleLineRange returns the [start, end) line indices in the combined scrollback+screen buffer that are currently visible, along with total lines.
func (*VTerm) VisibleScreen ¶
VisibleScreen returns the currently visible screen buffer as a copy.
func (*VTerm) VisibleScreenWithSelection ¶
VisibleScreenWithSelection returns the visible screen with selection highlighting applied.