Skip to content

Commit 4098c66

Browse files
committed
Restore MinGW code and use =begin/=end for indent
1 parent d0d84b4 commit 4098c66

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

lib/rex/ui/text/input/readline.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,18 @@ def readline_with_output(prompt, add_history=false)
140140
# []`Readline.readline`](https://github.com/luislavena/rb-readline/blob/ce4908dae45dbcae90a6e42e3710b8c3a1f2cd64/lib/readline.rb#L36-L58)
141141
# for rb-readline to support setting input and output. Output needs to
142142
# be set so that colorization works for the prompt on Windows.
143-
#
144143
self.prompt = prompt
145144

146145
# TODO: there are unhandled quirks in async output buffering that
147146
# we have not solved yet, for instance when loading meterpreter
148147
# extensions, supporting Windows, printing output from commands, etc.
149148
# Remove this guard when issues are resolved.
150-
# reset_sequence = "\n\001\r\033[K\002"
149+
=begin
150+
reset_sequence = "\n\001\r\033[K\002"
151+
if (/mingw/ =~ RUBY_PLATFORM)
152+
reset_sequence = ""
153+
end
154+
=end
151155
reset_sequence = ""
152156

153157
if defined? RbReadline

lib/rex/ui/text/output/stdio.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,24 @@ def io
5858
# Use ANSI Control chars to reset prompt position for async output
5959
# SEE https://github.com/rapid7/metasploit-framework/pull/7570
6060
def print_line(msg = '')
61-
6261
# TODO: there are unhandled quirks in async output buffering that
6362
# we have not solved yet, for instance when loading meterpreter
6463
# extensions, supporting Windows, printing output from commands, etc.
6564
# Remove this guard when issues are resolved.
66-
#
67-
# print("\033[s") # Save cursor position
68-
# print("\r\033[K" + msg + "\n")
69-
# if input and input.prompt
70-
# print("\r\033[K")
71-
# print(input.prompt.tr("\001\002", ''))
72-
# print(input.line_buffer.tr("\001\002", ''))
73-
# print("\033[u\033[B") # Restore cursor, move down one line
74-
# end
65+
=begin
66+
if (/mingw/ =~ RUBY_PLATFORM)
67+
print(msg + "\n")
68+
return
69+
end
70+
print("\033[s") # Save cursor position
71+
print("\r\033[K" + msg + "\n")
72+
if input and input.prompt
73+
print("\r\033[K")
74+
print(input.prompt.tr("\001\002", ''))
75+
print(input.line_buffer.tr("\001\002", ''))
76+
print("\033[u\033[B") # Restore cursor, move down one line
77+
end
78+
=end
7579

7680
print(msg + "\n")
7781
end

0 commit comments

Comments
 (0)