Class: RETerm::Components::Dialog
- Inherits:
-
RETerm::Component
- Object
- RETerm::Component
- RETerm::Components::Dialog
- Includes:
- RETerm::CDKComponent
- Defined in:
- lib/reterm/components/dialog.rb
Overview
CDK Dialog Component
Constant Summary collapse
- BUTTONS =
{ :ok => ["</B/24>OK"], :ok_cancel => ["</B/24>OK", "</B16>Cancel"] }
Constants included from LogHelpers
Instance Attribute Summary collapse
-
#buttons ⇒ Object
readonly
Returns the value of attribute buttons.
Attributes inherited from RETerm::Component
#activatable, #activate_focus, #highlight_focus, #window
Class Method Summary collapse
-
.show(args = {}) ⇒ Object
Client may invoke this to - create dialog and window - activate it - close / cleanup.
Instance Method Summary collapse
- #close! ⇒ Object
-
#initialize(args = {}) ⇒ Dialog
constructor
Initialize the Dialog component.
- #requested_cols ⇒ Object
- #requested_rows ⇒ Object
- #selected ⇒ Object
Methods included from RETerm::CDKComponent
#activatable?, #activate!, #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!, #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 = {}) ⇒ Dialog
Initialize the Dialog component
22 23 24 25 26 27 28 |
# File 'lib/reterm/components/dialog.rb', line 22 def initialize(args={}) super = [args[:message]].flatten.compact = [args[:buttons]].flatten.compact = BUTTONS[:ok_cancel] if .empty? end |
Instance Attribute Details
#buttons ⇒ Object (readonly)
Returns the value of attribute buttons.
7 8 9 |
# File 'lib/reterm/components/dialog.rb', line 7 def end |
Class Method Details
.show(args = {}) ⇒ Object
Client may invoke this to
- create dialog and window
- activate it
- close / cleanup
38 39 40 41 42 43 44 45 46 |
# File 'lib/reterm/components/dialog.rb', line 38 def self.show(args={}) dlg = self.new args win = Window.new win.component = dlg dlg.activate! dlg.close! return "" unless dlg.normal_exit? dlg.selected end |
Instance Method Details
#close! ⇒ Object
56 57 58 59 60 |
# File 'lib/reterm/components/dialog.rb', line 56 def close! window.erase window.finalize! self end |
#requested_cols ⇒ Object
52 53 54 |
# File 'lib/reterm/components/dialog.rb', line 52 def requested_cols [.size, ].max end |
#requested_rows ⇒ Object
48 49 50 |
# File 'lib/reterm/components/dialog.rb', line 48 def requested_rows 5 end |
#selected ⇒ Object
30 31 32 |
# File 'lib/reterm/components/dialog.rb', line 30 def selected strip_formatting([component.]) end |