Skip to content

Commit

Permalink
Add method for moving cursor up and to the beginning.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Sep 4, 2024
1 parent 0be10ab commit feaba8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def run
end

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
end

Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/utils/tty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def move_cursor_up(line_count)
"\033[#{line_count}A"
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) }
def move_cursor_down(line_count)
"\033[#{line_count}B"
Expand Down

0 comments on commit feaba8f

Please sign in to comment.