Sha256: 485935ed224792e1e4b55d4618846d3e59059c87b119bbbbaacf118652b56475

Contents?: true

Size: 1.14 KB

Versions: 19

Compression:

Stored size: 1.14 KB

Contents

module Vedeu

  # Store the current mode of the terminal.
  #
  module TerminalMode

    extend self

    # Returns a boolean indicating whether the terminal is currently in `cooked`
    # mode.
    #
    # @return [Boolean]
    def cooked_mode?
      mode == :cooked
    end

    # Sets the terminal in to `cooked` mode.
    #
    # @return [Symbol]
    def cooked_mode!
      @mode = :cooked
    end

    # Returns a boolean indicating whether the terminal is currently in `raw`
    # mode.
    #
    # @return [Boolean]
    def raw_mode?
      mode == :raw
    end

    # Sets the terminal in to `raw` mode.
    #
    # @return [Symbol]
    def raw_mode!
      @mode = :raw
    end

    # Toggles the terminal's mode between `cooked` and `raw`, depending on its
    # current mode.
    #
    # @return [Symbol]
    def switch_mode!
      return cooked_mode! if raw_mode?

      raw_mode!
    end

    # Returns the mode of the terminal, either `:raw` or `:cooked`. Can change
    # throughout the lifespan of the client application.
    #
    # @return [Symbol]
    def mode
      @mode ||= Vedeu::Configuration.terminal_mode
    end

  end # TerminalMode

end # Vedeu

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
vedeu-0.5.13 lib/vedeu/terminal_mode.rb
vedeu-0.5.12 lib/vedeu/terminal_mode.rb
vedeu-0.5.11 lib/vedeu/terminal_mode.rb
vedeu-0.5.10 lib/vedeu/terminal_mode.rb
vedeu-0.5.9 lib/vedeu/terminal_mode.rb
vedeu-0.5.8 lib/vedeu/terminal_mode.rb
vedeu-0.5.7 lib/vedeu/terminal_mode.rb
vedeu-0.5.6 lib/vedeu/terminal_mode.rb
vedeu-0.5.5 lib/vedeu/terminal_mode.rb
vedeu-0.5.4 lib/vedeu/terminal_mode.rb
vedeu-0.5.3 lib/vedeu/terminal_mode.rb
vedeu-0.5.2 lib/vedeu/terminal_mode.rb
vedeu-0.5.1 lib/vedeu/terminal_mode.rb
vedeu-0.5.0 lib/vedeu/terminal_mode.rb
vedeu-0.4.65 lib/vedeu/terminal_mode.rb
vedeu-0.4.64 lib/vedeu/terminal_mode.rb
vedeu-0.4.63 lib/vedeu/terminal_mode.rb
vedeu-0.4.62 lib/vedeu/terminal_mode.rb
vedeu-0.4.61 lib/vedeu/terminal_mode.rb