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 ownWorkingDirectorystate to resolve relative paths.UProcessManagerSubsystem: Used by thetasklistandtaskkillcommands to query and terminate activeFProcessRecordinstances.UUserSessionSubsystem: Used forwhoami,date, and resolving the user's home directory (~).
Technical Details
- Controller Class:
UTerminalApp(Inherits fromUAppBase) - View Target: User must assign a UMG Widget to
TerminalWidgetClass. - Window Specs:
- Initial Size:
780x520 - Resizable:
true - Maximizable:
true
- Initial Size:
- Data Structures:
FTerminalLine: A struct holding the stringTextand aFLinearColor Colorfor 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 theOutputBuffer.
- Delegates Exposed to UI:
FOnTerminalOutputChanged: Fires whenever the output buffer is modified so the UI can rebuild the text flow.FOnTerminalCleared: Fires when theclearcommand is used.
