ptrstream- endless stream of rdns |
git clone git://git.acid.vegas/ptrstream.git |
Log | Files | Refs | Archive | README | LICENSE |
commit d24c8064e15e73d66362904300b7483d7e5ec7c3
parent 413c36504e144429b70fb0f5f1eac971fb3901da Author: acidvegas <acid.vegas@acid.vegas> Date: Fri, 6 Dec 2024 18:11:19 -0500 Fixed error when terminal size was too small Diffstat:
|
1 file changed, 12 insertions(+), 2 deletions(-) |
diff --git a/ptrstream.go b/ptrstream.go @@ -452,7 +452,7 @@ func main() { app.QueueUpdateDraw(func() { var width int _, _, width, _ = progress.GetInnerRect() - if width == 0 { + if width <= 0 { return } @@ -465,7 +465,17 @@ func main() { formatNumber(failed), float64(failed)/float64(processed)*100) - barWidth := width - visibleLength(statsText) - 2 + textWidth := visibleLength(statsText) + barWidth := width - textWidth - 2 // -2 for the [] characters + + // Ensure barWidth is at least 1 + if barWidth < 1 { + // If there's not enough space, just show the stats without the progress bar + progress.Clear() + fmt.Fprint(progress, statsText) + return + } + filled := int(float64(barWidth) * (percent / 100)) if filled > barWidth { filled = barWidth |