Parent

Class/Module Index [+]

Quicksearch

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 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

Public Instance Methods

blur() click to toggle source
# File lib/sup/buffer.rb, line 150
def blur
  @focus = false
  @dirty = true
  @mode.blur
end
clear() click to toggle source
# File lib/sup/buffer.rb, line 136
def clear
  @w.clear
end
commit() click to toggle source
# File lib/sup/buffer.rb, line 105
def commit
  @dirty = false
  @w.noutrefresh
end
content_height() click to toggle source
# File lib/sup/buffer.rb, line 82
def content_height; @height - 1; end
content_width() click to toggle source
# File lib/sup/buffer.rb, line 83
def content_width; @width; end
draw(status) click to toggle source
# File lib/sup/buffer.rb, line 110
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 140
def draw_status status
  write @height - 1, 0, status, :color => :status_color
end
focus() click to toggle source
# File lib/sup/buffer.rb, line 144
def focus
  @focus = true
  @dirty = true
  @mode.focus
end
mark_dirty() click to toggle source
# File lib/sup/buffer.rb, line 103
def mark_dirty; @dirty = true; end
redraw(status) click to toggle source
# File lib/sup/buffer.rb, line 93
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 85
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 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.