home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!solaris.rz.tu-clausthal.de!news!fromme
- From: fromme@ipc1.rrzn.uni-hannover.de (Michael Fromme)
- Subject: Re: real-time character input
- Message-ID: <1992Aug20.163039.23729@newsserver.rrzn.uni-hannover.de>
- Sender: news@newsserver.rrzn.uni-hannover.de (News Service)
- Organization: Universit"at Hannover, Germany
- X-Newsreader: Tin 1.1 PL4
- References: <1992Aug13.112134.1@hamp.hampshire.edu>
- Date: Thu, 20 Aug 1992 16:30:39 GMT
- Lines: 40
-
- The problem is that the Unix tty drivers provide almost two modes of
- operation: the raw and the cooked mode. The most used cooked mode
- provides basic line editing possibilities as character erasion via
- DEL, character entry, line redraw, echoing and so on. If your program
- request characters from a tty-driver operating in cooked mode, you
- have to enter a complete line before the first character gets
- delivered. But you have the possibility to coorrect types and your
- program has not to take care of that.
-
- If your tty driver operates in raw mode, it delivers every character
- as it is received. Though all specials like BS, DEL, NL and CR are
- received as well.
-
- Of course, there are more modes of operation. You can tell the driver
- to perform CR to NL mapping on input, NL to CRNL mapping on output
- etc. This is required by most terminals.
-
- Solutions to this problem:
-
- 1) use the stty-command to set the tty-operation-mode in a
- shell script or via system(). Most stty's provide special
- raw and cooked-commands like macros. If you get in a mess
- using stty enter "^Jstty sane^J" to restore normal settings.
-
- 2) Use the curses-library, what should exist on your system.
- curses provides raw() and noraw(), echo() and noecho()
- calls. Remember: echoing is mostly done by the tty-driver!
-
- 3) Use iocntl-calls to set the specific options of the tty
- driver. This is system-specific, read the ioctl(2) man
- page of your system.
-
- If you plan to program a line editing routine for a non commercial
- application, check the readline-library from FSF (GNU).
-
-
- --
- Michael Fromme Lehrgebiet Rechnernetze und Verteilte Systeme
- fromme@rvs.uni-hannover.de Universit"at Hannover, Germany
- fromme@rvs.uni-hannover.dbp.de Tel: (ger) 0511 / 762 3681
-