Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!amdahl!pacbell!att!ihnp4!pegasus!hansen From: hansen@pegasus.UUCP (Tony L. Hansen) Newsgroups: comp.unix.wizards Subject: Re: terminfo Summary: some more info Keywords: terminfo, curses Message-ID: <3194@pegasus.UUCP> Date: 16 Sep 88 03:51:58 GMT References: <508@altos86.UUCP> <10544@ulysses.homer.nj.att.com> <1389@zen.co.uk> <3193@pegasus.UUCP> <1486@ficc.uu.net> Reply-To: hansen@pegasus.UUCP (XT1554000-Tony L. Hansen;LZ 3B-315;3207) Organization: AT&T Information Systems, Lincroft, NJ Lines: 106 <> = me < = Peter da Silva < Fine. I've got some more questions, if you don't mind... No problem. <> The free-form input format and longer names, however, make it considerably <> harder (and slower) to interpret the input file. < Nonsense. I wrote a termcap emulation for CP/M in 1981 that supported long < names. I didn't actually time it, but since the code I wrote did a strcmp < type search (abort as soon as a match fails) it might even be faster than < a two-byte match (which is what you seem to be implying termcap does). A two byte match done with && is considerably faster than calling strcmp(). Both abort as soon as a match fails and the first is done without the overhead of a function call. Parsing the data file is not the only problem with termcap, however. The algorithm for searching for a given capability, after having parsed the entire entry into memory, is an n^2 algorithm. The search for each capability starts over again at the very beginning of the entry. Given that curses pulls in a large majority of the boolean, numeric and string capabilities, this searching for all of the capabilities overshadows the parsing of the data file. < Also, there isn't much you can do to speed things up that will beat having < a TERMCAP environment entry. You haven't been doing your homework. Benchmarks run by Mark Horton showed that the linear algorithms used by the terminfo library and doing a single read from the file system were considerably faster even than the use of a TERMCAP environment variable. This was all reported in the 1982 Usenix proceedings. <> 5) I want to define my own capabilites <> The user defined terminfo capabilities user0 to user9 were added in <> SysVr3.1. You're free to do with these as you will. $TERMINFO/ti tic $TERMINFO/ti > /dev/null 2>&1 ln $TERMINFO/$T1/${TERM}X $TERMINFO/$T1/$TERM echo $TERMINFO One modifies their terminfo entry like this (this adds auto_left_margin and auto_right_margin to the current terminfo entry): TERMINFO=`chgtinfo am, bw,` To unset this, one does this: rm -r $TERMINFO unset TERMINFO This is both quick and easy. Especially under System V release 3 where tic is 3 to 10 times faster than the System V release 2 version of tic. With both termcap and terminfo, you have to remember to change back when you want to use the standard ones. I don't see an advantage on other side. And how do you usually edit your environment variable TERMCAP? Unless you have the ksh, you usually have to type it all in, do it via a separate program, or writing the variable to a temp file and using an editor such as vi on that temp file, then read the temp file back into your environment. < 10) Use the terminfo routines in other environments. I can define a < gamecap file and use the termcap routines to access it. The entries in < there don't have to have anything to do with terminals. I agree that the routines could be made usable in other environments. I believe that your use of the termcap routines for gamecap would require either having the source avaiable or doing various tricks with the environment. Actually, better yet would be a standard set of database routines available on all systems. < 11) Use standard UNIX tools on a terminfo file. What's the quickest way to < get a listing of all the terminals supported under terminfo? I don't know < any easy ones. The quickest way that I know of is: ls -C /usr/lib/terminfo/? Egrep also works fine on the files under /usr/lib/terminfo. Tony Hansen att!pegasus!hansen, attmail!tony