-
Notifications
You must be signed in to change notification settings - Fork 69
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
Clearing the screen from the previous prompts #108
Comments
I've found out a workaround, however something on the library would be nice if possible use std::io::{self, Write};
// Select an Operation:
// > Foo
// Bar
// The commands below would clear the lines above
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
io::stdout().flush().unwrap(); |
let confirmation_choice = Confirm::new().with_default(false).with_autoclear().prompt(); Would something like that be a good UX for you? It might also make sense to have that included in the Implementing this will be easy as we already have the entire logic of cleaning up all lines used by the prompt, so it would come down to not rendering the last line containing the final answer. So, possible approaches:
It seems to me that this kind of feature would either be enabled by all prompts in a program (be it 1 or many), or none of them. The scenario where some prompts showing the final answer and others are cleared from the screen is harder for me to picture, so it makes sense to optimize for the common case and go with approach #2. What are your thoughts? |
Hello! That was quite quick for an answer haha, yes it is perfect! I think passing it as an option would be better as the user probably would like to triple-check what he did haha In my very specific case, i was clearing all the previous prompts because i've made a "Back to previous Menu" thing: > Select an Operation: Check the Database
> Select the entry: japa4551
// This is the part that i would display some data, but i'm not there (yet)
> Would you like to select another entry? No
// In case the yes/no prompt above returns no, it clears the screen/prompts and "returns to the main menu"
// AKA sets "entry_selection_loop" to false and returns to the main loop |
Having an option in the prompt makes sense to me, but I also think it's important for the setting to be in RenderConfig. It'll probably be both :) It's on my radar, but it might take a while as I'm refactoring the code base to allow for some future improvements. If you're interested in creating a PR you have my support! |
I think I've run into something similar. We're using your library and it's great! The only thing that would improve it is that when we're using the password validator, if the user enters their password incorrectly it doesn't clear the prompt to try again -- they have to physically delete all the characters 😩 So having an option to clear would be amazing 🙏 |
Is your feature request related to a problem? Please describe.
If you're designing something like an Interactive Menu, its not possible to clear the screen from the previous prompts with traditional methods.
Describe the solution you'd like
I was imagining something like this:
Describe alternatives you've considered
I've tried things like the following, but all of those only run after the program is stopped for some reason
Additional context
Some back-end libraries (like crosstext) do have an option to Clear the text, so it should not be that difficult to implement.
The text was updated successfully, but these errors were encountered: