Sha256: c7b741436f2ff7e569aadf10c4c74b8b3e9d33d16a258aa942b55abbd3870ead

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

module Vedeu

  # Before the content of the buffer can be output to the terminal, if there are
  # any changes to the geometry of the interface (stored in the buffer), then
  # these need to be stored; replacing those already stored. This is our last
  # chance to do this as the terminal may have resized, or the client
  # application may have specified this this view should move to a new location.

  # Combines stored interface layout/geometry with an interface view/buffer
  # to create a single view to be sent to the terminal for output.
  #
  class Compositor

    # Convenience method to initialize a new Compositor and call its {#compose}
    # method.
    #
    # @return [Compositor]
    # @see #initialize
    def self.compose(name)
      new(name).compose
    end

    # Initialize a new Vedeu::Compositor.
    #
    # @param name [String] The name of the buffer.
    # @return [Compositor]
    def initialize(name)
      @name = name
    end

    # Applies any overridden colours or styles in the buffered view to the
    # stored interface.
    #
    # @return [Array<Interface>]
    def compose
      buffer.each do |view|
        view.colour = interface.colour unless view.colour
        view.style  = interface.style  unless view.style

        Vedeu::Output.render(view)
      end
    end

    private

    # @!attribute [r] name
    # @return [String]
    attr_reader :name

    # @return [Vedeu::Interface]
    def buffer
      Vedeu.buffers.find(name).content
    end

    # @return [Vedeu::Interface]
    def interface
      @interface ||= Vedeu.interfaces.find(name)
    end

  end # Compositor

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.4.13 lib/vedeu/output/compositor.rb
vedeu-0.4.12 lib/vedeu/output/compositor.rb
vedeu-0.4.11 lib/vedeu/output/compositor.rb
vedeu-0.4.10 lib/vedeu/output/compositor.rb