Sha256: e3b92f3b5eb2b873fb7307ad7768ac090d0d78c783d645c661920cf8aa426771

Contents?: true

Size: 868 Bytes

Versions: 3

Compression:

Stored size: 868 Bytes

Contents

module ANSI

  # = Terminal
  #
  # This library is based of HighLine's SystemExtensions
  # by James Edward Gray II.
  #
  # Copyright 2006 Gray Productions
  #
  # Distributed under the tems of the
  # {Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt].

  module Terminal

    module_function

    modes = %w{win32 termios curses stty}

    # This section builds character reading and terminal size functions
    # to suit the proper platform we're running on.
    #
    # Be warned: Here be dragons!
    #
    begin
      require 'ansi/terminal/' + (mode = modes.pop)
      CHARACTER_MODE = mode
    rescue LoadError
      retry
    end

    # Get the width of the terminal window.
    def terminal_width
      terminal_size[0]
    end

    # Get the height of the terminal window.
    def terminal_height
      terminal_size[1]
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ansi-1.4.1 lib/ansi/terminal.rb
ansi-1.4.0 lib/ansi/terminal.rb
ansi-1.3.0 lib/ansi/terminal.rb