jscanner

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 4b74b6c6ea4e1ac2675fed1087df26a005f417dc
parent d88400469de3ac51e5dd2998b3968759a4ea18a0
Author: Matthias Jaros <jaros@mailbox.org>
Date:   Mon, 23 Mar 2026 11:38:29 +0100

Fixed progress bar duplicates and now only redraw lines that actually
changes and the rest is fixed

Diffstat:
Msrc/main/java/com/it_jaros/network_scanner/ProgressBar.java | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/it_jaros/network_scanner/ProgressBar.java b/src/main/java/com/it_jaros/network_scanner/ProgressBar.java @@ -1,6 +1,8 @@ package com.it_jaros.network_scanner; import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -25,7 +27,17 @@ public class ProgressBar { } private void drawProgress(boolean last) { - // paint a bar per host + // find and print finished hosts one last time + for (Iterator<Progress> it = hosts.iterator(); it.hasNext();) { + Progress p = it.next(); + if (p.done().get() == p.total()) { + it.remove(); + drawBar(p); + } + } + + // the more progressed the host the more up it is + hosts.sort(Comparator.comparingInt((Progress p) -> p.done().get()).reversed()); for (Progress progress : hosts) { drawBar(progress); } @@ -43,7 +55,7 @@ public class ProgressBar { } private void drawBar(Progress progress) { - System.out.print("\u001b[2K\r"); + System.out.print("\u001b[2K\r"); // clear whole line System.out.println(createBar( progress.host(), progress.open().get(),