lib/vedeu/terminal/buffer.rb in vedeu-0.6.25 vs lib/vedeu/terminal/buffer.rb in vedeu-0.6.26
- old
+ new
@@ -18,11 +18,15 @@
# Return a grid of {Vedeu::Models::Cell} objects defined by the
# height and width of this virtual terminal.
#
# @return [Array<Array<Vedeu::Models::Cell>>]
def buffer
- @output ||= empty_buffer.dup
+ @output ||= Array.new(Vedeu.height) do |y|
+ Array.new(Vedeu.width) do |x|
+ Vedeu::Models::Cell.new(position: [y + 1, x + 1])
+ end
+ end
end
alias_method :cells, :buffer
# Clear the output.
#
@@ -34,19 +38,10 @@
reset
Vedeu.renderers.clear if Vedeu.ready?
end
- # @return [Array<Array<Vedeu::Models::Cell>>]
- def empty_buffer
- @empty_buffer ||= Array.new(Vedeu.height) do |y|
- Array.new(Vedeu.width) do |x|
- Vedeu::Models::Cell.new(position: [y + 1, x + 1])
- end
- end
- end
-
# @return [Vedeu::Models::Page]
def output
Vedeu::Models::Page.coerce(buffer)
end
@@ -79,10 +74,14 @@
# Removes all content from the virtual terminal; effectively
# clearing it.
#
# @return [Array<Array<Vedeu::Models::Cell>>]
def reset
- @output = empty_buffer
+ @output = Array.new(Vedeu.height) do |y|
+ Array.new(Vedeu.width) do |x|
+ Vedeu::Models::Cell.new(position: [y + 1, x + 1])
+ end
+ end
end
# Write a collection of cells to the virtual terminal.
#
# @param value [Array<Array<Vedeu::Views::Char>>]