Skip to content

Typed characters never reach elements: SpectreConsoleProvider drops ConsoleKeyInfo.KeyChar, so text input and shifted symbols are impossible #152

Description

@matt-edmondson

What's wrong

TUI/Services/SpectreConsoleProvider.cs (around lines 84-96) reads a key with Console.ReadKey(true) and returns InputResult.FromKey(keyInfo.Key, keyInfo.Modifiers). It discards keyInfo.KeyChar.

The model supports characters: InputResult.Character, InputResult.FromCharacter and InputType.Character all exist (TUI/Models/InputResult.cs:54). But nothing in the repository creates a character result. SpectreConsoleProvider is the only real provider, so no element can ever receive one.

Failure scenario

  • Typing ! reaches the element as ConsoleKey.D1 + Shift, so it cannot tell ! from 1.
  • /, ?, @, " arrive as Oem* keys, which differ from one keyboard layout to another.
  • Caps Lock state is lost, so upper and lower case can't be recovered reliably.
  • Non-US layouts and dead-key or IME composition produce the wrong characters.

As a result, a text box, search field, or any other text-entry element can't be built on this library.

Suggested fix / acceptance criteria

  • When keyInfo.KeyChar is printable (not '\0' and not a control character), fill in InputResult.Character as well as the key and modifiers.
  • Filling in both fields keeps existing key-based handlers working.
  • Add a provider-level or InputResult test showing that a Shift+D1 key info carries Character == '!'.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingreadyFully specified; implement as written

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions