Sha256: 9ca3b5a25b30c2102b493c8c1cd8f53268d4dce30083b02e0465dd137ddab768

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

require 'rex/ui'
require 'windows_console_color_support'

module Rex
module Ui
module Text

###
#
# This class implements output against standard out.
#
###
class Output::Stdio < Rex::Ui::Text::Output

	def supports_color?
		case config[:color]
		when true
			return true
		when false
			return false
		else # auto
			if (Rex::Compat.is_windows)
				return true
			end
			term = Rex::Compat.getenv('TERM')
			return (term and term.match(/(?:vt10[03]|xterm(?:-color)?|linux|screen|rxvt)/i) != nil)
		end
	end

	#
	# Prints the supplied message to standard output.
	#
	def print_raw(msg = '')
		if (Rex::Compat.is_windows and supports_color?)
			WindowsConsoleColorSupport.new($stdout).write(msg)
		else
			$stdout.print(msg)
		end
		$stdout.flush

		msg
	end
end

end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
librex-0.0.63 lib/rex/ui/text/output/stdio.rb