Add method for moving cursor up and to the beginning.

This commit is contained in:
Markus Reiter 2024-08-21 23:01:48 +02:00
parent 984cde114a
commit 9fd4c97fac
No known key found for this signature in database
GPG Key ID: 245293B51702655B
2 changed files with 6 additions and 1 deletions

View File

@ -290,7 +290,7 @@ module Homebrew
end end
if previous_pending_line_count.positive? if previous_pending_line_count.positive?
$stdout.print Tty.move_cursor_up(previous_pending_line_count) $stdout.print Tty.move_cursor_up_beginning(previous_pending_line_count)
$stdout.flush $stdout.flush
end end

View File

@ -56,6 +56,11 @@ module Tty
"\033[#{line_count}A" "\033[#{line_count}A"
end end
sig { params(line_count: Integer).returns(String) }
def move_cursor_up_beginning(line_count)
"\033[#{line_count}F"
end
sig { params(line_count: Integer).returns(String) } sig { params(line_count: Integer).returns(String) }
def move_cursor_down(line_count) def move_cursor_down(line_count)
"\033[#{line_count}B" "\033[#{line_count}B"