Sha256: c0f19d32741a040982504fed8af0db338db26a9121fd9b0bf087278388fda7d5

Contents?: true

Size: 656 Bytes

Versions: 21

Compression:

Stored size: 656 Bytes

Contents

require 'tins/xt/ask_and_send'

begin
  require 'io/console'
rescue LoadError
end

module Tins
  module Terminal

    module_function

    def rows
      IO.ask_and_send(:console).ask_and_send(:winsize).ask_and_send(:[], 0) ||
        `stty size 2>/dev/null`.split[0].to_i.nonzero? ||
        `tput lines 2>/dev/null`.to_i.nonzero? ||
        25
    end

    def lines
      rows
    end

    def columns
      IO.ask_and_send(:console).ask_and_send(:winsize).ask_and_send(:[], 1) ||
        `stty size 2>/dev/null`.split[1].to_i.nonzero? ||
        `tput cols 2>/dev/null`.to_i.nonzero? ||
        80
    end

    def cols
      columns
    end
  end
end

Version data entries

21 entries across 20 versions & 3 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/lib/tins/terminal.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/lib/tins/terminal.rb
tdiary-5.0.8 vendor/bundle/gems/tins-0.13.2/lib/tins/terminal.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/tins-0.13.2/lib/tins/terminal.rb
tins-1.3.0 lib/tins/terminal.rb
tins-1.2.0 lib/tins/terminal.rb
tins-1.1.0 lib/tins/terminal.rb
tins-1.0.1 lib/tins/terminal.rb
tins-1.0.0 lib/tins/terminal.rb
tins-0.13.2 lib/tins/terminal.rb
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/tins-0.13.1/lib/tins/terminal.rb
tins-0.13.1 lib/tins/terminal.rb
tins-0.13.0 lib/tins/terminal.rb
tins-0.12.0 lib/tins/terminal.rb
tins-0.11.0 lib/tins/terminal.rb
tins-0.10.0 lib/tins/terminal.rb
tins-0.9.0 lib/tins/terminal.rb
tins-0.8.4 lib/tins/terminal.rb
tins-0.8.3 lib/tins/terminal.rb
tins-0.8.2 lib/tins/terminal.rb