Class TerminalScrollbackBuffer
Scrollback ring buffer for terminal displays. Stores text lines with their associated colors using Scylla.Core.Structures.ScyllaRingBuffer<T>. When the buffer reaches capacity, oldest entries are automatically overwritten.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public class TerminalScrollbackBuffer
Constructors
TerminalScrollbackBuffer(int)
Creates a new TerminalScrollbackBuffer with the specified capacity.
Declaration
public TerminalScrollbackBuffer(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | Maximum number of lines to retain. |
Properties
Capacity
Gets the maximum capacity of the buffer.
Declaration
public int Capacity { get; }
Property Value
| Type | Description |
|---|---|
| int |
Count
Gets the number of lines currently stored.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Append(string, Color32, ScrollbackAttributeRun[])
Appends a line to the buffer.
Declaration
public void Append(string text, Color32 color, ScrollbackAttributeRun[] runs = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The plain text content. |
| Color32 | color | The foreground color. |
| ScrollbackAttributeRun[] | runs | Optional styled spans within the line. Pass |
Clear()
Clears all lines from the buffer.
Declaration
public void Clear()
GetLine(int)
Gets the line at the specified index. Index 0 is the oldest entry, index Count-1 is the newest.
Declaration
public ScrollbackLine GetLine(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The logical index (0 = oldest). |
Returns
| Type | Description |
|---|---|
| ScrollbackLine | The scrollback line at the specified index. |
RemapColors(IReadOnlyDictionary<uint, uint>)
Rewrites the color of every stored line that the map has an entry for, which is how terminal history follows a theme change instead of staying on the old colors.
Declaration
public int RemapColors(IReadOnlyDictionary<uint, uint> map)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyDictionary<uint, uint> | map | A packed-color translation table, as produced by BuildMap(ColorPalette, ColorPalette, Dictionary<uint, uint>). Null or empty is a no-op. |
Returns
| Type | Description |
|---|---|
| int | The number of lines whose color changed. |
Remarks
ScrollbackLine is a readonly struct and the underlying ring buffer has no way to write at an index, so the pass reads each line from the oldest end and appends it again. Reading one before writing one keeps occupancy from ever rising, so this is safe on a buffer that is full and has already wrapped, and after exactly Count iterations the lines are back in their original order.
Rebuilt lines reuse the original text and attribute-run references, so the whole pass allocates nothing.