Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!motcsd!dms!shepperd From: shepperd@dms.UUCP (Dave Shepperd) Newsgroups: comp.unix.xenix Subject: Re: scrip + history = cmdline history ?????? Message-ID: <777@dms.UUCP> Date: 4 Jun 89 22:26:47 GMT References: <614@tapa.UUCP> Organization: Atari Games Inc., Milpitas, CA Lines: 26 From article <614@tapa.UUCP>, by larry@tapa.UUCP (Larry Pajakowski): > > Under DOS this is easy to handle since the application uses DOS i/o for cooked > and BIOS and/or direct screen write for raw i/o. Xenix/Unix on the other hand > uses ioctl calls to do this. How could a program like script which uses pty's > figure out when to buffer keystrokes for the cooked input or get out of the > way for the raw input? > I've written a command line editor with history as a line discipline which makes it application independent. The line discipline is what does the "cooking" of keyboard input. What the disciplines do to distinguish cooked and raw modes is to inspect the flags in the tty structure. If certain bits are set, then it assumes cooked mode. If certain bits are clear, it assumes raw mode and steps aside. The same line discipline routines are used by "real" terminal drivers as well as pseudo terminal drivers. This technique, easy to do in kernel code, my be somewhat difficult to use in a user program, but not impossible. It would require an ioctl to get the tty stats at various places and times which might bring your system to its knees. -- Dave Shepperd. shepperd@dms.UUCP or weitek!dms!shepperd Atari Games Corporation, Sycamore Drive, Milpitas CA 95035. (Arcade Video Game Manufacturer, NOT Atari Corp. ST manufacturer).