Class: Canis::AbstractTextPadRenderer
- Defined in:
- lib/canis/core/widgets/textpad.rb
Overview
renderer {{{ Very basic renderer that only prints based on color pair of the textpad
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attr ⇒ Object
attribute for row, color_pair, and the Ncurses int for the colorpair.
-
#color_pair ⇒ Object
attribute for row, color_pair, and the Ncurses int for the colorpair.
-
#content_cols ⇒ Object
content cols is the width in columns of pad list is the data array.
-
#cp ⇒ Object
attribute for row, color_pair, and the Ncurses int for the colorpair.
-
#list ⇒ Object
content cols is the width in columns of pad list is the data array.
-
#source ⇒ Object
the widget this is associated with.
Instance Method Summary collapse
-
#initialize(source = nil) ⇒ AbstractTextPadRenderer
constructor
A new instance of AbstractTextPadRenderer.
-
#pre_render ⇒ Object
(also: #update_colors)
have the renderer get the latest colors from the widget.
-
#render(pad, lineno, text) ⇒ Object
concrete / derived classes should override this for their specific uses.
-
#render_all(pad, arr) ⇒ Object
derived classes may choose to override this.
Constructor Details
#initialize(source = nil) ⇒ AbstractTextPadRenderer
Returns a new instance of AbstractTextPadRenderer.
1541 1542 1543 |
# File 'lib/canis/core/widgets/textpad.rb', line 1541 def initialize source=nil @source = source end |
Instance Attribute Details
#attr ⇒ Object
attribute for row, color_pair, and the Ncurses int for the colorpair
1534 1535 1536 |
# File 'lib/canis/core/widgets/textpad.rb', line 1534 def attr @attr end |
#color_pair ⇒ Object
attribute for row, color_pair, and the Ncurses int for the colorpair
1534 1535 1536 |
# File 'lib/canis/core/widgets/textpad.rb', line 1534 def color_pair @color_pair end |
#content_cols ⇒ Object
content cols is the width in columns of pad list is the data array
1537 1538 1539 |
# File 'lib/canis/core/widgets/textpad.rb', line 1537 def content_cols @content_cols end |
#cp ⇒ Object
attribute for row, color_pair, and the Ncurses int for the colorpair
1534 1535 1536 |
# File 'lib/canis/core/widgets/textpad.rb', line 1534 def cp @cp end |
#list ⇒ Object
content cols is the width in columns of pad list is the data array
1537 1538 1539 |
# File 'lib/canis/core/widgets/textpad.rb', line 1537 def list @list end |
#source ⇒ Object
the widget this is associated with.
1539 1540 1541 |
# File 'lib/canis/core/widgets/textpad.rb', line 1539 def source @source end |
Instance Method Details
#pre_render ⇒ Object Also known as: update_colors
have the renderer get the latest colors from the widget. Override this if for some reason the renderer wishes to hardcode its own. But then the widgets colors would be changed ?
1547 1548 1549 1550 1551 1552 |
# File 'lib/canis/core/widgets/textpad.rb', line 1547 def pre_render @attr = @source.attr cp = get_color($datacolor, @source.color(), @source.bgcolor()) @color_pair = @source.color_pair || cp @cp = FFI::NCurses.COLOR_PAIR(cp) end |
#render(pad, lineno, text) ⇒ Object
concrete / derived classes should override this for their specific uses. Called if only a row is changed.
1574 1575 1576 1577 |
# File 'lib/canis/core/widgets/textpad.rb', line 1574 def render pad, lineno, text FFI::NCurses.mvwaddstr(pad, lineno, 0, @clearstring) if @clearstring FFI::NCurses.mvwaddstr(pad, lineno, 0, text) end |
#render_all(pad, arr) ⇒ Object
derived classes may choose to override this. However, they should set size and color and attrib at the start since these can change after the object has been created depending on the application.
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 |
# File 'lib/canis/core/widgets/textpad.rb', line 1558 def render_all pad, arr pre_render @content_cols = @source.pad_cols @clearstring = " " * @content_cols @list = arr att = @attr || NORMAL FFI::NCurses.wattron(pad, @cp | att) arr.each_with_index { |line, ix| render pad, ix, line } FFI::NCurses.wattroff(pad, @cp | att) end |