mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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
This commit is contained in:
parent
2c415cda85
commit
65cb250cb1
1 changed files with 1 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue