Documentation
¶
Index ¶
- type CompressionDictionary
- type DeltaGenerator
- type LineRingBuffer
- func (rb *LineRingBuffer) Append(line []byte)
- func (rb *LineRingBuffer) Capacity() int
- func (rb *LineRingBuffer) Clear()
- func (rb *LineRingBuffer) Get(index int) []byte
- func (rb *LineRingBuffer) GetAllLines() [][]byte
- func (rb *LineRingBuffer) SetAll(newLines [][]byte)
- func (rb *LineRingBuffer) Size() int
- func (rb *LineRingBuffer) UpdateDimensions(newRows int)
- type StateGenerator
- func (sg *StateGenerator) GenerateState(output []byte) *sessionv1.TerminalState
- func (sg *StateGenerator) GenerateStateWithCursor(output []byte, cursorX, cursorY, paneWidth, paneHeight *int) *sessionv1.TerminalState
- func (sg *StateGenerator) GetCompressionStats() map[string]interface{}
- func (sg *StateGenerator) GetCurrentSequence() uint64
- func (sg *StateGenerator) Reset()
- func (sg *StateGenerator) UpdateDimensions(cols, rows int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompressionDictionary ¶
type CompressionDictionary struct {
// contains filtered or unexported fields
}
CompressionDictionary manages dynamic dictionary learning for LZMA compression
func NewCompressionDictionary ¶
func NewCompressionDictionary(level string) *CompressionDictionary
NewCompressionDictionary creates a new compression dictionary for pattern learning
type DeltaGenerator ¶
type DeltaGenerator struct {
// contains filtered or unexported fields
}
DeltaGenerator generates MOSH-style delta compression for terminal output. Tracks terminal state and produces TerminalDelta messages containing only changed lines. Reduces bandwidth by 70-90% for typical terminal usage (especially animations).
func NewDeltaGenerator ¶
func NewDeltaGenerator(cols, rows int) *DeltaGenerator
NewDeltaGenerator creates a new delta generator with initial dimensions.
func (*DeltaGenerator) GenerateDelta ¶
func (dg *DeltaGenerator) GenerateDelta(output []byte) *sessionv1.TerminalDelta
GenerateDelta compares new output with previous state and generates a delta. Returns TerminalDelta protobuf message with only changed lines.
func (*DeltaGenerator) GenerateFullSync ¶
func (dg *DeltaGenerator) GenerateFullSync(output []byte, cols, rows int) *sessionv1.TerminalDelta
GenerateFullSync generates a full state sync (used for initial load or recovery). Sends complete terminal state as a delta with full_sync=true.
func (*DeltaGenerator) Reset ¶
func (dg *DeltaGenerator) Reset()
Reset resets the delta generator state (called on reconnect).
func (*DeltaGenerator) UpdateDimensions ¶
func (dg *DeltaGenerator) UpdateDimensions(cols, rows int)
UpdateDimensions updates terminal dimensions (called on resize).
type LineRingBuffer ¶
type LineRingBuffer struct {
// contains filtered or unexported fields
}
LineRingBuffer is a fixed-size circular buffer for terminal lines. Optimized for terminal viewport semantics where old lines scroll out. This is more efficient than slice-based storage for terminal delta tracking because it provides O(1) append operations with zero allocations after initialization.
func NewLineRingBuffer ¶
func NewLineRingBuffer(capacity int) *LineRingBuffer
NewLineRingBuffer creates a ring buffer for terminal viewport. capacity should match the terminal row count (e.g., 24, 80, 100).
func (*LineRingBuffer) Append ¶
func (rb *LineRingBuffer) Append(line []byte)
Append adds a line to the buffer (overwrites oldest if full). This is an O(1) operation with zero allocations after buffer initialization.
func (*LineRingBuffer) Capacity ¶
func (rb *LineRingBuffer) Capacity() int
Capacity returns the maximum capacity of the buffer.
func (*LineRingBuffer) Clear ¶
func (rb *LineRingBuffer) Clear()
Clear resets the buffer to empty state.
func (*LineRingBuffer) Get ¶
func (rb *LineRingBuffer) Get(index int) []byte
Get retrieves line at logical index (0 = oldest visible line, size-1 = newest). Returns nil if index is out of bounds. This is an O(1) operation.
func (*LineRingBuffer) GetAllLines ¶
func (rb *LineRingBuffer) GetAllLines() [][]byte
GetAllLines returns all lines in the buffer in chronological order. Returns a slice view (not a copy) for efficiency. Caller should not modify the returned slices.
func (*LineRingBuffer) SetAll ¶
func (rb *LineRingBuffer) SetAll(newLines [][]byte)
SetAll replaces buffer contents with new lines (truncates to capacity). This is used for full sync operations. If newLines exceeds capacity, only the last N lines are kept.
func (*LineRingBuffer) Size ¶
func (rb *LineRingBuffer) Size() int
Size returns the current number of lines in the buffer.
func (*LineRingBuffer) UpdateDimensions ¶
func (rb *LineRingBuffer) UpdateDimensions(newRows int)
UpdateDimensions resizes the buffer to match new terminal dimensions. Preserves as many recent lines as possible (up to new capacity).
type StateGenerator ¶
type StateGenerator struct {
// contains filtered or unexported fields
}
StateGenerator generates MOSH-style complete terminal state snapshots. Unlike delta-based approaches, sends complete terminal screen state for robustness. Uses LZMA compression with dynamic dictionary learning for bandwidth optimization.
func NewStateGenerator ¶
func NewStateGenerator(cols, rows int) *StateGenerator
NewStateGenerator creates a new MOSH-style state generator
func (*StateGenerator) GenerateState ¶
func (sg *StateGenerator) GenerateState(output []byte) *sessionv1.TerminalState
GenerateState creates a complete terminal state snapshot from terminal output. Returns TerminalState protobuf message with complete screen buffer.
func (*StateGenerator) GenerateStateWithCursor ¶
func (sg *StateGenerator) GenerateStateWithCursor(output []byte, cursorX, cursorY, paneWidth, paneHeight *int) *sessionv1.TerminalState
GenerateStateWithCursor creates a complete terminal state snapshot with real cursor position and dimensions. Uses real tmux cursor position when provided, falls back to calculated position if nil.
func (*StateGenerator) GetCompressionStats ¶
func (sg *StateGenerator) GetCompressionStats() map[string]interface{}
GetCompressionStats returns compression statistics for monitoring
func (*StateGenerator) GetCurrentSequence ¶
func (sg *StateGenerator) GetCurrentSequence() uint64
GetCurrentSequence returns the current sequence number (thread-safe)
func (*StateGenerator) Reset ¶
func (sg *StateGenerator) Reset()
Reset resets the state generator (called on reconnect)
func (*StateGenerator) UpdateDimensions ¶
func (sg *StateGenerator) UpdateDimensions(cols, rows int)
UpdateDimensions updates terminal dimensions