class Canis::AbstractTextPadRenderer

renderer {{{ Very basic renderer that only prints based on color pair of the textpad

Attributes

attr[RW]

attribute for row, color_pair, and the Ncurses int for the colorpair

color_pair[RW]

attribute for row, color_pair, and the Ncurses int for the colorpair

content_cols[RW]

content cols is the width in columns of pad list is the data array

cp[RW]

attribute for row, color_pair, and the Ncurses int for the colorpair

list[RW]

content cols is the width in columns of pad list is the data array

source[RW]

the widget this is associated with.

Public Class Methods

new(source=nil) click to toggle source
# File lib/canis/core/widgets/textpad.rb, line 1541
def initialize source=nil
  @source = source
end

Public Instance Methods

pre_render() click to toggle source

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
Also aliased as: update_colors
render(pad, lineno, text) click to toggle source

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
render_all(pad, arr) click to toggle source

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
update_colors()
Alias for: pre_render