beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.74k stars 1.82k forks source link

Redisplay last screen when "?" is entered at prompt. #297

Open mrmachine opened 11 years ago

mrmachine commented 11 years ago

In case another process has written to stdout and either overwritten the last screen or pushed it out of the scrollback buffer. In this case, simply re-displaying the key shortcuts for each choice without displaying the actual choices and the last screen is not much help.

sampsyo commented 11 years ago

This sounds like a good feature to have.

I do worry, though, that it will be somewhat complicated to implement. We'll have to add a new loop around every chunk of output we want to repeat, which might be daunting given how gnarly the control flow already is for those prompts. It would be great to find a simple way to implement this, but I'm not sure yet what that would be.

What sorts of output usually push prompts out of the scrollback? Maybe we would do well to address those (either also or instead). If it's just beets' own verbose output (beet -v), for example, maybe we should provide a way to dump that to a file so it doesn't interfere with the main interface.

mrmachine commented 11 years ago

I noticed it with bad request errors in the discogs plugin, which I haven't silenced because I'm trying to work out what causes them and how to prevent them properly. I think the first one overwrites the prompt line, and subsequent output pushes everything up the screen.

However, I think it might be possible for any other process to write to console in this way as well and there's nothing we could do about it. This is probably an extreme edge case, e.g. severe errors when using a Linux system directly at the console, but IF it's not a major headache to implement (sounds like it could be), I think it would be a good UI behaviour to have.

Maybe we could avoid having to buffer the output so we could re-print it, by actually re-starting the current loop instead? This would mean re-calculating anything and re-making any API calls as well as re-printing output to stdout. I guess this is probably not a very nice idea :)

Otherwise, could we tap into the print_() function. Instead of writing to stdout it could write to a global buffer, and then at each loop or prompt in the code we print the buffer, and after each prompt where a valid choice is made, we clear the buffer and continue. If no valid choice is made, we re-print the buffer?

mrmachine commented 11 years ago

Here is another example of some output from beets that is being printed to stdout while waiting at a prompt:

Started encoding /Users/tailee/dataset/Music.iTunes/Björk/Bastards/01 Crystalline (Omar Souleyman Remix).m4a Encoding /Users/tailee/dataset/Music.iTunes/Björk/Bastards/01 Crystalline (Omar Souleyman Remix).m4a failed. Cleaning up...

sampsyo commented 11 years ago

Ah—we should definitely endeavor to hide this kind of output (logs from import-triggered plugins). Looks like this comes from the convert plugin; let's silence its output from its import stage.

On Thu, May 30, 2013 at 6:02 AM, Tai Lee notifications@github.com wrote:

Here is another example of some output from beets that is being printed to stdout while waiting at a prompt: Started encoding /Users/tailee/dataset/Music.iTunes/Björk/Bastards/01 Crystalline (Omar Souleyman Remix).m4a

Encoding /Users/tailee/dataset/Music.iTunes/Björk/Bastards/01 Crystalline (Omar Souleyman Remix).m4a failed. Cleaning up...

Reply to this email directly or view it on GitHub: https://github.com/sampsyo/beets/issues/297#issuecomment-18678469

mrmachine commented 11 years ago

Just an idea. Might it be sufficient to add support for "hidden" or symbol options (like "?") to the input functions, and simply add a continue action for that option in the choose candidates function? Alternatively, we could add another visible option "re-Display" that does the same thing.

sampsyo commented 11 years ago

100% agree—it would be great if this option (and others like it) could be hidden from the prompt's list, which is already somewhat unwieldy.

mrmachine commented 11 years ago

Here is another example of errors written to stdout pushing data off screen.

Chromaprint::FingerprintCalculator::Calculate() -- Not enough data. Image has 2 rows, needs at least 16 rows. Chromaprint::FingerprintCalculator::Calculate() -- Not enough data. Image has 11 rows, needs at least 16 rows.

This was printed to stdout (number of rows varies) about 50 times.

sampsyo commented 11 years ago

That particular instance of extraneous should be fixed in sampsyo/pyacoustid@8939e030ba28493d827b5ce85cf1e43bd6c6a8aa (pyacoustid v1.0.0).