Class: Rex::Ui::Text::Output

Inherits:
Output
  • Object
show all
Includes:
Color
Defined in:
lib/rex/ui/text/output.rb

Overview

This class implements text-based output but is not tied to an output medium.

Direct Known Subclasses

Buffer, File, Socket, Stdio

Defined Under Namespace

Classes: Buffer, File, Socket, Stdio

Constant Summary

Constants included from Color

Color::AnsiAttributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Color

#ansi, #colorize, #do_colorize, #reset_color, #substitute_colors

Methods inherited from Output

#flush, #prompting, #prompting?

Constructor Details

#initializeOutput

Returns a new instance of Output.



23
24
25
26
27
28
# File 'lib/rex/ui/text/output.rb', line 23

def initialize
	@config = {
		:color => :auto, # true, false, :auto
	}
	super
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



29
30
31
# File 'lib/rex/ui/text/output.rb', line 29

def config
  @config
end

Instance Method Details

#auto_colorObject



39
40
41
# File 'lib/rex/ui/text/output.rb', line 39

def auto_color
	@config[:color] = :auto
end

#disable_colorObject



31
32
33
# File 'lib/rex/ui/text/output.rb', line 31

def disable_color
	@config[:color] = false
end

#enable_colorObject



35
36
37
# File 'lib/rex/ui/text/output.rb', line 35

def enable_color
	@config[:color] = true
end


68
69
70
# File 'lib/rex/ui/text/output.rb', line 68

def print(msg = '')
	print_raw(substitute_colors(msg))
end


56
57
58
# File 'lib/rex/ui/text/output.rb', line 56

def print_debug(msg = '')
	print_line("%bld%cya[!]%clr #{msg}")
end


48
49
50
# File 'lib/rex/ui/text/output.rb', line 48

def print_error(msg = '')
	print_line("%bld%red[-]%clr #{msg}")
end


52
53
54
# File 'lib/rex/ui/text/output.rb', line 52

def print_good(msg = '')
	print_line("%bld%grn[+]%clr #{msg}")
end


64
65
66
# File 'lib/rex/ui/text/output.rb', line 64

def print_line(msg = '')
	print(msg + "\n")
end


60
61
62
# File 'lib/rex/ui/text/output.rb', line 60

def print_status(msg = '')
	print_line("%bld%blu[*]%clr #{msg}")
end

#resetObject



72
73
# File 'lib/rex/ui/text/output.rb', line 72

def reset
end

#update_prompt(prompt = nil) ⇒ Object



43
44
45
46
# File 'lib/rex/ui/text/output.rb', line 43

def update_prompt(prompt = nil)
	return if prompt.nil?
	substitute_colors(prompt, true)
end