r-lib / progress

Progress bar in your R terminal
http://r-lib.github.io/progress/
Other
468 stars 39 forks source link

Support for multi-line output #105

Closed daattali closed 4 years ago

daattali commented 4 years ago

If I have a non-short message in the progress bar, the bar itself becomes almost non existent:

Here's a modified example from the README, where I just added the words "from https://someverylongurl.com":

pb <- progress_bar$new(
    format = "  downloading from https://someverylongurl.com [:bar] :percent eta: :eta",
    total = 100, clear = FALSE, width= 60)
for (i in 1:100) {
    pb$tick()
    Sys.sleep(1 / 100)
}

The result is:

downloading from https://someverylongurl.com [=] 100% e..

I tried inserting a line break after the URL, so that the tokens would have their own line to span which would be enough space, but that doesn't really work because then the progress bar just outputs all the messages one after the other to the console. It would be great to be able to use a format like downloading from https://someverylongurl.com\n[:bar] :percent eta: :eta

gaborcsardi commented 4 years ago

Multiline output is only possibly in a real terminal, not in the R Gui or in RStudio. So even if progress supported that, you would need some fallback. I am afraid that you'll need to make the message shorter, e.g. use https://host/.../filename or similar. It is also not crucial to show downloading from.

daattali commented 4 years ago

My actual use case is very different, I'm reading large files and want to show which file is currently being read - including the relative path. For now I'm just not showing the file name (and I guess based on your answer, I'll never show the file name :) )

If this can't be supported, you can close the issue

gaborcsardi commented 4 years ago

Well, it can be supported, in a Unix terminal, there is some discussion in #26 about it. But not in any IDE.

For your use case, you can have a progress bar / status bar, that shows some overall progress, e.g. some of

and in addition to this, show one file that is being loaded. You would change this file to another one every second. I think that would be a nice and informative display.