lib/garcon/utility/misc.rb
# Returns the columns and lines of the current tty.
#
# @return [Integer]
#   Number of columns and lines of tty, returns [0, 0] if no tty is present.
#
Returns the columns and lines of the current tty.
Returns the columns and lines of the current tty .
def terminal_dimensions
    [0, 0] unless  STDOUT.tty?
    [80, 40] if OS.windows?
    if ENV['COLUMNS'] && ENV['LINES']
      [ENV['COLUMNS'].to_i, ENV['LINES'].to_i]
    elsif ENV['TERM'] && command_in_path?('tput')
      [`tput cols`.to_i, `tput lines`.to_i]
    elsif command_in_path?('stty')
      `stty size`.scan(/\d+/).map {|s| s.to_i }
    else
      [0, 0]
    end
  rescue
    [0, 0]
  end
def terminal_dimensions [ 0 , 0 ] unless STDOUT . tty? [ 80 , 40 ] if OS . windows? if ENV [ 'COLUMNS' ] && ENV [ 'LINES' ] [ ENV [ 'COLUMNS' ] . to_i , ENV [ 'LINES' ] . to_i ] elsif ENV [ 'TERM' ] && command_in_path? ( 'tput' ) [ ` tput cols ` . to_i , ` tput lines ` . to_i ] elsif command_in_path? ( 'stty' ) ` stty size ` . scan ( / \d + / ) . map { | s | s . to_i } else [ 0 , 0 ] end rescue [ 0 , 0 ] end
Returns the columns and lines of the current tty.
Returns the columns and lines of the current tty .
Number of columns and lines of tty, returns [0, 0] if no tty is present.
Number of columns and lines of tty returns [ 0 0 ] if no tty is present .
Integer