Skip to content

Commit c00930d

Browse files
committed
windows clear screen with \e 2 J
Windows Terminal does smart screen clearing when \e 2 J (not clear entire screen but scrolls down just needed) On consoles not support sequences, ruby still converts it to API call.
1 parent 9ff3c70 commit c00930d

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

lib/reline/windows.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,7 @@ def self.scroll_down(val)
390390
end
391391

392392
def self.clear_screen
393-
return unless csbi = get_console_screen_buffer_info
394-
buffer_width = csbi[0, 2].unpack1('S')
395-
attributes = csbi[8, 2].unpack1('S')
396-
_window_left, window_top, _window_right, window_bottom = *csbi[10,8].unpack('S*')
397-
fill_length = buffer_width * (window_bottom - window_top + 1)
398-
screen_topleft = window_top * 65536
399-
written = 0.chr * 4
400-
@@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, fill_length, screen_topleft, written)
401-
@@FillConsoleOutputAttribute.call(@@hConsoleHandle, attributes, fill_length, screen_topleft, written)
402-
@@SetConsoleCursorPosition.call(@@hConsoleHandle, screen_topleft)
393+
@@output.write "\e[2J" "\e[H"
403394
end
404395

405396
def self.set_screen_size(rows, columns)

0 commit comments

Comments
 (0)