Class: Canis::PadReader

Inherits:
Object show all
Defined in:
lib/canis/core/util/extras/padreader.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = {}, &block) ⇒ PadReader

You may pass height, width, row and col for creating a window otherwise a fullscreen window will be created. If you pass a window from caller then that window will be used. Some keys are trapped, jkhl space, pgup, pgdown, end, home, t b This is currently very minimal and was created to get me started to integrating pads into other classes such as textview.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/canis/core/util/extras/padreader.rb', line 39

def initialize config={}, &block

  @config = config
  @rows = FFI::NCurses.LINES-1
  @cols = FFI::NCurses.COLS-1
  @prow = @pcol = 0
  @startrow = 0
  @startcol = 0

  h = config.fetch(:height, 0)
  w = config.fetch(:width, 0)
  t = config.fetch(:row, 0)
  l = config.fetch(:col, 0)
  @rows = h unless h == 0
  @cols = w unless w == 0
  @startrow = t unless t == 0
  @startcol = l unless l == 0
  @suppress_border = config[:suppress_border]
  unless @suppress_border
    @startrow += 1
    @startcol += 1
    @rows -=3  # 3 is since print_border_only reduces one from width, to check whether this is correct
    @cols -=3
  end
  @top = t
  @left = l
  view_file config[:filename]
  @window = config[:window] || Canis::Window.new(:height => h, :width => w, :top => t, :left => l)
  # print border reduces on from width for some historical reason
  @window.print_border_only @top, @left, h-1, w, $datacolor
  @ph = @content_rows
  @pw = @content_cols # get max col
  @pad = FFI::NCurses.newpad(@ph, @pw)

  Ncurses::Panel.update_panels
  @content.each_index { |ix|

    FFI::NCurses.mvwaddstr(@pad,ix, 0, @content[ix])
  }
  @window.wrefresh
  padrefresh
  #FFI::NCurses.prefresh(@pad, 0,0, @startrow ,@startcol, @rows,@cols);

  @window.bkgd(Ncurses.COLOR_PAIR(5));
  FFI::NCurses.keypad(@pad, true);
  #@form = Form.new @window
  config[:row] = config[:col] = 0 # ??? XXX
end

Instance Method Details

#runObject



104
105
106
107
108
# File 'lib/canis/core/util/extras/padreader.rb', line 104

def run
  #@form.repaint
  #@window.wrefresh
  return handle_keys
end