magmax / python-inquirer

A collection of common interactive command line user interfaces, based on Inquirer.js (https://github.com/SBoudrias/Inquirer.js/)
MIT License
1.01k stars 97 forks source link

List options wont clear from screen after selected. #57

Open sdushantha opened 5 years ago

sdushantha commented 5 years ago

I am trying to prompt the user for multiple questions using inquirer.List. I am able to select the items but the options wont clear away when asking for the next one.

>>> inquirer.prompt(questions);inquirer.prompt(questions)                        
[?] What size do you need?: Large
   Jumbo
 > Large
   Standard
   Medium
   Small
   Micro

[?] What size do you need?: Medium
   Jumbo
   Large
   Standard
 > Medium
   Small
   Micro

Is it possible to clear the options like inquirer.js does?

AuHau commented 5 years ago

I am afraid there is no support for this feature at this moment.

mauricesvp commented 4 years ago

This can achieved by adding

print(self.terminal.home + self.terminal.clear, end="")

before this, however this could come with potential side effects.

NaleRaphael commented 4 years ago

Thanks for this awesome package! I was running into this problem yesterday, and I've customize a component to solve it after digging into source code. You can check it out here: https://gist.github.com/NaleRaphael/64acf6404aeab749ae335a457d842c95

The idea of this implementation is that we have to know have many lines have been printed, and then we can move the cursor to that line and clear those lines under it. (with the help of blessed.Terminal().move_up() and blessed.Terminal().clear_eol())

And also thanks for the advice from @mauricesvp. But since it will clear the whole history (printed lines) in current terminal, I have to give up on it.