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
|
|
|
|
|
|
2005-11-15 05:22:13 +00:00
|
|
|
#
|
|
|
|
|
# Appends the supplied message to the output buffer.
|
|
|
|
|
#
|
2005-07-14 22:58:09 +00:00
|
|
|
def print(msg = '')
|
|
|
|
|
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
|
|
|
|
|
|
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
|
2008-10-19 21:03:39 +00:00
|
|
|
end
|