From 65cb250cb15f8b93cee8a1a7c1e8adb1b2e6e95e Mon Sep 17 00:00:00 2001 From: YO4 Date: Sat, 11 Dec 2021 23:40:01 +0900 Subject: [ruby/reline] 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. https://github.com/ruby/reline/commit/c00930dab9 --- lib/reline/windows.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'lib/reline') diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb index 23bbd087a4..8710e6cb80 100644 --- a/lib/reline/windows.rb +++ b/lib/reline/windows.rb @@ -390,16 +390,7 @@ class Reline::Windows end def self.clear_screen - return unless csbi = get_console_screen_buffer_info - buffer_width = csbi[0, 2].unpack1('S') - attributes = csbi[8, 2].unpack1('S') - _window_left, window_top, _window_right, window_bottom = *csbi[10,8].unpack('S*') - fill_length = buffer_width * (window_bottom - window_top + 1) - screen_topleft = window_top * 65536 - written = 0.chr * 4 - @@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, fill_length, screen_topleft, written) - @@FillConsoleOutputAttribute.call(@@hConsoleHandle, attributes, fill_length, screen_topleft, written) - @@SetConsoleCursorPosition.call(@@hConsoleHandle, screen_topleft) + @@output.write "\e[2J" "\e[H" end def self.set_screen_size(rows, columns) -- cgit v1.2.3