Class: Redwood::Buffer
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #blur ⇒ Object
- #clear ⇒ Object
- #commit ⇒ Object
- #content_height ⇒ Object
- #content_width ⇒ Object
- #draw(status) ⇒ Object
- #draw_status(status) ⇒ Object
- #focus ⇒ Object
-
#initialize(window, mode, width, height, opts = {}) ⇒ Buffer
constructor
A new instance of Buffer.
- #mark_dirty ⇒ Object
- #redraw(status) ⇒ Object
- #resize(rows, cols) ⇒ Object
-
#write(y, x, s, opts = {}) ⇒ Object
s nil means a blank line!.
Constructor Details
#initialize(window, mode, width, height, opts = {}) ⇒ Buffer
Returns a new instance of Buffer.
56 57 58 59 60 61 62 63 64 |
# File 'lib/sup/buffer.rb', line 56 def initialize window, mode, width, height, opts={} @w = window @mode = mode @dirty = true @focus = false @title = opts[:title] || "" @force_to_top = opts[:force_to_top] || false @x, @y, @width, @height = 0, 0, width, height end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
52 53 54 |
# File 'lib/sup/buffer.rb', line 52 def height @height end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
52 53 54 |
# File 'lib/sup/buffer.rb', line 52 def mode @mode end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
52 53 54 |
# File 'lib/sup/buffer.rb', line 52 def title @title end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
52 53 54 |
# File 'lib/sup/buffer.rb', line 52 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
52 53 54 |
# File 'lib/sup/buffer.rb', line 52 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
52 53 54 |
# File 'lib/sup/buffer.rb', line 52 def y @y end |
Instance Method Details
#blur ⇒ Object
127 128 129 130 131 |
# File 'lib/sup/buffer.rb', line 127 def blur @focus = false @dirty = true @mode.blur end |
#clear ⇒ Object
113 114 115 |
# File 'lib/sup/buffer.rb', line 113 def clear @w.clear end |
#commit ⇒ Object
89 90 91 92 |
# File 'lib/sup/buffer.rb', line 89 def commit @dirty = false @w.noutrefresh end |
#content_height ⇒ Object
66 |
# File 'lib/sup/buffer.rb', line 66 def content_height; @height - 1; end |
#content_width ⇒ Object
67 |
# File 'lib/sup/buffer.rb', line 67 def content_width; @width; end |
#draw(status) ⇒ Object
94 95 96 97 98 |
# File 'lib/sup/buffer.rb', line 94 def draw status @mode.draw draw_status status commit end |
#draw_status(status) ⇒ Object
117 118 119 |
# File 'lib/sup/buffer.rb', line 117 def draw_status status write @height - 1, 0, status, :color => :status_color end |
#focus ⇒ Object
121 122 123 124 125 |
# File 'lib/sup/buffer.rb', line 121 def focus @focus = true @dirty = true @mode.focus end |
#mark_dirty ⇒ Object
87 |
# File 'lib/sup/buffer.rb', line 87 def mark_dirty; @dirty = true; end |
#redraw(status) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/sup/buffer.rb', line 77 def redraw status if @dirty draw status else draw_status status end commit end |
#resize(rows, cols) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/sup/buffer.rb', line 69 def resize rows, cols return if cols == @width && rows == @height @width = cols @height = rows @dirty = true mode.resize rows, cols end |
#write(y, x, s, opts = {}) ⇒ Object
s nil means a blank line!
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/sup/buffer.rb', line 101 def write y, x, s, opts={} return if x >= @width || y >= @height @w.attrset Colormap.color_for(opts[:color] || :none, opts[:highlight]) s ||= "" maxl = @width - x @w.mvaddstr y, x, s[0 ... maxl] unless s.length >= maxl || opts[:no_fill] @w.mvaddstr(y, x + s.length, " " * (maxl - s.length)) end end |