aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYO4 <ysno@ac.auone-net.jp>2021-12-11 23:40:01 +0900
committergit <svn-admin@ruby-lang.org>2021-12-20 14:51:52 +0900
commit65cb250cb15f8b93cee8a1a7c1e8adb1b2e6e95e (patch)
tree021321d7dd400b340b5ba353932bd9c1ed9dc76b
parent2c415cda854ab02f8341428b5346a115d3648a48 (diff)
downloadruby-65cb250cb15f8b93cee8a1a7c1e8adb1b2e6e95e.tar.gz
[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
-rw-r--r--lib/reline/windows.rb11
1 files changed, 1 insertions, 10 deletions
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)