Class: IndicatorWindow
- Inherits:
-
Curses::Window
- Object
- Curses::Window
- IndicatorWindow
- Defined in:
- lib/profanity_fe/indicator_window.rb
Constant Summary collapse
- @@list =
Array.new
Instance Attribute Summary collapse
-
#bg ⇒ Object
Returns the value of attribute bg.
-
#fg ⇒ Object
Returns the value of attribute fg.
-
#label ⇒ Object
Returns the value of attribute label.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ IndicatorWindow
constructor
A new instance of IndicatorWindow.
- #redraw ⇒ Object
- #update(new_value) ⇒ Object
Constructor Details
#initialize(*args) ⇒ IndicatorWindow
Returns a new instance of IndicatorWindow.
16 17 18 19 20 21 22 23 |
# File 'lib/profanity_fe/indicator_window.rb', line 16 def initialize(*args) @fg = [ '444444', 'ffff00' ] @bg = [ nil, nil ] @label = '*' @value = nil @@list.push(self) super(*args) end |
Instance Attribute Details
#bg ⇒ Object
Returns the value of attribute bg.
8 9 10 |
# File 'lib/profanity_fe/indicator_window.rb', line 8 def bg @bg end |
#fg ⇒ Object
Returns the value of attribute fg.
8 9 10 |
# File 'lib/profanity_fe/indicator_window.rb', line 8 def fg @fg end |
#label ⇒ Object
Returns the value of attribute label.
9 10 11 |
# File 'lib/profanity_fe/indicator_window.rb', line 9 def label @label end |
#layout ⇒ Object
Returns the value of attribute layout.
8 9 10 |
# File 'lib/profanity_fe/indicator_window.rb', line 8 def layout @layout end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/profanity_fe/indicator_window.rb', line 9 def value @value end |
Class Method Details
.list ⇒ Object
4 5 6 |
# File 'lib/profanity_fe/indicator_window.rb', line 4 def IndicatorWindow.list @@list end |
Instance Method Details
#redraw ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/profanity_fe/indicator_window.rb', line 33 def redraw setpos(0,0) if @value if @value.is_a?(Integer) attron(color_pair(get_color_pair_id(@fg[@value], @bg[@value]))|Curses::A_NORMAL) { addstr @label } else attron(color_pair(get_color_pair_id(@fg[1], @bg[1]))|Curses::A_NORMAL) { addstr @label } end else attron(color_pair(get_color_pair_id(@fg[0], @bg[0]))|Curses::A_NORMAL) { addstr @label } end noutrefresh true end |
#update(new_value) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/profanity_fe/indicator_window.rb', line 24 def update(new_value) if new_value == @value false else @value = new_value redraw end end |