Class: BundleUpdateInteractive::CLI::MultiSelect::List

Inherits:
TTY::Prompt::MultiList
  • Object
show all
Defined in:
lib/bundle_update_interactive/cli/multi_select.rb

Instance Method Summary collapse

Constructor Details

#initialize(prompt, **options) ⇒ List

Returns a new instance of List.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 14

def initialize(prompt, **options)
  @opener = options.delete(:opener)
  defaults = {
    cycle: true,
    help_color: :itself.to_proc,
    per_page: [TTY::Prompt::Paginator::DEFAULT_PAGE_SIZE, TTY::Screen.height.to_i - 3].max,
    quiet: true,
    show_help: :always
  }
  super(prompt, **defaults.merge(options))
end

Instance Method Details

#keyctrl_aObject



33
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 33

def keyctrl_a(*); end

#keyctrl_rObject



34
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 34

def keyctrl_r(*); end

#keypress(event) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 36

def keypress(event)
  case event.value
  when "k", "p" then keyup
  when "j", "n" then keydown
  when "a" then select_all
  when "r" then reverse_selection
  when "o" then opener&.call(choices[@active - 1].value)
  end
end

#reverse_selectionObject



32
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 32

alias reverse_selection keyctrl_r

#select_allObject

Unregister tty-prompt’s default ctrl-a and ctrl-r bindings



31
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 31

alias select_all keyctrl_a

#selected_namesObject



26
27
28
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 26

def selected_names
  ""
end