Class: RETerm::Components::Label
- Inherits:
-
RETerm::Component
- Object
- RETerm::Component
- RETerm::Components::Label
- Defined in:
- lib/reterm/components/label.rb
Overview
Simply renders text to window
Constant Summary
Constants included from LogHelpers
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from RETerm::Component
#activatable, #activate_focus, #highlight_focus, #window
Instance Method Summary collapse
- #draw! ⇒ Object
- #erase ⇒ Object
-
#initialize(args = {}) ⇒ Label
constructor
Initialize the Label component.
- #requested_cols ⇒ Object
- #requested_rows ⇒ Object
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 = {}) ⇒ Label
Initialize the Label component
12 13 14 15 |
# File 'lib/reterm/components/label.rb', line 12 def initialize(args={}) super @text = args[:text] || "" end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/reterm/components/label.rb', line 6 def text @text end |
Instance Method Details
#draw! ⇒ Object
25 26 27 28 |
# File 'lib/reterm/components/label.rb', line 25 def draw! padding = " " * [0, window.cols - @text.size-2].max window.mvaddstr(0, 0, @text + padding) end |
#erase ⇒ Object
30 31 32 33 34 |
# File 'lib/reterm/components/label.rb', line 30 def erase padding = " " * [0, window.cols - @text.size-2].max window.mvaddstr(0, 0, " " * (@text + padding).size) window.refresh end |
#requested_cols ⇒ Object
21 22 23 |
# File 'lib/reterm/components/label.rb', line 21 def requested_cols @text.size + 1 end |
#requested_rows ⇒ Object
17 18 19 |
# File 'lib/reterm/components/label.rb', line 17 def requested_rows 2 end |