Show / Hide Table of Contents

Class C64KeyboardHandler

A console prompt keyboard handler that acts like the text editor on the Commodore 64 and VIC-20 computers.

Inheritance
object
KeyboardConsoleComponent
C64KeyboardHandler
Implements
IComponent
Inherited Members
KeyboardConsoleComponent.OnRemoved(IScreenObject)
KeyboardConsoleComponent.SortOrder
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: SadConsole.Components
Assembly: SadConsole.Extended.dll
Syntax
public class C64KeyboardHandler : KeyboardConsoleComponent, IComponent
Remarks

This handler lets the user move the cursor with the keyboard arrow keys. When the ENTER key is pressed, the current line is sent to the EnterPressedAction callback. All empty characters are trimmed from the start and end of the string.

Constructors

C64KeyboardHandler(string)

Creates a new keyboard handler with the specified prompt.

Declaration
public C64KeyboardHandler(string prompt)
Parameters
Type Name Description
string prompt

The prompt to display to the user.

Fields

EnterPressedAction

This is a callback for the owner of this keyboard handler. When it returns true, the handler will print the prompt. 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.

Declaration
public Func<C64KeyboardHandler, Cursor, string, bool> EnterPressedAction
Field Value
Type Description
Func<C64KeyboardHandler, Cursor, string, bool>

Properties

EraseGlyph

The glyph to print when erasing a character, such as when the backspace key is pressed to erase a character.

Declaration
public char EraseGlyph { get; set; }
Property Value
Type Description
char

Prompt

The prompt to display to the user.

Declaration
public string Prompt { get; set; }
Property Value
Type Description
string

ReplaceEmptyGlyph

The glyph used to replace the empty characters that may be in the string sent to EnterPressedAction.

Declaration
public char ReplaceEmptyGlyph { get; set; }
Property Value
Type Description
char

Methods

OnAdded(IScreenObject)

Called when this component is added to an object with a cursor; caches reference to the cursor.

Declaration
public override void OnAdded(IScreenObject host)
Parameters
Type Name Description
IScreenObject host

The host object for the component.

Overrides
KeyboardConsoleComponent.OnAdded(IScreenObject)
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.C64KeyboardHandler._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()

Prints the prompt at the cursors current position.

Declaration
public void PrintPrompt()

ProcessKeyboard(IScreenObject, Keyboard, out bool)

Called by a host when the keyboard is being processed.

Declaration
public override void ProcessKeyboard(IScreenObject consoleObject, Keyboard info, out bool handled)
Parameters
Type Name Description
IScreenObject consoleObject
Keyboard info
bool handled

When set to true informs the host caller that we handled the mouse and to stop others from handling.

Overrides
KeyboardConsoleComponent.ProcessKeyboard(IScreenObject, Keyboard, out bool)

Implements

IComponent

Extension Methods

ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX