home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4383 < prev    next >
Encoding:
Text File  |  1992-08-20  |  2.3 KB  |  53 lines

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