[plug] supressing JUST newline echo

Bernd Felsche bernie at innovative.iinet.net.au
Thu Jul 15 00:42:57 WST 2004


On Wednesday 14 July 2004 22:13, Craig Ringer wrote:
> 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 -opost

will prevent output post-processing, including echoing of carriage
returns. 

There are basically 3 modes of terminal control; raw, cooked and
pickled. :-)

Look at "icanon" in stty and play with that a bit until you grok
what it does... then add other input and output processing options
as the become necessary. A long time ago, it seems, I wrote a simple
menu system using icanon and times in a shell program.

The thing was lost in the great ESDI crash of 1991 or thereabouts.

I gather that this is some sort of interactive process where input
mostly gets echoed to the user, but you don't want the cursor to
move off the line when enter is pressed. Can't remember exactly how
I did that at the time... seemed trivial after I figured it out. :-)

Hint: stty -g spews out the bits you need to restore the tty to a
previous state.

-- 
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ /  ASCII ribbon campaign | I'm a .signature virus!
 X   against HTML mail     | Copy me into your ~/.signature
/ \  and postings          | to help me spread!





More information about the plug mailing list