Class: RETerm::Components::SelectList
- Inherits:
-
RETerm::Component
- Object
- RETerm::Component
- RETerm::Components::SelectList
- Includes:
- RETerm::CDKComponent, ItemHelpers
- Defined in:
- lib/reterm/components/select_list.rb
Overview
Select List CDK Component
Constant Summary
Constants included from LogHelpers
Instance Attribute Summary
Attributes inherited from RETerm::Component
#activatable, #activate_focus, #highlight_focus, #window
Instance Method Summary collapse
- #activate!(*input) ⇒ Object
- #current ⇒ Object
-
#initialize(args = {}) ⇒ SelectList
constructor
Initialize the SelectList component.
- #requested_cols ⇒ Object
- #requested_rows ⇒ Object
- #reset! ⇒ Object
- #selected ⇒ Object
Methods included from ItemHelpers
Methods included from RETerm::CDKComponent
#activatable?, #bind_key, #cdk?, #colors=, #component, #deactivate!, #draw!, #early_exit?, #erase, #escape_hit?, #init?, #init_cdk, #normal_exit?, #strip_formatting, #title_attrib=, #value
Methods inherited from RETerm::Component
#activatable?, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch
Methods included from KeyBindings
#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?
Methods included from LogHelpers
Methods included from EventDispatcher
Constructor Details
#initialize(args = {}) ⇒ SelectList
Initialize the SelectList component
14 15 16 17 18 |
# File 'lib/reterm/components/select_list.rb', line 14 def initialize(args={}) super @title = args[:title] || "" @items = args[:items] || [] end |
Instance Method Details
#activate!(*input) ⇒ Object
42 43 44 45 |
# File 'lib/reterm/components/select_list.rb', line 42 def activate!(*input) super selected end |
#current ⇒ Object
32 33 34 |
# File 'lib/reterm/components/select_list.rb', line 32 def current @items[component.getCurrentItem] end |
#requested_cols ⇒ Object
24 25 26 |
# File 'lib/reterm/components/select_list.rb', line 24 def requested_cols [@title.size, max_item_size].max + 2 end |
#requested_rows ⇒ Object
20 21 22 |
# File 'lib/reterm/components/select_list.rb', line 20 def requested_rows 5 + @items.size end |
#reset! ⇒ Object
28 29 30 |
# File 'lib/reterm/components/select_list.rb', line 28 def reset! component.setCurrentItem(0) end |
#selected ⇒ Object
36 37 38 39 40 |
# File 'lib/reterm/components/select_list.rb', line 36 def selected (0...@items.size).collect { |i| component.selections[i] == 1 ? @items[i] : nil }.compact end |