Land #7596, fixes for console corruption on Linux and Windows
commit
d76c3033a7
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue