Skip to content

Commit

Permalink
[ruby/reline] Support longer than screen height on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Dec 17, 2020
1 parent 0158ba7 commit cdf2790
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/reline/windows.rb
Expand Up @@ -233,14 +233,19 @@ def self.move_cursor_column(val)

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
end

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)
Expand All @@ -257,6 +262,8 @@ def self.erase_after_cursor

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')
Expand Down
1 change: 1 addition & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Expand Up @@ -426,6 +426,7 @@ def test_prompt_list_caching
end

def test_enable_bracketed_paste
omit if Reline::IOGate.win?
write_inputrc <<~LINES
set enable-bracketed-paste on
LINES
Expand Down

0 comments on commit cdf2790

Please sign in to comment.