diff --git a/lib/rex/ui/text/output.rb b/lib/rex/ui/text/output.rb index 05869acf26..c811a3eb1c 100644 --- a/lib/rex/ui/text/output.rb +++ b/lib/rex/ui/text/output.rb @@ -63,18 +63,7 @@ class Output < Rex::Ui::Output end def print_line(msg = '') - if (/mingw/ =~ RUBY_PLATFORM) - print(msg + "\n") - return - end - print("\033[s") # Save cursor position - print("\r\033[K" + msg + "\n") - if input and input.prompt - print("\r\033[K") - print(input.prompt.tr("\001\002", '')) - print(input.line_buffer.tr("\001\002", '')) - print("\033[u\033[B") # Restore cursor, move down one line - end + print(msg + "\n") end def print_warning(msg = '') diff --git a/lib/rex/ui/text/output/stdio.rb b/lib/rex/ui/text/output/stdio.rb index 02be514344..6e85363f13 100644 --- a/lib/rex/ui/text/output/stdio.rb +++ b/lib/rex/ui/text/output/stdio.rb @@ -55,6 +55,23 @@ class Output::Stdio < Rex::Ui::Text::Output @io ||= $stdout end + # Use ANSI Control chars to reset prompt position for async output + # SEE https://github.com/rapid7/metasploit-framework/pull/7570 + def print_line(msg = '') + if (/mingw/ =~ RUBY_PLATFORM) + print(msg + "\n") + return + end + print("\033[s") # Save cursor position + print("\r\033[K" + msg + "\n") + if input and input.prompt + print("\r\033[K") + print(input.prompt.tr("\001\002", '')) + print(input.line_buffer.tr("\001\002", '')) + print("\033[u\033[B") # Restore cursor, move down one line + end + end + # # Prints the supplied message to standard output. #