# File lib/sup/buffer.rb, line 70 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 @atime = Time.at 0 @system = opts[:system] || false end
# File lib/sup/buffer.rb, line 150 def blur @focus = false @dirty = true @mode.blur end
# File lib/sup/buffer.rb, line 136 def clear @w.clear end
# File lib/sup/buffer.rb, line 105 def commit @dirty = false @w.noutrefresh end
# File lib/sup/buffer.rb, line 82 def content_height; @height - 1; end
# File lib/sup/buffer.rb, line 83 def content_width; @width; end
# File lib/sup/buffer.rb, line 110 def draw status @mode.draw draw_status status commit @atime = Time.now end
# File lib/sup/buffer.rb, line 140 def draw_status status write @height - 1, 0, status, :color => :status_color end
# File lib/sup/buffer.rb, line 144 def focus @focus = true @dirty = true @mode.focus end
# File lib/sup/buffer.rb, line 103 def mark_dirty; @dirty = true; end
# File lib/sup/buffer.rb, line 93 def redraw status if @dirty draw status else draw_status status end commit end
# File lib/sup/buffer.rb, line 85 def resize rows, cols return if cols == @width && rows == @height @width = cols @height = rows @dirty = true mode.resize rows, cols end
s nil means a blank line!
# File lib/sup/buffer.rb, line 118 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" ## 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] unless opts[:no_fill] l = s.display_length unless l >= maxl @w.mvaddstr(y, x + l, " " * (maxl - l)) end end end