Reputation: 6595
Would really like to retrieve the entire line as it is typed before it is submitted so checks can be run before the user adds a line break? How would one accomplish this?
Thank you for reading.
Upvotes: 2
Views: 381
Reputation: 13560
You can archive this by setting stdin.lineMode
to false
. In that case you get a stream event for every character typed instead of only one per line. If you want to handle the outputing of the entered character on your own, you can also disable stdin.echoMode
. In that case you have to pring the entered characters on your own. You have to enable it again after your program exits, otherwise the terminal stays in that mode.
One problem is that you are unable to reactivate echoMode
in case of a program crash as there is no global crash handler. See issue 17743 for that.
Upvotes: 4