Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I create a child progressbar? #66

Open
GitAntoinee opened this issue Mar 1, 2020 · 2 comments · May be fixed by #70
Open

How can I create a child progressbar? #66

GitAntoinee opened this issue Mar 1, 2020 · 2 comments · May be fixed by #70

Comments

@GitAntoinee
Copy link

Hello,
Is there a way to create child progress bar like https://github.com/Mpdreamz/shellprogressbar

@ctongfei
Copy link
Owner

ctongfei commented Mar 2, 2020

Hi! This is planned for a future version (v1.0), but I'm afraid it won't be ready for at least a few months.

@vehovsky vehovsky linked a pull request Apr 13, 2020 that will close this issue
@ctongfei ctongfei added this to the 1.0 milestone Apr 24, 2020
@Lc3586
Copy link

Lc3586 commented May 7, 2023

Hello, Is there a way to create child progress bar like https://github.com/Mpdreamz/shellprogressbar

maybe you can try this

/**
     * 支持在控制台打印多行进度条
     *
     * @author LCTR
     * @date 2023-05-07
     */
    public class ConsoleMultiProgressBarConsumer
            extends ConsoleProgressBarConsumer {
        final int index;
        final PrintStream out;

        public ConsoleMultiProgressBarConsumer(PrintStream out,
                                               int index) {
            super(out);
            this.out = out;
            this.index = index;
        }

        public ConsoleMultiProgressBarConsumer(PrintStream out,
                                               int maxRenderedLength,
                                               int index) {
            super(out,
                  maxRenderedLength);
            this.out = out;
            this.index = index;
        }

        @Override
        public void accept(String str) {
            out.print(StringExtension.newString("\r\n",
                                                index));

            out.print(matcher.appendTail(sb));
            //super.accept(str);

            out.print(StringExtension.newString("\033[F",
                                                index));
        }
    }
new ProgressBarBuilder()
                                .setTaskName("#01"))
                                .setInitialMax(100)
                                .setConsumer(new ConsoleMultiProgressBarConsumer(new PrintStream(new FileOutputStream(FileDescriptor.out)),
                                                                                 1))
                                .hideEta()
                                .setUpdateIntervalMillis(100)
                                .build();
new ProgressBarBuilder()
                                .setTaskName("#02"))
                                .setInitialMax(100)
                                .setConsumer(new ConsoleMultiProgressBarConsumer(new PrintStream(new FileOutputStream(FileDescriptor.out)),
                                                                                 2))
                                .hideEta()
                                .setUpdateIntervalMillis(100)
                                .build();
new ProgressBarBuilder()
                                .setTaskName("#03"))
                                .setInitialMax(100)
                                .setConsumer(new ConsoleMultiProgressBarConsumer(new PrintStream(new FileOutputStream(FileDescriptor.out)),
                                                                                 3))
                                .hideEta()
                                .setUpdateIntervalMillis(100)
                                .build();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants