builder/extra/cluster-home/lib/ruby/tungsten/util.rb
# Returns [width, height] of terminal when detected, nil if not detected.
# Think of this as a simpler version of Highline's Highline::SystemExtensions.terminal_size()
Returns [width, height] of terminal when detected, nil if not detected.
Think of this as a simpler version of Highline's Highline::SystemExtensions.terminal_size()
Returns [ width height ] of terminal when detected nil if not detected . Think of this as a simpler version of Highline ' s Highline :: SystemExtensions . terminal_size ()
def detect_terminal_size
    unless @terminal_size
      if (ENV['COLUMNS'] =~ /^\d+$/) && (ENV['LINES'] =~ /^\d+$/)
        @terminal_size = [ENV['COLUMNS'].to_i, ENV['LINES'].to_i]
      elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && command_exists?('tput')
        @terminal_size = [`tput cols`.to_i, `tput lines`.to_i]
      elsif STDIN.tty? && command_exists?('stty')
        @terminal_size = `stty size`.scan(/\d+/).map { |s| s.to_i }.reverse
      else
        @terminal_size = [80, 30]
      end
    end
    return @terminal_size
  rescue => e
    [80, 30]
  end
def detect_terminal_size unless @terminal_size if ( ENV [ 'COLUMNS' ] =~ / ^ \d +$ / ) && ( ENV [ 'LINES' ] =~ / ^ \d +$ / ) @terminal_size = [ ENV [ 'COLUMNS' ] . to_i , ENV [ 'LINES' ] . to_i ] elsif ( RUBY_PLATFORM =~ / java / || ( ! STDIN . tty? && ENV [ 'TERM' ] ) ) && command_exists? ( 'tput' ) @terminal_size = [ ` tput cols ` . to_i , ` tput lines ` . to_i ] elsif STDIN . tty? && command_exists? ( 'stty' ) @terminal_size = ` stty size ` . scan ( / \d + / ) . map { | s | s . to_i } . reverse else @terminal_size = [ 80 , 30 ] end end return @terminal_size rescue => e [ 80 , 30 ] end
Returns [width, height] of terminal when detected, nil if not detected.
Returns [ width height ] of terminal when detected nil if not detected .