Sha256: 1e5c7f344f42922f1e5fee5331c1f6f03ede01ebb2b357c985c59a1ed5d2ab84

Contents?: true

Size: 832 Bytes

Versions: 2

Compression:

Stored size: 832 Bytes

Contents

# -*- coding: binary -*-
require 'rex/ui'

begin
	require 'windows_console_color_support'
rescue ::LoadError
end

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

2 entries across 2 versions & 1 rubygems

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