2005-07-14 22:58:09 +00:00
|
|
|
require 'rex/ui'
|
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Ui
|
|
|
|
module Text
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class implements output against a buffer.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
class Output::Buffer < Rex::Ui::Text::Output
|
|
|
|
|
2005-11-15 05:22:13 +00:00
|
|
|
#
|
|
|
|
# Initializes an output buffer.
|
|
|
|
#
|
2005-07-14 22:58:09 +00:00
|
|
|
def initialize
|
|
|
|
self.buf = ''
|
|
|
|
end
|
|
|
|
|
2009-11-10 03:27:48 +00:00
|
|
|
def supports_color?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2005-11-15 05:22:13 +00:00
|
|
|
#
|
|
|
|
# Appends the supplied message to the output buffer.
|
|
|
|
#
|
2009-11-10 03:27:48 +00:00
|
|
|
def print_raw(msg = '')
|
2005-07-14 22:58:09 +00:00
|
|
|
self.buf += msg || ''
|
2005-10-02 03:21:26 +00:00
|
|
|
|
2006-09-12 05:34:58 +00:00
|
|
|
if self.on_print_proc
|
|
|
|
self.on_print_proc.call(msg)
|
|
|
|
end
|
|
|
|
|
2005-10-02 03:21:26 +00:00
|
|
|
msg
|
2005-07-14 22:58:09 +00:00
|
|
|
end
|
2010-02-24 16:46:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Read everything out of the buffer and reset it
|
|
|
|
#
|
|
|
|
def dump_buffer
|
|
|
|
self.buf ||= ''
|
|
|
|
buffer = self.buf.dup
|
|
|
|
reset()
|
|
|
|
buffer
|
|
|
|
end
|
2005-07-14 22:58:09 +00:00
|
|
|
|
2005-11-15 05:22:13 +00:00
|
|
|
#
|
|
|
|
# Reset the buffer to an empty string.
|
|
|
|
#
|
2005-07-14 22:58:09 +00:00
|
|
|
def reset
|
|
|
|
self.buf = ''
|
|
|
|
end
|
2005-11-15 05:22:13 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# The underlying buffer state.
|
|
|
|
#
|
2005-07-14 22:58:09 +00:00
|
|
|
attr_accessor :buf
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2009-11-10 03:27:48 +00:00
|
|
|
end
|