[comp.unix.questions] Question on implementing "repeat...until keypress"?

guy@gorodish.UUCP (02/09/87)

(This is NOT a C question, it's an operating system question.  C
doesn't know anything about modes for reading lines vs.  modes for
reading characters, which is as it should be.  I'm redirecting this
to comp.unix.questions, where it belongs.)

>  ioctl(0, TIOCGETP, &ttyb);
>  ttyb.sg_flags ^= (RAW | ECHO);
>  ioctl(0, TIOCSETP, &ttyb);

Is there some reason why this example requires that you:

	1) turn off parity checking and generation?

	2) disable XON/XOFF flow control?

	3) disable the user's interrupt and quit characters?

	4) disable all special output processing (such as mapping
	   newlines to CR/LF)?

If not, then you should be going into CBREAK mode, not RAW mode.
(Two advantages of the S3/S5 terminal driver interface:  1) it
doesn't have CBREAK or RAW mode, so you have to think about what you
want to change, and 2) it's different from the older ones, so you
can't just work from mistaken impressions about what RAW mode really
is.)

RAW mode was intended for binary data transfer, as is used for
up/down loading terminals and the like, UUCP, etc..  (Yes, I know
EMACS uses it, but that's just because the only way to guarantee no
special input processing whatsoever with the older V7-style interface
is to turn RAW mode on.)

The original poster said they were running under S5, so V7/BSD
solutions don't help much.  John Plocher's solution is a correct one
for those systems.

mouse@mcgill-vision.UUCP (02/12/87)

In article <12911@sun.uucp>, guy%gorodish@Sun.COM (Guy Harris) writes:
> Is there some reason why this example requires that you:
> [assorted things]
> If not, then you should be going into CBREAK mode, not RAW mode.

True enough, in this case.

> (Yes, I know EMACS uses [RAW mode], but that's just because the only
> way to guarantee no special input processing whatsoever with the
> older V7-style interface is to turn RAW mode on.)	

It's also much easier to simply turn RAW on than to grovel through
struct tchars and struct ltchars turning all the characters off and
then fiddling half a dozen bits to get the literal input and output
effect.

					der Mouse

USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: think!mosart!mcgill-vision!mouse@harvard.harvard.edu

guy@gorodish.UUCP (02/14/87)

>It's also much easier to simply turn RAW on than to grovel through
>struct tchars and struct ltchars turning all the characters off and
>then fiddling half a dozen bits to get the literal input and output
>effect.

This is completely irrelevant.  Fiddling all the modes individually
doesn't provide the proper mode, so the fact that fiddling them is
more complicated doesn't make any difference.  If it were possible to
get a more correct mode by fiddling lots of bits, that would be the
right thing to do; the fact that it might be easier to do the wrong
thing than the right thing is no excuse for doing the wrong thing.