Sha256: 4a448dceaf210cee13467903e12befbc90c12869192cad8f1a88b3b10683045d

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

require 'io/console'

module FancyIrb
  module TerminalInfo
    def self.lines
      STDOUT.winsize[0]
    end

    def self.cols
      STDOUT.winsize[1]
    end

    if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
      TPUT = {
        :sc   => "\e[s",
        :rc   => "\e[u",
        :cuu1 => "\e[1A",
        :cuf1 => "\e[1C",
      }
    elsif RbConfig::CONFIG['host_os'] =~ /linux/
      TPUT = {
        :sc   => `script -q -e -t /dev/null -c 'tput sc'`,
        :rc   => `script -q -e -t /dev/null -c 'tput rc'`,
        :cuu1 => `script -q -e -t /dev/null -c 'tput cuu1'`,
        :cuf1 => `script -q -e -t /dev/null -c 'tput cuf1'`,
      }
    else
      TPUT = {
        :sc   => `tput sc`,
        :rc   => `tput rc`,
        :cuu1 => `tput cuu1`,
        :cuf1 => `tput cuf1`,
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fancy_irb-1.3.0 lib/fancy_irb/terminal_info.rb