ClassicConsoleKeyboardHandler Class
Definition
Section titled “Definition”A classic console/terminal prompt keyboard handler.
public class ClassicConsoleKeyboardHandler : KeyboardConsoleComponent, IComponentInheritance object → KeyboardConsoleComponent
Implements IComponent
Constructors
Section titled “Constructors”ClassicConsoleKeyboardHandler(string)
Section titled “ClassicConsoleKeyboardHandler(string)”Creates the handler with the specified prompt.
public ClassicConsoleKeyboardHandler(string prompt = "> ")Parameters
Section titled “Parameters”prompt string
The prompt to display to the user.
Fields
Section titled “Fields”EnterPressedAction
Section titled “EnterPressedAction”This is a callback for the owner of this keyboard handler. The parameters are the component itself, the Cursor used by the handler, and the string input by the user. It’s called when the user presses ENTER.
public Action<ClassicConsoleKeyboardHandler, Cursor, string> EnterPressedActionProperties
Section titled “Properties”IsReady
Section titled “IsReady”A flag that when set to true prints a new line and the prompt.
public bool IsReady { get; set; }Prompt
Section titled “Prompt”The prompt to display to the user.
public string Prompt { get; set; }EraseGlyph
Section titled “EraseGlyph”The glyph to print when erasing a character, such as when the backspace key is pressed to erase a character.
public char EraseGlyph { get; set; }ReplaceEmptyGlyph
Section titled “ReplaceEmptyGlyph”The glyph used to replace the empty characters that may be in the string sent to EnterPressedAction.
public char ReplaceEmptyGlyph { get; set; }CursorLastY
Section titled “CursorLastY”This holds the row that the virtual cursor is starting from when someone is typing.
public int CursorLastY { get; set; }Methods
Section titled “Methods”OnAdded(IScreenObject)
Section titled “OnAdded(IScreenObject)”Called when this component is added to an object with a cursor; caches reference to the cursor.
public override void OnAdded(IScreenObject host)Parameters
Section titled “Parameters”host IScreenObject
The host object for the component.
Remarks
Section titled “Remarks”Makes the cursor visible, disables word breaks and the string parser, and prints the prompt. If the host is a Console, it uses the SadConsole.Components.ClassicConsoleKeyboardHandler._attachedCursor property, caching reference to it. You can’t change the cursor reference unless you re-add this component. If the host is a IScreenObject, the first instance of a cursor in the SadComponents collection is used. If there is no cursor, an exception is thrown.
PrintPrompt()
Section titled “PrintPrompt()”Prints the prompt and locks the cursor to the column that ends at the prompt.
public void PrintPrompt()ProcessKeyboard(IScreenObject, Keyboard, out bool)
Section titled “ProcessKeyboard(IScreenObject, Keyboard, out bool)”Called by a host when the keyboard is being processed.
public override void ProcessKeyboard(IScreenObject consoleObject, Keyboard info, out bool handled)Parameters
Section titled “Parameters”consoleObject IScreenObject
info Keyboard
handled bool
When set to true informs the host caller that we handled the mouse and to stop others from handling.