class TTY::Color::Support
def disabled?
- Api: - public
Returns:
-
(Boolean)
-
def disabled? no_color = @env["NO_COLOR"] !(no_color.nil? || no_color.empty?) end
def from_curses(curses_class = nil)
- Api: - private
Returns:
-
(Boolean)
-
def from_curses(curses_class = nil) return NoValue if TTY::Color.windows? require "curses" if defined?(Curses) curses_class ||= Curses curses_class.init_screen has_color = curses_class.has_colors? curses_class.close_screen return has_color end NoValue rescue LoadError warn "no native curses support" if @verbose NoValue end
def from_env
- Api: - private
def from_env ENV_VARS.any? { |key| @env.key?(key) } || NoValue end
def from_term
- Api: - private
def from_term case @env["TERM"] when "dumb" then false when TERM_REGEX then true else NoValue end end
def from_tput
- Api: - private
def from_tput return NoValue unless TTY::Color.command?("tput colors") `tput colors 2>/dev/null`.to_i > 2 rescue Errno::ENOENT NoValue end
def initialize(env, verbose: false)
- Api: - public
def initialize(env, verbose: false) @env = env @verbose = verbose end
def support?
- Api: - public
Returns:
-
(Boolean)
-
def support? return false unless TTY::Color.tty? return false if disabled? value = false SOURCES.each do |from_check| break if (value = public_send(from_check)) != NoValue end value == NoValue ? false : value end