ctongfei / progressbar

Terminal-based progress bar for Java / JVM
http://tongfei.me/progressbar/
MIT License
1.07k stars 102 forks source link

Support PowerShell #136

Closed eum2o closed 2 years ago

eum2o commented 2 years ago

Tested with

Problem

PowerShell seems to have problems with the used chars/encoding. The progress looks like this:

image image

How to Reproduce

I just used the declarative example

final List<Object> objects = IntStream.range(0, 100).mapToObj(i -> new Object()).toList();
for (Object entry : ProgressBar.wrap(objects, "Foobar")) {
    Thread.sleep(200);
    // Progress will be automatically monitored by a progress bar
}
eum2o commented 2 years ago

Maybe I created the issue too fast. By setting the style to ASCII, it works fine. Read this on http://tongfei.me/progressbar/styles/

Example:

final List<Object> objects = IntStream.range(0, 100).mapToObj(i -> new Object()).toList();
ProgressBarBuilder pbb = new ProgressBarBuilder().setTaskName("Foobar")
        .setInitialMax(objects.size())
        .setStyle(ProgressBarStyle.ASCII);
try (ProgressBar pb = pbb.build()) {
    for (Object object : objects) {
        Thread.sleep(200);
        pb.step();
    }
}
ctongfei commented 2 years ago

Hello @eum2o -- this is not a bug of Progressbar, rather, this is because your PowerShell terminal uses the default "Cascadia" font, which does not support the box-drawing glyphs. You can change the default font of your PowerShell to any of the following fonts and it should work: Menlo, Fira Mono, Source Code Pro, Iosevka, JetBrains Mono or SF Mono.