namespace DodoSSH.Client.Shell.Keyboard;
/// What pressing a terminal key does.
internal enum TerminalKeyKind
{
/// Sends its bytes, after any latched modifier has had its say.
Send,
/// Latches Ctrl for the next key, and releases itself after it.
Control,
/// Latches Alt for the next key, and releases itself after it.
Alt,
/// Pastes the clipboard, through the same path a right-click on the desktop takes.
Paste,
}
///
/// One key the phone's own keyboard does not have.
///
///
///
/// A record for the convenience of construction and nothing else: two keys are the same key when their
/// is, which is what the bar stores. The byte array would make record equality reference
/// equality anyway, so nothing here leans on it.
///
///
/// exists for the labels that are words — ctrl+B % — which want two cells on
/// the quick-access keyboard where an arrow wants one. It is a fact about the label rather than a layout
/// choice made per screen, so it lives here.
///
///
/// Stable across releases; the bar and the group order are stored by it.
/// What the key says.
/// What pressing it does.
/// What it sends, for . Empty otherwise.
/// What it is for, for the customise screen and for accessibility.
internal sealed record TerminalKey(string Id, string Label, TerminalKeyKind Kind, byte[] Bytes, string Hint)
{
/// Whether the label is long enough to want a double-width cell.
internal bool IsWide => Label.Length > 4;
/// Whether this is one of the two latching modifiers.
internal bool IsModifier => Kind is TerminalKeyKind.Control or TerminalKeyKind.Alt;
/// Whether this key was added by the person using it rather than shipped.
internal bool IsCustom => Id.StartsWith(TerminalKeyCatalog.CustomPrefix, StringComparison.Ordinal);
}
/// A named set of keys on the quick-access keyboard.
/// Stable across releases; the order and the hidden set are stored by it.
/// The caption above the keys.
/// The keys, in the order they are drawn.
internal sealed record TerminalKeyGroup(string Id, string Title, IReadOnlyList Keys);