class RETerm::Components::SelectList
Select List CDK Component
Public Class Methods
new(args={})
click to toggle source
Initialize the SelectList
component
@param [Hash] args list params @option args [String] :title title of list @option args [Array<String>] :items items to
populate list with
Calls superclass method
RETerm::Component::new
# File lib/reterm/components/select_list.rb, line 14 def initialize(args={}) super @title = args[:title] || "" @items = args[:items] || [] end
Public Instance Methods
activate!(*input)
click to toggle source
Calls superclass method
RETerm::CDKComponent#activate!
# File lib/reterm/components/select_list.rb, line 42 def activate!(*input) super selected end
current()
click to toggle source
# File lib/reterm/components/select_list.rb, line 32 def current @items[component.getCurrentItem] end
requested_cols()
click to toggle source
# File lib/reterm/components/select_list.rb, line 24 def requested_cols [@title.size, max_item_size].max + 2 end
requested_rows()
click to toggle source
# File lib/reterm/components/select_list.rb, line 20 def requested_rows 5 + @items.size end
reset!()
click to toggle source
# File lib/reterm/components/select_list.rb, line 28 def reset! component.setCurrentItem(0) end
selected()
click to toggle source
# 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
Private Instance Methods
_component()
click to toggle source
# File lib/reterm/components/select_list.rb, line 49 def _component choices = [ " ", "-->" ] CDK::SELECTION.new(window.cdk_scr, # cdkscreen, 2, 1, CDK::RIGHT, # xplace, yplace, select pos window.rows - 2, # widget height window.cols - 2, # widget width @title, # title @items, @items.size, # items choices, choices.size, # space bar choices Ncurses::A_REVERSE, # highlight true, false) # box, shadow end