Class: Pry::Shell::UI::Menu

Inherits:
Base
  • Object
show all
Defined in:
lib/pry/shell/ui/menu.rb

Constant Summary collapse

HEADER =
"PRY-SHELL Main Menu"
ITEMS =
[
  { name: "1) Available sessions", value: "list" },
  { name: "2) Configuration", value: "configuration" },
  { name: "3) About pry-shell", value: "about" },
  { name: "4) Quit", value: "quit" }
].freeze
{
  "list" => -> { List.draw! },
  "configuration" => -> { Configuration.draw! },
  "about" => -> { About.draw! },
  "quit" => -> { clear! && exit(0) }
}.freeze

Constants inherited from Base

Base::SEPERATOR

Class Method Summary collapse

Methods inherited from Base

clear!, draw!, stop_main_ui!

Class Method Details

.draw_contentObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pry/shell/ui/menu.rb', line 22

def draw_content
  prompt.on(:keypress) do |event|
    if event.value == "j"
      prompt.trigger(:keydown)
    end

    if event.value == "k"
      prompt.trigger(:keyup)
    end
  end
  selection = prompt.select("Select a menu item", ITEMS)

  switch_to(selection)
end

Override this to remove “press any key” prompt



38
# File 'lib/pry/shell/ui/menu.rb', line 38

def draw_footer; end

.switch_to(selected_ui) ⇒ Object



40
41
42
# File 'lib/pry/shell/ui/menu.rb', line 40

def switch_to(selected_ui)
  MENU_ACTIONS[selected_ui].call
end