Class TerminalCLI
Grid-native CLI input handler for terminal displays. Renders the command prompt, user input text, and cursor directly into the bottom row(s) of a CellGrid. Processes keyboard input via UnityEngine.InputSystem.Keyboard.current for special keys and UnityEngine.InputSystem.Keyboard.onTextInput for character input. Has no dependency on the Scylla Input module.
Implements
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public class TerminalCLI : IDisposable
Constructors
TerminalCLI(UITextModeView, TextModeTerminalSettings)
Creates a new TerminalCLI.
Declaration
public TerminalCLI(UITextModeView view, TextModeTerminalSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| UITextModeView | view | The UITextModeView for rendering cells. |
| TextModeTerminalSettings | settings | The terminal settings. |
Properties
AutoCompleter
Gets or sets the pluggable auto-completer. May be null to disable tab completion.
Declaration
public IAutoCompleter AutoCompleter { get; set; }
Property Value
| Type | Description |
|---|---|
| IAutoCompleter |
HasSuggestionHint
Gets whether there is a completion hint to draw, which is the case while Tab is cycling through more than one completion.
Declaration
public bool HasSuggestionHint { get; }
Property Value
| Type | Description |
|---|---|
| bool |
History
Gets or sets the pluggable input history. May be null to disable history navigation.
Declaration
public IInputHistory History { get; set; }
Property Value
| Type | Description |
|---|---|
| IInputHistory |
IsFocused
Gets whether the CLI is focused.
Declaration
public bool IsFocused { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsInteractable
Gets or sets whether the CLI is interactable.
Declaration
public bool IsInteractable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Text
Gets or sets the CLI input text.
Declaration
public string Text { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Clear()
Clears the input text and resets the cursor.
Declaration
public void Clear()
Dispose()
Disposes of the CLI input handler and unsubscribes from events.
Declaration
public void Dispose()
Focus()
Focuses the CLI input.
Declaration
public void Focus()
Paste(string)
Inserts text at the cursor, as a paste. The command line holds one line, so line breaks and tabs become spaces and a trailing line break is dropped. Characters typing would not insert are left out, and the text is cut at the input length limit.
Declaration
public void Paste(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to paste. |
ProcessInput(float)
Processes special key input (Escape, Enter, arrows, Tab, Backspace, Delete, Home, End). Action keys that support key repeat (Backspace, Delete, arrows, Home, End) use software repeat with an initial delay followed by a fast repeat interval.
Declaration
public void ProcessInput(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | Frame delta time for key repeat timing. |
Render(int, int)
Renders the CLI prompt, input text, and cursor into the specified row of the grid.
Declaration
public void Render(int row, int columns)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | The grid row to render into. |
| int | columns | The number of columns available. |
RenderSuggestionHint(int, int)
Renders the completion hint into the given row: the completions Tab is cycling through, laid out along a single line with the current one picked out.
Declaration
public void RenderSuggestionHint(int row, int columns)
Parameters
| Type | Name | Description |
|---|---|---|
| int | row | The grid row to render into, normally the one above the prompt. |
| int | columns | The number of columns available. |
Remarks
Only draws when HasSuggestionHint is true. The row is an
overlay on top of the log area, so the line underneath returns when the hint is
dropped and the grid is next redrawn. That redraw is not automatic: the terminal
renders only when the content is marked dirty, which it forces every frame while
the CLI holds focus but not once focus is gone. Every path that can leave a hint
showing therefore has to call HideSuggestionHint itself, focus loss
included, or the stale row keeps being painted over live output.
SetBackgroundColor(Color32)
Sets the background color for CLI rendering.
Declaration
public void SetBackgroundColor(Color32 color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | color | The new background color. |
Unfocus()
Unfocuses the CLI input.
Declaration
public void Unfocus()
UpdateSettings(TextModeTerminalSettings)
Updates settings from a TextModeTerminalSettings instance.
Declaration
public void UpdateSettings(TextModeTerminalSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| TextModeTerminalSettings | settings | The new terminal settings. |
Events
OnCommandSubmitted
Fired when a command is submitted via Enter.
Declaration
public event Action<string> OnCommandSubmitted
Event Type
| Type | Description |
|---|---|
| Action<string> |
OnEscapePressed
Fired when the user presses Escape.
Declaration
public event Action OnEscapePressed
Event Type
| Type | Description |
|---|---|
| Action |