class Redwood::Buffer

Attributes

atime[R]
height[R]
mode[R]
title[R]
width[R]
x[R]
y[R]

Public Class Methods

new(window, mode, width, height, opts={}) click to toggle source
# File lib/sup/buffer.rb, line 23
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

Public Instance Methods

blur() click to toggle source
# File lib/sup/buffer.rb, line 99
def blur
  @focus = false
  @dirty = true
  @mode.blur
end
clear() click to toggle source
# File lib/sup/buffer.rb, line 85
def clear
  @w.clear
end
commit() click to toggle source
# File lib/sup/buffer.rb, line 59
def commit
  @dirty = false
  @w.noutrefresh
end
content_height() click to toggle source
# File lib/sup/buffer.rb, line 36
def content_height; @height - 1; end
content_width() click to toggle source
# File lib/sup/buffer.rb, line 37
def content_width; @width; end
draw(status) click to toggle source
# File lib/sup/buffer.rb, line 64
def draw status
  @mode.draw
  draw_status status
  commit
  @atime = Time.now
end
draw_status(status) click to toggle source
# File lib/sup/buffer.rb, line 89
def draw_status status
  write @height - 1, 0, status, :color => :status_color
end
focus() click to toggle source
# File lib/sup/buffer.rb, line 93
def focus
  @focus = true
  @dirty = true
  @mode.focus
end
mark_dirty() click to toggle source
# File lib/sup/buffer.rb, line 57
def mark_dirty; @dirty = true; end
redraw(status) click to toggle source
# File lib/sup/buffer.rb, line 47
def redraw status
  if @dirty
    draw status
  else
    draw_status status
  end

  commit
end
resize(rows, cols) click to toggle source
# File lib/sup/buffer.rb, line 39
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={}) click to toggle source

s nil means a blank line!

# File lib/sup/buffer.rb, line 72
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

  # fill up the line with blanks to overwrite old screen contents
  @w.mvaddstr y, x, " " * maxl unless opts[:no_fill]

  @w.mvaddstr y, x, s.slice_by_display_length(maxl)
end