Non-canonical input

The noncanon program provides a means of entering data via the keyboard without echoing it to the screen. This is known as non-canonical input mode, the usual echoing of input being canonical input mode. The general details of terminal control are very complex, but simple access has been provided with the kbd channel.

Here is a sample program which may be used to test the effect of kbd channel:

   PROGRAM noncanon CONTEXT VOID
   USE standard
   BEGIN
      STRING password;
      FILE kbd;  open(kbd,"",kbd channel);
      WHILE
         CHAR ch;  get bin(kbd,ch);
         ch /= REPR lf
      DO
         password+:=ch;
         print("*")
      OD;
      close(kbd);
      print(("You entered [",
             password,"]",
             newline))
   END
   FINISH

Notice that the program cannot be aborted by pressing ^C. Ensure you close the FILE opened with the kbd channel after use otherwise you'll find all your commands at the command prompt unechoed. If that happens, issue the following command at the prompt:

   $ stty sane

when normal echoing will be restored.


Sian Mountbatten 2012-01-19