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

William Case billlinux at rogers.com
Fri Aug 24 23:57:17 UTC 2007


Thanks again Alan;

On Sat, 2007-08-25 at 00:36 +0100, Alan Cox wrote:
> > 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.

A year or so ago when I was reading about keyboard input and tty, I came
across canonical mode, and couldn't figure out what it would be used
for, shrugged (kinda), assumed it was only of historical interest and
moved on.  I will re-visit canonical mode and see how it applies.
-- 
Regards Bill




More information about the users mailing list