Class: Yatte::HelpOverlay
- Inherits:
-
Object
- Object
- Yatte::HelpOverlay
- Defined in:
- lib/yatte/help_overlay.rb
Overview
Static modal listing every keyboard shortcut. Open from the editor via Ctrl+K; close with Escape, Enter, or Ctrl+K again.
Constant Summary collapse
- SHORTCUTS =
[ ["Ctrl-S", "Save file"], ["Ctrl-Q", "Quit (3 presses if dirty)"], ["Ctrl-F", "Incremental search"], ["Ctrl-H", "Find and replace"], ["Ctrl-G", "Jump to line number"], ["Ctrl-Z / Ctrl-Y", "Undo / Redo"], ["Ctrl-C / X / V", "Copy / Cut / Paste"], ["Ctrl-A", "Select all"], ["Ctrl-T", "Open file (fuzzy finder)"], ["Ctrl-P", "Project search"], ["Ctrl-W", "Close tab (3 presses if dirty)"], ["Ctrl-K", "This help screen"], ["Alt-Left / Alt-Right", "Switch tab"], ["Ctrl-Home / Ctrl-End", "Start / end of file"], ["Ctrl-Left / Ctrl-Right", "Move by word"], ["Home / End", "Start / end of line"], ["Page Up / Page Down", "Scroll one screen"], ["Shift-Arrow", "Extend selection"], ["Tab", "Insert 2 spaces"], ["Escape", "Cancel current prompt"] ].freeze
- KEY_COLUMN_WIDTH =
24
Instance Method Summary collapse
-
#initialize(terminal:, input:, background:) ⇒ HelpOverlay
constructor
A new instance of HelpOverlay.
-
#show ⇒ Object
Draws the modal and blocks until the user dismisses it.
Constructor Details
#initialize(terminal:, input:, background:) ⇒ HelpOverlay
Returns a new instance of HelpOverlay.
32 33 34 35 36 |
# File 'lib/yatte/help_overlay.rb', line 32 def initialize(terminal:, input:, background:) @terminal = terminal @input = input @background = background end |
Instance Method Details
#show ⇒ Object
Draws the modal and blocks until the user dismisses it.
39 40 41 42 43 44 45 |
# File 'lib/yatte/help_overlay.rb', line 39 def show loop do draw key = @input.read_keypress return if [:escape, :enter, :ctrl_k].include?(key) end end |