Class: TermCanvas::Text
Instance Attribute Summary collapse
-
#background_color ⇒ Object
readonly
Returns the value of attribute background_color.
-
#foreground_color ⇒ Object
readonly
Returns the value of attribute foreground_color.
Attributes inherited from Object
Instance Method Summary collapse
- #draw(win) ⇒ Object
-
#initialize(x:, y:, body:, foreground_color:, background_color:) ⇒ Text
constructor
A new instance of Text.
Methods inherited from Object
#position_offset, #position_override, #set_index
Constructor Details
#initialize(x:, y:, body:, foreground_color:, background_color:) ⇒ Text
Returns a new instance of Text.
16 17 18 19 20 21 22 |
# File 'lib/term_canvas/text.rb', line 16 def initialize(x:, y:, body:, foreground_color:, background_color:) @x = x @y = y @body = body @foreground_color = foreground_color @background_color = background_color end |
Instance Attribute Details
#background_color ⇒ Object (readonly)
Returns the value of attribute background_color.
3 4 5 |
# File 'lib/term_canvas/text.rb', line 3 def background_color @background_color end |
#foreground_color ⇒ Object (readonly)
Returns the value of attribute foreground_color.
3 4 5 |
# File 'lib/term_canvas/text.rb', line 3 def foreground_color @foreground_color end |
Instance Method Details
#draw(win) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/term_canvas/text.rb', line 25 def draw(win) color_pair_id = TermCanvas::BaseScreen.instance.find_or_create_color_pair( foreground_color: @foreground_color, background_color: @background_color, ).id color_pair = Curses.color_pair(color_pair_id) win.setpos(@y, @x) win.attron(color_pair) win.addstr(@body) win.attroff(color_pair) end |