class Canis::AbstractTextPadRenderer
renderer {{{ Very basic renderer that only prints based on color pair of the textpad
Attributes
attribute for row, color_pair
, and the Ncurses
int for the colorpair
attribute for row, color_pair
, and the Ncurses
int for the colorpair
content cols is the width in columns of pad list is the data array
attribute for row, color_pair
, and the Ncurses
int for the colorpair
content cols is the width in columns of pad list is the data array
the widget this is associated with.
Public Class Methods
# File lib/canis/core/widgets/textpad.rb, line 1541 def initialize source=nil @source = source end
Public Instance Methods
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 ?
# 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
concrete / derived classes should override this for their specific uses. Called if only a row is changed.
# 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
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.
# 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