Class: Redwood::Buffer
Instance Attribute Summary collapse
-
#atime ⇒ Object
readonly
Returns the value of attribute atime.
-
#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.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sup/buffer.rb', line 74 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 @hidden = opts[:hidden] || false @x, @y, @width, @height = 0, 0, width, height @atime = Time.at 0 @system = opts[:system] || false end |
Instance Attribute Details
#atime ⇒ Object (readonly)
Returns the value of attribute atime.
70 71 72 |
# File 'lib/sup/buffer.rb', line 70 def atime @atime end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
70 71 72 |
# File 'lib/sup/buffer.rb', line 70 def height @height end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
70 71 72 |
# File 'lib/sup/buffer.rb', line 70 def mode @mode end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
70 71 72 |
# File 'lib/sup/buffer.rb', line 70 def title @title end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
70 71 72 |
# File 'lib/sup/buffer.rb', line 70 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
70 71 72 |
# File 'lib/sup/buffer.rb', line 70 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
70 71 72 |
# File 'lib/sup/buffer.rb', line 70 def y @y end |
Instance Method Details
#blur ⇒ Object
153 154 155 156 157 |
# File 'lib/sup/buffer.rb', line 153 def blur @focus = false @dirty = true @mode.blur end |
#clear ⇒ Object
139 140 141 |
# File 'lib/sup/buffer.rb', line 139 def clear @w.clear end |
#commit ⇒ Object
110 111 112 113 |
# File 'lib/sup/buffer.rb', line 110 def commit @dirty = false @w.noutrefresh end |
#content_height ⇒ Object
87 |
# File 'lib/sup/buffer.rb', line 87 def content_height; @height - 1; end |
#content_width ⇒ Object
88 |
# File 'lib/sup/buffer.rb', line 88 def content_width; @width; end |
#draw(status) ⇒ Object
115 116 117 118 119 120 |
# File 'lib/sup/buffer.rb', line 115 def draw status @mode.draw draw_status status commit @atime = Time.now end |
#draw_status(status) ⇒ Object
143 144 145 |
# File 'lib/sup/buffer.rb', line 143 def draw_status status write @height - 1, 0, status, :color => :status_color end |
#focus ⇒ Object
147 148 149 150 151 |
# File 'lib/sup/buffer.rb', line 147 def focus @focus = true @dirty = true @mode.focus end |
#mark_dirty ⇒ Object
108 |
# File 'lib/sup/buffer.rb', line 108 def mark_dirty; @dirty = true; end |
#redraw(status) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/sup/buffer.rb', line 98 def redraw status if @dirty draw status else draw_status status end commit end |
#resize(rows, cols) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/sup/buffer.rb', line 90 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!
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/sup/buffer.rb', line 123 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 # maximum display width width stringl = maxl # string "length" # fill up the line with blanks to overwrite old screen contents @w.mvaddstr y, x, " " * maxl unless opts[:no_fill] ## the next horribleness is thanks to ruby's lack of widechar support stringl += 1 while stringl < s.length && s[0 ... stringl].display_length < maxl @w.mvaddstr y, x, s[0 ... stringl] end |