Skip to content

C64KeyboardHandler Class

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

C#
public class C64KeyboardHandler : KeyboardConsoleComponent, IComponent

Inheritance objectKeyboardConsoleComponent

Implements IComponent

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.

Creates a new keyboard handler with the specified prompt.

C#
public C64KeyboardHandler(string prompt)

prompt string
The prompt to display to the user.

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.

C#
public Func<C64KeyboardHandler, Cursor, string, bool> EnterPressedAction

The prompt to display to the user.

C#
public string Prompt { get; set; }

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

C#
public char EraseGlyph { get; set; }

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

C#
public char ReplaceEmptyGlyph { get; set; }

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

C#
public override void OnAdded(IScreenObject host)

host IScreenObject
The host object for the component.

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.

Prints the prompt at the cursors current position.

C#
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.

C#
public override void ProcessKeyboard(IScreenObject consoleObject, Keyboard info, out bool handled)

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.