Class ConsoleImproved
This class implements improved handling for Console access including:
- multiline input
- hotkeys
Inheritance
Inherited Members
Namespace: Dotnet.Shell.Logic.Console
Assembly: dotnet-shell-lib.dll
Syntax
public class ConsoleImproved
Constructors
| Improve this Doc View SourceConsoleImproved(IConsole, Shell)
Initializes a new instance of the ConsoleImproved class.
Declaration
public ConsoleImproved(IConsole consoleImplementation, Shell shell)
Parameters
| Type | Name | Description |
|---|---|---|
| IConsole | consoleImplementation | The console implementation. |
| Shell | shell | The shell. |
Fields
| Improve this Doc View SourceTag
An optional object to store state in
Declaration
public object Tag
Field Value
| Type | Description |
|---|---|
| System.Object |
Properties
| Improve this Doc View SourceCursorPosition
Gets the cursor position.
Declaration
public int CursorPosition { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The cursor position. |
KeyOverrides
Gets the key overrides.
Declaration
public List<KeyValuePair<ConsoleKeyEx, Func<ConsoleImproved, ConsoleKeyEx, Task<bool>>>> KeyOverrides { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<ConsoleKeyEx, System.Func<ConsoleImproved, ConsoleKeyEx, System.Threading.Tasks.Task<System.Boolean>>>> | The key overrides. |
Shell
Gets the shell.
Declaration
public Shell Shell { get; }
Property Value
| Type | Description |
|---|---|
| Shell | The shell. |
UserEnteredText
Gets or sets the user entered text.
Declaration
public string UserEnteredText { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | The user entered text. |
UserEnteredTextPosition
Gets the user entered text position.
Declaration
public int UserEnteredTextPosition { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The user entered text position. |
Width
Gets the width of the screen
Declaration
public int Width { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The width. |
Methods
| Improve this Doc View SourceAddKeyOverride(ConsoleKeyEx, Func<ConsoleImproved, ConsoleKeyEx, Task<Boolean>>)
Adds a key override.
Declaration
public void AddKeyOverride(ConsoleKeyEx key, Func<ConsoleImproved, ConsoleKeyEx, Task<bool>> func)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsoleKeyEx | key | The key. |
| System.Func<ConsoleImproved, ConsoleKeyEx, System.Threading.Tasks.Task<System.Boolean>> | func | The function. |
ClearUserEntry(Int32)
Clears the user text entry from the screen.
Declaration
public void ClearUserEntry(int numLinesToClear = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | numLinesToClear | The number lines to clear. |
DisplayPrompt(Boolean)
Displays the prompt.
Declaration
public void DisplayPrompt(bool forcePromptOntoNewLine = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | forcePromptOntoNewLine | if set to |
DisplayPrompt(String, Boolean)
Displays the prompt.
Declaration
public void DisplayPrompt(string text, bool forcePromptOntoNewLine)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text. |
| System.Boolean | forcePromptOntoNewLine | if set to |
GetCommandAsync(CancellationToken)
Gets the command tryed in by the user asynchronously.
Declaration
public async Task<string> GetCommandAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.String> | Task |
IgnoreTab()
Ignores the last tab character
Declaration
public void IgnoreTab()
ReplaceUserEntryAtPosition(String, Int32)
Replaces the user text at the specified position.
Declaration
public void ReplaceUserEntryAtPosition(string text, int position)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text. |
| System.Int32 | position | The position. |
Reset()
Resets this instance.
Declaration
public void Reset()
Write(ColorString)
Writes the specified text.
Declaration
public void Write(ColorString text)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorString | text | The text. |
Write(String, Boolean)
Writes the specified text.
Declaration
public void Write(string text = "", bool multiline = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | The text. |
| System.Boolean | multiline | if set to |
WriteLine(ColorString)
Writes the line.
Declaration
public void WriteLine(ColorString text)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorString | text | The text. |
WriteLine(String)
Writes the line.
Declaration
public void WriteLine(string message = "")
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | message | The message. |