Sha256: 839a41b15fd510397d589035cf80eeaca13ce78fa8b6926ee057694de637a4a6
Contents?: true
Size: 855 Bytes
Versions: 6
Compression:
Stored size: 855 Bytes
Contents
require "hirb" module CutePrint class TermWidth # A terminal width that tries to determine the terminal width # automatically. # @api private class Detected attr_reader :width def initialize @width = detect_width end def visible :detect end private FALLBACK_WIDTH = 79 def detect_width return width_override_for_tests if width_override_for_tests width, _height = Hirb::Util.detect_terminal_size # Hirb returns nil if it can't determine the terminal width. # Program run in Emacs have an apparent terminal width of "0". width = FALLBACK_WIDTH if width.nil? || width == 0 width end def width_override_for_tests n = ENV['CUTE_PRINT_TERM_WIDTH'] n && Integer(n) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems