ruby-changes:64239
From: aycabta <ko1@a...>
Date: Thu, 17 Dec 2020 20:24:48 +0900 (JST)
Subject: [ruby-changes:64239] cdf2790aa0 (master): [ruby/reline] Support longer than screen height on Windows
https://git.ruby-lang.org/ruby.git/commit/?id=cdf2790aa0 From cdf2790aa089c5ff608dd97407b5ce684cc9f415 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Thu, 17 Dec 2020 19:57:44 +0900 Subject: [ruby/reline] Support longer than screen height on Windows https://github.com/ruby/reline/commit/2a97ca9362 diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb index b09290b..937941b 100644 --- a/lib/reline/windows.rb +++ b/lib/reline/windows.rb @@ -233,7 +233,9 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L233 def self.move_cursor_up(val) if val > 0 - @@SetConsoleCursorPosition.call(@@hConsoleHandle, (cursor_pos.y - val) * 65536 + cursor_pos.x) + y = cursor_pos.y - val + y = 0 if y < 0 + @@SetConsoleCursorPosition.call(@@hConsoleHandle, y * 65536 + cursor_pos.x) elsif val < 0 move_cursor_down(-val) end @@ -241,6 +243,9 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L243 def self.move_cursor_down(val) if val > 0 + screen_height = get_screen_size.first + y = cursor_pos.y + val + y = screen_height - 1 if y > (screen_height - 1) @@SetConsoleCursorPosition.call(@@hConsoleHandle, (cursor_pos.y + val) * 65536 + cursor_pos.x) elsif val < 0 move_cursor_up(-val) @@ -257,6 +262,8 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L262 def self.scroll_down(val) return if val.zero? + screen_height = get_screen_size.first + val = screen_height - 1 if val > (screen_height - 1) scroll_rectangle = [0, val, get_screen_size.last, get_screen_size.first].pack('s4') destination_origin = 0 # y * 65536 + x fill = [' '.ord, 0].pack('SS') diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 83ead69..8468729 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -426,6 +426,7 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L426 end def test_enable_bracketed_paste + omit if Reline::IOGate.win? write_inputrc <<~LINES set enable-bracketed-paste on LINES -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/