Raxol.Core.KeyboardShortcutsBehaviour behaviour (Raxol v0.3.0)

View Source

Behaviour for the KeyboardShortcuts module. This allows for mocking the KeyboardShortcuts module in tests.

Summary

Types

shortcut()

@type shortcut() :: String.t()

shortcut_callback()

@type shortcut_callback() :: function()

shortcut_context()

@type shortcut_context() :: atom() | nil

shortcut_name()

@type shortcut_name() :: atom() | String.t()

shortcut_opts()

@type shortcut_opts() :: keyword()

Callbacks

cleanup()

@callback cleanup() :: :ok

get_current_context()

@callback get_current_context() :: shortcut_context()

get_shortcuts_for_context(context)

@callback get_shortcuts_for_context(context :: shortcut_context()) :: [map()]

handle_keyboard_event(event)

@callback handle_keyboard_event(event :: tuple()) :: :ok

init()

@callback init() :: :ok

register_shortcut(shortcut, name, callback, opts)

@callback register_shortcut(
  shortcut :: shortcut(),
  name :: shortcut_name(),
  callback :: shortcut_callback(),
  opts :: shortcut_opts()
) :: :ok

set_context(context)

@callback set_context(context :: shortcut_context()) :: :ok

show_shortcuts_help()

@callback show_shortcuts_help() :: {:ok, String.t()} | :ok

trigger_shortcut(name, context)

@callback trigger_shortcut(
  name :: shortcut_name(),
  context :: shortcut_context()
) :: :ok | {:error, :shortcut_not_found}

unregister_shortcut(name, context)

@callback unregister_shortcut(
  name :: shortcut_name(),
  context :: shortcut_context()
) :: :ok