Sha256: 10204ca98e2147837be53c8d3ed76f5db202a78cfe88d0ee9ff88b308f7d91f8

Contents?: true

Size: 794 Bytes

Versions: 8

Compression:

Stored size: 794 Bytes

Contents

require 'cli/ui'
require 'io/console'

module CLI
  module UI
    module Terminal
      DEFAULT_WIDTH = 80
      DEFAULT_HEIGHT = 24

      # Returns the width of the terminal, if possible
      # Otherwise will return 80
      #
      def self.width
        if console = IO.respond_to?(:console) && IO.console
          width = console.winsize[1]
          width.zero? ? DEFAULT_WIDTH : width
        else
          DEFAULT_WIDTH
        end
      rescue Errno::EIO
        DEFAULT_WIDTH
      end

      def self.height
        if console = IO.respond_to?(:console) && IO.console
          height = console.winsize[0]
          height.zero? ? DEFAULT_HEIGHT : height
        else
          DEFAULT_HEIGHT
        end
      rescue Errno::EIO
        DEFAULT_HEIGHT
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
shopify-cli-0.9.2 vendor/deps/cli-ui/lib/cli/ui/terminal.rb
shopify-cli-0.9.1 vendor/deps/cli-ui/lib/cli/ui/terminal.rb
shopify-cli-0.9.0 vendor/deps/cli-ui/lib/cli/ui/terminal.rb
cli-ui-1.3.0 lib/cli/ui/terminal.rb
cli-ui-1.2.3 lib/cli/ui/terminal.rb
cli-ui-1.2.2 lib/cli/ui/terminal.rb
cli-ui-1.2.0 lib/cli/ui/terminal.rb
cli-ui-1.2.1 lib/cli/ui/terminal.rb