Sha256: c54f55b48f4b0839a870d44b3cec2576d427d8cc7127a6e8c7f4d20301f461ba

Contents?: true

Size: 1.91 KB

Versions: 23

Compression:

Stored size: 1.91 KB

Contents

module Vedeu

  # This module is included in Vedeu::Interface to provide means to store client
  # application views created with {Vedeu.renders} or {Vedeu.views}.
  #
  # @api private
  module DisplayBuffer

    include Vedeu::Common

    # Store the view and immediate refresh it; causing to be pushed to the
    # Terminal.
    #
    # @return [Interface]
    def store_immediate
      store_deferred

      Vedeu::Refresh.by_name(name)

      self
    end

    # Store the view if it has a name. This view will be shown next time the
    # refresh event is triggered for the interface.
    #
    # @raise [InvalidSyntax] The name is not defined.
    # @return [Vedeu::Interface]
    def store_deferred
      unless present?(name)
        fail InvalidSyntax, 'Cannot store an interface without a name.'
      end

      store_new_buffer

      self
    end

    private

    # Registers a set of buffers for the interface unless already registered,
    # and also adds interface's name to list of focussable interfaces.
    #
    # @see Vedeu::Buffer
    # @return [Vedeu::Interface]
    def store_new_buffer
      if Vedeu.buffers.registered?(name)
        Vedeu.buffers.find(name).add(self)

      else
        Vedeu::Buffer.new(name: name, back: self).store

      end

      self
    end

    # Registers interface name in focus list unless already registered.
    #
    # @return [Vedeu::Interface]
    def store_focusable
      Vedeu.focusable.add(name) unless Vedeu.focusable.registered?(name)

      self
    end

    # Registers a new cursor for the interface unless already registered.
    #
    # @return [Vedeu::Interface]
    def store_cursor
      Vedeu.cursors.by_name(name)

      self
    end

    # Registers a new group for the interface unless already registered.
    #
    # @return [Vedeu::Interface]
    def store_group
      Vedeu.groups.by_name(group).add(name) if group?

      self
    end

  end # DisplayBuffer

end # Vedeu

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
vedeu-0.4.55 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.54 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.53 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.52 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.51 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.50 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.49 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.48 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.47 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.46 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.45 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.44 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.43 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.42 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.41 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.40 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.39 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.38 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.37 lib/vedeu/buffers/display_buffer.rb
vedeu-0.4.36 lib/vedeu/buffers/display_buffer.rb