Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!tank!oddjob!gargoyle!att!ihnp4!pegasus!hansen From: hansen@pegasus.UUCP (Tony L. Hansen) Newsgroups: comp.unix.wizards Subject: Re: terminfo Summary: things added recently to terminfo & curses Keywords: terminfo, curses Message-ID: <3193@pegasus.UUCP> Date: 9 Sep 88 04:54:40 GMT References: <508@altos86.UUCP> <10544@ulysses.homer.nj.att.com> <1389@zen.co.uk> Reply-To: hansen@pegasus.att.com Organization: AT&T Information Systems, Lincroft, NJ Lines: 201 It's been interesting watching the recent discussions about terminfo and curses, asking about the why's and wherefores, etc. As one of the people who has been involved in the evolution of terminfo and curses, I thought I'd add a little bit of real information to the net bandwidth. 1) why was terminfo created? I believe that the main reason terminfo was written to begin with was that the expressibility of arithmetic within a character attribute was severely limited. Using the termcap arithmetic operators, one just cannot express all of the different types of calculations necessary to handle the numerous types of terminals present and appearing out there. Termcap is certainly capable of handling numerous terminals, but there are just as many which it cannot handle. Once the decision was made to change the arithmetic capabilities of the database to something which was more reasonable and usable with any terminal, it was decided that it would be best to break away from the old format entirely, allowing further improvements. The longer names permit more capabilities to be supported easily. Although there do exist equivalent termcap names for each and every terminfo name there is, quick, what does the termcap "Fr" or "%1" capabilities represent? The terminfo names of "kf63" and "khlp" representing the function-key #63 and the Help function key are certainly more usable. The free-form input format and longer names, however, make it considerably harder (and slower) to interpret the input file. Consequently, the compiled, binary format and structure representation of the entire set of capabilities permits very fast access to all of the capabilities. Termcap uses an n^2 algorithm to access capabilities. 2) How do I manipulate the database to change an entry? All systems should have the uncompiled source to the terminfo database as well as the compiled format. If yours doesn't, then complain to the vendor. If you still cannot get the source, then you will have to make use of the other tools available. Unfortunately, System V release 2 didn't come with any way of looking at the binary files. It's for that reason that I wrote the infocmp program which subsequently was o made available in source format for all via the AT&T Toolchest at a very low cost o added to System V release 3.0 There have also been similar programs posted to the net; untic is one. In a similar vein, I wrote captoinfo to convert termcap entries into terminfo source format. It also became available within the Toolchest and in System V release 3.0. PD versions of this program have also appeared on the net. 3) Why has terminfo changed over the past few years All evolution to terminfo has been of two flavors: o add new capabilities to more fully support different terminals o add new arithmetic operations This was all done in an upwardly compatible manner. One should also be able to take a terminfo binary compiled on one release of the system to another release of the same system. One should also be able to take the binary from one system of one type and put it onto another system of a different type, but there may be difficulties going from an 8-bit byte machine to a 9-bit byte machine. If necessary, the binary file will be scanned a byte at a time to collect the 16-bit integer values, as the format is supposed to be completely portable no matter what the byte order of the machine in use. There may have been some minor bugs in the SysVr2 version preventing full support of this on some machines, but the intent was there and works completely in SysVr3. 4) I want to access the alternate character set of the terminal The terminfo capability "acsc" (alternate character set characters) defines a complete map of the alt. character set. It was added in System V release 3.0. Curses has always supported A_ALTCHARSET as a bit map similar to A_BOLD. Additional curses level support (added in SysVr3.0) for these characters comes in the form of variables named ACS_* (like ACS_ULCORNER and ACS_RTEE). Yes, these characters are automatically used by the box() function. 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. 6) I want to redefine things on the fly For redefining the number of lines and columns, the most straight-forward method is to use $LINES and $COLUMNS to override the values kept within the database. The terminfo level routines look for these values. The terminfo level routines may also look at a couple of ioctl values to determine the size of the window, but these are less reliable when going beyond the local machine's boundaries. Redefining other capabilities is somewhat more complicated, but not impossible. Those with a SysVr3.1 source licence should look at chgtinfo in the curses directory. I don't know if or when chgtinfo will make it into the mainline system. One would use it like this: TERMINFO=`chgtinfo xhp, smso=\E[3m, smul@,` export TERMINFO This would create a temporary version of the current terminfo entry under /usr/tmp using the given modifications. 7) How do I deal with supporting both termcap and terminfo versions of a terminal? I recommend that you maintain only the terminfo version, since it can describe so much more about the terminal. Then use "infocmp -C" when necessary to create the termcap version of the entry. 5) What has changed in curses? Yes, the curses library has evolved somewhat since Mark Horton's original rewrite, which appeared in System V release 2. With System V release 3.0, o considerable tuning to make it faster o additional terminfo capabilities and arithmetic operations o support for an alternate character set o support for soft labels o additional minor functions o rewrite of the curses and terminfo manual pages o rewrite of the chapter on curses and terminfo in the Programmer's Guide o tput enhanced "tput init" provides the initialization capabilities of tset tput can provide parameters to capabilities which require them o infocmp added o captoinfo added With System V release 3.1, o A rewrite of the insides of curses by K. Phong Vo. The result is considerably smaller, yet faster, than all earlier versions. o many new functions o internationalization: full support for 16-bit character sets and removal of the 8-bit dependencies. This was done in both a binary and source level compatible manner. o additional terminfo capabilities With System V release 3.2 o full support for color terminals The other major players in these enhancements besides myself, Mark Horton and K. Phong Vo, were Ernie Rice, Ephrayim Naiman and Sam Shteingart. 6) Some specific requests in the article to which this is a followup: < Terminfo Wish List: < Support for backtab as a keypad character (maybe even support for tab as a < keypad character, not just ^I). Added in SVr3.0. Many additional input keys became supported due to the large number of terminals in use with word processing systems. < Support for terminals which allow on screen labels to descibe function < keys (ie something like lab_f* but allowing a string parameter instead of < a cursor) Added in SVr3.0. The curses level offers a set of routines named slk_* for dealing with the "soft labels" < Modify pkey_* to allow length of string instead of using just assuming a < terminating character (eg support for length of string on stack, %l) Added in SVr3.0 were full support of the additional sprintf() sequences. For example, to print a string out as exactly 16 characters, one would use the normal sprintf() sequence of: %16.16s < Support sequences to control block mode applications. < Ability to define re-definable character sets. I don't think that these have been considered. < Support colour as well as standard high-lighting modes. Added in SVr3.2 < Ability to use line drawing character sets (eg a set of commands that will < emit corners, vertical lines, horizontal lines etc.) Added in SVr3.0. See above. ----------------------------------------------------------------------------- I hope some of this information proves useful for someone. Tony Hansen att!pegasus!hansen, attmail!tony