Class: IndicatorWindow

Inherits:
Curses::Window
  • Object
show all
Defined in:
lib/profanity_fe/indicator_window.rb

Constant Summary collapse

@@list =
Array.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#bgObject

Returns the value of attribute bg.



8
9
10
# File 'lib/profanity_fe/indicator_window.rb', line 8

def bg
  @bg
end

#fgObject

Returns the value of attribute fg.



8
9
10
# File 'lib/profanity_fe/indicator_window.rb', line 8

def fg
  @fg
end

#labelObject

Returns the value of attribute label.



9
10
11
# File 'lib/profanity_fe/indicator_window.rb', line 9

def label
  @label
end

#layoutObject

Returns the value of attribute layout.



8
9
10
# File 'lib/profanity_fe/indicator_window.rb', line 8

def layout
  @layout
end

#valueObject (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

.listObject



4
5
6
# File 'lib/profanity_fe/indicator_window.rb', line 4

def IndicatorWindow.list
  @@list
end

Instance Method Details

#redrawObject



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