Skip to content

Commit

Permalink
Scroll down when ^C is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Jan 29, 2021
1 parent 4bc8c2c commit 6877a7e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/reline/line_editor.rb
Expand Up @@ -150,6 +150,13 @@ def reset(prompt = '', encoding:)
@screen_height = @screen_size.first
reset_variables(prompt, encoding: encoding)
@old_trap = Signal.trap('SIGINT') {
if @scroll_partial_screen
move_cursor_down(@screen_height - (@line_index - @scroll_partial_screen) - 1)
else
move_cursor_down(@highest_in_all - @line_index - 1)
end
Reline::IOGate.move_cursor_column(0)
scroll_down(1)
@old_trap.call if @old_trap.respond_to?(:call) # can also be string, ex: "DEFAULT"
raise Interrupt
}
Expand Down Expand Up @@ -420,6 +427,7 @@ def rerender
end
end
@buffer_of_lines[@line_index] = @line
@rest_height = 0 if @scroll_partial_screen
else
line = modify_lines(whole_lines)[@line_index]
render_partial(prompt, prompt_width, line, 0)
Expand Down

0 comments on commit 6877a7e

Please sign in to comment.