Sha256: 856cab6853701ac6c86b2152c68b3b4ad357aec3e033c12761e0693482c9987a
Contents?: true
Size: 1.03 KB
Versions: 55
Compression:
Stored size: 1.03 KB
Contents
require 'cli/ui' require 'io/console' module CLI module UI module Terminal DEFAULT_WIDTH = 80 DEFAULT_HEIGHT = 24 # Returns the width of the terminal, if possible # Otherwise will return DEFAULT_WIDTH # def self.width winsize[1] end # Returns the width of the terminal, if possible # Otherwise, will return DEFAULT_HEIGHT # def self.height winsize[0] end def self.winsize @winsize ||= begin winsize = IO.console.winsize setup_winsize_trap if winsize.any?(&:zero?) [DEFAULT_HEIGHT, DEFAULT_WIDTH] else winsize end rescue [DEFAULT_HEIGHT, DEFAULT_WIDTH] end end def self.setup_winsize_trap @winsize_trap ||= Signal.trap('WINCH') do @winsize = nil end end end end end
Version data entries
55 entries across 55 versions & 2 rubygems