views:

19

answers:

0

The question is pretty much in the title. I need to have my terminal in non-canonical mode for some input I am getting from the user (I need to have Ctrl-D act as an immediate "finished" signal, rather than flushing the input when pressed and only EOF-ing when there is no input to flush.), but this makes it impossible to ERASE. I am not looking to remove the characters from the input buffer, as they've obviously already been flushed (I'll handle that internally), but instead just need for the user to see the character disappear when they hit backspace, rather than just seeing a ^? appear.

At the moment, I use the following to enter non-canonical mode:

stty -icanon min 1 time 0

Is there a stty flag for this, or any other way of doing it?

Alternatively I'd like to have Ctrl-D always flush and send an EOF, but as far as I understand it, in reality Ctrl-D only actually flushes the input - it is merely when the flushed input is 0 bytes that an EOF is triggered. I don't suppose there's a way to say "When I press Ctrl-D, it should flush twice if there are bytes in the buffer, but only once if there are no bytes"?