From cdf2d155b484ef96527180435467e0b70b0ae8cf Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 18 Apr 2025 15:48:08 -0700 Subject: Let errors scroll off the screen --- ccp.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ccp.go b/ccp.go index 94eac96..e42195a 100644 --- a/ccp.go +++ b/ccp.go @@ -167,7 +167,7 @@ func run() error { case <-frameTimer.C: } - width, _, err := term.GetSize(int(os.Stdout.Fd())) + width, height, err := term.GetSize(int(os.Stdout.Fd())) if err != nil { width = 80 } @@ -175,7 +175,7 @@ func run() error { currentProgress.mu.Lock() current := currentProgress.current - max := currentProgress.max + maxBytes := currentProgress.max copyingFrom := currentProgress.copyingFrom copyingTo := currentProgress.copyingTo errs := currentProgress.errs @@ -193,8 +193,8 @@ func run() error { } } progress := 0. - if max > 0 { - progress = float64(current) / float64(max) + if maxBytes > 0 { + progress = float64(current) / float64(maxBytes) } etaStr := "..." if eta >= 0 { @@ -209,7 +209,7 @@ func run() error { copyingFile, bar.ViewAs(progress), etaStr) - for _, e := range errs { + for _, e := range errs[max(len(errs)-max(height-5, 0), 0):] { fmt.Fprintln(renderer, warningStyle(e.Error())) } renderer.Flush() -- cgit v1.3.1