chjj / blessed

A high-level terminal interface library for node.js.
Other
11.31k stars 535 forks source link

keypressed incompatiable with Nodemon #334

Open stockholmux opened 6 years ago

stockholmux commented 6 years ago

If running a script that uses blessed executed by nodemon, the key presses will only register after hitting enter/return.

screen.on('keypress', function(ch, key){ console.log(key); });

If you type 'asdf' then you won't see any of the key press logs, but if you press enter/return, you'll see the long for 'a', then 's', then 'd', then 'f' and finally return all at the same time.

Running the same script with plain 'node', the behaviour will be as expected.

TapGhoul commented 6 years ago

Nodemon likely uses a readline style input (or buffers input) for optimisation. If this is a case, this is intended behaviour and is caused by nodemon, not blessed.

jimpsson commented 6 years ago

I had this problem as well, and it was a bit unclear on how to solve it when consulting the Nodemon documentation. Seems like it's not even in the docs.

But it's actually easy to solve, just pass the following flag to Nodemon when firing it up: -I, --no-stdin

For over clarification: nodemon -I your_blessed_program_now_working.js

Then all your $TERM (xterm etc) escape sequences will work as usual, and Nodemon will re-execute your program when you write any changes to the file.

fatfatson commented 5 years ago

I had this problem as well, and it was a bit unclear on how to solve it when consulting the Nodemon documentation. Seems like it's not even in the docs.

But it's actually easy to solve, just pass the following flag to Nodemon when firing it up: -I, --no-stdin

For over clarification: nodemon -I your_blessed_program_now_working.js

Then all your $TERM (xterm etc) escape sequences will work as usual, and Nodemon will re-execute your program when you write any changes to the file.

if add the -I option, ctrl-c won't response after the first restarting