class RETerm::Components::Dialog
Constants
- BUTTONS
Attributes
Public Class Methods
new(args={})
click to toggle source
Initialize the Dialog
component
@param [Hash] args dialog params @option args [String, Array<String>] :message string
message(s) to assign to dialog
@option args [String, Array<String>] :buttons string
buttons to assign to dialog
Calls superclass method
RETerm::Component::new
# File lib/reterm/components/dialog.rb, line 22 def initialize(args={}) super @message = [args[:message]].flatten.compact @buttons = [args[:buttons]].flatten.compact @buttons = BUTTONS[:ok_cancel] if @buttons.empty? end
show(args={})
click to toggle source
Client may invoke this to
- create dialog and window - activate it - close / cleanup
# 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
Public Instance Methods
close!()
click to toggle source
# File lib/reterm/components/dialog.rb, line 56 def close! window.erase window.finalize! self end
requested_cols()
click to toggle source
# File lib/reterm/components/dialog.rb, line 52 def requested_cols [message.size, total_button_size].max end
requested_rows()
click to toggle source
# File lib/reterm/components/dialog.rb, line 48 def requested_rows 5 end
selected()
click to toggle source
# File lib/reterm/components/dialog.rb, line 30 def selected strip_formatting(buttons[component.current_button]) end
Private Instance Methods
_component()
click to toggle source
# File lib/reterm/components/dialog.rb, line 64 def _component CDK::DIALOG.new(window.cdk_scr, CDK::CENTER, CDK::CENTER, @message, @message.size, @buttons, @buttons.size, Ncurses.COLOR_PAIR(2) | Ncurses::A_REVERSE, # highlight true, true, false) # seperate, box, shadow end