lib/hirb/util.rb in hirb-0.2.7 vs lib/hirb/util.rb in hirb-0.2.8

- old
+ new

@@ -57,11 +57,16 @@ end # 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 - (ENV['COLUMNS'] =~ /^\d+$/) && (ENV['LINES'] =~ /^\d+$/) ? [ENV['COLUMNS'].to_i, ENV['LINES'].to_i] : - ( command_exists?('stty') ? `stty size`.scan(/\d+/).map { |s| s.to_i }.reverse : nil ) + if (ENV['COLUMNS'] =~ /^\d+$/) && (ENV['LINES'] =~ /^\d+$/) + [ENV['COLUMNS'].to_i, ENV['LINES'].to_i] + elsif RUBY_PLATFORM =~ /java/ && command_exists?('tput') + [`tput cols`.to_i, `tput lines`.to_i] + else + command_exists?('stty') ? `stty size`.scan(/\d+/).map { |s| s.to_i }.reverse : nil + end rescue nil end # Captures STDOUT of anything run in its block and returns it as string. \ No newline at end of file