Class: RETerm::Components::Splash
- Inherits:
-
RETerm::Component
- Object
- RETerm::Component
- RETerm::Components::Splash
- Defined in:
- lib/reterm/components/splash.rb
Overview
Splash Screen
Constant Summary
Constants included from LogHelpers
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#widget ⇒ Object
readonly
Returns the value of attribute widget.
Attributes inherited from RETerm::Component
#activatable, #activate_focus, #highlight_focus, #window
Class Method Summary collapse
-
.show(args = {}, &bl) ⇒ Object
Client may invoke this to - create dialog and window - activate it - periodically invoke callback, check return value - close / cleanup.
Instance Method Summary collapse
- #activate!(*input) ⇒ Object
- #close! ⇒ Object
- #draw! ⇒ Object
-
#initialize(args = {}) ⇒ Splash
constructor
Initialize the Splash component.
- #requested_cols ⇒ Object
- #requested_rows ⇒ Object
- #sync! ⇒ Object
- #window=(win) ⇒ Object
Methods inherited from RETerm::Component
#activatable?, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #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 = {}) ⇒ Splash
Initialize the Splash component
12 13 14 15 16 17 |
# File 'lib/reterm/components/splash.rb', line 12 def initialize(args={}) super @widget = args[:widget] @callback = args[:callback] @terminate = false end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
5 6 7 |
# File 'lib/reterm/components/splash.rb', line 5 def callback @callback end |
#widget ⇒ Object (readonly)
Returns the value of attribute widget.
5 6 7 |
# File 'lib/reterm/components/splash.rb', line 5 def @widget end |
Class Method Details
.show(args = {}, &bl) ⇒ Object
Client may invoke this to
- create dialog and window
- activate it
- periodically invoke callback,
check return value
- close / cleanup
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/reterm/components/splash.rb', line 25 def self.show(args={}, &bl) splash = self.new args.merge(:callback => bl) win = Window.new args.merge(:component => splash, :x => :center, :y => :center) #win.component = splash splash.activate! update_reterm(true) splash.close! end |
Instance Method Details
#activate!(*input) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/reterm/components/splash.rb', line 74 def activate!(*input) until @terminate window.draw! sleep SYNC_TIMEOUT.to_f / 1000 run_sync! @terminate = !!callback.call end end |
#close! ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/reterm/components/splash.rb', line 44 def close! .erase .finalize! window.erase window.finalize! # get rid of all outstanding input flush_input end |
#draw! ⇒ Object
59 60 61 62 |
# File 'lib/reterm/components/splash.rb', line 59 def draw! window.border! .draw! end |
#requested_cols ⇒ Object
40 41 42 |
# File 'lib/reterm/components/splash.rb', line 40 def requested_cols @widget.requested_cols + 3 end |
#requested_rows ⇒ Object
36 37 38 |
# File 'lib/reterm/components/splash.rb', line 36 def requested_rows @widget.requested_rows + 3 end |
#sync! ⇒ Object
55 56 57 |
# File 'lib/reterm/components/splash.rb', line 55 def sync! .sync! end |
#window=(win) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/reterm/components/splash.rb', line 64 def window=(win) super(win) cw = win.create_child :rows => .requested_rows, :cols => .requested_cols, :x => 1, :y => 1 raise ArgumentError, "could not create child" if cw.win.nil? cw.component = end |