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

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

Overview

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

Direct Known Subclasses

Buffer, File, Socket, Stdio, Tee

Defined Under Namespace

Classes: Buffer, File, Socket, Stdio, Tee

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.



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

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

Instance Method Details

#auto_colorObject



41
42
43
# File 'lib/rex/ui/text/output.rb', line 41

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

#disable_colorObject



33
34
35
# File 'lib/rex/ui/text/output.rb', line 33

def disable_color
  @config[:color] = false
end

#enable_colorObject



37
38
39
# File 'lib/rex/ui/text/output.rb', line 37

def enable_color
  @config[:color] = true
end


74
75
76
# File 'lib/rex/ui/text/output.rb', line 74

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


58
59
60
# File 'lib/rex/ui/text/output.rb', line 58

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


50
51
52
# File 'lib/rex/ui/text/output.rb', line 50

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


54
55
56
# File 'lib/rex/ui/text/output.rb', line 54

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


66
67
68
# File 'lib/rex/ui/text/output.rb', line 66

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


62
63
64
# File 'lib/rex/ui/text/output.rb', line 62

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


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

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

#resetObject



78
79
# File 'lib/rex/ui/text/output.rb', line 78

def reset
end

#update_prompt(prompt = nil) ⇒ Object



45
46
47
48
# File 'lib/rex/ui/text/output.rb', line 45

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