Skip to content

Commit

Permalink
progress bars need work > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Apr 3, 2024
1 parent e768d92 commit 26ec1ac
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/org/rascalmpl/repl/TerminalProgressBarMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ private class ProgressBar {
private final Instant startTime;
private Duration duration;
private String message = "";
private int stepper = 0;
private int stepper = 1;
private final String[] clocks = new String[] {"🕐" , "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕛"};
public int nesting = 0;

ProgressBar(String name, int max) {
this.threadId = Thread.currentThread().getId();
this.threadName = Thread.currentThread().getName();
this.name = name;
this.max = max;
this.max = Math.max(1, max);
this.startTime = Instant.now();
this.duration = Duration.ZERO;
this.message = name;
Expand Down Expand Up @@ -109,10 +109,16 @@ void update() {
}

int newWidth() {
current = Math.min(max, current); // for robustness sake
var partDone = (current * 1.0) / (max * 1.0);
return (int) Math.floor(barWidth * partDone);
if (max != 0) {
current = Math.min(max, current); // for robustness sake
var partDone = (current * 1.0) / (max * 1.0);
return (int) Math.floor(barWidth * partDone);
}
else {
return barWidth % stepper;
}
}

/**
* Print the current state of the progress bar
*/
Expand Down

0 comments on commit 26ec1ac

Please sign in to comment.