[net.dcom] Xon/Xoff and editors

lmc@denelcor.UUCP (Lyle McElhaney) (11/09/83)

One of the really nice features of screen editors is the "function-key"
concept, in which a single keystroke can cause an action to take place, be
it moving the cursor or justifying a paragraph. This is what screen editing
is all about. But what does this require?

In order to get every single character typed *as it is typed*, the editor
must place the terminal in raw mode (as opposed to cooked - forget cbreak
for now), because cooked mode buffers incoming characters into lines.
However the very nature of raw mode is to pass through *all* characters
to the editor, even XON and XOFF.

That is why XON/XOFF flow control is suspended by EMACS (and the Rand editor
and vi). All these editors have ways to tailor your terminal to their
language - and all require the specification of fill characters if required
by the terminal.

					Lyle McElhaney
					...(hao,nbires,brl-bmd)!denelcor!lmc

guy@rlgvax.UUCP (Guy Harris) (11/10/83)

	One of the really nice features of screen editors is the
	"function-key" concept, in which a single keystroke can cause
	an action to take place, be it moving the cursor or justifying
	a paragraph. This is what screen editing is all about. But what
	does this require?

	In order to get every single character typed *as it is typed*, the
	editor must place the terminal in raw mode (as opposed to cooked -
	forget cbreak for now)

WHAT?  Why should we forget cbreak for now?  It provides *exactly* what
you're asking for, without turning of XON/XOFF, so it is extremely relevant
to this discussion and cannot be left out.  Admittedly, if you're running
a version of UNIX prior to V7, you don't have CBREAK, but programs can be
written to run, with some degradation, on V6 systems with the aid of
conditional compilations (if you haven't upgraded to a V7 or later system,
you have to expect a lot of things about UNIX to be considerably less nice).

All the character-at-a-time input programs we've done here (our office
automation system is screen-oriented, and it's a lot of code) runs in CBREAK
mode, not in RAW mode.  The main screen editors used here (one we did, and "vi")
run in CBREAK mode, not in RAW mode.  "vnews" runs in CBREAK mode, not in RAW
mode.  Most of the screen-oriented games that come with 4.xBSD run in CBREAK
mode, not in RAW mode.  There's a reason for this; in V7 (and its descendants),
RAW mode was intended for binary data transmission (i.e., 8 bits come in to
the line, the same 8 bits go to the process, and 8 bits go out of the process,
the same 8 bits go out on the line, no more, no less) and CBREAK was probably
*specifically* added for the benefit of screen editors and the like.  It
permits you to use the interrupt and quit characters (or disable them, if
you wish), to use the XON and XOFF characters (or disable them, if you wish).
It does not effect character output at all, so if your character-at-a-time
input program wants tab expansion, or CRMOD handling, or delays, or parity
checking and generation it can use them.

	However the very nature of raw mode is to pass through *all*
	characters to the editor, even XON and XOFF.

That's why most screen oriented programs *don't use* raw mode.

	That is why XON/XOFF flow control is suspended by EMACS (and the
	Rand editor and vi). All these editors have ways to tailor your
	terminal to their language - and all require the specification of
	fill characters if required by the terminal.

Yes, EMACS runs in raw mode.  We don't have the Rand editor here, but "vi"
damn well does *NOT* run in raw mode; it runs in cbreak mode.  (Maybe "stty"
lied to me, but I went into "vi" on one terminal and did an "stty" from
another terminal to find out what mode the terminal running "vi" was in;
the word "cbreak" appeared and the word "raw" did NOT.)  The reason EMACS
uses raw mode is that the search and quote commands are bound to the ^S
and ^Q keys.  Some versions of EMACS have been modified not to bind those
functions to those keys and to run in CBREAK mode on VT100s.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

mark@cbosgd.UUCP (Mark Horton) (11/10/83)

Actually, EMACS uses raw mode for two reasons.  One is that xon and xoff
are commands (search and quote).  The other is that some terminals have
meta keys and can send 8 bit characters.

I understand that CCA EMACS runs in cbreak mode, sets the xon/xoff characters
to two unused control chars (^^ and null or some such things), and
runs with xon/xoff flow control.  Of course, this works best on terminals
like the Ambassador that allow you to ste the xon/xoff chars as well.

vi runs in cbreak mode - it has since 1978.  It's a little known fact that
a very old version of vi (ex version 1.1 in visual mode) used ^S as a
"print the name of the file and my position in it" command and ^Q as a
quote (like EMACS) command.  Since it ran in raw mode, xon/xoff was not
an option.  When V7 came out, the ^S command was moved to ^G, and ^Q
was moved to ^V.  A year later, nobody remembered that ^G and ^V used
to be on other keys.  However, EMACS stands by its ^S and ^Q commands.

preece@uicsl.UUCP (11/12/83)

#R:denelcor:-20000:uicsl:4100003:000:335
uicsl!preece    Nov 11 16:11:00 1983

One of the nice things about Emacs is that you CAN re-bind any key you
like to any command you like.  That won't help you get xon/xoff running,
of course, unless you change the i/o to cbreak mode; I don't know
whether that would work.  We haven't felt any particular ill effects from
running Emacs without xon/xoff on our Ambassadors.