[前][次][番号順一覧][スレッド一覧]

ruby-changes:70338

From: YO4 <ko1@a...>
Date: Mon, 20 Dec 2021 14:52:05 +0900 (JST)
Subject: [ruby-changes:70338] 65cb250cb1 (master): [ruby/reline] windows clear screen with \e 2 J

https://git.ruby-lang.org/ruby.git/commit/?id=65cb250cb1

From 65cb250cb15f8b93cee8a1a7c1e8adb1b2e6e95e Mon Sep 17 00:00:00 2001
From: YO4 <ysno@a...>
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(-)

diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
index 23bbd087a45..8710e6cb80f 100644
--- a/lib/reline/windows.rb
+++ b/lib/reline/windows.rb
@@ -390,16 +390,7 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L390
   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.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]