Skip to content

Commit 6bd3f84

Browse files
committed
handling cases of control sequence being unavailable
MRI addresses this by converting the control code output to the console to win32api or by enabling VT sequence output to the console. JRuby does not do these things. Handle this by enabling VT sequence output to the console. If that fails, when in legacy console, SGR code printed as a garbage.
1 parent a481513 commit 6bd3f84

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/reline/io/windows.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def initialize
3535

3636
@legacy_console = getconsolemode & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0
3737
@jruby_p = RUBY_ENGINE == 'jruby'
38+
if @jruby_p && @legacy_console
39+
setconsolemode(getconsolemode() | ENABLE_VIRTUAL_TERMINAL_PROCESSING)
40+
@legacy_console = getconsolemode & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0
41+
end
3842
end
3943

4044
def encoding

0 commit comments

Comments
 (0)