Yureka LogoDocs

Terminal

The Terminal is a simulated command-line interface (CLI) application allowing advanced navigation and interaction with the Virtual Filesystem and OS processes.

Core Features

  • Built-in Commands: Extensive suite of standard POSIX-like commands (ls, cd, pwd, mkdir, touch, rm, cp, mv, cat, echo, whoami, date, uname).
  • Process Control: Commands for listing and terminating apps (tasklist, taskkill).
  • History: Maintains command history, accessible via Up/Down arrow keys.
  • Output Buffer: Capped ring-buffer for color-tagged terminal output lines.
  • Path Resolution: Supports relative, absolute, and shorthand paths (~, ..).

Architecture & Dependencies

The UTerminalApp is a complex controller that deeply integrates with almost all OS subsystems:

  • UVirtualFilesystemSubsystem: Critical for directory traversal (cd), listing (ls), and file manipulation (touch, mkdir, rm, cp, mv). The Terminal maintains its own WorkingDirectory state to resolve relative paths.
  • UProcessManagerSubsystem: Used by the tasklist and taskkill commands to query and terminate active FProcessRecord instances.
  • UUserSessionSubsystem: Used for whoami, date, and resolving the user's home directory (~).

Technical Details

  • Controller Class: UTerminalApp (Inherits from UAppBase)
  • View Target: User must assign a UMG Widget to TerminalWidgetClass.
  • Window Specs:
    • Initial Size: 780x520
    • Resizable: true
    • Maximizable: true
  • Data Structures:
    • FTerminalLine: A struct holding the string Text and a FLinearColor Color for UI rendering.
  • Key Methods:
    • ExecuteCommand(const FString& CommandLine): The main entry point parsing user input.
    • Print(Text, Color), PrintError(), PrintSuccess(): Helper functions to push lines to the OutputBuffer.
  • Delegates Exposed to UI:
    • FOnTerminalOutputChanged: Fires whenever the output buffer is modified so the UI can rebuild the text flow.
    • FOnTerminalCleared: Fires when the clear command is used.