Class QuantumConsole
Provides the UI and I/O interface for the QuantumConsoleProcessor. Invokes commands on the processor and displays the output.
Namespace: QFSW.QC
Assembly: QFSW.QC.dll
Syntax
[DisallowMultipleComponent]
public class QuantumConsole : MonoBehaviour
Properties
AreActionsExecuting
If any actions are currently executing
Declaration
public bool AreActionsExecuting { get; }
Property Value
Type | Description |
---|---|
Boolean |
Instance
Singleton reference to the console. Only valid and set if the singleton option is enabled for the console.
Declaration
public static QuantumConsole Instance { get; }
Property Value
Type | Description |
---|---|
QuantumConsole |
IsActive
Declaration
public bool IsActive { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsFocused
Declaration
public bool IsFocused { get; }
Property Value
Type | Description |
---|---|
Boolean |
KeyConfig
Declaration
public QuantumKeyConfig KeyConfig { get; set; }
Property Value
Type | Description |
---|---|
QuantumKeyConfig |
Localization
Declaration
public QuantumLocalization Localization { get; set; }
Property Value
Type | Description |
---|---|
QuantumLocalization |
MaxStoredLogs
The maximum number of logs that may be stored in the log storage before old logs are removed.
Declaration
public int MaxStoredLogs { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Theme
Declaration
public QuantumTheme Theme { get; }
Property Value
Type | Description |
---|---|
QuantumTheme |
Methods
Activate()
Activates the Quantum Console.
Declaration
public void Activate()
Activate(Boolean)
Activates the Quantum Console.
Declaration
public void Activate(bool shouldFocus)
Parameters
Type | Name | Description |
---|---|---|
Boolean | shouldFocus | If the input field should be automatically focused. |
AppendLog(ILog)
Declaration
protected void AppendLog(ILog log)
Parameters
Type | Name | Description |
---|---|---|
ILog | log |
ApplyTheme(QuantumTheme, Boolean)
Applies a theme to the Quantum Console.
Declaration
public void ApplyTheme(QuantumTheme theme, bool forceRefresh = false)
Parameters
Type | Name | Description |
---|---|---|
QuantumTheme | theme | The desired theme to apply. |
Boolean | forceRefresh |
BeginResponse(Action<String>, ResponseConfig)
Begin accepting text input from the user as a response.
Declaration
public void BeginResponse(Action<string> onSubmitResponseCallback, ResponseConfig config)
Parameters
Type | Name | Description |
---|---|---|
Action<String> | onSubmitResponseCallback | Method that will provide the submitted response text when it is submitted. |
ResponseConfig | config | The configuration to use for this response. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
CancelAllActions()
Cancels any actions currently executing.
Declaration
public void CancelAllActions()
ClearBuffers()
Declaration
protected virtual void ClearBuffers()
ClearConsole()
Clears the Quantum Console.
Declaration
public void ClearConsole()
ConstructDebugLog(String, String, LogType, Boolean, Boolean)
Declaration
protected virtual ILog ConstructDebugLog(string condition, string stackTrace, LogType type, bool prependTimeStamp, bool appendStackTrace)
Parameters
Type | Name | Description |
---|---|---|
String | condition | |
String | stackTrace | |
LogType | type | |
Boolean | prependTimeStamp | |
Boolean | appendStackTrace |
Returns
Type | Description |
---|---|
ILog |
CreateLogQueue()
Declaration
protected virtual ILogQueue CreateLogQueue()
Returns
Type | Description |
---|---|
ILogQueue |
CreateLogStorage()
Declaration
protected virtual ILogStorage CreateLogStorage()
Returns
Type | Description |
---|---|
ILogStorage |
CreateSuggestionStack()
Declaration
protected virtual SuggestionStack CreateSuggestionStack()
Returns
Type | Description |
---|---|
SuggestionStack |
Deactivate()
Deactivates the Quantum Console.
Declaration
public void Deactivate()
FocusConsoleInput()
Selects and focuses the input field for the console.
Declaration
public void FocusConsoleInput()
GenerateCommandLog(String)
Declaration
protected ILog GenerateCommandLog(string command)
Parameters
Type | Name | Description |
---|---|---|
String | command |
Returns
Type | Description |
---|---|
ILog |
GetConsoleText()
Declaration
public string GetConsoleText()
Returns
Type | Description |
---|---|
String |
InvokeCommand()
Invokes the command currently inputted into the Quantum Console.
Declaration
public void InvokeCommand()
InvokeCommand(String)
Invokes the given command.
Declaration
public object InvokeCommand(string command)
Parameters
Type | Name | Description |
---|---|---|
String | command | The command to invoke. |
Returns
Type | Description |
---|---|
Object | The return value, if any, of the invoked command. |
InvokeCommandsAsync(IEnumerable<String>)
Invokes a sequence of commands, only starting a new command when the previous is complete.
Declaration
public Task InvokeCommandsAsync(IEnumerable<string> commands)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<String> | commands | The commands to invoke. |
Returns
Type | Description |
---|---|
Task |
InvokeExternalCommandsAsync(String)
Declaration
public Task InvokeExternalCommandsAsync(string filePath)
Parameters
Type | Name | Description |
---|---|---|
String | filePath |
Returns
Type | Description |
---|---|
Task |
LogToConsole(ILog)
Logs text to the Quantum Console.
Declaration
public void LogToConsole(ILog log)
Parameters
Type | Name | Description |
---|---|---|
ILog | log | Log to be logged. |
LogToConsole(String, Boolean)
Logs text to the Quantum Console.
Declaration
public void LogToConsole(string logText, bool newLine = true)
Parameters
Type | Name | Description |
---|---|---|
String | logText | Text to be logged. |
Boolean | newLine | If a newline should be ins |
LogToConsoleAsync(ILog)
Thread safe API to format and log text to the Quantum Console.
Declaration
public void LogToConsoleAsync(ILog log)
Parameters
Type | Name | Description |
---|---|---|
ILog | log | Log to be logged. |
LogToConsoleAsync(String, LogType)
Thread safe API to format and log text to the Quantum Console.
Declaration
public void LogToConsoleAsync(string logText, LogType logType = LogType.Log)
Parameters
Type | Name | Description |
---|---|---|
String | logText | Text to be logged. |
LogType | logType | The type of the log to be logged. |
OnValidate()
Declaration
protected virtual void OnValidate()
OverrideConsoleInput(String, Boolean)
Overrides the console input field.
Declaration
public void OverrideConsoleInput(string newInput, bool shouldFocus = true)
Parameters
Type | Name | Description |
---|---|---|
String | newInput | The text to override the current input with. |
Boolean | shouldFocus | If the input field should be automatically focused. |
RemoveLogTrace()
Removes the last log from the console.
Declaration
public void RemoveLogTrace()
RequireFlush()
Declaration
protected void RequireFlush()
Serialize(Object)
Serializes a value using the current serializer and theme.
Declaration
public string Serialize(object value)
Parameters
Type | Name | Description |
---|---|---|
Object | value | The value to the serialize. |
Returns
Type | Description |
---|---|
String | The serialized value. |
SetSuggestion(Int32)
Sets the selected suggestion on the console.
Declaration
public void SetSuggestion(int suggestionIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | suggestionIndex | The index of the suggestion to set. |
StartAction(IEnumerator<ICommandAction>)
Starts executing an action.
Declaration
public void StartAction(IEnumerator<ICommandAction> action)
Parameters
Type | Name | Description |
---|---|---|
IEnumerator<ICommandAction> | action | The action to start. |
Toggle()
Toggles the Quantum Console.
Declaration
public void Toggle()
Update()
Declaration
protected virtual void Update()
Events
OnActivate
Callback executed when the QC is activated.
Declaration
public event Action OnActivate
Event Type
Type | Description |
---|---|
Action |
OnClear
Callback executed when the QC is cleared.
Declaration
public event Action OnClear
Event Type
Type | Description |
---|---|
Action |
OnDeactivate
Callback executed when the QC is deactivated.
Declaration
public event Action OnDeactivate
Event Type
Type | Description |
---|---|
Action |
OnInvoke
Callback executed when the QC invokes a command.
Declaration
public event Action<string> OnInvoke
Event Type
Type | Description |
---|---|
Action<String> |
OnLog
Callback executed when text has been logged to the QC.
Declaration
public event Action<ILog> OnLog
Event Type
Type | Description |
---|---|
Action<ILog> |
OnStateChange
Callback executed when the QC state changes.
Declaration
public event Action OnStateChange
Event Type
Type | Description |
---|---|
Action |
OnSuggestionSetGenerated
Callback executed when a new suggestion set is created. The user may modify the suggestion set.
Declaration
public event Action<SuggestionSet> OnSuggestionSetGenerated
Event Type
Type | Description |
---|---|
Action<SuggestionSet> |