Sha256: 5d3840f7f099180b60c5ec253132ddc33a85373572a3017cfae74833af7ce5e5

Contents?: true

Size: 1.73 KB

Versions: 10

Compression:

Stored size: 1.73 KB

Contents

module Vedeu

  module Bindings

    # Provides events to manage Vedeu.
    #
    module System

      extend self

      # Setup events relating to running Vedeu. This method is called
      # by Vedeu.
      #
      # @return [TrueClass]
      def setup!
        cleanup!
        command!
        editor!
        exit!
        initialize!
        keypress!
        log!
        mode_switch!
      end

      private

      # :nocov:

      # See {file:docs/events/system.md#\_cleanup_}
      def cleanup!
        Vedeu.bind(:_cleanup_) do
          Vedeu.trigger(:_drb_stop_)
          Vedeu.trigger(:cleanup)
        end
      end

      # See {file:docs/events/system.md#\_command_}
      def command!
        Vedeu.bind(:_command_) { |command| Vedeu.trigger(:command, command) }
      end

      # See {file:docs/events/system.md#\_editor_}
      def editor!
        Vedeu.bind(:_editor_) do |key|
          Vedeu::Editor::Editor.keypress(name: Vedeu.focus, input: key)
        end
      end

      # See {file:docs/events/system.md#\_exit_}
      def exit!
        Vedeu.bind(:_exit_) { Vedeu.exit }
      end

      # See {file:docs/events/system.md#\_initialize_}
      def initialize!
        Vedeu.bind(:_initialize_) { Vedeu.ready! }
      end

      # See {file:docs/events/system.md#\_keypress_}
      def keypress!
        Vedeu.bind(:_keypress_) { |key| Vedeu.keypress(key) }
      end

      # See {file:docs/events/system.md#\_log_}
      def log!
        Vedeu.bind(:_log_) { |msg| Vedeu.log(type: :debug, message: msg) }
      end

      # See {file:docs/events/system.md#\_mode_switch_}
      def mode_switch!
        Vedeu.bind(:_mode_switch_) { fail Vedeu::Error::ModeSwitch }
      end

      # :nocov:

    end # System

  end # Bindings

end # Vedeu

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vedeu-0.6.29 lib/vedeu/bindings/system.rb
vedeu-0.6.28 lib/vedeu/bindings/system.rb
vedeu-0.6.27 lib/vedeu/bindings/system.rb
vedeu-0.6.26 lib/vedeu/bindings/system.rb
vedeu-0.6.25 lib/vedeu/bindings/system.rb
vedeu-0.6.24 lib/vedeu/bindings/system.rb
vedeu-0.6.23 lib/vedeu/bindings/system.rb
vedeu-0.6.22 lib/vedeu/bindings/system.rb
vedeu-0.6.21 lib/vedeu/bindings/system.rb
vedeu-0.6.20 lib/vedeu/bindings/system.rb