Class: RETerm::Components::ScrollList
Overview
Scrolling List CDK Component
Constant Summary
Constants included
from LogHelpers
LogHelpers::LOG_FILE
Instance Attribute Summary collapse
#activatable, #activate_focus, #highlight_focus, #window
Instance Method Summary
collapse
#max_item_size
#activatable?, #bind_key, #cdk?, #colors=, #component, #deactivate!, #draw!, #early_exit?, #erase, #escape_hit?, #init?, #init_cdk, #normal_exit?, #strip_formatting, #title_attrib=, #value
#activatable?, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch
#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?
Methods included from LogHelpers
#logger
#dispatch, #handle
Constructor Details
#initialize(args = {}) ⇒ ScrollList
Initialize the ScrollList component
16
17
18
19
20
|
# File 'lib/reterm/components/scroll_list.rb', line 16
def initialize(args={})
super
@title = args[:title] || ""
@items = args[:items] || []
end
|
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
8
9
10
|
# File 'lib/reterm/components/scroll_list.rb', line 8
def items
@items
end
|
Instance Method Details
#<<(item) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/reterm/components/scroll_list.rb', line 34
def <<(item)
@items << item
if window.expand? &&
(window.rows < (requested_rows + ) ||
window.cols < (requested_cols + ))
window.request_expansion requested_rows + ,
requested_cols +
end
end
|
#activate!(*input) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/reterm/components/scroll_list.rb', line 65
def activate!(*input)
i = super
return nil unless normal_exit?
dispatch(:selected)
@items[i]
end
|
#current ⇒ Object
57
58
59
|
# File 'lib/reterm/components/scroll_list.rb', line 57
def current
selected
end
|
#current_index ⇒ Object
61
62
63
|
# File 'lib/reterm/components/scroll_list.rb', line 61
def current_index
component.getCurrentItem
end
|
#empty! ⇒ Object
49
50
51
|
# File 'lib/reterm/components/scroll_list.rb', line 49
def empty!
@items.clear
end
|
#quit_on_enter=(v) ⇒ Object
22
23
24
|
# File 'lib/reterm/components/scroll_list.rb', line 22
def quit_on_enter=(v)
component.quit_on_enter = v
end
|
#requested_cols ⇒ Object
30
31
32
|
# File 'lib/reterm/components/scroll_list.rb', line 30
def requested_cols
[@title.size, max_item_size].max + 2
end
|
#requested_rows ⇒ Object
26
27
28
|
# File 'lib/reterm/components/scroll_list.rb', line 26
def requested_rows
2 + @items.size
end
|
#reset! ⇒ Object
45
46
47
|
# File 'lib/reterm/components/scroll_list.rb', line 45
def reset!
component.setCurrentItem(0)
end
|
#selected ⇒ Object
53
54
55
|
# File 'lib/reterm/components/scroll_list.rb', line 53
def selected
@items[component.getCurrentItem]
end
|