lib/vedeu/terminal/buffer.rb in vedeu-0.6.40 vs lib/vedeu/terminal/buffer.rb in vedeu-0.6.41

- old
+ new

@@ -82,26 +82,34 @@ Vedeu::Models::Cell.new(position: [y, x]) end end end - # Write a collection of cells to the virtual terminal. + # Write a collection of cells to the virtual terminal, will + # then send written content to be rendered by a renderer. # # @param value [Array<Array<Vedeu::Views::Char>>] # @return [Array<Array<Vedeu::Views::Char>>] def write(value) - values = Array(value).flatten + update_buffer(value) - values.each do |v| - buffer[v.position.y][v.position.x] = v if valid_position?(v) - end - render self end + # Write a collection of cells to the virtual terminal, but do + # not send to a renderer. + # + # @param value [Array<Array<Vedeu::Views::Char>>] + # @return [Array<Array<Vedeu::Views::Char>>] + def update(value) + update_buffer(value) + + self + end + private # @param from [Array] An Array of rows, or an Array of cells. # @param which [Fixnum] A Fixnum representing the index; the row # number or the cell number for a row. @@ -118,10 +126,20 @@ def position?(value) value.respond_to?(:position) && value.position.is_a?(Vedeu::Geometry::Position) end + # @param value [Array<Array<Vedeu::Views::Char>>] + # @return [Array<Array<Vedeu::Views::Char>>] + def update_buffer(value) + values = Array(value).flatten + + values.each do |v| + buffer[v.position.y][v.position.x] = v if valid_position?(v) + end + end + # Returns a boolean indicating the value has a position # attribute and is within the terminal boundary. # # @param value [void] # @return [Boolean] @@ -142,11 +160,12 @@ end # Terminal # @!method clear # @see Vedeu::Terminal::Buffer#clear - def_delegators Vedeu::Terminal::Buffer, :clear - def_delegators Vedeu::Terminal::Buffer, :refresh + def_delegators Vedeu::Terminal::Buffer, + :clear, + :refresh # :nocov: # See {file:docs/events/visibility.md#\_clear_} Vedeu.bind(:_clear_) { Vedeu.clear }