Sha256: 25d098452c106bf8d7b9fe6940d4f1977369552c1f5abdeb1f163fa00e374ff6
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
module Vedeu # Sends the interface to the terminal or output device. # class Output # Writes content (the provided interface object with associated lines, # streams, colours and styles) to the area defined by the interface. # # @return [Array|String] # @see #initialize def self.render(interface) new(interface).render end # Return a new instance of Output. # # @param interface [Interface] # @return [Output] def initialize(interface) @interface = interface end # Send the view to the terminal. # # @return [Array] def render Terminal.output(view, interface.cursor.to_s) end private attr_reader :interface # For each visible line of the interface, set the foreground and background # colours to those specified when the interface was defined, then starting # write space characters over the area which the interface occupies. # # @return [String] def clear Vedeu.log("Clearing view: '#{interface.name}'") interface.height.times.inject([interface.colour]) do |line, index| line << interface.origin(index) { ' ' * interface.width } end.join end # Produces a single string which contains all content and escape sequences # required to render this interface in the terminal window. # # @return [String] def view out = [ clear ] Vedeu.log("Rendering view: '#{interface.name}'") viewport.each_with_index do |line, index| out << interface.origin(index) out << line.join end out.join end def viewport @_viewport ||= Vedeu::Viewport.new(interface).render end end # Output end # Vedeu
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.3.3 | lib/vedeu/output/output.rb |
vedeu-0.3.2 | lib/vedeu/output/output.rb |