Cauldron2D.Drafter.Client.WindowKeys (Cauldron2D.Drafter v0.3.0)

Copy Markdown View Source

Turns a CauldronGPU window's key events into the events a drafter app gets from a terminal speaking the kitty keyboard protocol with key releases (Drafter.Terminal.KittyKeyboard): a press is the legacy {:key, ...} event followed by {:key_down, key, modifiers}, a repeat the legacy event alone, a release {:key_up, key, modifiers}. Shifted glyphs are those of a US keyboard.

iex> alias Cauldron2D.Drafter.Client.WindowKeys
iex> WindowKeys.events({:key, :down, :a, false}, [:shift])
[{:key, :A}, {:key_down, :a, [:shift]}]
iex> WindowKeys.events({:key, :up, :return, false}, [])
[{:key_up, :enter, []}]

Summary

Functions

The drafter events for one window key event with modifiers held.

The modifiers held after event, from those held before it, in the order [:ctrl, :alt, :shift].

Types

modifier()

@type modifier() :: :ctrl | :alt | :shift

window_event()

@type window_event() :: {:key, :down | :up, atom(), boolean()}

Functions

events(arg, modifiers)

@spec events(window_event(), [modifier()]) :: [tuple()]

The drafter events for one window key event with modifiers held.

modifiers(arg, held)

@spec modifiers(window_event(), [modifier()]) :: [modifier()]

The modifiers held after event, from those held before it, in the order [:ctrl, :alt, :shift].