Land #7596, fixes for console corruption on Linux and Windows

bug/bundler_fix
Brent Cook 2016-11-27 22:13:12 -06:00
commit d76c3033a7
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
2 changed files with 12 additions and 4 deletions

View File

@ -139,12 +139,16 @@ begin
# for rb-readline to support setting input and output. Output needs to be set so that colorization works for the
# prompt on Windows.
self.prompt = prompt
reset_sequence = "\001\r\033[K\002"
if (/mingw/ =~ RUBY_PLATFORM)
reset_sequence = ""
end
if defined? RbReadline
RbReadline.rl_instream = fd
RbReadline.rl_outstream = output
begin
line = RbReadline.readline("\001\r\033[K\002" + prompt)
line = RbReadline.readline(reset_sequence + prompt)
rescue ::Exception => exception
RbReadline.rl_cleanup_after_signal()
RbReadline.rl_deprep_terminal()
@ -158,7 +162,7 @@ begin
line.try(:dup)
else
::Readline.readline("\001\r\033[K\002" + prompt, true)
::Readline.readline(reset_sequence + prompt, true)
end
end

View File

@ -63,12 +63,16 @@ 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)
print(input.line_buffer)
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