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

setting message doesn't trigger re-draw #22

Open
mcginty opened this issue Aug 11, 2016 · 5 comments
Open

setting message doesn't trigger re-draw #22

mcginty opened this issue Aug 11, 2016 · 5 comments

Comments

@mcginty
Copy link

mcginty commented Aug 11, 2016

have to call tick() afterwards to get it to show the message

@nabijaczleweli
Copy link
Contributor

That should be the default behaviour

@mcginty
Copy link
Author

mcginty commented Aug 30, 2016

Why? It seems like if you set the message on a progress bar, that should be the message that's displayed?

@nabijaczleweli
Copy link
Contributor

nabijaczleweli commented Aug 30, 2016

Because double-redrawing every tick is really bad?
Code example of correct usage of ProgressBar::message()

// or, y'know, iterate over current dir, it's too early to do that so I hardcoded it
static FILES: &'static [&'static str] = &[".gitignore", ".travis.yml", "Cargo.lock", "Cargo.toml", "LICENSE", "README.md", "appveyor.yml", "assets/icon.png", "gh_rsa.enc", "not-stakkr.sublime-project", "not-stakkr.sublime-workspace", "rustfmt.toml", "src/lib.rs", "src/main.rs", "src/ops/init.rs", "src/ops/mod.rs", "src/ops/token.rs", "src/options.rs", "src/outcome.rs", "src/util.rs", "tests/mod.rs", "tests/util/mod.rs", "tests/util/prompt_exact_len.rs"];

let mut pb = ProgressBar::new(FILES.len());
for f in FILES {
    pb.message(f);
    pb.inc();
    thread::sleep_ms(5);
}

@mcginty
Copy link
Author

mcginty commented Aug 30, 2016

Lol, thumbs down. Ouch.

Yeah, I get what you're saying, but the underlying issue around that seems like an architectural challenge of either having a transactional API or having an animation thread.

In my project, for example, I've wrapped pb in a thread that animates at a specified framerate, and it queues up actions to be executed in the next display frame. Perhaps this is something pb should just do to solve this problem.

@winstonewert
Copy link
Contributor

I think we should leave as is.

None of the show/tick/message options trigger redraws upon changes.

I think there is merit in the approach suggested where a seperate thread updates the UX at a particular frame rate. However, that is a rather different approach to what pb is doing and would require a complete rearchitecture of the system. So, perhaps there is a place for a crate that does that, but pb isn't it.

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

No branches or pull requests

3 participants