OT What does RET (Enter) do and how does it do it ??

Alan Cox alan at lxorguk.ukuu.org.uk
Fri Aug 24 23:36:58 UTC 2007


> programs like emacs.  But you are saying that this equally applicable to
> all programs.  That I could, if I wanted change the function of RET by
> changing the keymap a particular application uses.  It is just that the
> use of RET is fairly well standardized. 

Its partly wired in. Certain parts of the behaviour are encoded into the
terminal layer in the kernel (originally designed from the days people
sat at terminals with serial links (or current loop) to the box in the
data centre.

In normal line by line behaviour the return key is fixed (you can pick
between carriage-return and line feed that is all), but the other
'special' characters like the delete key can be changed. This is so
called "canonical" or "cooked mode". You can turn this off to do character
by character processing (as emacs does) which is "raw mode".

The idea of cooked mode is that most programs at the time wanted lines of
typed input so the kernel handles this to ensure the editing behaviour was
standard, it was efficient and on big machines (with hundreds of
terminals) you didn't wake processes each keypress. Indeed some machines
had serial ports that didn't wake the machine but supported all the line
editing features in hardware until you hit return.




More information about the users mailing list