Struct LineScrollWindow
Represents a snapshot of the currently visible content produced by GetWindow(). Contains the visible VisualLine array and scroll state, allowing rendering code to operate without holding a reference to the buffer.
Inherited Members
Namespace: Scylla.Core.Util.UI
Assembly: ScyllaCore.dll
Syntax
public readonly struct LineScrollWindow
Remarks
This is a value type (struct). Copying it copies the array reference and all scalar fields, but does not clone the Lines array contents. The struct is intended to be consumed within a single render frame.
Constructors
LineScrollWindow(VisualLine[], int, int, int)
Creates a new line scroll window snapshot.
Declaration
public LineScrollWindow(VisualLine[] lines, int scrollOffset, int totalVisualLines, int windowSize)
Parameters
| Type | Name | Description |
|---|---|---|
| VisualLine[] | lines | The visible visual lines, ordered oldest-to-newest.
Pass |
| int | scrollOffset | The current scroll offset in visual lines from the bottom (0 = newest content visible). |
| int | totalVisualLines | The total number of visual lines across all logical lines in the buffer. Used to compute ScrollProgress and scroll-bar position. |
| int | windowSize | The maximum number of visual lines the window can display. Used to compute IsAtTop and ScrollProgress. |
Fields
Empty
An empty window with no visible lines. Safe to pass to any rendering method; it has zero lines and zero scroll offsets.
Declaration
public static readonly LineScrollWindow Empty
Field Value
| Type | Description |
|---|---|
| LineScrollWindow |
Lines
The visible visual lines in this window. Index 0 is the oldest visible line (displayed at the top of the window); the last index is the newest visible line (displayed at the bottom).
Declaration
public readonly VisualLine[] Lines
Field Value
| Type | Description |
|---|---|
| VisualLine[] |
ScrollOffset
The current scroll offset measured in visual lines from the bottom (newest content). A value of 0 means the newest content is visible. Larger values indicate scrolling toward older content.
Declaration
public readonly int ScrollOffset
Field Value
| Type | Description |
|---|---|
| int |
TotalVisualLines
The total number of visual lines in the buffer.
Declaration
public readonly int TotalVisualLines
Field Value
| Type | Description |
|---|---|
| int |
WindowSize
The window size (maximum visible lines).
Declaration
public readonly int WindowSize
Field Value
| Type | Description |
|---|---|
| int |
Properties
IsAtBottom
Gets whether the view is at the bottom (showing newest content).
Declaration
public bool IsAtBottom { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsAtTop
Gets whether the view is at the top (showing oldest content).
Declaration
public bool IsAtTop { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsEmpty
Gets whether this window is empty.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
LineCount
Gets the number of visible lines in this window.
Declaration
public int LineCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
ScrollProgress
Gets the scroll progress as a normalized value. 0.0 means the newest content is fully visible (bottom). 1.0 means the oldest content is fully visible (top). Returns 0.0 when all content fits within the window (no scrolling possible).
Declaration
public float ScrollProgress { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
GetCombinedText()
Gets the combined text of all visible lines, separated by newlines. When the window contains exactly one line, returns that line's text directly without allocating a StringBuilder.
Declaration
public string GetCombinedText()
Returns
| Type | Description |
|---|---|
| string | The combined text, or |
GetCombinedTextWithSelection(TextSelectionRange, Color)
Gets the combined text of all visible lines with selection highlighting applied using
TMP <mark> tags to render the selection color.
Declaration
public string GetCombinedTextWithSelection(TextSelectionRange selection, Color selectionColor)
Parameters
| Type | Name | Description |
|---|---|---|
| TextSelectionRange | selection | The selection range to highlight. When the selection is empty, invalid, or does not overlap any visible line, behaves identically to GetCombinedText(). |
| Color | selectionColor | The highlight color for selected text. |
Returns
| Type | Description |
|---|---|
| string | The combined text with TMP selection markup, or plain text if nothing is selected. |
GetEnumerator()
Gets an enumerator for the visible lines.
Declaration
public LineScrollWindow.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| LineScrollWindow.Enumerator | An enumerator. |
GetLine(int)
Gets a visual line by its index within this window. The index is relative to the window (0 = topmost visible line), not to the buffer.
Declaration
public VisualLine GetLine(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The window-relative index (0 = topmost visible). |
Returns
| Type | Description |
|---|---|
| VisualLine | The visual line at the specified position. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when index is out of range. |
TryGetLine(int, out VisualLine)
Attempts to get a visual line by its window-relative index. The index is relative to the window (0 = topmost visible line), not to the buffer.
Declaration
public bool TryGetLine(int index, out VisualLine line)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The window-relative index. |
| VisualLine | line | The visual line if found; otherwise |
Returns
| Type | Description |
|---|---|
| bool |
|
WriteTo(StringBuilder)
Writes the combined text of all visible lines to a StringBuilder.
A null sb is silently ignored.
No string allocation occurs if the caller reuses the same instance across calls.
Declaration
public void WriteTo(StringBuilder sb)
Parameters
| Type | Name | Description |
|---|---|---|
| StringBuilder | sb | The StringBuilder to write to. May be |
WriteToWithSelection(StringBuilder, TextSelectionRange, string)
Writes the combined text with selection highlighting to a StringBuilder,
using a caller-supplied pre-built TMP mark open tag to avoid per-call string allocation.
A null sb is silently ignored.
Declaration
public void WriteToWithSelection(StringBuilder sb, TextSelectionRange selection, string markOpenTag)
Parameters
| Type | Name | Description |
|---|---|---|
| StringBuilder | sb | The StringBuilder to write to. May be |
| TextSelectionRange | selection | The selection range to highlight. |
| string | markOpenTag | A complete TMP mark opening tag, for example |
WriteToWithSelection(StringBuilder, TextSelectionRange, Color)
Writes the combined text with selection highlighting to a StringBuilder.
This overload converts selectionColor to an RGBA hex string on every
call and allocates a temporary string for the mark tag. For repeated rendering use
the WriteToWithSelection(StringBuilder, TextSelectionRange, string) overload
with a pre-built tag to avoid per-frame allocation.
Declaration
public void WriteToWithSelection(StringBuilder sb, TextSelectionRange selection, Color selectionColor)
Parameters
| Type | Name | Description |
|---|---|---|
| StringBuilder | sb | The StringBuilder to write to. |
| TextSelectionRange | selection | The selection range to highlight. |
| Color | selectionColor | The highlight color for selected text. |