Class: Rex::Ui::Text::Output::Stdio
- Inherits:
-
Rex::Ui::Text::Output
- Object
- Output
- Rex::Ui::Text::Output
- Rex::Ui::Text::Output::Stdio
- Defined in:
- lib/rex/ui/text/output/stdio.rb
Overview
This class implements output against standard out.
Constant Summary
Constants included from Color
Instance Attribute Summary collapse
-
#io ⇒ IO
IO to write to.
Attributes inherited from Rex::Ui::Text::Output
Instance Method Summary collapse
-
#flush ⇒ Object
Methods.
-
#initialize(options = {}) ⇒ Stdio
constructor
A new instance of Stdio.
-
#print_raw(msg = '') ⇒ Object
(also: #write)
Prints the supplied message to standard output.
- #puts(*args) ⇒ Object
- #supports_color? ⇒ Boolean
Methods inherited from Rex::Ui::Text::Output
#auto_color, #disable_color, #enable_color, #print, #print_debug, #print_error, #print_good, #print_line, #print_status, #print_warning, #reset, #update_prompt
Methods included from Color
#ansi, #colorize, #do_colorize, #reset_color, #substitute_colors
Methods inherited from Output
#print, #print_debug, #print_error, #print_good, #print_line, #print_status, #print_warning, #prompting, #prompting?
Constructor Details
#initialize(options = {}) ⇒ Stdio
Returns a new instance of Stdio.
35 36 37 38 39 40 41 |
# File 'lib/rex/ui/text/output/stdio.rb', line 35 def initialize(={}) .assert_valid_keys(:io) super() self.io = [:io] end |
Instance Attribute Details
Instance Method Details
#flush ⇒ Object
Methods
47 48 49 |
# File 'lib/rex/ui/text/output/stdio.rb', line 47 def flush io.flush end |
#print_raw(msg = '') ⇒ Object Also known as: write
Prints the supplied message to standard output.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rex/ui/text/output/stdio.rb', line 61 def print_raw(msg = '') if (Rex::Compat.is_windows and supports_color?) WindowsConsoleColorSupport.new(io).write(msg) else io.print(msg) end io.flush msg end |
#puts(*args) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rex/ui/text/output/stdio.rb', line 74 def puts(*args) args.each do |argument| line = argument.to_s write(line) unless line.ends_with? "\n" # yes, this is output, but `IO#puts` uses `rb_default_rs`, which is # [`$/`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/io.c#L12168-L12172), # which is [`$INPUT_RECORD_SEPARATOR`](https://github.com/ruby/ruby/blob/3af8e150aded9d162bfd41426aaaae0279e5a653/lib/English.rb#L83) write($INPUT_RECORD_SEPARATOR) end end nil end |
#supports_color? ⇒ Boolean
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/rex/ui/text/output/stdio.rb', line 90 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 |