summaryrefslogtreecommitdiff
path: root/lib/reline/windows.rb
diff options
context:
space:
mode:
authorYoshinao Muramatu <ysno@ac.auone-net.jp>2020-08-30 14:42:41 +0900
committeraycabta <aycabta@gmail.com>2020-09-12 08:35:51 +0900
commita840ef85690281a92b62e2d0dd84f7de69cfd4ae (patch)
tree8e69dd7e01044e6293d5ec84fc102fce94dace96 /lib/reline/windows.rb
parent0862744010907ecda8c8122557e97de9238d51a1 (diff)
[ruby/reline] not clear scrollback buffer
https://github.com/ruby/reline/commit/ba800f1461
Diffstat (limited to 'lib/reline/windows.rb')
-rw-r--r--lib/reline/windows.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
index 6459daa37f..a7bd381283 100644
--- a/lib/reline/windows.rb
+++ b/lib/reline/windows.rb
@@ -250,15 +250,17 @@ class Reline::Windows
end
def self.clear_screen
- coord_screen_top_left = 0
- written = 0.chr * 4
csbi = 0.chr * 22
return if @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi) == 0
- con_size = csbi[0, 4].unpack('SS').inject(:*)
+ buffer_width = csbi[0, 2].unpack('S').first
attributes = csbi[8, 2].unpack('S').first
- @@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, con_size, coord_screen_top_left, written)
- @@FillConsoleOutputAttribute.call(@@hConsoleHandle, attributes, con_size, coord_screen_top_left, written)
- @@SetConsoleCursorPosition.call(@@hConsoleHandle, coord_screen_top_left)
+ 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)
end
def self.set_screen_size(rows, columns)