module

Tryst::UI::Keysyms

@api private

Translates the DSL's Tk-free key vocabulary (friendly symbols, "Ctrl-x" style modifier strings) into real Tk bind event patterns. Its own small lookup, kept separate from Handle so it's easy to extend.

Constants

FRIENDLY = {"enter" => "Return", "return" => "Return", "escape" => "Escape", "tab" => "Tab", "space" => "space", "backspace" => "BackSpace", "delete" => "Delete", "insert" => "Insert", "up" => "Up", "down" => "Down", "left" => "Left", "right" => "Right", "home" => "Home", "end" => "End", "page_up" => "Prior", "page_down" => "Next", "f1" => "F1", "f2" => "F2", "f3" => "F3", "f4" => "F4", "f5" => "F5", "f6" => "F6", "f7" => "F7", "f8" => "F8", "f9" => "F9", "f10" => "F10", "f11" => "F11", "f12" => "F12"}

Friendly name -> Tk keysym. Anything not listed here passes through as the literal keysym (so e.g. :q or "q" still works for plain letter keys without needing an entry).

MODIFIER_ALIASES = {"ctrl" => "Control", "control" => "Control", "alt" => "Alt", "option" => "Alt", "opt" => "Alt", "shift" => "Shift", "cmd" => "Command", "command" => "Command", "meta" => "Meta"}

"Ctrl"/"Cmd"/etc, however people spell them -> Tk's own modifier keyword.

Class methods

patterns_for(modifiers : Array(String), keysym : String) : Array(String)

Tk event patterns to bind for a resolved (modifiers, keysym) pair - usually just one, but two combinations are known cross-platform gotchas where the literal <Modifier-key> pattern silently never fires, so every real spelling is bound instead:

  • Shift+Tab: X11 delivers it as the distinct keysym ISO_Left_Tab, not Tab with a Shift modifier.
  • Shift+letter: a real Shift+P press reports keysym "P" outright, never keysym "p" plus a Shift bit. Unlike Tab, the shifted keysym here is simply the uppercase letter, so it's derived rather than hardcoded per key.
Source
resolve(spec : Symbol) : Tuple(Array(String), String)

spec is either a friendly Symbol (:enter) or a "Modifier-Modifier-Key" String ("Ctrl-Shift-s"). Returns {tk_modifiers, tk_keysym}.

Source
resolve(spec : String) : Tuple(Array(String), String)
Source