Class TextModeTerminal
Reusable terminal UI frontend component. Composes a UITextModeView (GPU grid renderer), TerminalScrollbackBuffer, TerminalGridRenderer, TerminalCLI, TerminalEmulator, and TextModeSelectionManager into a complete terminal panel.
Has two operational modes:
- Log Mode (default): Scrollback buffer + optional CLI input row.
- Full-Screen Mode: Alternate screen buffer driven by TerminalEmulator.
This is a plain C# class (not MonoBehaviour) with zero dependencies beyond Core, TextMode, and Unity.InputSystem. The terminal uses transparent cell backgrounds by default; consumers add their own background behind the view.
Implements
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public sealed class TextModeTerminal : IDisposable
Constructors
TextModeTerminal(RectTransform, TextModeTerminalSettings)
Creates a new TextModeTerminal.
Declaration
public TextModeTerminal(RectTransform parent, TextModeTerminalSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | parent | The parent RectTransform to attach the terminal view to. |
| TextModeTerminalSettings | settings | The terminal settings. |
Properties
CLI
Gets the terminal CLI instance (log mode only). Null if CLI is disabled.
Declaration
public TerminalCLI CLI { get; }
Property Value
| Type | Description |
|---|---|
| TerminalCLI |
Emulator
Gets the terminal emulator for full-screen mode.
Declaration
public TerminalEmulator Emulator { get; }
Property Value
| Type | Description |
|---|---|
| TerminalEmulator |
FullScreenScrollOffset
Gets how many lines the full-screen view is scrolled back into the scrollback. Zero means it shows the live screen.
Declaration
public int FullScreenScrollOffset { get; }
Property Value
| Type | Description |
|---|---|
| int |
FullScreenScrollbackLength
Gets how many lines the full-screen scrollback holds.
Declaration
public int FullScreenScrollbackLength { get; }
Property Value
| Type | Description |
|---|---|
| int |
HasSelection
Gets whether any text is currently selected.
Declaration
public bool HasSelection { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsFullScreenMode
Gets whether the terminal is currently in full-screen mode.
Declaration
public bool IsFullScreenMode { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MaxScrollPosition
Gets the maximum scroll position in pixels (log mode).
Declaration
public float MaxScrollPosition { get; }
Property Value
| Type | Description |
|---|---|
| float |
PinnedBottomRows
Gets or sets how many rows at the bottom of the screen stay in place while the full-screen view is scrolled back, for a status line that belongs to the present rather than to the history.
Declaration
public int PinnedBottomRows { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Applies to full-screen mode only, where it also keeps a selection off those rows. In log mode the terminal pins the command line rows instead and ignores this value.
RootObject
Gets the root GameObject of the terminal.
Declaration
public GameObject RootObject { get; }
Property Value
| Type | Description |
|---|---|
| GameObject |
RootTransform
Gets the root RectTransform of the terminal.
Declaration
public RectTransform RootTransform { get; }
Property Value
| Type | Description |
|---|---|
| RectTransform |
ScrollPosition
Gets the current scroll position in pixels (log mode).
Declaration
public float ScrollPosition { get; }
Property Value
| Type | Description |
|---|---|
| float |
View
Gets the UITextModeView used for grid rendering.
Declaration
public UITextModeView View { get; }
Property Value
| Type | Description |
|---|---|
| UITextModeView |
ViewportHeight
Gets the viewport height in pixels (log mode).
Declaration
public float ViewportHeight { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
AppendLine(string, Color32)
Appends a line of text with a specific color to the scrollback buffer.
Declaration
public void AppendLine(string text, Color32 color)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to append. |
| Color32 | color | The foreground color for the text. |
Remarks
TMP-style rich text tags are stripped, since TextMode renders plain characters only, and the text is split on linebreaks into one scrollback line per line.
ANSI style markup is honored. A passage wrapped in the SGR sequences for inverse video is stored with the Inverse attribute and renders with its foreground and background swapped. The escape sequences themselves are removed, so they take up no cells and never reach the clipboard. See ANSIAttributeParser for the attributes that are recognized.
See Also
ApplyScrollVelocity(float)
Applies a velocity to the scroll physics for momentum scrolling.
Declaration
public void ApplyScrollVelocity(float velocity)
Parameters
| Type | Name | Description |
|---|---|---|
| float | velocity | The velocity in pixels per second. |
Clear()
Clears the scrollback buffer and resets scroll state.
Declaration
public void Clear()
CopySelectionToClipboard()
Copies the current selection to the system clipboard. After SelectAll() in log mode this is the whole log, including the lines scrolled out of view.
Declaration
public void CopySelectionToClipboard()
Destroy()
Destroys the terminal and releases all resources.
Declaration
public void Destroy()
Dispose()
Declaration
public void Dispose()
Feed(byte[], int, int)
Feeds raw bytes through the VT parser into the terminal emulator (full-screen mode). In log mode this is a no-op.
Declaration
public void Feed(byte[] data, int offset, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The byte data to feed. |
| int | offset | Start offset in the data array. |
| int | count | Number of bytes to feed. |
Feed(string)
Feeds a string through the VT parser into the terminal emulator (full-screen mode). In log mode this is a no-op.
Declaration
public void Feed(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to feed. |
HandleDrag(Vector2)
Handles an ongoing drag gesture.
Declaration
public void HandleDrag(Vector2 screenPosition)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | screenPosition | The current screen position of the drag. |
HandleDragEnd(Vector2)
Handles the end of a drag gesture.
Declaration
public void HandleDragEnd(Vector2 screenPosition)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | screenPosition | The screen position of the drag end. |
HandleDragStart(Vector2)
Handles the start of a drag gesture.
Declaration
public void HandleDragStart(Vector2 screenPosition)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | screenPosition | The screen position of the drag start. |
Initialize()
Initializes the terminal, creating all visual and logical components. Must be called before any other operations.
Declaration
public void Initialize()
PasteIntoCommandLine(string)
Inserts text into the command line at its cursor, as a paste. Line breaks and tabs become spaces, since the command line holds one line. Does nothing without a command line.
Declaration
public void PasteIntoCommandLine(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to paste, usually the clipboard's. |
Remarks
For a host that maps pasting to its own input, with UseBuiltInClipboardShortcuts turned off.
ScrollBy(float)
Scrolls by a relative amount in pixels.
Declaration
public void ScrollBy(float pixels)
Parameters
| Type | Name | Description |
|---|---|---|
| float | pixels | The pixel amount to scroll. |
ScrollFullScreenBy(int)
Scrolls the full-screen view back into the scrollback, or forward towards the live screen.
Declaration
public void ScrollFullScreenBy(int lines)
Parameters
| Type | Name | Description |
|---|---|---|
| int | lines | Lines to move. Positive scrolls back into history, negative forward. |
Remarks
Only the primary screen has history. On the alternate screen, and in log mode, this does nothing. Rows set with PinnedBottomRows stay in place.
ScrollFullScreenToBottom()
Returns the full-screen view to the live screen.
Declaration
public void ScrollFullScreenToBottom()
ScrollTo(float)
Scrolls to a specific position in pixels.
Declaration
public void ScrollTo(float position)
Parameters
| Type | Name | Description |
|---|---|---|
| float | position | The target scroll position in pixels. |
ScrollToBottom()
Scrolls to the bottom (newest content).
Declaration
public void ScrollToBottom()
ScrollToTop()
Scrolls to the top (oldest content).
Declaration
public void ScrollToTop()
SelectAll()
Selects all text. In log mode that is the whole log: every log row in view is highlighted and stays so while the log scrolls, and CopySelectionToClipboard() copies every line in the scrollback. In full-screen mode it is the whole screen.
Declaration
public void SelectAll()
SetVisible(bool)
Sets the visibility of the terminal.
Declaration
public void SetVisible(bool visible)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | visible | Whether the terminal should be visible. |
SwitchToFullScreen()
Switches the terminal to full-screen mode. The TerminalEmulator drives the grid directly. Log mode state is preserved.
Declaration
public void SwitchToFullScreen()
SwitchToLogMode()
Switches back to log mode, restoring the scrollback view.
Declaration
public void SwitchToLogMode()
Update(float)
Updates the terminal. Call once per frame.
Declaration
public void Update(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | Frame delta time. |
UpdateFont(TMP_FontAsset)
Updates the font used by the terminal.
Declaration
public void UpdateFont(TMP_FontAsset fontAsset)
Parameters
| Type | Name | Description |
|---|---|---|
| TMP_FontAsset | fontAsset | The new font asset. |
UpdateSettings(TextModeTerminalSettings)
Updates the terminal with new settings.
Declaration
public void UpdateSettings(TextModeTerminalSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| TextModeTerminalSettings | settings | The new terminal settings. |
Events
OnHyperlinkClicked
Raised with the URI when the player Ctrl+clicks a hyperlink in full-screen mode.
Declaration
public event Action<string> OnHyperlinkClicked
Event Type
| Type | Description |
|---|---|
| Action<string> |
Remarks
Raised whether or not OpenHyperlinksOnCtrlClick opens the link, and for any URI scheme. Turn that setting off to handle links here instead.