UOperatingSystemTerminalHistory
#include <OperatingSystemSimulator/Public/Programs/Terminal/OperatingSystemTerminalHistory.h>class UOperatingSystemTerminalHistoryDefined in OperatingSystemTerminalHistory.h:18
Inherits:
UOperatingSystemProgramData
Inheritance diagram
Section titled “Inheritance diagram”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class UOperatingSystemTerminalHistory["UOperatingSystemTerminalHistory"]
class UOperatingSystemProgramData["UOperatingSystemProgramData"]
UOperatingSystemProgramData <|-- UOperatingSystemTerminalHistory
Collaboration diagram
Section titled “Collaboration diagram”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class UOperatingSystemTerminalHistory["UOperatingSystemTerminalHistory"]
class UOperatingSystemTerminal["UOperatingSystemTerminal"]
UOperatingSystemTerminalHistory *-- UOperatingSystemTerminal
Class detail
Section titled “Class detail”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class UOperatingSystemTerminalHistory {
+UOperatingSystemTerminalHistory()
+AddToHistory(const FString &NewCommand)
+ClearHistory()
+GetNextCommand(FString &OutCommand) bool
+GetPreviousCommand(FString &OutCommand) bool
+ShouldCreate() const override bool
+OnCreate() override
+MaxSupportedHistoryCommands : uint8
+CommandHistory : TArray< FString >
+CommandHistoryIndex : int32
+ParentTerminal : TWeakObjectPtr< UOperatingSystemTerminal
}
This class represents the history of commands entered in an operating system terminal. It stores the command history and provides methods to add to the history, clear the history, and retrieve previous and next commands.
Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
UOperatingSystemTerminalHistory | ||
void | AddToHistory | Adds a new command to the command history. The command is specified as a FString parameter named NewCommand. The index of the command history is reset to INDEX_NONE, indicating that there is no current command selected. |
void | ClearHistory | Clears the command history by resetting the command history index to INDEX_NONE and emptying the command history array. |
bool | GetNextCommand | Retrieves the next command from the command history by incrementing the command history index and retrieving the command at the new index. If the command history is empty or the index exceeds the command history size, the method returns false and does not modify the OutCommand parameter. Otherwise, it returns true and assigns the retrieved command to the OutCommand parameter. |
bool | GetPreviousCommand | Retrieves the command that was entered before the current command in the command history. It decrements the CommandHistoryIndex to move to the previous command. If the CommandHistoryIndex becomes invalid (i.e., less than zero or greater than or equal to the size of the command history array), it is set to zero, which represents the first command in the history. |
UOperatingSystemTerminalHistory
Section titled “UOperatingSystemTerminalHistory”UOperatingSystemTerminalHistory()Defined in OperatingSystemTerminalHistory.h:54
Section titled “Defined in OperatingSystemTerminalHistory.h:54”AddToHistory
Section titled “AddToHistory”void AddToHistory(const FString & NewCommand)Defined in OperatingSystemTerminalHistory.h:87
Adds a new command to the command history. The command is specified as a FString parameter named NewCommand. The index of the command history is reset to INDEX_NONE, indicating that there is no current command selected.
Parameters
Section titled “Parameters”NewCommandThe new command to be added to the history.
See also: CommandHistoryIndex
See also: CommandHistory
References
Section titled “References”ClearHistory
Section titled “ClearHistory”void ClearHistory()Defined in OperatingSystemTerminalHistory.h:95
Clears the command history by resetting the command history index to INDEX_NONE and emptying the command history array.
See also: CommandHistoryIndex
See also: CommandHistory
References
Section titled “References”GetNextCommand
Section titled “GetNextCommand”bool GetNextCommand(FString & OutCommand)Defined in OperatingSystemTerminalHistory.h:109 Retrieves the next command from the command history by incrementing the command history index and retrieving the command at the new index. If the command history is empty or the index exceeds the command history size, the method returns false and does not modify the OutCommand parameter. Otherwise, it returns true and assigns the retrieved command to the OutCommand parameter.
Parameters
Section titled “Parameters”OutCommandThe variable where the next command will be stored if it exists.
Returns
Section titled “Returns”True if the next command was retrieved successfully, false otherwise.
See also: CommandHistory
See also: CommandHistoryIndex
References
Section titled “References”GetPreviousCommand
Section titled “GetPreviousCommand”bool GetPreviousCommand(FString & OutCommand)Defined in OperatingSystemTerminalHistory.h:126 Retrieves the command that was entered before the current command in the command history. It decrements the CommandHistoryIndex to move to the previous command. If the CommandHistoryIndex becomes invalid (i.e., less than zero or greater than or equal to the size of the command history array), it is set to zero, which represents the first command in the history.
If the command history is empty, the method returns false, indicating that there is no previous command. Otherwise, it returns true and assigns the retrieved command to the OutCommand parameter.
Parameters
Section titled “Parameters”OutCommandThe variable where the previous command will be stored if it exists.
Returns
Section titled “Returns”True if the previous command was retrieved successfully, false otherwise.
See also: CommandHistory
See also: CommandHistoryIndex
References
Section titled “References”Protected Methods
Section titled “Protected Methods”| Return | Name | Description |
|---|---|---|
bool | ShouldCreate virtual const override | Determines whether the operating system terminal history should be created. |
void | OnCreate virtual override | Determines whether the operating system terminal history should be created. |
ShouldCreate
Section titled “ShouldCreate”virtual const override
virtual bool ShouldCreate() const overrideDefined in OperatingSystemTerminalHistory.h:63 Determines whether the operating system terminal history should be created.
Returns
Section titled “Returns”Whether the operating system terminal history should be created.
References
Section titled “References”Reimplements
Section titled “Reimplements”OnCreate
Section titled “OnCreate”virtual override
virtual void OnCreate() overrideDefined in OperatingSystemTerminalHistory.h:73 Determines whether the operating system terminal history should be created.
The OnCreate method is invoked when the [UOperatingSystemTerminalHistory](#uoperatingsystemterminalhistory) instance is created. It is responsible for initializing the command history, setting the parent terminal, and performing any other necessary setup.
References
Section titled “References”Reimplements
Section titled “Reimplements”Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
uint8 | MaxSupportedHistoryCommands | How many commands should be supported <br/> |
TArray< FString > | CommandHistory | CommandHistory array stores the history of commands entered in the Operating System Terminal. It is marked as Transient, which means it will not be saved when the game state is serialized. |
int32 | CommandHistoryIndex | Property for storing the index of the command history in the operating system terminal. |
TWeakObjectPtr< UOperatingSystemTerminal > | ParentTerminal | Represents a weak reference to the parent operating system terminal. |
MaxSupportedHistoryCommands
Section titled “MaxSupportedHistoryCommands”uint8 MaxSupportedHistoryCommandsDefined in OperatingSystemTerminalHistory.h:24 How many commands should be supported <br/>
Referenced by
Section titled “Referenced by”CommandHistory
Section titled “CommandHistory”TArray< FString > CommandHistoryDefined in OperatingSystemTerminalHistory.h:31 CommandHistory array stores the history of commands entered in the Operating System Terminal. It is marked as Transient, which means it will not be saved when the game state is serialized.
Referenced by
Section titled “Referenced by”CommandHistoryIndex
Section titled “CommandHistoryIndex”int32 CommandHistoryIndexDefined in OperatingSystemTerminalHistory.h:39 Property for storing the index of the command history in the operating system terminal.
This property is marked as transient, meaning it will not be saved or serialized when the instance is saved or serialized.
Referenced by
Section titled “Referenced by”ParentTerminal
Section titled “ParentTerminal”TWeakObjectPtr< UOperatingSystemTerminal > ParentTerminalDefined in OperatingSystemTerminalHistory.h:50 Represents a weak reference to the parent operating system terminal.
A weak reference is a non-owning reference to an object that does not keep the object alive. If the parent terminal object is deleted, the weak reference will automatically become null. It is important to check if the weak reference is valid before using it to avoid any errors.
See also: UOperatingSystemTerminal