[plug] supressing JUST newline echo

Craig Ringer craig at postnewspapers.com.au
Wed Jul 14 22:13:55 WST 2004


Hi folks

I'm running into an interesting problem. I need to read a block of 
input, terminated with a carriage return (\r, enter key). This is in a 
Python program, but I doubt that matters. I also need to prevent the CR
from resulting in the display of a new line. I need everything else to 
work though - backspace, CTL-C, etc. In other words, I want a normal 
buffered read, but to suppress the display of the newline?

Is there any way to do this without using a getch() like function and 
manually handling backspace, CTL-C, etc?

'stty igncr' doesn't do what I want - I need to receive the CR, just not 
echo it.
'stty -echo' also doesn't do the trick, as with a buffered read there's 
no way of presenting feedback to the user until the input has finished.
'stty -echonl' does exactly the opposite of what I want - it permits 
newlines to be displayed even when everything else is being suppressed.

So ... is there something obvious all UNIX programmers "just know" that 
I'm missing here? I haven't needed to do any apps before that need much 
control over console input, and the experience so far is proving ... 
frustrating.

--
Craig Ringer




More information about the plug mailing list