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
permalink #initialize(window, mode, width, height, opts = {}) ⇒ Buffer
Returns a new instance of Buffer.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sup/buffer.rb', line 18 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
permalink #atime ⇒ Object (readonly)
Returns the value of attribute atime.
14 15 16 |
# File 'lib/sup/buffer.rb', line 14 def atime @atime end |
permalink #height ⇒ Object (readonly)
Returns the value of attribute height.
14 15 16 |
# File 'lib/sup/buffer.rb', line 14 def height @height end |
permalink #mode ⇒ Object (readonly)
Returns the value of attribute mode.
14 15 16 |
# File 'lib/sup/buffer.rb', line 14 def mode @mode end |
permalink #title ⇒ Object (readonly)
Returns the value of attribute title.
14 15 16 |
# File 'lib/sup/buffer.rb', line 14 def title @title end |
permalink #width ⇒ Object (readonly)
Returns the value of attribute width.
14 15 16 |
# File 'lib/sup/buffer.rb', line 14 def width @width end |
Instance Method Details
permalink #blur ⇒ Object
[View source]
94 95 96 97 98 |
# File 'lib/sup/buffer.rb', line 94 def blur @focus = false @dirty = true @mode.blur end |
permalink #clear ⇒ Object
[View source]
80 81 82 |
# File 'lib/sup/buffer.rb', line 80 def clear @w.clear end |
permalink #commit ⇒ Object
[View source]
54 55 56 57 |
# File 'lib/sup/buffer.rb', line 54 def commit @dirty = false @w.noutrefresh end |
permalink #content_height ⇒ Object
[View source]
31 |
# File 'lib/sup/buffer.rb', line 31 def content_height; @height - 1; end |
permalink #content_width ⇒ Object
[View source]
32 |
# File 'lib/sup/buffer.rb', line 32 def content_width; @width; end |
permalink #draw(status) ⇒ Object
[View source]
59 60 61 62 63 64 |
# File 'lib/sup/buffer.rb', line 59 def draw status @mode.draw draw_status status commit @atime = Time.now end |
permalink #draw_status(status) ⇒ Object
[View source]
84 85 86 |
# File 'lib/sup/buffer.rb', line 84 def draw_status status write @height - 1, 0, status, :color => :status_color end |
permalink #focus ⇒ Object
[View source]
88 89 90 91 92 |
# File 'lib/sup/buffer.rb', line 88 def focus @focus = true @dirty = true @mode.focus end |
permalink #mark_dirty ⇒ Object
[View source]
52 |
# File 'lib/sup/buffer.rb', line 52 def mark_dirty; @dirty = true; end |
permalink #redraw(status) ⇒ Object
[View source]
42 43 44 45 46 47 48 49 50 |
# File 'lib/sup/buffer.rb', line 42 def redraw status if @dirty draw status else draw_status status end commit end |
permalink #resize(rows, cols) ⇒ Object
[View source]
34 35 36 37 38 39 40 |
# File 'lib/sup/buffer.rb', line 34 def resize rows, cols return if cols == @width && rows == @height @width = cols @height = rows @dirty = true mode.resize rows, cols end |
permalink #write(y, x, s, opts = {}) ⇒ Object
s nil means a blank line!
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/sup/buffer.rb', line 67 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 |