Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!chen@MITRE-GATEWAY.ARPA From: chen@MITRE-GATEWAY.ARPA (MS W420) Newsgroups: net.unix-wizards Subject: Re: THE LAST WORD (HOPEFULLY) ON THE GREAT IOCTL DEBATE Message-ID: <678@brl-tgr.ARPA> Date: Tue, 13-Aug-85 14:05:50 EDT Article-I.D.: brl-tgr.678 Posted: Tue Aug 13 14:05:50 1985 Date-Received: Sun, 18-Aug-85 03:10:51 EDT Sender: news@brl-tgr.ARPA Lines: 44 Hmmmm. Reminds me of something I did a while back. I was working on a multi-window vi that was to run under curses. Needless to say, I quickly discovered that curses really sucks if you want to do any non-trivial tty-driver handling. I ended up writing a set of library routines to handle tty drivers in a portable way. My goal was to enable application programs to handle tty driver settings as states or objects. Instead of calling a routine to immediately change the state of the driver, you pass a structure representing some tty state to a routine and tell it what operation you want performed on that state. The routine gives you back a structure and sets an error field in that structure if the current tty driver can't accomodate your request. After you've monkeyed around with a tty structure to your heart's content, you can then call a routine with a tty structure as a parameter which will set the state of the real tty to correspond to the state of the tty structure. There's also a routine which returns a structure that reflects the current state of the real tty. This enables an application program to find out about the capabilities of its tty driver, get the current settings, keep many different terminal settings around, and switch among them at will. The applications programs see only a defined structure and a set of routines. The definition of the structure changes from system to system but the user does nothing with the structure other than store them, pass them to the library routines, and check the error field (which exists in all incarnations). When I stopped working on it, the library could handle everything vi needed to do. Set/reset special characters, cbreak, echo, tabs, etc. Although I've only been able to test it under 4.2, it should (or will) run under 4.x, 2.x, v7, v8, and System V. I don't have the code lying around at the moment, but if anybody's interested in it, drop me a line. Or you could always redo it yourself if you're feeling particularly masochistic. It wasn't hard, just tedious. Ray Chen chen@mitre-gw