Sha256: 2861eeb6469e8429a97218da484feb3dd6a9a30b164bc61d8c84023bf2fe2f94

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

require 'vedeu/output/refresh_group'

module Vedeu

  # Refreshes the terminal.
  #
  # @note
  #   In the cases of {#all} and {#by_group}, the interfaces will be refreshed
  #   in z-index order, meaning that interfaces with a lower z-index will be
  #   drawn first. This means overlapping interfaces will be drawn as specified.
  #
  # @api public
  module Refresh

    module_function

    # Refresh all registered interfaces.
    #
    # @example
    #   Vedeu.trigger(:_refresh_)
    #
    #   Vedeu::Refresh.all
    #
    # @return [Array]
    def all
      Vedeu.timer('Refresh All') do
        Vedeu.interfaces.zindexed.each { |model| by_name(model.name) }
      end
    end

    # Refresh the interface which is currently focussed.
    #
    # @return [Array|ModelNotFound|NilClass]
    def by_focus
      by_name(Vedeu.focus) if Vedeu.focus
    end

    # Refresh an interface, or collection of interfaces belonging to a group.
    #
    # @example
    #   Vedeu.trigger(:_refresh_group_, group_name)
    #
    #   Vedeu::Refresh.by_group(group_name)
    #
    # @param group_name [String] The name of the group to be refreshed.
    # @return [Array|ModelNotFound] A collection of the names of interfaces
    #   refreshed, or an exception if the group was not found.
    def by_group(group_name)
      Vedeu.timer("Refresh Group: '#{group_name}'") do
        Vedeu::RefreshGroup.by_name(group_name)
      end
    end

    # Refresh an interface by name.
    #
    # @example
    #   Vedeu.trigger(:_refresh_, name)
    #
    #   Vedeu::Refresh.by_name(name)
    #
    # @param name [String] The name of the interface to be refreshed using the
    #   named buffer.
    # @return [Array|ModelNotFound]
    def by_name(name)
      Vedeu.timer("Refresh Interface: '#{name}'") do
        Vedeu.buffers.by_name(name).render
      end
    end

  end # Refresh

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.4.55 lib/vedeu/output/refresh.rb