Module: EasyCreds::Views::InitDispatch

Defined in:
lib/easy_creds/views/init_dispatch.rb

Overview

Pure keystroke → state mutation dispatcher. Returns nil (normal redraw), or a signal symbol:

:manual_entry  — caller must prompt for hidden input
:save          — caller should write the file and exit
:quit          — caller should confirm and exit
:toggle_help   — caller flips the help overlay flag

Constant Summary collapse

UP =
["\e[A", 'k'].freeze
DOWN =
["\e[B", 'j'].freeze
PAGE_UP =
["\e[5~", "\e[I"].freeze
PAGE_DOWN =
["\e[6~", "\e[G"].freeze
HOME_KEY =
["\e[H", "\e[1~", "\eOH"].freeze
END_KEY =
["\e[F", "\e[4~", "\eOF"].freeze
SIGNAL_KEYS =

Keys that return a signal directly without touching state.

{
  'm' => :manual_entry,
  's' => :save, 'S' => :save,
  'q' => :quit, "\e" => :quit,
  '?' => :toggle_help, 'h' => :toggle_help
}.freeze

Class Method Summary collapse

Class Method Details

.handle(key, state, root: nil) ⇒ Object

Returns nil (redraw) or a signal symbol (:manual_entry, :save, :quit, :toggle_help).



28
29
30
31
32
33
# File 'lib/easy_creds/views/init_dispatch.rb', line 28

def self.handle(key, state, root: nil)
  nav = navigate(key, state)
  return nav unless nav == :not_navigation

  SIGNAL_KEYS.fetch(key) { mutate(key, state, root: root) }
end