dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.63k stars 278 forks source link

Ouput of data with prettyJson package removes the cursor #273

Closed StarpTech closed 6 years ago

StarpTech commented 6 years ago

Hi, I implemented a command which ouutput the result of an action as coloured YAML-style with the https://github.com/rafeca/prettyjson package. It look like that printing the data turns the console in a different mode because only after keypress event the vorpal line local@starptech~$ appears

vorpal.ui.redraw(Prettyjson.render(err || resp))

Any idea why the cursor is removed? Only restarting the cli will bring back the default behaviour. Thanks.

dthree commented 6 years ago

Have you checked to see if this only happens with prettyJSON? It might just be your use of redraw.

Check out the docs:

https://github.com/dthree/vorpal/wiki/API-%7C-vorpal.ui

You might have to do ui.redraw.done afterwards.


I believe I exposed redraw for a constant rerendering of content (such as a blinking cursor), in which case you don't want the prompt to come back unless explicitly stated.

StarpTech commented 6 years ago

HI @dthree the fix works thanks!

dthree commented 6 years ago

Great!