diff options
Diffstat (limited to 'lib/termcap/grot')
-rw-r--r-- | lib/termcap/grot/COPYING | 347 | ||||
-rw-r--r-- | lib/termcap/grot/ChangeLog | 137 | ||||
-rw-r--r-- | lib/termcap/grot/INSTALL | 176 | ||||
-rw-r--r-- | lib/termcap/grot/Makefile.in | 138 | ||||
-rw-r--r-- | lib/termcap/grot/NEWS | 20 | ||||
-rw-r--r-- | lib/termcap/grot/README | 34 | ||||
-rwxr-xr-x | lib/termcap/grot/configure | 998 | ||||
-rw-r--r-- | lib/termcap/grot/configure.in | 23 | ||||
-rw-r--r-- | lib/termcap/grot/termcap.info | 80 | ||||
-rw-r--r-- | lib/termcap/grot/termcap.info-1 | 1114 | ||||
-rw-r--r-- | lib/termcap/grot/termcap.info-2 | 974 | ||||
-rw-r--r-- | lib/termcap/grot/termcap.info-3 | 1480 | ||||
-rw-r--r-- | lib/termcap/grot/termcap.info-4 | 220 | ||||
-rw-r--r-- | lib/termcap/grot/termcap.texi | 3617 | ||||
-rw-r--r-- | lib/termcap/grot/texinfo.tex | 4422 |
15 files changed, 13780 insertions, 0 deletions
diff --git a/lib/termcap/grot/COPYING b/lib/termcap/grot/COPYING new file mode 100644 index 0000000..2b940a4 --- /dev/null +++ b/lib/termcap/grot/COPYING @@ -0,0 +1,347 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +The Free Software Foundation has exempted Bash from the requirement of +Paragraph 2c of the General Public License. This is to say, there is +no requirement for Bash to print a notice when it is started +interactively in the usual way. We made this exception because users +and standards expect shells not to print such messages. This +exception applies to any program that serves as a shell and that is +based primarily on Bash as opposed to other GNU software. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/lib/termcap/grot/ChangeLog b/lib/termcap/grot/ChangeLog new file mode 100644 index 0000000..e8c4751 --- /dev/null +++ b/lib/termcap/grot/ChangeLog @@ -0,0 +1,137 @@ +Wed Aug 16 20:45:44 1995 David J. MacKenzie <djm@geech.gnu.ai.mit.edu> + + * version.c: Version 1.3. + + * termcap.c (tgetent): Use the user-supplied buffer even if we + don't find a matching terminal, so the program can set the buffer + if they want (`less' does this). From Bob Pegram + <pegram@emba.uvm.edu>. + +Wed Jul 26 11:44:51 1995 David J. MacKenzie <djm@geech.gnu.ai.mit.edu> + + * termcap.c: TERMCAP_NAME -> TERMCAP_FILE. + + * configure.in: Add --enable-install-termcap and --with-termcap + options. + + * Makefile.in: Add hooks for new configure options. + + * Makefile.in (DISTFILES): Add termcap.src. + (DEFS): Remove -DNO_ARG_ARRAY. + (install-data, uninstall-data): New targets. + + * tparam.c (tparam): Remove arg array version and the #ifdef. + + * termcap.c: Move #define of bcopy to after #include <string.h>. + + * termcap.h: Prototype the arg to the tputs outfun arg. + + * Makefile.in: realclean -> maintainer-clean. Use @prefix@ and + @exec_prefix@. + + * Makefile.in (DISTFILES): Add install-sh. + +Fri Apr 7 14:57:45 1995 Richard Stallman <rms@mole.gnu.ai.mit.edu> + + * termcap.c (tgetent): Don't try to return the allocated address. + Always return 1 if successful. + +Tue Feb 14 02:34:43 1995 Richard Stallman <rms@pogo.gnu.ai.mit.edu> + + * termcap.c (speeds): Make it ints. Add some higher speeds. + (tputs) [emacs]: If speed is high, convert to smaller units. + (tputs): Really use SPEED to calculate PADCOUNT. + +Sat Dec 17 07:20:24 1994 Richard Stallman <rms@mole.gnu.ai.mit.edu> + + * termcap.c (tgetst1): Let ^? stand for DEL character. + +Thu Jun 30 04:35:50 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * configure.in: Use AC_HAVE_HEADERS instead of AC_UNISTD_H. + Add AC_PROG_RANLIB. + * Makefile.in (AR, RANLIB): New variables. + (install, libtermcap.a): Use them instead of hard-wired commands. + +Sat Jun 4 12:21:41 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * termcap.c [HAVE_CONFIG_H]: Include <sys/file.h>, and include + <fcntl.h> #ifdef USG5, so we get O_* defns. + +Wed May 25 19:05:30 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * termcap.c (O_RDONLY): Define to 0 if not already defined. + (tgetent): Use O_RDONLY instead of explicit 0 in call to open. + +Wed Jan 5 22:20:15 1993 Morten Welinder (terra@diku.dk) + + * termcap.c (tgetent) [INTERNAL_TERMINAL]: Fake internal terminal + without reading any files. + (valid_file_name, tgetent) [MSDOS]: Drive letter support. + (tgetent) [MSDOS]: Use text mode for database. + +Fri Dec 17 00:22:43 1993 Mike Long (mike.long@analog.com) + + * termcap.c (tgetent): Replaced literal filenames for termcap + database with preprocessor symbol TERMCAP_NAME. + (TERMCAP_NAME): Define if not defined. + +Fri Sep 10 00:35:07 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * Makefile.in (.c.o): Put -I. before -I$(srcdir). + * termcap.c: Include <config.h> instead of "config.h". + * tparam.c: Likewise. + +Thu Jul 29 20:53:30 1993 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) + + * Makefile.in (config.status): Run config.status --recheck, not + configure, to get the right args passed. + +Thu Apr 15 12:45:10 1993 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) + + * Version 1.2. + + * tparam.c [!emacs] (xmalloc, xrealloc, memory_out): New functions. + (tparam1): Use them. + + * termcap.c, tparam.c: Use NULL or '\0' where appropriate + instead of 0. Rename some vars. + * termcap.c (tgetent): If EOF is reached on termcap file, + free allocated resources before returning. + + * termcap.c (tgetent): Use /etc/termcap if TERMCAP is an entry + for a term type other than TERM. + From pjr@jet.UK (Paul J Rippin). + +Sat Apr 10 23:55:12 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) + + * tparam.c (tparam1): Don't set the 0200 bit on a non-0 character code. + From junio@twinsun.COM (Junio Hamano). + +Tue Dec 8 22:02:15 1992 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) + + * termcap.c, tparam.c: Use HAVE_STRING_H instead of USG. + +Thu Dec 3 13:47:56 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) + + * termcap.c, tparam.c [HAVE_CONFIG_H]: Include config.h. + +Fri Oct 23 12:35:29 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * termcap.h [__STDC__]: Add consts. From Franc,ois Pinard. + +Tue Oct 13 15:52:21 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) + + * Version 1.1. + +Tue Sep 29 21:04:39 1992 David J. MacKenzie (djm@geech.gnu.ai.mit.edu) + + * termcap.[ch], tparam.c: Fix some lint. + + * version.c: New file. + +Local Variables: +mode: indented-text +left-margin: 8 +version-control: never +End: diff --git a/lib/termcap/grot/INSTALL b/lib/termcap/grot/INSTALL new file mode 100644 index 0000000..95d84c8 --- /dev/null +++ b/lib/termcap/grot/INSTALL @@ -0,0 +1,176 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/lib/termcap/grot/Makefile.in b/lib/termcap/grot/Makefile.in new file mode 100644 index 0000000..e6f06ae --- /dev/null +++ b/lib/termcap/grot/Makefile.in @@ -0,0 +1,138 @@ +# Makefile for GNU termcap library. +# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. + +#### Start of system configuration section. #### + +srcdir = @srcdir@ +VPATH = @srcdir@ + +CC = @CC@ +AR = ar +RANLIB = @RANLIB@ + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +MAKEINFO = makeinfo + +DEFS = @DEFS@ -DTERMCAP_FILE=\"$(termcapfile)\" + +CFLAGS = -g + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +# Directory in which to install libtermcap.a. +libdir = $(exec_prefix)/lib + +# Directory in which to install termcap.h. +includedir = $(prefix)/include + +# Directory in which to optionally also install termcap.h, +# so compilers besides gcc can find it by default. +# If it is empty or not defined, termcap.h will only be installed in +# includedir. +oldincludedir = /usr/include + +# Directory in which to install the documentation info files. +infodir = $(prefix)/info + +# File to which `install-data' should install the data file +# if --enable-install-termcap was given. +termcapfile = @termcapfile@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +SRCS = termcap.c tparam.c version.c +OBJS = termcap.o tparam.o version.o +HDRS = termcap.h +DISTFILES = $(SRCS) $(HDRS) ChangeLog COPYING README INSTALL NEWS \ +termcap.src termcap.texi termcap.info* \ +texinfo.tex Makefile.in configure configure.in mkinstalldirs install-sh + +all: libtermcap.a info + +.c.o: + $(CC) -c $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) $(CFLAGS) $< + +install: all installdirs @installdata@ + $(INSTALL_DATA) libtermcap.a $(libdir)/libtermcap.a + -$(RANLIB) $(libdir)/libtermcap.a + cd $(srcdir); $(INSTALL_DATA) termcap.h $(includedir)/termcap.h + -cd $(srcdir); test -z "$(oldincludedir)" || \ + $(INSTALL_DATA) termcap.h $(oldincludedir)/termcap.h + cd $(srcdir); for f in termcap.info*; \ + do $(INSTALL_DATA) $$f $(infodir)/$$f; done + +uninstall: @uninstalldata@ + rm -f $(libdir)/libtermcap.a $(includedir)/termcap.h + test -z "$(oldincludedir)" || rm -f $(oldincludedir)/termcap.h + rm -f $(infodir)/termcap.info* + +# These are separate targets to avoid trashing the user's existing +# termcap file unexpectedly. +install-data: + $(INSTALL_DATA) ${srcdir}/termcap.src ${termcapfile} + +uninstall-data: + rm -f ${termcapfile} + +installdirs: + $(SHELL) ${srcdir}/mkinstalldirs $(bindir) $(libdir) \ + $(includedir) $(infodir) + +Makefile: Makefile.in config.status + $(SHELL) config.status +config.status: configure + $(SHELL) config.status --recheck +configure: configure.in + cd $(srcdir) && autoconf + +libtermcap.a: $(OBJS) + $(AR) rc $@ $(OBJS) + -$(RANLIB) $@ + +info: termcap.info + +termcap.info: termcap.texi + $(MAKEINFO) $(srcdir)/termcap.texi --output=$@ + +TAGS: $(SRCS) + etags $(SRCS) + +clean: + rm -f *.a *.o core + +mostlyclean: clean + +distclean: clean + rm -f Makefile config.status config.cache config.log + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "rebuilding the deleted files requires makeinfo." + rm -f TAGS *.info* + +dist: $(DISTFILES) + echo termcap-`sed -e '/version_string/!d' -e 's/[^0-9]*\([0-9a-z.]*\).*/\1/' -e q version.c` > .fname + rm -rf `cat .fname` + mkdir `cat .fname` + ln $(DISTFILES) `cat .fname` + tar chzf `cat .fname`.tar.gz `cat .fname` + rm -rf `cat .fname` .fname diff --git a/lib/termcap/grot/NEWS b/lib/termcap/grot/NEWS new file mode 100644 index 0000000..e5d58b9 --- /dev/null +++ b/lib/termcap/grot/NEWS @@ -0,0 +1,20 @@ +Major changes in release 1.3: + +Termcap data file is now included in distribution and may optionally + be installed, or used in a non-default location. +Support for a fake internal terminal (no external files). +Higher tty speeds supported. +Portability tweaks. + +Major changes in release 1.2: + +For `%.', only set the high bit on NUL. +Fix a file descriptor and memory leak. +Add const in termcap.h prototypes. +Configuration improvements. + +Major changes in release 1.1: + +Fix portability problems. +Improve configuration and installation. +Fix compiler warnings. diff --git a/lib/termcap/grot/README b/lib/termcap/grot/README new file mode 100644 index 0000000..ba1a19c --- /dev/null +++ b/lib/termcap/grot/README @@ -0,0 +1,34 @@ +This is the GNU termcap library -- a library of C functions that +enable programs to send control strings to terminals in a way +independent of the terminal type. The GNU termcap library does not +place an arbitrary limit on the size of termcap entries, unlike most +other termcap libraries. + +Most of this package is also distributed with GNU Emacs, but it is +available in this separate distribution to make it easier to install +as -ltermcap. However, use of termcap is discouraged. Termcap is +being phased out in favor of the terminfo-based ncurses library, which +contains an emulation of the termcap library routines in addition to +an excellent curses implementation. ncurses is available from the +usual GNU archive sites. + +See the file INSTALL for compilation and installation instructions. +Additionally: + +This package contains termcap.src, the latest official termcap data +file. By default, it is not installed. The current version contains +some entries that are more than 1023 bytes long, which is the largest +value that is safe to use with the many historical applications that +only allocate a 1024 byte termcap buffer (telnet, for example). If +you make sure that all of your programs allocate buffers of at least +2500 bytes, or let the termcap library do it by passing a NULL +pointer, then it is safe to install the new termcap file, as described +below. + +You can give configure two special options: + --enable-install-termcap install the termcap data file + --with-termcap=FILE use data file FILE instead of /etc/termcap + +Please report any bugs in this library to bug-gnu-emacs@prep.ai.mit.edu. +You can check which version of the library you have by using the RCS +`ident' command on libtermcap.a. diff --git a/lib/termcap/grot/configure b/lib/termcap/grot/configure new file mode 100755 index 0000000..8a885fa --- /dev/null +++ b/lib/termcap/grot/configure @@ -0,0 +1,998 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.4 +# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --enable-install-termcap install the termcap data file" +ac_help="$ac_help + --with-termcap=FILE use data file FILE instead of /etc/termcap" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE + +# Initialize some other variables. +subdirs= + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -build | --build | --buil | --bui | --bu | --b) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=PREFIX install architecture-dependent files in PREFIX + [same as prefix] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +--enable and --with options recognized:$ac_help +EOF + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.4" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=termcap.h + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5' + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +# Check whether --enable-install-termcap or --disable-install-termcap was given. +enableval="$enable_install_termcap" +if test -n "$enableval"; then + if test $enableval = yes; then + installdata=install-data uninstalldata=uninstall-data + fi +fi + + +# Check whether --with-termcap or --without-termcap was given. +withval="$with_termcap" +if test -n "$withval"; then + termcapfile=$withval +else + termcapfile=/etc/termcap +fi + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if ${CC-cc} -E conftest.c 2>&5 | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 +if test $ac_cv_prog_gcc = yes; then + GCC=yes + if test "${CFLAGS+set}" != set; then + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_gcc_g=yes +else + ac_cv_prog_gcc_g=no +fi +rm -f conftest* + +fi + echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6 + if test $ac_cv_prog_gcc_g = yes; then + CFLAGS="-g -O" + else + CFLAGS="-O" + fi + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_ifs" + # As a last resort, use the slow shell script. + test -z "$ac_cv_path_install" && ac_cv_path_install="$ac_install_sh" +fi + INSTALL="$ac_cv_path_install" +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 612 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 626 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +for ac_hdr in string.h unistd.h +do +ac_safe=`echo "$ac_hdr" | tr './\055' '___'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 659 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +# If we cannot run a trivial program, we must be cross compiling. +echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_c_cross=yes +else +cat > conftest.$ac_ext <<EOF +#line 696 "configure" +#include "confdefs.h" +main(){return(0);} +EOF +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + ac_cv_c_cross=no +else + ac_cv_c_cross=yes +fi +fi +rm -fr conftest* +fi +cross_compiling=$ac_cv_c_cross +echo "$ac_t""$ac_cv_c_cross" 1>&6 + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 717 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> +EOF +eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 739 "configure" +#include "confdefs.h" +#include <string.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 757 "configure" +#include "confdefs.h" +#include <stdlib.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + ac_cv_header_stdc=no +else +cat > conftest.$ac_ext <<EOF +#line 778 "configure" +#include "confdefs.h" +#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +eval $ac_link +if test -s conftest && (./conftest; exit) 2>/dev/null; then + : +else + ac_cv_header_stdc=no +fi +fi +rm -fr conftest* +fi +fi +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \ + >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.4" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@installdata@%$installdata%g +s%@uninstalldata@%$uninstalldata%g +s%@termcapfile@%$termcapfile%g +s%@CC@%$CC%g +s%@RANLIB@%$RANLIB%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@CPP@%$CPP%g + +CEOF +EOF +cat >> $CONFIG_STATUS <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"Makefile"} +EOF +cat >> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust relative srcdir, etc. for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file +fi; done +rm -f conftest.subs + + + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/lib/termcap/grot/configure.in b/lib/termcap/grot/configure.in new file mode 100644 index 0000000..f3f944f --- /dev/null +++ b/lib/termcap/grot/configure.in @@ -0,0 +1,23 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(termcap.h) + +AC_ARG_ENABLE(install-termcap, +[ --enable-install-termcap install the termcap data file], +[if test $enableval = yes; then + installdata=install-data uninstalldata=uninstall-data + fi]) +AC_SUBST(installdata)dnl +AC_SUBST(uninstalldata)dnl + +AC_ARG_WITH(termcap, +[ --with-termcap=FILE use data file FILE instead of /etc/termcap], +termcapfile=$withval, termcapfile=/etc/termcap) +AC_SUBST(termcapfile)dnl + +AC_PROG_CC +AC_PROG_RANLIB +AC_PROG_INSTALL +AC_HAVE_HEADERS(string.h unistd.h) +AC_STDC_HEADERS + +AC_OUTPUT(Makefile) diff --git a/lib/termcap/grot/termcap.info b/lib/termcap/grot/termcap.info new file mode 100644 index 0000000..f663195 --- /dev/null +++ b/lib/termcap/grot/termcap.info @@ -0,0 +1,80 @@ +This is Info file ./termcap.info, produced by Makeinfo-1.55 from the +input file ./termcap.texi. + + This file documents the termcap library of the GNU system. + + Copyright (C) 1988 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +Indirect: +termcap.info-1: 874 +termcap.info-2: 47411 +termcap.info-3: 90390 +termcap.info-4: 138827 + +Tag Table: +(Indirect) +Node: Top874 +Node: Introduction4105 +Node: Library5832 +Node: Preparation6851 +Node: Find8034 +Node: Interrogate11492 +Node: Initialize16800 +Node: Padding18440 +Node: Why Pad19146 +Node: Not Enough20768 +Node: Describe Padding23336 +Node: Output Padding24826 +Node: Parameters28441 +Node: Encode Parameters30101 +Node: Using Parameters36185 +Node: tparam36780 +Node: tgoto38806 +Node: Data Base41361 +Node: Format42257 +Node: Capability Format44346 +Node: Naming47411 +Node: Inheriting51980 +Node: Changing54224 +Node: Capabilities55388 +Node: Basic58127 +Node: Screen Size62180 +Node: Cursor Motion63920 +Node: Wrapping74062 +Node: Scrolling77091 +Node: Windows82980 +Node: Clearing83714 +Node: Insdel Line85478 +Node: Insdel Char90390 +Node: Standout100375 +Node: Underlining109433 +Node: Cursor Visibility111852 +Node: Bell112600 +Node: Keypad113149 +Node: Meta Key117864 +Node: Initialization118818 +Node: Pad Specs121369 +Node: Status Line123422 +Node: Half-Line125306 +Node: Printer126108 +Node: Summary127787 +Node: Var Index138114 +Node: Cap Index138827 +Node: Index145991 + +End Tag Table diff --git a/lib/termcap/grot/termcap.info-1 b/lib/termcap/grot/termcap.info-1 new file mode 100644 index 0000000..a5b5da0 --- /dev/null +++ b/lib/termcap/grot/termcap.info-1 @@ -0,0 +1,1114 @@ +This is Info file ./termcap.info, produced by Makeinfo-1.55 from the +input file ./termcap.texi. + + This file documents the termcap library of the GNU system. + + Copyright (C) 1988 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: termcap.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) + +* Menu: + +* Introduction:: What is termcap? Why this manual? +* Library:: The termcap library functions. +* Data Base:: What terminal descriptions in `/etc/termcap' look like. +* Capabilities:: Definitions of the individual terminal capabilities: + how to write them in descriptions, and how to use + their values to do display updating. +* Summary:: Brief table of capability names and their meanings. +* Var Index:: Index of C functions and variables. +* Cap Index:: Index of termcap capabilities. +* Index:: Concept index. + + -- The Detailed Node Listing -- + +The Termcap Library + +* Preparation:: Preparing to use the termcap library. +* Find:: Finding the description of the terminal being used. +* Interrogate:: Interrogating the description for particular capabilities. +* Initialize:: Initialization for output using termcap. +* Padding:: Outputting padding. +* Parameters:: Encoding parameters such as cursor positions. + +Padding + +* Why Pad:: Explanation of padding. +* Not Enough:: When there is not enough padding. +* Describe Padding:: The data base says how much padding a terminal needs. +* Output Padding:: Using `tputs' to output the needed padding. + +Filling In Parameters + +* Encode Parameters:: The language for encoding parameters. +* Using Parameters:: Outputting a string command with parameters. + +Sending Display Commands with Parameters + +* tparam:: The general case, for GNU termcap only. +* tgoto:: The special case of cursor motion. + +The Format of the Data Base + +* Format:: Overall format of a terminal description. +* Capability Format:: Format of capabilities within a description. +* Naming:: Naming conventions for terminal types. +* Inheriting:: Inheriting part of a description from +a related terminal type. +* Changing:: When changes in the data base take effect. + +Definitions of the Terminal Capabilities + +* Basic:: Basic characteristics. +* Screen Size:: Screen size, and what happens when it changes. +* Cursor Motion:: Various ways to move the cursor. +* Wrapping:: What happens if you write a character in the last column. +* Scrolling:: Pushing text up and down on the screen. +* Windows:: Limiting the part of the window that output affects. +* Clearing:: Erasing one or many lines. +* Insdel Line:: Making new blank lines in mid-screen; deleting lines. +* Insdel Char:: Inserting and deleting characters within a line. +* Standout:: Highlighting some of the text. +* Underlining:: Underlining some of the text. +* Cursor Visibility:: Making the cursor more or less easy to spot. +* Bell:: Attracts user's attention; not localized on the screen. +* Keypad:: Recognizing when function keys or arrows are typed. +* Meta Key:: META acts like an extra shift key. +* Initialization:: Commands used to initialize or reset the terminal. +* Pad Specs:: Info for the kernel on how much padding is needed. +* Status Line:: A status line displays "background" information. +* Half-Line:: Moving by half-lines, for superscripts and subscripts. +* Printer:: Controlling auxiliary printers of display terminals. + + +File: termcap.info, Node: Introduction, Next: Library, Prev: Top, Up: Top + +Introduction +************ + + "Termcap" is a library and data base that enables programs to use +display terminals in a terminal-independent manner. It originated in +Berkeley Unix. + + The termcap data base describes the capabilities of hundreds of +different display terminals in great detail. Some examples of the +information recorded for a terminal could include how many columns wide +it is, what string to send to move the cursor to an arbitrary position +(including how to encode the row and column numbers), how to scroll the +screen up one or several lines, and how much padding is needed for such +a scrolling operation. + + The termcap library is provided for easy access this data base in +programs that want to do terminal-independent character-based display +output. + + This manual describes the GNU version of the termcap library, which +has some extensions over the Unix version. All the extensions are +identified as such, so this manual also tells you how to use the Unix +termcap. + + The GNU version of the termcap library is available free as source +code, for use in free programs, and runs on Unix and VMS systems (at +least). You can find it in the GNU Emacs distribution in the files +`termcap.c' and `tparam.c'. + + This manual was written for the GNU project, whose goal is to +develop a complete free operating system upward-compatible with Unix +for user programs. The project is approximately two thirds complete. +For more information on the GNU project, including the GNU Emacs editor +and the mostly-portable optimizing C compiler, send one dollar to + + Free Software Foundation + 675 Mass Ave + Cambridge, MA 02139 + + +File: termcap.info, Node: Library, Next: Data Base, Prev: Introduction, Up: Top + +The Termcap Library +******************* + + The termcap library is the application programmer's interface to the +termcap data base. It contains functions for the following purposes: + + * Finding the description of the user's terminal type (`tgetent'). + + * Interrogating the description for information on various topics + (`tgetnum', `tgetflag', `tgetstr'). + + * Computing and performing padding (`tputs'). + + * Encoding numeric parameters such as cursor positions into the + terminal-specific form required for display commands (`tparam', + `tgoto'). + +* Menu: + +* Preparation:: Preparing to use the termcap library. +* Find:: Finding the description of the terminal being used. +* Interrogate:: Interrogating the description for particular capabilities. +* Initialize:: Initialization for output using termcap. +* Padding:: Outputting padding. +* Parameters:: Encoding parameters such as cursor positions. + + +File: termcap.info, Node: Preparation, Next: Find, Up: Library + +Preparing to Use the Termcap Library +==================================== + + To use the termcap library in a program, you need two kinds of +preparation: + + * The compiler needs declarations of the functions and variables in + the library. + + On GNU systems, it suffices to include the header file `termcap.h' + in each source file that uses these functions and variables. + + On Unix systems, there is often no such header file. Then you must + explictly declare the variables as external. You can do likewise + for the functions, or let them be implicitly declared and cast + their values from type `int' to the appropriate type. + + We illustrate the declarations of the individual termcap library + functions with ANSI C prototypes because they show how to pass the + arguments. If you are not using the GNU C compiler, you probably + cannot use function prototypes, so omit the argument types and + names from your declarations. + + * The linker needs to search the library. Usually either + `-ltermcap' or `-ltermlib' as an argument when linking will do + this. + + +File: termcap.info, Node: Find, Next: Interrogate, Prev: Preparation, Up: Library + +Finding a Terminal Description: `tgetent' +========================================= + + An application program that is going to use termcap must first look +up the description of the terminal type in use. This is done by calling +`tgetent', whose declaration in ANSI Standard C looks like: + + int tgetent (char *BUFFER, char *TERMTYPE); + +This function finds the description and remembers it internally so that +you can interrogate it about specific terminal capabilities (*note +Interrogate::.). + + The argument TERMTYPE is a string which is the name for the type of +terminal to look up. Usually you would obtain this from the environment +variable `TERM' using `getenv ("TERM")'. + + If you are using the GNU version of termcap, you can alternatively +ask `tgetent' to allocate enough space. Pass a null pointer for +BUFFER, and `tgetent' itself allocates the storage using `malloc'. +There is no way to get the address that was allocated, and you +shouldn't try to free the storage. + + With the Unix version of termcap, you must allocate space for the +description yourself and pass the address of the space as the argument +BUFFER. There is no way you can tell how much space is needed, so the +convention is to allocate a buffer 2048 characters long and assume that +is enough. (Formerly the convention was to allocate 1024 characters and +assume that was enough. But one day, for one kind of terminal, that was +not enough.) + + No matter how the space to store the description has been obtained, +termcap records its address internally for use when you later +interrogate the description with `tgetnum', `tgetstr' or `tgetflag'. If +the buffer was allocated by termcap, it will be freed by termcap too if +you call `tgetent' again. If the buffer was provided by you, you must +make sure that its contents remain unchanged for as long as you still +plan to interrogate the description. + + The return value of `tgetent' is -1 if there is some difficulty +accessing the data base of terminal types, 0 if the data base is +accessible but the specified type is not defined in it, and some other +value otherwise. + + Here is how you might use the function `tgetent': + + #ifdef unix + static char term_buffer[2048]; + #else + #define term_buffer 0 + #endif + + init_terminal_data () + { + char *termtype = getenv ("TERM"); + int success; + + if (termtype == 0) + fatal ("Specify a terminal type with `setenv TERM <yourtype>'.\n"); + + success = tgetent (term_buffer, termtype); + if (success < 0) + fatal ("Could not access the termcap data base.\n"); + if (success == 0) + fatal ("Terminal type `%s' is not defined.\n", termtype); + } + +Here we assume the function `fatal' prints an error message and exits. + + If the environment variable `TERMCAP' is defined, its value is used +to override the terminal type data base. The function `tgetent' checks +the value of `TERMCAP' automatically. If the value starts with `/' +then it is taken as a file name to use as the data base file, instead +of `/etc/termcap' which is the standard data base. If the value does +not start with `/' then it is itself used as the terminal description, +provided that the terminal type TERMTYPE is among the types it claims +to apply to. *Note Data Base::, for information on the format of a +terminal description. + + +File: termcap.info, Node: Interrogate, Next: Initialize, Prev: Find, Up: Library + +Interrogating the Terminal Description +====================================== + + Each piece of information recorded in a terminal description is +called a "capability". Each defined terminal capability has a +two-letter code name and a specific meaning. For example, the number +of columns is named `co'. *Note Capabilities::, for definitions of all +the standard capability names. + + Once you have found the proper terminal description with `tgetent' +(*note Find::.), your application program must "interrogate" it for +various terminal capabilities. You must specify the two-letter code of +the capability whose value you seek. + + Capability values can be numeric, boolean (capability is either +present or absent) or strings. Any particular capability always has +the same value type; for example, `co' always has a numeric value, +while `am' (automatic wrap at margin) is always a flag, and `cm' +(cursor motion command) always has a string value. The documentation +of each capability says which type of value it has. + + There are three functions to use to get the value of a capability, +depending on the type of value the capability has. Here are their +declarations in ANSI C: + + int tgetnum (char *NAME); + int tgetflag (char *NAME); + char *tgetstr (char *NAME, char **AREA); + +`tgetnum' + Use `tgetnum' to get a capability value that is numeric. The + argument NAME is the two-letter code name of the capability. If + the capability is present, `tgetnum' returns the numeric value + (which is nonnegative). If the capability is not mentioned in the + terminal description, `tgetnum' returns -1. + +`tgetflag' + Use `tgetflag' to get a boolean value. If the capability NAME is + present in the terminal description, `tgetflag' returns 1; + otherwise, it returns 0. + +`tgetstr' + Use `tgetstr' to get a string value. It returns a pointer to a + string which is the capability value, or a null pointer if the + capability is not present in the terminal description. + + There are two ways `tgetstr' can find space to store the string + value: + + * You can ask `tgetstr' to allocate the space. Pass a null + pointer for the argument AREA, and `tgetstr' will use + `malloc' to allocate storage big enough for the value. + Termcap will never free this storage or refer to it again; you + should free it when you are finished with it. + + This method is more robust, since there is no need to guess + how much space is needed. But it is supported only by the GNU + termcap library. + + * You can provide the space. Provide for the argument AREA the + address of a pointer variable of type `char *'. Before + calling `tgetstr', initialize the variable to point at + available space. Then `tgetstr' will store the string value + in that space and will increment the pointer variable to + point after the space that has been used. You can use the + same pointer variable for many calls to `tgetstr'. + + There is no way to determine how much space is needed for a + single string, and no way for you to prevent or handle + overflow of the area you have provided. However, you can be + sure that the total size of all the string values you will + obtain from the terminal description is no greater than the + size of the description (unless you get the same capability + twice). You can determine that size with `strlen' on the + buffer you provided to `tgetent'. See below for an example. + + Providing the space yourself is the only method supported by + the Unix version of termcap. + + Note that you do not have to specify a terminal type or terminal +description for the interrogation functions. They automatically use the +description found by the most recent call to `tgetent'. + + Here is an example of interrogating a terminal description for +various capabilities, with conditionals to select between the Unix and +GNU methods of providing buffer space. + + char *tgetstr (); + + char *cl_string, *cm_string; + int height; + int width; + int auto_wrap; + + char PC; /* For tputs. */ + char *BC; /* For tgoto. */ + char *UP; + + interrogate_terminal () + { + #ifdef UNIX + /* Here we assume that an explicit term_buffer + was provided to tgetent. */ + char *buffer + = (char *) malloc (strlen (term_buffer)); + #define BUFFADDR &buffer + #else + #define BUFFADDR 0 + #endif + + char *temp; + + /* Extract information we will use. */ + cl_string = tgetstr ("cl", BUFFADDR); + cm_string = tgetstr ("cm", BUFFADDR); + auto_wrap = tgetflag ("am"); + height = tgetnum ("li"); + width = tgetnum ("co"); + + /* Extract information that termcap functions use. */ + temp = tgetstr ("pc", BUFFADDR); + PC = temp ? *temp : 0; + BC = tgetstr ("le", BUFFADDR); + UP = tgetstr ("up", BUFFADDR); + } + +*Note Padding::, for information on the variable `PC'. *Note Using +Parameters::, for information on `UP' and `BC'. + + +File: termcap.info, Node: Initialize, Next: Padding, Prev: Interrogate, Up: Library + +Initialization for Use of Termcap +================================= + + Before starting to output commands to a terminal using termcap, an +application program should do two things: + + * Initialize various global variables which termcap library output + functions refer to. These include `PC' and `ospeed' for padding + (*note Output Padding::.) and `UP' and `BC' for cursor motion + (*note tgoto::.). + + * Tell the kernel to turn off alteration and padding of + horizontal-tab characters sent to the terminal. + + To turn off output processing in Berkeley Unix you would use `ioctl' +with code `TIOCLSET' to set the bit named `LLITOUT', and clear the bits +`ANYDELAY' using `TIOCSETN'. In POSIX or System V, you must clear the +bit named `OPOST'. Refer to the system documentation for details. + + If you do not set the terminal flags properly, some older terminals +will not work. This is because their commands may contain the +characters that normally signify newline, carriage return and +horizontal tab--characters which the kernel thinks it ought to modify +before output. + + When you change the kernel's terminal flags, you must arrange to +restore them to their normal state when your program exits. This +implies that the program must catch fatal signals such as `SIGQUIT' and +`SIGINT' and restore the old terminal flags before actually terminating. + + Modern terminals' commands do not use these special characters, so +if you do not care about problems with old terminals, you can leave the +kernel's terminal flags unaltered. + + +File: termcap.info, Node: Padding, Next: Parameters, Prev: Initialize, Up: Library + +Padding +======= + + "Padding" means outputting null characters following a terminal +display command that takes a long time to execute. The terminal +description says which commands require padding and how much; the +function `tputs', described below, outputs a terminal command while +extracting from it the padding information, and then outputs the +padding that is necessary. + +* Menu: + +* Why Pad:: Explanation of padding. +* Not Enough:: When there is not enough padding. +* Describe Padding:: The data base says how much padding a terminal needs. +* Output Padding:: Using `tputs' to output the needed padding. + + +File: termcap.info, Node: Why Pad, Next: Not Enough, Up: Padding + +Why Pad, and How +---------------- + + Most types of terminal have commands that take longer to execute +than they do to send over a high-speed line. For example, clearing the +screen may take 20msec once the entire command is received. During +that time, on a 9600 bps line, the terminal could receive about 20 +additional output characters while still busy clearing the screen. +Every terminal has a certain amount of buffering capacity to remember +output characters that cannot be processed yet, but too many slow +commands in a row can cause the buffer to fill up. Then any additional +output that cannot be processed immediately will be lost. + + To avoid this problem, we normally follow each display command with +enough useless charaters (usually null characters) to fill up the time +that the display command needs to execute. This does the job if the +terminal throws away null characters without using up space in the +buffer (which most terminals do). If enough padding is used, no output +can ever be lost. The right amount of padding avoids loss of output +without slowing down operation, since the time used to transmit padding +is time that nothing else could be done. + + The number of padding characters needed for an operation depends on +the line speed. In fact, it is proportional to the line speed. A 9600 +baud line transmits about one character per msec, so the clear screen +command in the example above would need about 20 characters of padding. +At 1200 baud, however, only about 3 characters of padding are needed +to fill up 20msec. + + +File: termcap.info, Node: Not Enough, Next: Describe Padding, Prev: Why Pad, Up: Padding + +When There Is Not Enough Padding +-------------------------------- + + There are several common manifestations of insufficient padding. + + * Emacs displays `I-search: ^Q-' at the bottom of the screen. + + This means that the terminal thought its buffer was getting full of + display commands, so it tried to tell the computer to stop sending + any. + + * The screen is garbled intermittently, or the details of garbling + vary when you repeat the action. (A garbled screen could be due + to a command which is simply incorrect, or to user option in the + terminal which doesn't match the assumptions of the terminal + description, but this usually leads to reproducible failure.) + + This means that the buffer did get full, and some commands were + lost. Many changeable factors can change which ones are lost. + + * Screen is garbled at high output speeds but not at low speeds. + Padding problems nearly always go away at low speeds, usually even + at 1200 baud. + + This means that a high enough speed permits commands to arrive + faster than they can be executed. + + Although any obscure command on an obscure terminal might lack +padding, in practice problems arise most often from the clearing +commands `cl' and `cd' (*note Clearing::.), the scrolling commands `sf' +and `sr' (*note Scrolling::.), and the line insert/delete commands `al' +and `dl' (*note Insdel Line::.). + + Occasionally the terminal description fails to define `sf' and some +programs will use `do' instead, so you may get a problem with `do'. If +so, first define `sf' just like `do', then add some padding to `sf'. + + The best strategy is to add a lot of padding at first, perhaps 200 +msec. This is much more than enough; in fact, it should cause a +visible slowdown. (If you don't see a slowdown, the change has not +taken effect; *note Changing::..) If this makes the problem go away, +you have found the right place to add padding; now reduce the amount +until the problem comes back, then increase it again. If the problem +remains, either it is in some other capability or it is not a matter of +padding at all. + + Keep in mind that on many terminals the correct padding for +insert/delete line or for scrolling is cursor-position dependent. If +you get problems from scrolling a large region of the screen but not +from scrolling a small part (just a few lines moving), it may mean that +fixed padding should be replaced with position-dependent padding. + + +File: termcap.info, Node: Describe Padding, Next: Output Padding, Prev: Not Enough, Up: Padding + +Specifying Padding in a Terminal Description +-------------------------------------------- + + In the terminal description, the amount of padding required by each +display command is recorded as a sequence of digits at the front of the +command. These digits specify the padding time in milliseconds (msec). +They can be followed optionally by a decimal point and one more digit, +which is a number of tenths of msec. + + Sometimes the padding needed by a command depends on the cursor +position. For example, the time taken by an "insert line" command is +usually proportional to the number of lines that need to be moved down +or cleared. An asterisk (`*') following the padding time says that the +time should be multiplied by the number of screen lines affected by the +command. + + :al=1.3*\E[L: + +is used to describe the "insert line" command for a certain terminal. +The padding required is 1.3 msec per line affected. The command itself +is `ESC [ L'. + + The padding time specified in this way tells `tputs' how many pad +characters to output. *Note Output Padding::. + + Two special capability values affect padding for all commands. +These are the `pc' and `pb'. The variable `pc' specifies the character +to pad with, and `pb' the speed below which no padding is needed. The +defaults for these variables, a null character and 0, are correct for +most terminals. *Note Pad Specs::. + + +File: termcap.info, Node: Output Padding, Prev: Describe Padding, Up: Padding + +Performing Padding with `tputs' +------------------------------- + + Use the termcap function `tputs' to output a string containing an +optional padding spec of the form described above (*note Describe +Padding::.). The function `tputs' strips off and decodes the padding +spec, outputs the rest of the string, and then outputs the appropriate +padding. Here is its declaration in ANSI C: + + char PC; + short ospeed; + + int tputs (char *STRING, int NLINES, int (*OUTFUN) ()); + + Here STRING is the string (including padding spec) to be output; +NLINES is the number of lines affected by the operation, which is used +to multiply the amount of padding if the padding spec ends with a `*'. +Finally, OUTFUN is a function (such as `fputchar') that is called to +output each character. When actually called, OUTFUN should expect one +argument, a character. + + The operation of `tputs' is controlled by two global variables, +`ospeed' and `PC'. The value of `ospeed' is supposed to be the +terminal output speed, encoded as in the `ioctl' system call which gets +the speed information. This is needed to compute the number of padding +characters. The value of `PC' is the character used for padding. + + You are responsible for storing suitable values into these variables +before using `tputs'. The value stored into the `PC' variable should be +taken from the `pc' capability in the terminal description (*note Pad +Specs::.). Store zero in `PC' if there is no `pc' capability. + + The argument NLINES requires some thought. Normally, it should be +the number of lines whose contents will be cleared or moved by the +command. For cursor motion commands, or commands that do editing +within one line, use the value 1. For most commands that affect +multiple lines, such as `al' (insert a line) and `cd' (clear from the +cursor to the end of the screen), NLINES should be the screen height +minus the current vertical position (origin 0). For multiple insert +and scroll commands such as `AL' (insert multiple lines), that same +value for NLINES is correct; the number of lines being inserted is not +correct. + + If a "scroll window" feature is used to reduce the number of lines +affected by a command, the value of NLINES should take this into +account. This is because the delay time required depends on how much +work the terminal has to do, and the scroll window feature reduces the +work. *Note Scrolling::. + + Commands such as `ic' and `dc' (insert or delete characters) are +problematical because the padding needed by these commands is +proportional to the number of characters affected, which is the number +of columns from the cursor to the end of the line. It would be nice to +have a way to specify such a dependence, and there is no need for +dependence on vertical position in these commands, so it is an obvious +idea to say that for these commands NLINES should really be the number +of columns affected. However, the definition of termcap clearly says +that NLINES is always the number of lines affected, even in this case, +where it is always 1. It is not easy to change this rule now, because +too many programs and terminal descriptions have been written to follow +it. + + Because NLINES is always 1 for the `ic' and `dc' strings, there is +no reason for them to use `*', but some of them do. These should be +corrected by deleting the `*'. If, some day, such entries have +disappeared, it may be possible to change to a more useful convention +for the NLINES argument for these operations without breaking any +programs. + + +File: termcap.info, Node: Parameters, Prev: Padding, Up: Library + +Filling In Parameters +===================== + + Some terminal control strings require numeric "parameters". For +example, when you move the cursor, you need to say what horizontal and +vertical positions to move it to. The value of the terminal's `cm' +capability, which says how to move the cursor, cannot simply be a +string of characters; it must say how to express the cursor position +numbers and where to put them within the command. + + The specifications of termcap include conventions as to which +string-valued capabilities require parameters, how many parameters, and +what the parameters mean; for example, it defines the `cm' string to +take two parameters, the vertical and horizontal positions, with 0,0 +being the upper left corner. These conventions are described where the +individual commands are documented. + + Termcap also defines a language used within the capability +definition for specifying how and where to encode the parameters for +output. This language uses character sequences starting with `%'. +(This is the same idea as `printf', but the details are different.) +The language for parameter encoding is described in this section. + + A program that is doing display output calls the functions `tparam' +or `tgoto' to encode parameters according to the specifications. These +functions produce a string containing the actual commands to be output +(as well a padding spec which must be processed with `tputs'; *note +Padding::.). + +* Menu: + +* Encode Parameters:: The language for encoding parameters. +* Using Parameters:: Outputting a string command with parameters. + + +File: termcap.info, Node: Encode Parameters, Next: Using Parameters, Up: Parameters + +Describing the Encoding +----------------------- + + A terminal command string that requires parameters contains special +character sequences starting with `%' to say how to encode the +parameters. These sequences control the actions of `tparam' and +`tgoto'. + + The parameters values passed to `tparam' or `tgoto' are considered +to form a vector. A pointer into this vector determines the next +parameter to be processed. Some of the `%'-sequences encode one +parameter and advance the pointer to the next parameter. Other +`%'-sequences alter the pointer or alter the parameter values without +generating output. + + For example, the `cm' string for a standard ANSI terminal is written +as `\E[%i%d;%dH'. (`\E' stands for ESC.) `cm' by convention always +requires two parameters, the vertical and horizontal goal positions, so +this string specifies the encoding of two parameters. Here `%i' +increments the two values supplied, and each `%d' encodes one of the +values in decimal. If the cursor position values 20,58 are encoded +with this string, the result is `\E[21;59H'. + + First, here are the `%'-sequences that generate output. Except for +`%%', each of them encodes one parameter and advances the pointer to +the following parameter. + +`%%' + Output a single `%'. This is the only way to represent a literal + `%' in a terminal command with parameters. `%%' does not use up a + parameter. + +`%d' + As in `printf', output the next parameter in decimal. + +`%2' + Like `%02d' in `printf': output the next parameter in decimal, and + always use at least two digits. + +`%3' + Like `%03d' in `printf': output the next parameter in decimal, and + always use at least three digits. Note that `%4' and so on are + *not* defined. + +`%.' + Output the next parameter as a single character whose ASCII code is + the parameter value. Like `%c' in `printf'. + +`%+CHAR' + Add the next parameter to the character CHAR, and output the + resulting character. For example, `%+ ' represents 0 as a space, + 1 as `!', etc. + + The following `%'-sequences specify alteration of the parameters +(their values, or their order) rather than encoding a parameter for +output. They generate no output; they are used only for their side +effects on the parameters. Also, they do not advance the "next +parameter" pointer except as explicitly stated. Only `%i', `%r' and +`%>' are defined in standard Unix termcap. The others are GNU +extensions. + +`%i' + Increment the next two parameters. This is used for terminals that + expect cursor positions in origin 1. For example, `%i%d,%d' would + output two parameters with `1' for 0, `2' for 1, etc. + +`%r' + Interchange the next two parameters. This is used for terminals + whose cursor positioning command expects the horizontal position + first. + +`%s' + Skip the next parameter. Do not output anything. + +`%b' + Back up one parameter. The last parameter used will become once + again the next parameter to be output, and the next output command + will use it. Using `%b' more than once, you can back up any + number of parameters, and you can refer to each parameter any + number of times. + +`%>C1C2' + Conditionally increment the next parameter. Here C1 and C2 are + characters which stand for their ASCII codes as numbers. If the + next parameter is greater than the ASCII code of C1, the ASCII + code of C2 is added to it. + +`%a OP TYPE POS' + Perform arithmetic on the next parameter, do not use it up, and do + not output anything. Here OP specifies the arithmetic operation, + while TYPE and POS together specify the other operand. + + Spaces are used above to separate the operands for clarity; the + spaces don't appear in the data base, where this sequence is + exactly five characters long. + + The character OP says what kind of arithmetic operation to + perform. It can be any of these characters: + + `=' + assign a value to the next parameter, ignoring its old value. + The new value comes from the other operand. + + `+' + add the other operand to the next parameter. + + `-' + subtract the other operand from the next parameter. + + `*' + multiply the next parameter by the other operand. + + `/' + divide the next parameter by the other operand. + + The "other operand" may be another parameter's value or a constant; + the character TYPE says which. It can be: + + `p' + Use another parameter. The character POS says which + parameter to use. Subtract 64 from its ASCII code to get the + position of the desired parameter relative to this one. Thus, + the character `A' as POS means the parameter after the next + one; the character `?' means the parameter before the next + one. + + `c' + Use a constant value. The character POS specifies the value + of the constant. The 0200 bit is cleared out, so that 0200 + can be used to represent zero. + + The following `%'-sequences are special purpose hacks to compensate +for the weird designs of obscure terminals. They modify the next +parameter or the next two parameters but do not generate output and do +not use up any parameters. `%m' is a GNU extension; the others are +defined in standard Unix termcap. + +`%n' + Exclusive-or the next parameter with 0140, and likewise the + parameter after next. + +`%m' + Complement all the bits of the next parameter and the parameter + after next. + +`%B' + Encode the next parameter in BCD. It alters the value of the + parameter by adding six times the quotient of the parameter by ten. + Here is a C statement that shows how the new value is computed: + + PARM = (PARM / 10) * 16 + PARM % 10; + +`%D' + Transform the next parameter as needed by Delta Data terminals. + This involves subtracting twice the remainder of the parameter by + 16. + + PARM -= 2 * (PARM % 16); + + +File: termcap.info, Node: Using Parameters, Prev: Encode Parameters, Up: Parameters + +Sending Display Commands with Parameters +---------------------------------------- + + The termcap library functions `tparam' and `tgoto' serve as the +analog of `printf' for terminal string parameters. The newer function +`tparam' is a GNU extension, more general but missing from Unix +termcap. The original parameter-encoding function is `tgoto', which is +preferable for cursor motion. + +* Menu: + +* tparam:: The general case, for GNU termcap only. +* tgoto:: The special case of cursor motion. + + +File: termcap.info, Node: tparam, Next: tgoto, Up: Using Parameters + +`tparam' +........ + + The function `tparam' can encode display commands with any number of +parameters and allows you to specify the buffer space. It is the +preferred function for encoding parameters for all but the `cm' +capability. Its ANSI C declaration is as follows: + + char *tparam (char *CTLSTRING, char *BUFFER, int SIZE, int PARM1,...) + + The arguments are a control string CTLSTRING (the value of a terminal +capability, presumably), an output buffer BUFFER and SIZE, and any +number of integer parameters to be encoded. The effect of `tparam' is +to copy the control string into the buffer, encoding parameters +according to the `%' sequences in the control string. + + You describe the output buffer by its address, BUFFER, and its size +in bytes, SIZE. If the buffer is not big enough for the data to be +stored in it, `tparam' calls `malloc' to get a larger buffer. In +either case, `tparam' returns the address of the buffer it ultimately +uses. If the value equals BUFFER, your original buffer was used. +Otherwise, a new buffer was allocated, and you must free it after you +are done with printing the results. If you pass zero for SIZE and +BUFFER, `tparam' always allocates the space with `malloc'. + + All capabilities that require parameters also have the ability to +specify padding, so you should use `tputs' to output the string +produced by `tparam'. *Note Padding::. Here is an example. + + { + char *buf; + char buffer[40]; + + buf = tparam (command, buffer, 40, parm); + tputs (buf, 1, fputchar); + if (buf != buffer) + free (buf); + } + + If a parameter whose value is zero is encoded with `%.'-style +encoding, the result is a null character, which will confuse `tputs'. +This would be a serious problem, but luckily `%.' encoding is used only +by a few old models of terminal, and only for the `cm' capability. To +solve the problem, use `tgoto' rather than `tparam' to encode the `cm' +capability. + + +File: termcap.info, Node: tgoto, Prev: tparam, Up: Using Parameters + +`tgoto' +....... + + The special case of cursor motion is handled by `tgoto'. There are +two reasons why you might choose to use `tgoto': + + * For Unix compatibility, because Unix termcap does not have + `tparam'. + + * For the `cm' capability, since `tgoto' has a special feature to + avoid problems with null characters, tabs and newlines on certain + old terminal types that use `%.' encoding for that capability. + + Here is how `tgoto' might be declared in ANSI C: + + char *tgoto (char *CSTRING, int HPOS, int VPOS) + + There are three arguments, the terminal description's `cm' string and +the two cursor position numbers; `tgoto' computes the parametrized +string in an internal static buffer and returns the address of that +buffer. The next time you use `tgoto' the same buffer will be reused. + + Parameters encoded with `%.' encoding can generate null characters, +tabs or newlines. These might cause trouble: the null character because +`tputs' would think that was the end of the string, the tab because the +kernel or other software might expand it into spaces, and the newline +becaue the kernel might add a carriage-return, or padding characters +normally used for a newline. To prevent such problems, `tgoto' is +careful to avoid these characters. Here is how this works: if the +target cursor position value is such as to cause a problem (that is to +say, zero, nine or ten), `tgoto' increments it by one, then compensates +by appending a string to move the cursor back or up one position. + + The compensation strings to use for moving back or up are found in +global variables named `BC' and `UP'. These are actual external C +variables with upper case names; they are declared `char *'. It is up +to you to store suitable values in them, normally obtained from the +`le' and `up' terminal capabilities in the terminal description with +`tgetstr'. Alternatively, if these two variables are both zero, the +feature of avoiding nulls, tabs and newlines is turned off. + + It is safe to use `tgoto' for commands other than `cm' only if you +have stored zero in `BC' and `UP'. + + Note that `tgoto' reverses the order of its operands: the horizontal +position comes before the vertical position in the arguments to +`tgoto', even though the vertical position comes before the horizontal +in the parameters of the `cm' string. If you use `tgoto' with a +command such as `AL' that takes one parameter, you must pass the +parameter to `tgoto' as the "vertical position". + + +File: termcap.info, Node: Data Base, Next: Capabilities, Prev: Library, Up: Top + +The Format of the Data Base +*************************** + + The termcap data base of terminal descriptions is stored in the file +`/etc/termcap'. It contains terminal descriptions, blank lines, and +comments. + + A terminal description starts with one or more names for the +terminal type. The information in the description is a series of +"capability names" and values. The capability names have standard +meanings (*note Capabilities::.) and their values describe the terminal. + +* Menu: + +* Format:: Overall format of a terminal description. +* Capability Format:: Format of capabilities within a description. +* Naming:: Naming conventions for terminal types. +* Inheriting:: Inheriting part of a description from +a related terminal type. +* Changing:: When changes in the data base take effect. + + +File: termcap.info, Node: Format, Next: Capability Format, Up: Data Base + +Terminal Description Format +=========================== + + Aside from comments (lines starting with `#', which are ignored), +each nonblank line in the termcap data base is a terminal description. +A terminal description is nominally a single line, but it can be split +into multiple lines by inserting the two characters `\ newline'. This +sequence is ignored wherever it appears in a description. + + The preferred way to split the description is between capabilities: +insert the four characters `: \ newline tab' immediately before any +colon. This allows each sub-line to start with some indentation. This +works because, after the `\ newline' are ignored, the result is `: tab +:'; the first colon ends the preceding capability and the second colon +starts the next capability. If you split with `\ newline' alone, you +may not add any indentation after them. + + Here is a real example of a terminal description: + + dw|vt52|DEC vt52:\ + :cr=^M:do=^J:nl=^J:bl=^G:\ + :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ + :cm=\EY%+ %+ :co#80:li#24:\ + :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ + :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: + + Each terminal description begins with several names for the terminal +type. The names are separated by `|' characters, and a colon ends the +last name. The first name should be two characters long; it exists +only for the sake of very old Unix systems and is never used in modern +systems. The last name should be a fully verbose name such as "DEC +vt52" or "Ann Arbor Ambassador with 48 lines". The other names should +include whatever the user ought to be able to specify to get this +terminal type, such as `vt52' or `aaa-48'. *Note Naming::, for +information on how to choose terminal type names. + + After the terminal type names come the terminal capabilities, +separated by colons and with a colon after the last one. Each +capability has a two-letter name, such as `cm' for "cursor motion +string" or `li' for "number of display lines". + + +File: termcap.info, Node: Capability Format, Next: Naming, Prev: Format, Up: Data Base + +Writing the Capabilities +======================== + + There are three kinds of capabilities: flags, numbers, and strings. +Each kind has its own way of being written in the description. Each +defined capability has by convention a particular kind of value; for +example, `li' always has a numeric value and `cm' always a string value. + + A flag capability is thought of as having a boolean value: the value +is true if the capability is present, false if not. When the +capability is present, just write its name between two colons. + + A numeric capability has a value which is a nonnegative number. +Write the capability name, a `#', and the number, between two colons. +For example, `...:li#48:...' is how you specify the `li' capability for +48 lines. + + A string-valued capability has a value which is a sequence of +characters. Usually these are the characters used to perform some +display operation. Write the capability name, a `=', and the +characters of the value, between two colons. For example, +`...:cm=\E[%i%d;%dH:...' is how the cursor motion command for a +standard ANSI terminal would be specified. + + Special characters in the string value can be expressed using +`\'-escape sequences as in C; in addition, `\E' stands for ESC. `^' is +also a kind of escape character; `^' followed by CHAR stands for the +control-equivalent of CHAR. Thus, `^a' stands for the character +control-a, just like `\001'. `\' and `^' themselves can be represented +as `\\' and `\^'. + + To include a colon in the string, you must write `\072'. You might +ask, "Why can't `\:' be used to represent a colon?" The reason is that +the interrogation functions do not count slashes while looking for a +capability. Even if `:ce=ab\:cd:' were interpreted as giving the `ce' +capability the value `ab:cd', it would also appear to define `cd' as a +flag. + + The string value will often contain digits at the front to specify +padding (*note Padding::.) and/or `%'-sequences within to specify how +to encode parameters (*note Parameters::.). Although these things are +not to be output literally to the terminal, they are considered part of +the value of the capability. They are special only when the string +value is processed by `tputs', `tparam' or `tgoto'. By contrast, `\' +and `^' are considered part of the syntax for specifying the characters +in the string. + + Let's look at the VT52 example again: + + dw|vt52|DEC vt52:\ + :cr=^M:do=^J:nl=^J:bl=^G:\ + :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ + :cm=\EY%+ %+ :co#80:li#24:\ + :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ + :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: + + Here we see the numeric-valued capabilities `co' and `li', the flags +`bs' and `pt', and many string-valued capabilities. Most of the +strings start with ESC represented as `\E'. The rest contain control +characters represented using `^'. The meanings of the individual +capabilities are defined elsewhere (*note Capabilities::.). + diff --git a/lib/termcap/grot/termcap.info-2 b/lib/termcap/grot/termcap.info-2 new file mode 100644 index 0000000..6098d62 --- /dev/null +++ b/lib/termcap/grot/termcap.info-2 @@ -0,0 +1,974 @@ +This is Info file ./termcap.info, produced by Makeinfo-1.55 from the +input file ./termcap.texi. + + This file documents the termcap library of the GNU system. + + Copyright (C) 1988 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: termcap.info, Node: Naming, Next: Inheriting, Prev: Capability Format, Up: Data Base + +Terminal Type Name Conventions +============================== + + There are conventions for choosing names of terminal types. For one +thing, all letters should be in lower case. The terminal type for a +terminal in its most usual or most fundamental mode of operation should +not have a hyphen in it. + + If the same terminal has other modes of operation which require +different terminal descriptions, these variant descriptions are given +names made by adding suffixes with hyphens. Such alternate descriptions +are used for two reasons: + + * When the terminal has a switch that changes its behavior. Since + the computer cannot tell how the switch is set, the user must tell + the computer by choosing the appropriate terminal type name. + + For example, the VT-100 has a setup flag that controls whether the + cursor wraps at the right margin. If this flag is set to "wrap", + you must use the terminal type `vt100-am'. Otherwise you must use + `vt100-nam'. Plain `vt100' is defined as a synonym for either + `vt100-am' or `vt100-nam' depending on the preferences of the + local site. + + The standard suffix `-am' stands for "automatic margins". + + * To give the user a choice in how to use the terminal. This is done + when the terminal has a switch that the computer normally controls. + + For example, the Ann Arbor Ambassador can be configured with many + screen sizes ranging from 20 to 60 lines. Fewer lines make bigger + characters but more lines let you see more of what you are editing. + As a result, users have different preferences. Therefore, termcap + provides terminal types for many screen sizes. If you choose type + `aaa-30', the terminal will be configured to use 30 lines; if you + choose `aaa-48', 48 lines will be used, and so on. + + Here is a list of standard suffixes and their conventional meanings: + +`-w' + Short for "wide". This is a mode that gives the terminal more + columns than usual. This is normally a user option. + +`-am' + "Automatic margins". This is an alternate description for use when + the terminal's margin-wrap switch is on; it contains the `am' + flag. The implication is that normally the switch is off and the + usual description for the terminal says that the switch is off. + +`-nam' + "No automatic margins". The opposite of `-am', this names an + alternative description which lacks the `am' flag. This implies + that the terminal is normally operated with the margin-wrap switch + turned on, and the normal description of the terminal says so. + +`-na' + "No arrows". This terminal description initializes the terminal to + keep its arrow keys in local mode. This is a user option. + +`-rv' + "Reverse video". This terminal description causes text output for + normal video to appear as reverse, and text output for reverse + video to come out as normal. Often this description differs from + the usual one by interchanging the two strings which turn reverse + video on and off. + + This is a user option; you can choose either the "reverse video" + variant terminal type or the normal terminal type, and termcap will + obey. + +`-s' + "Status". Says to enable use of a status line which ordinary + output does not touch (*note Status Line::.). + + Some terminals have a special line that is used only as a status + line. For these terminals, there is no need for an `-s' variant; + the status line commands should be defined by default. On other + terminals, enabling a status line means removing one screen line + from ordinary use and reducing the effective screen height. For + these terminals, the user can choose the `-s' variant type to + request use of a status line. + +`-NLINES' + Says to operate with NLINES lines on the screen, for terminals + such as the Ambassador which provide this as an option. Normally + this is a user option; by choosing the terminal type, you control + how many lines termcap will use. + +`-NPAGESp' + Says that the terminal has NPAGES pages worth of screen memory, + for terminals where this is a hardware option. + +`-unk' + Says that description is not for direct use, but only for + reference in `tc' capabilities. Such a description is a kind of + subroutine, because it describes the common characteristics of + several variant descriptions that would use other suffixes in + place of `-unk'. + + +File: termcap.info, Node: Inheriting, Next: Changing, Prev: Naming, Up: Data Base + +Inheriting from Related Descriptions +==================================== + + When two terminal descriptions are similar, their identical parts do +not need to be given twice. Instead, one of the two can be defined in +terms of the other, using the `tc' capability. We say that one +description "refers to" the other, or "inherits from" the other. + + The `tc' capability must be the last one in the terminal description, +and its value is a string which is the name of another terminal type +which is referred to. For example, + + N9|aaa|ambassador|aaa-30|ann arbor ambassador/30 lines:\ + :ti=\E[2J\E[30;0;0;30p:\ + :te=\E[60;0;0;30p\E[30;1H\E[J:\ + :li#30:tc=aaa-unk: + +defines the terminal type `aaa-30' (also known as plain `aaa') in terms +of `aaa-unk', which defines everything about the Ambassador that is +independent of screen height. The types `aaa-36', `aaa-48' and so on +for other screen heights are likewise defined to inherit from `aaa-unk'. + + The capabilities overridden by `aaa-30' include `li', which says how +many lines there are, and `ti' and `te', which configure the terminal +to use that many lines. + + The effective terminal description for type `aaa' consists of the +text shown above followed by the text of the description of `aaa-unk'. +The `tc' capability is handled automatically by `tgetent', which finds +the description thus referenced and combines the two descriptions +(*note Find::.). Therefore, only the implementor of the terminal +descriptions needs to think about using `tc'. Users and application +programmers do not need to be concerned with it. + + Since the reference terminal description is used last, capabilities +specified in the referring description override any specifications of +the same capabilities in the reference description. + + The referring description can cancel out a capability without +specifying any new value for it by means of a special trick. Write the +capability in the referring description, with the character `@' after +the capability name, as follows: + + NZ|aaa-30-nam|ann arbor ambassador/30 lines/no automatic-margins:\ + :am@:tc=aaa-30: + + +File: termcap.info, Node: Changing, Prev: Inheriting, Up: Data Base + +When Changes in the Data Base Take Effect +========================================= + + Each application program must read the terminal description from the +data base, so a change in the data base is effective for all jobs +started after the change is made. + + The change will usually have no effect on a job that have been in +existence since before the change. The program probably read the +terminal description once, when it was started, and is continuing to +use what it read then. If the program does not have a feature for +reexamining the data base, then you will need to run it again (probably +killing the old job). + + If the description in use is coming from the `TERMCAP' environment +variable, then the data base file is effectively overridden, and +changes in it will have no effect until you change the `TERMCAP' +variable as well. For example, some users' `.login' files +automatically copy the terminal description into `TERMCAP' to speed +startup of applications. If you have done this, you will need to +change the `TERMCAP' variable to make the changed data base take effect. + + +File: termcap.info, Node: Capabilities, Next: Summary, Prev: Data Base, Up: Top + +Definitions of the Terminal Capabilities +**************************************** + + This section is divided into many subsections, each for one aspect of +use of display terminals. For writing a display program, you usually +need only check the subsections for the operations you want to use. +For writing a terminal description, you must read each subsection and +fill in the capabilities described there. + + String capabilities that are display commands may require numeric +parameters (*note Parameters::.). Most such capabilities do not use +parameters. When a capability requires parameters, this is explicitly +stated at the beginning of its definition. In simple cases, the first +or second sentence of the definition mentions all the parameters, in +the order they should be given, using a name in upper case for each +one. For example, the `rp' capability is a command that requires two +parameters; its definition begins as follows: + + String of commands to output a graphic character C, repeated N + times. + + In complex cases or when there are many parameters, they are +described explicitly. + + When a capability is described as obsolete, this means that programs +should not be written to look for it, but terminal descriptions should +still be written to provide it. + + When a capability is described as very obsolete, this means that it +should be omitted from terminal descriptions as well. + +* Menu: + +* Basic:: Basic characteristics. +* Screen Size:: Screen size, and what happens when it changes. +* Cursor Motion:: Various ways to move the cursor. +* Wrapping:: What happens if you write a character in the last column. +* Scrolling:: Pushing text up and down on the screen. +* Windows:: Limiting the part of the window that output affects. +* Clearing:: Erasing one or many lines. +* Insdel Line:: Making new blank lines in mid-screen; deleting lines. +* Insdel Char:: Inserting and deleting characters within a line. +* Standout:: Highlighting some of the text. +* Underlining:: Underlining some of the text. +* Cursor Visibility:: Making the cursor more or less easy to spot. +* Bell:: Attracts user's attention; not localized on the screen. +* Keypad:: Recognizing when function keys or arrows are typed. +* Meta Key:: META acts like an extra shift key. +* Initialization:: Commands used to initialize or reset the terminal. +* Pad Specs:: Info for the kernel on how much padding is needed. +* Status Line:: A status line displays "background" information. +* Half-Line:: Moving by half-lines, for superscripts and subscripts. +* Printer:: Controlling auxiliary printers of display terminals. + + +File: termcap.info, Node: Basic, Next: Screen Size, Up: Capabilities + +Basic Characteristics +===================== + + This section documents the capabilities that describe the basic and +nature of the terminal, and also those that are relevant to the output +of graphic characters. + +`os' + Flag whose presence means that the terminal can overstrike. This + means that outputting a graphic character does not erase whatever + was present in the same character position before. The terminals + that can overstrike include printing terminals, storage tubes (all + obsolete nowadays), and many bit-map displays. + +`eo' + Flag whose presence means that outputting a space erases a + character position even if the terminal supports overstriking. If + this flag is not present and overstriking is supported, output of + a space has no effect except to move the cursor. + + (On terminals that do not support overstriking, you can always + assume that outputting a space at a position erases whatever + character was previously displayed there.) + +`gn' + Flag whose presence means that this terminal type is a generic type + which does not really describe any particular terminal. Generic + types are intended for use as the default type assigned when the + user connects to the system, with the intention that the user + should specify what type he really has. One example of a generic + type is the type `network'. + + Since the generic type cannot say how to do anything interesting + with the terminal, termcap-using programs will always find that the + terminal is too weak to be supported if the user has failed to + specify a real terminal type in place of the generic one. The + `gn' flag directs these programs to use a different error message: + "You have not specified your real terminal type", rather than + "Your terminal is not powerful enough to be used". + +`hc' + Flag whose presence means this is a hardcopy terminal. + +`rp' + String of commands to output a graphic character C, repeated N + times. The first parameter value is the ASCII code for the desired + character, and the second parameter is the number of times to + repeat the character. Often this command requires padding + proportional to the number of times the character is repeated. + This effect can be had by using parameter arithmetic with + `%'-sequences to compute the amount of padding, then generating + the result as a number at the front of the string so that `tputs' + will treat it as padding. + +`hz' + Flag whose presence means that the ASCII character `~' cannot be + output on this terminal because it is used for display commands. + + Programs handle this flag by checking all text to be output and + replacing each `~' with some other character(s). If this is not + done, the screen will be thoroughly garbled. + + The old Hazeltine terminals that required such treatment are + probably very rare today, so you might as well not bother to + support this flag. + +`CC' + String whose presence means the terminal has a settable command + character. The value of the string is the default command + character (which is usually ESC). + + All the strings of commands in the terminal description should be + written to use the default command character. If you are writing + an application program that changes the command character, use the + `CC' capability to figure out how to translate all the display + commands to work with the new command character. + + Most programs have no reason to look at the `CC' capability. + +`xb' + Flag whose presence identifies Superbee terminals which are unable + to transmit the characters ESC and `Control-C'. Programs which + support this flag are supposed to check the input for the code + sequences sent by the F1 and F2 keys, and pretend that ESC or + `Control-C' (respectively) had been read. But this flag is + obsolete, and not worth supporting. + + +File: termcap.info, Node: Screen Size, Next: Cursor Motion, Prev: Basic, Up: Capabilities + +Screen Size +=========== + + A terminal description has two capabilities, `co' and `li', that +describe the screen size in columns and lines. But there is more to +the question of screen size than this. + + On some operating systems the "screen" is really a window and the +effective width can vary. On some of these systems, `tgetnum' uses the +actual width of the window to decide what value to return for the `co' +capability, overriding what is actually written in the terminal +description. On other systems, it is up to the application program to +check the actual window width using a system call. For example, on BSD +4.3 systems, the system call `ioctl' with code `TIOCGWINSZ' will tell +you the current screen size. + + On all window systems, termcap is powerless to advise the application +program if the user resizes the window. Application programs must deal +with this possibility in a system-dependent fashion. On some systems +the C shell handles part of the problem by detecting changes in window +size and setting the `TERMCAP' environment variable appropriately. +This takes care of application programs that are started subsequently. +It does not help application programs already running. + + On some systems, including BSD 4.3, all programs using a terminal get +a signal named `SIGWINCH' whenever the screen size changes. Programs +that use termcap should handle this signal by using `ioctl TIOCGWINSZ' +to learn the new screen size. + +`co' + Numeric value, the width of the screen in character positions. + Even hardcopy terminals normally have a `co' capability. + +`li' + Numeric value, the height of the screen in lines. + + +File: termcap.info, Node: Cursor Motion, Next: Wrapping, Prev: Screen Size, Up: Capabilities + +Cursor Motion +============= + + Termcap assumes that the terminal has a "cursor", a spot on the +screen where a visible mark is displayed, and that most display +commands take effect at the position of the cursor. It follows that +moving the cursor to a specified location is very important. + + There are many terminal capabilities for different cursor motion +operations. A terminal description should define as many as possible, +but most programs do not need to use most of them. One capability, +`cm', moves the cursor to an arbitrary place on the screen; this by +itself is sufficient for any application as long as there is no need to +support hardcopy terminals or certain old, weak displays that have only +relative motion commands. Use of other cursor motion capabilities is an +optimization, enabling the program to output fewer characters in some +common cases. + + If you plan to use the relative cursor motion commands in an +application program, you must know what the starting cursor position +is. To do this, you must keep track of the cursor position and update +the records each time anything is output to the terminal, including +graphic characters. In addition, it is necessary to know whether the +terminal wraps after writing in the rightmost column. *Note Wrapping::. + + One other motion capability needs special mention: `nw' moves the +cursor to the beginning of the following line, perhaps clearing all the +starting line after the cursor, or perhaps not clearing at all. This +capability is a least common denominator that is probably supported +even by terminals that cannot do most other things such as `cm' or `do'. +Even hardcopy terminals can support `nw'. + +`cm' + String of commands to position the cursor at line L, column C. + Both parameters are origin-zero, and are defined relative to the + screen, not relative to display memory. + + All display terminals except a few very obsolete ones support `cm', + so it is acceptable for an application program to refuse to + operate on terminals lacking `cm'. + +`ho' + String of commands to move the cursor to the upper left corner of + the screen (this position is called the "home position"). In + terminals where the upper left corner of the screen is not the + same as the beginning of display memory, this command must go to + the upper left corner of the screen, not the beginning of display + memory. + + Every display terminal supports this capability, and many + application programs refuse to operate if the `ho' capability is + missing. + +`ll' + String of commands to move the cursor to the lower left corner of + the screen. On some terminals, moving up from home position does + this, but programs should never assume that will work. Just + output the `ll' string (if it is provided); if moving to home + position and then moving up is the best way to get there, the `ll' + command will do that. + +`cr' + String of commands to move the cursor to the beginning of the line + it is on. If this capability is not specified, many programs + assume they can use the ASCII carriage return character for this. + +`le' + String of commands to move the cursor left one column. Unless the + `bw' flag capability is specified, the effect is undefined if the + cursor is at the left margin; do not use this command there. If + `bw' is present, this command may be used at the left margin, and + it wraps the cursor to the last column of the preceding line. + +`nd' + String of commands to move the cursor right one column. The + effect is undefined if the cursor is at the right margin; do not + use this command there, not even if `am' is present. + +`up' + String of commands to move the cursor vertically up one line. The + effect of sending this string when on the top line is undefined; + programs should never use it that way. + +`do' + String of commands to move the cursor vertically down one line. + The effect of sending this string when on the bottom line is + undefined; programs should never use it that way. + + Some programs do use `do' to scroll up one line if used at the + bottom line, if `sf' is not defined but `sr' is. This is only to + compensate for certain old, incorrect terminal descriptions. (In + principle this might actually lead to incorrect behavior on other + terminals, but that seems to happen rarely if ever.) But the + proper solution is that the terminal description should define + `sf' as well as `do' if the command is suitable for scrolling. + + The original idea was that this string would not contain a newline + character and therefore could be used without disabling the + kernel's usual habit of converting of newline into a + carriage-return newline sequence. But many terminal descriptions + do use newline in the `do' string, so this is not possible; a + program which sends the `do' string must disable output conversion + in the kernel (*note Initialize::.). + +`bw' + Flag whose presence says that `le' may be used in column zero to + move to the last column of the preceding line. If this flag is + not present, `le' should not be used in column zero. + +`nw' + String of commands to move the cursor to start of next line, + possibly clearing rest of line (following the cursor) before + moving. + +`DO', `UP', `LE', `RI' + Strings of commands to move the cursor N lines down vertically, up + vertically, or N columns left or right. Do not attempt to move + past any edge of the screen with these commands; the effect of + trying that is undefined. Only a few terminal descriptions provide + these commands, and most programs do not use them. + +`CM' + String of commands to position the cursor at line L, column C, + relative to display memory. Both parameters are origin-zero. + This capability is present only in terminals where there is a + difference between screen-relative and memory-relative addressing, + and not even in all such terminals. + +`ch' + String of commands to position the cursor at column C in the same + line it is on. This is a special case of `cm' in which the + vertical position is not changed. The `ch' capability is provided + only when it is faster to output than `cm' would be in this + special case. Programs should not assume most display terminals + have `ch'. + +`cv' + String of commands to position the cursor at line L in the same + column. This is a special case of `cm' in which the horizontal + position is not changed. The `cv' capability is provided only + when it is faster to output than `cm' would be in this special + case. Programs should not assume most display terminals have `cv'. + +`sc' + String of commands to make the terminal save the current cursor + position. Only the last saved position can be used. If this + capability is present, `rc' should be provided also. Most + terminals have neither. + +`rc' + String of commands to make the terminal restore the last saved + cursor position. If this capability is present, `sc' should be + provided also. Most terminals have neither. + +`ff' + String of commands to advance to the next page, for a hardcopy + terminal. + +`ta' + String of commands to move the cursor right to the next hardware + tab stop column. Missing if the terminal does not have any kind of + hardware tabs. Do not send this command if the kernel's terminal + modes say that the kernel is expanding tabs into spaces. + +`bt' + String of commands to move the cursor left to the previous hardware + tab stop column. Missing if the terminal has no such ability; many + terminals do not. Do not send this command if the kernel's + terminal modes say that the kernel is expanding tabs into spaces. + + The following obsolete capabilities should be included in terminal +descriptions when appropriate, but should not be looked at by new +programs. + +`nc' + Flag whose presence means the terminal does not support the ASCII + carriage return character as `cr'. This flag is needed because + old programs assume, when the `cr' capability is missing, that + ASCII carriage return can be used for the purpose. We use `nc' to + tell the old programs that carriage return may not be used. + + New programs should not assume any default for `cr', so they need + not look at `nc'. However, descriptions should contain `nc' + whenever they do not contain `cr'. + +`xt' + Flag whose presence means that the ASCII tab character may not be + used for cursor motion. This flag exists because old programs + assume, when the `ta' capability is missing, that ASCII tab can be + used for the purpose. We use `xt' to tell the old programs not to + use tab. + + New programs should not assume any default for `ta', so they need + not look at `xt' in connection with cursor motion. Note that `xt' + also has implications for standout mode (*note Standout::.). It + is obsolete in regard to cursor motion but not in regard to + standout. + + In fact, `xt' means that the terminal is a Teleray 1061. + +`bc' + Very obsolete alternative name for the `le' capability. + +`bs' + Flag whose presence means that the ASCII character backspace may be + used to move the cursor left. Obsolete; look at `le' instead. + +`nl' + Obsolete capability which is a string that can either be used to + move the cursor down or to scroll. The same string must scroll + when used on the bottom line and move the cursor when used on any + other line. New programs should use `do' or `sf', and ignore `nl'. + + If there is no `nl' capability, some old programs assume they can + use the newline character for this purpose. These programs follow + a bad practice, but because they exist, it is still desirable to + define the `nl' capability in a terminal description if the best + way to move down is *not* a newline. + + +File: termcap.info, Node: Wrapping, Next: Scrolling, Prev: Cursor Motion, Up: Capabilities + +Wrapping +======== + + "Wrapping" means moving the cursor from the right margin to the left +margin of the following line. Some terminals wrap automatically when a +graphic character is output in the last column, while others do not. +Most application programs that use termcap need to know whether the +terminal wraps. There are two special flag capabilities to describe +what the terminal does when a graphic character is output in the last +column. + +`am' + Flag whose presence means that writing a character in the last + column causes the cursor to wrap to the beginning of the next line. + + If `am' is not present, writing in the last column leaves the + cursor at the place where the character was written. + + Writing in the last column of the last line should be avoided on + terminals with `am', as it may or may not cause scrolling to occur + (*note Scrolling::.). Scrolling is surely not what you would + intend. + + If your program needs to check the `am' flag, then it also needs + to check the `xn' flag which indicates that wrapping happens in a + strange way. Many common terminals have the `xn' flag. + +`xn' + Flag whose presence means that the cursor wraps in a strange way. + At least two distinct kinds of strange behavior are known; the + termcap data base does not contain anything to distinguish the two. + + On Concept-100 terminals, output in the last column wraps the + cursor almost like an ordinary `am' terminal. But if the next + thing output is a newline, it is ignored. + + DEC VT-100 terminals (when the wrap switch is on) do a different + strange thing: the cursor wraps only if the next thing output is + another graphic character. In fact, the wrap occurs when the + following graphic character is received by the terminal, before the + character is placed on the screen. + + On both of these terminals, after writing in the last column a + following graphic character will be displayed in the first column + of the following line. But the effect of relative cursor motion + characters such as newline or backspace at such a time depends on + the terminal. The effect of erase or scrolling commands also + depends on the terminal. You can't assume anything about what + they will do on a terminal that has `xn'. So, to be safe, you + should never do these things at such a time on such a terminal. + + To be sure of reliable results on a terminal which has the `xn' + flag, output a `cm' absolute positioning command after writing in + the last column. Another safe thing to do is to output + carriage-return newline, which will leave the cursor at the + beginning of the following line. + +`LP' + Flag whose presence means that it is safe to write in the last + column of the last line without worrying about undesired + scrolling. `LP' indicates the DEC flavor of `xn' strangeness. + + +File: termcap.info, Node: Scrolling, Next: Windows, Prev: Wrapping, Up: Capabilities + +Scrolling +========= + + "Scrolling" means moving the contents of the screen up or down one or +more lines. Moving the contents up is "forward scrolling"; moving them +down is "reverse scrolling". + + Scrolling happens after each line of output during ordinary output +on most display terminals. But in an application program that uses +termcap for random-access output, scrolling happens only when +explicitly requested with the commands in this section. + + Some terminals have a "scroll region" feature. This lets you limit +the effect of scrolling to a specified range of lines. Lines outside +the range are unaffected when scrolling happens. The scroll region +feature is available if either `cs' or `cS' is present. + +`sf' + String of commands to scroll the screen one line up, assuming it is + output with the cursor at the beginning of the bottom line. + +`sr' + String of commands to scroll the screen one line down, assuming it + is output with the cursor at the beginning of the top line. + +`do' + A few programs will try to use `do' to do the work of `sf'. This + is not really correct--it is an attempt to compensate for the + absence of a `sf' command in some old terminal descriptions. + + Since these terminal descriptions do define `sr', perhaps at one + time the definition of `do' was different and it could be used for + scrolling as well. But it isn't desirable to combine these two + functions in one capability, since scrolling often requires more + padding than simply moving the cursor down. Defining `sf' and + `do' separately allows you to specify the padding properly. Also, + all sources agree that `do' should not be relied on to do + scrolling. + + So the best approach is to add `sf' capabilities to the + descriptions of these terminals, copying the definition of `do' if + that does scroll. + +`SF' + String of commands to scroll the screen N lines up, assuming it is + output with the cursor at the beginning of the bottom line. + +`SR' + String of commands to scroll the screen N lines down, assuming it + is output with the cursor at the beginning of the top line. + +`cs' + String of commands to set the scroll region. This command takes + two parameters, START and END, which are the line numbers + (origin-zero) of the first line to include in the scroll region + and of the last line to include in it. When a scroll region is + set, scrolling is limited to the specified range of lines; lines + outside the range are not affected by scroll commands. + + Do not try to move the cursor outside the scroll region. The + region remains set until explicitly removed. To remove the scroll + region, use another `cs' command specifying the full height of the + screen. + + The cursor position is undefined after the `cs' command is set, so + position the cursor with `cm' immediately afterward. + +`cS' + String of commands to set the scroll region using parameters in + different form. The effect is the same as if `cs' were used. + Four parameters are required: + + 1. Total number of lines on the screen. + + 2. Number of lines above desired scroll region. + + 3. Number of lines below (outside of) desired scroll region. + + 4. Total number of lines on the screen, the same as the first + parameter. + + This capability is a GNU extension that was invented to allow the + Ann Arbor Ambassador's scroll-region command to be described; it + could also be done by putting non-Unix `%'-sequences into a `cs' + string, but that would have confused Unix programs that used the + `cs' capability with the Unix termcap. Currently only GNU Emacs + uses the `cS' capability. + +`ns' + Flag which means that the terminal does not normally scroll for + ordinary sequential output. For modern terminals, this means that + outputting a newline in ordinary sequential output with the cursor + on the bottom line wraps to the top line. For some obsolete + terminals, other things may happen. + + The terminal may be able to scroll even if it does not normally do + so. If the `sf' capability is provided, it can be used for + scrolling regardless of `ns'. + +`da' + Flag whose presence means that lines scrolled up off the top of the + screen may come back if scrolling down is done subsequently. + + The `da' and `db' flags do not, strictly speaking, affect how to + scroll. But programs that scroll usually need to clear the lines + scrolled onto the screen, if these flags are present. + +`db' + Flag whose presence means that lines scrolled down off the bottom + of the screen may come back if scrolling up is done subsequently. + +`lm' + Numeric value, the number of lines of display memory that the + terminal has. A value of zero means that the terminal has more + display memory than can fit on the screen, but no fixed number of + lines. (The number of lines may depend on the amount of text in + each line.) + + Any terminal description that defines `SF' should also define `sf'; +likewise for `SR' and `sr'. However, many terminals can only scroll by +one line at a time, so it is common to find `sf' and not `SF', or `sr' +without `SR'. + + Therefore, all programs that use the scrolling facilities should be +prepared to work with `sf' in the case that `SF' is absent, and +likewise with `sr'. On the other hand, an application program that +uses only `sf' and not `SF' is acceptable, though slow on some +terminals. + + When outputting a scroll command with `tputs', the NLINES argument +should be the total number of lines in the portion of the screen being +scrolled. Very often these commands require padding proportional to +this number of lines. *Note Padding::. + + +File: termcap.info, Node: Windows, Next: Clearing, Prev: Scrolling, Up: Capabilities + +Windows +======= + + A "window", in termcap, is a rectangular portion of the screen to +which all display operations are restricted. Wrapping, clearing, +scrolling, insertion and deletion all operate as if the specified +window were all the screen there was. + +`wi' + String of commands to set the terminal output screen window. This + string requires four parameters, all origin-zero: + 1. The first line to include in the window. + + 2. The last line to include in the window. + + 3. The first column to include in the window. + + 4. The last column to include in the window. + + Most terminals do not support windows. + + +File: termcap.info, Node: Clearing, Next: Insdel Line, Prev: Windows, Up: Capabilities + +Clearing Parts of the Screen +============================ + + There are several terminal capabilities for clearing parts of the +screen to blank. All display terminals support the `cl' string, and +most display terminals support all of these capabilities. + +`cl' + String of commands to clear the entire screen and position the + cursor at the upper left corner. + +`cd' + String of commands to clear the line the cursor is on, and all the + lines below it, down to the bottom of the screen. This command + string should be used only with the cursor in column zero; their + effect is undefined if the cursor is elsewhere. + +`ce' + String of commands to clear from the cursor to the end of the + current line. + +`ec' + String of commands to clear N characters, starting with the + character that the cursor is on. This command string is expected + to leave the cursor position unchanged. The parameter N should + never be large enough to reach past the right margin; the effect + of such a large parameter would be undefined. + + Clear to end of line (`ce') is extremely important in programs that +maintain an updating display. Nearly all display terminals support this +operation, so it is acceptable for a an application program to refuse to +work if `ce' is not present. However, if you do not want this +limitation, you can accomplish clearing to end of line by outputting +spaces until you reach the right margin. In order to do this, you must +know the current horizontal position. Also, this technique assumes +that writing a space will erase. But this happens to be true on all +the display terminals that fail to support `ce'. + + +File: termcap.info, Node: Insdel Line, Next: Insdel Char, Prev: Clearing, Up: Capabilities + +Insert/Delete Line +================== + + "Inserting a line" means creating a blank line in the middle of the +screen, and pushing the existing lines of text apart. In fact, the +lines above the insertion point do not change, while the lines below +move down, and one is normally lost at the bottom of the screen. + + "Deleting a line" means causing the line to disappear from the +screen, closing up the gap by moving the lines below it upward. A new +line appears at the bottom of the screen. Usually this line is blank, +but on terminals with the `db' flag it may be a line previously moved +off the screen bottom by scrolling or line insertion. + + Insertion and deletion of lines is useful in programs that maintain +an updating display some parts of which may get longer or shorter. +They are also useful in editors for scrolling parts of the screen, and +for redisplaying after lines of text are killed or inserted. + + Many terminals provide commands to insert or delete a single line at +the cursor position. Some provide the ability to insert or delete +several lines with one command, using the number of lines to insert or +delete as a parameter. Always move the cursor to column zero before +using any of these commands. + +`al' + String of commands to insert a blank line before the line the + cursor is on. The existing line, and all lines below it, are + moved down. The last line in the screen (or in the scroll region, + if one is set) disappears and in most circumstances is discarded. + It may not be discarded if the `db' is present (*note + Scrolling::.). + + The cursor must be at the left margin before this command is used. + This command does not move the cursor. + +`dl' + String of commands to delete the line the cursor is on. The + following lines move up, and a blank line appears at the bottom of + the screen (or bottom of the scroll region). If the terminal has + the `db' flag, a nonblank line previously pushed off the screen + bottom may reappear at the bottom. + + The cursor must be at the left margin before this command is used. + This command does not move the cursor. + +`AL' + String of commands to insert N blank lines before the line that + the cursor is on. It is like `al' repeated N times, except that + it is as fast as one `al'. + +`DL' + String of commands to delete N lines starting with the line that + the cursor is on. It is like `dl' repeated N times, except that + it is as fast as one `dl'. + + Any terminal description that defines `AL' should also define `al'; +likewise for `DL' and `dl'. However, many terminals can only insert or +delete one line at a time, so it is common to find `al' and not `AL', +or `dl' without `DL'. + + Therefore, all programs that use the insert and delete facilities +should be prepared to work with `al' in the case that `AL' is absent, +and likewise with `dl'. On the other hand, it is acceptable to write +an application that uses only `al' and `dl' and does not look for `AL' +or `DL' at all. + + If a terminal does not support line insertion and deletion directly, +but does support a scroll region, the effect of insertion and deletion +can be obtained with scrolling. However, it is up to the individual +user program to check for this possibility and use the scrolling +commands to get the desired result. It is fairly important to implement +this alternate strategy, since it is the only way to get the effect of +line insertion and deletion on the popular VT100 terminal. + + Insertion and deletion of lines is affected by the scroll region on +terminals that have a settable scroll region. This is useful when it is +desirable to move any few consecutive lines up or down by a few lines. +*Note Scrolling::. + + The line pushed off the bottom of the screen is not lost if the +terminal has the `db' flag capability; instead, it is pushed into +display memory that does not appear on the screen. This is the same +thing that happens when scrolling pushes a line off the bottom of the +screen. Either reverse scrolling or deletion of a line can bring the +apparently lost line back onto the bottom of the screen. If the +terminal has the scroll region feature as well as `db', the pushed-out +line really is lost if a scroll region is in effect. + + When outputting an insert or delete command with `tputs', the NLINES +argument should be the total number of lines from the cursor to the +bottom of the screen (or scroll region). Very often these commands +require padding proportional to this number of lines. *Note Padding::. + + For `AL' and `DL' the NLINES argument should *not* depend on the +number of lines inserted or deleted; only the total number of lines +affected. This is because it is just as fast to insert two or N lines +with `AL' as to insert one line with `al'. + diff --git a/lib/termcap/grot/termcap.info-3 b/lib/termcap/grot/termcap.info-3 new file mode 100644 index 0000000..d5b309f --- /dev/null +++ b/lib/termcap/grot/termcap.info-3 @@ -0,0 +1,1480 @@ +This is Info file ./termcap.info, produced by Makeinfo-1.55 from the +input file ./termcap.texi. + + This file documents the termcap library of the GNU system. + + Copyright (C) 1988 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: termcap.info, Node: Insdel Char, Next: Standout, Prev: Insdel Line, Up: Capabilities + +Insert/Delete Character +======================= + + "Inserting a character" means creating a blank space in the middle +of a line, and pushing the rest of the line rightward. The character +in the rightmost column is lost. + + "Deleting a character" means causing the character to disappear from +the screen, closing up the gap by moving the rest of the line leftward. +A blank space appears in the rightmost column. + + Insertion and deletion of characters is useful in programs that +maintain an updating display some parts of which may get longer or +shorter. It is also useful in editors for redisplaying the results of +editing within a line. + + Many terminals provide commands to insert or delete a single +character at the cursor position. Some provide the ability to insert +or delete several characters with one command, using the number of +characters to insert or delete as a parameter. + + Many terminals provide an insert mode in which outputting a graphic +character has the added effect of inserting a position for that +character. A special command string is used to enter insert mode and +another is used to exit it. The reason for designing a terminal with +an insert mode rather than an insert command is that inserting +character positions is usually followed by writing characters into +them. With insert mode, this is as fast as simply writing the +characters, except for the fixed overhead of entering and leaving +insert mode. However, when the line speed is great enough, padding may +be required for the graphic characters output in insert mode. + + Some terminals require you to enter insert mode and then output a +special command for each position to be inserted. Or they may require +special commands to be output before or after each graphic character to +be inserted. + + Deletion of characters is usually accomplished by a straightforward +command to delete one or several positions; but on some terminals, it +is necessary to enter a special delete mode before using the delete +command, and leave delete mode afterward. Sometimes delete mode and +insert mode are the same mode. + + Some terminals make a distinction between character positions in +which a space character has been output and positions which have been +cleared. On these terminals, the effect of insert or delete character +runs to the first cleared position rather than to the end of the line. +In fact, the effect may run to more than one line if there is no +cleared position to stop the shift on the first line. These terminals +are identified by the `in' flag capability. + + On terminals with the `in' flag, the technique of skipping over +characters that you know were cleared, and then outputting text later +on in the same line, causes later insert and delete character +operations on that line to do nonstandard things. A program that has +any chance of doing this must check for the `in' flag and must be +careful to write explicit space characters into the intermediate +columns when `in' is present. + + A plethora of terminal capabilities are needed to describe all of +this complexity. Here is a list of them all. Following the list, we +present an algorithm for programs to use to take proper account of all +of these capabilities. + +`im' + String of commands to enter insert mode. + + If the terminal has no special insert mode, but it can insert + characters with a special command, `im' should be defined with a + null value, because the `vi' editor assumes that insertion of a + character is impossible if `im' is not provided. + + New programs should not act like `vi'. They should pay attention + to `im' only if it is defined. + +`ei' + String of commands to leave insert mode. This capability must be + present if `im' is. + + On a few old terminals the same string is used to enter and exit + insert mode. This string turns insert mode on if it was off, and + off it it was on. You can tell these terminals because the `ei' + string equals the `im' string. If you want to support these + terminals, you must always remember accurately whether insert mode + is in effect. However, these terminals are obsolete, and it is + reasonable to refuse to support them. On all modern terminals, you + can safely output `ei' at any time to ensure that insert mode is + turned off. + +`ic' + String of commands to insert one character position at the cursor. + The cursor does not move. + + If outputting a graphic character while in insert mode is + sufficient to insert the character, then the `ic' capability + should be defined with a null value. + + If your terminal offers a choice of ways to insert--either use + insert mode or use a special command--then define `im' and do not + define `ic', since this gives the most efficient operation when + several characters are to be inserted. *Do not* define both + strings, for that means that *both* must be used each time + insertion is done. + +`ip' + String of commands to output following an inserted graphic + character in insert mode. Often it is used just for a padding + spec, when padding is needed after an inserted character (*note + Padding::.). + +`IC' + String of commands to insert N character positions at and after + the cursor. It has the same effect as repeating the `ic' string + and a space, N times. + + If `IC' is provided, application programs may use it without first + entering insert mode. + +`mi' + Flag whose presence means it is safe to move the cursor while in + insert mode and assume the terminal remains in insert mode. + +`in' + Flag whose presence means that the terminal distinguishes between + character positions in which space characters have been output and + positions which have been cleared. + + An application program can assume that the terminal can do character +insertion if *any one of* the capabilities `IC', `im', `ic' or `ip' is +provided. + + To insert N blank character positions, move the cursor to the place +to insert them and follow this algorithm: + + 1. If an `IC' string is provided, output it with parameter N and you + are finished. Otherwise (or if you don't want to bother to look + for an `IC' string) follow the remaining steps. + + 2. Output the `im' string, if there is one, unless the terminal is + already in insert mode. + + 3. Repeat steps 4 through 6, N times. + + 4. Output the `ic' string if any. + + 5. Output a space. + + 6. Output the `ip' string if any. + + 7. Output the `ei' string, eventually, to exit insert mode. There is + no need to do this right away. If the `mi' flag is present, you + can move the cursor and the cursor will remain in insert mode; + then you can do more insertion elsewhere without reentering insert + mode. + + To insert N graphic characters, position the cursor and follow this +algorithm: + + 1. If an `IC' string is provided, output it with parameter N, then + output the graphic characters, and you are finished. Otherwise + (or if you don't want to bother to look for an `IC' string) follow + the remaining steps. + + 2. Output the `im' string, if there is one, unless the terminal is + already in insert mode. + + 3. For each character to be output, repeat steps 4 through 6. + + 4. Output the `ic' string if any. + + 5. Output the next graphic character. + + 6. Output the `ip' string if any. + + 7. Output the `ei' string, eventually, to exit insert mode. There is + no need to do this right away. If the `mi' flag is present, you + can move the cursor and the cursor will remain in insert mode; + then you can do more insertion elsewhere without reentering insert + mode. + + Note that this is not the same as the original Unix termcap +specifications in one respect: it assumes that the `IC' string can be +used without entering insert mode. This is true as far as I know, and +it allows you be able to avoid entering and leaving insert mode, and +also to be able to avoid the inserted-character padding after the +characters that go into the inserted positions. + + Deletion of characters is less complicated; deleting one column is +done by outputting the `dc' string. However, there may be a delete +mode that must be entered with `dm' in order to make `dc' work. + +`dc' + String of commands to delete one character position at the cursor. + If `dc' is not present, the terminal cannot delete characters. + +`DC' + String of commands to delete N characters starting at the cursor. + It has the same effect as repeating the `dc' string N times. Any + terminal description that has `DC' also has `dc'. + +`dm' + String of commands to enter delete mode. If not present, there is + no delete mode, and `dc' can be used at any time (assuming there is + a `dc'). + +`ed' + String of commands to exit delete mode. This must be present if + `dm' is. + + To delete N character positions, position the cursor and follow these +steps: + + 1. If the `DC' string is present, output it with parameter N and you + are finished. Otherwise, follow the remaining steps. + + 2. Output the `dm' string, unless you know the terminal is already in + delete mode. + + 3. Output the `dc' string N times. + + 4. Output the `ed' string eventually. If the flag capability `mi' is + present, you can move the cursor and do more deletion without + leaving and reentering delete mode. + + As with the `IC' string, we have departed from the original termcap +specifications by assuming that `DC' works without entering delete mode +even though `dc' would not. + + If the `dm' and `im' capabilities are both present and have the same +value, it means that the terminal has one mode for both insertion and +deletion. It is useful for a program to know this, because then it can +do insertions after deletions, or vice versa, without leaving +insert/delete mode and reentering it. + + +File: termcap.info, Node: Standout, Next: Underlining, Prev: Insdel Char, Up: Capabilities + +Standout and Appearance Modes +============================= + + "Appearance modes" are modifications to the ways characters are +displayed. Typical appearance modes include reverse video, dim, bright, +blinking, underlined, invisible, and alternate character set. Each +kind of terminal supports various among these, or perhaps none. + + For each type of terminal, one appearance mode or combination of +them that looks good for highlighted text is chosen as the "standout +mode". The capabilities `so' and `se' say how to enter and leave +standout mode. Programs that use appearance modes only to highlight +some text generally use the standout mode so that they can work on as +many terminals as possible. Use of specific appearance modes other +than "underlined" and "alternate character set" is rare. + + Terminals that implement appearance modes fall into two general +classes as to how they do it. + + In some terminals, the presence or absence of any appearance mode is +recorded separately for each character position. In these terminals, +each graphic character written is given the appearance modes current at +the time it is written, and keeps those modes until it is erased or +overwritten. There are special commands to turn the appearance modes +on or off for characters to be written in the future. + + In other terminals, the change of appearance modes is represented by +a marker that belongs to a certain screen position but affects all +following screen positions until the next marker. These markers are +traditionally called "magic cookies". + + The same capabilities (`so', `se', `mb' and so on) for turning +appearance modes on and off are used for both magic-cookie terminals +and per-character terminals. On magic cookie terminals, these give the +commands to write the magic cookies. On per-character terminals, they +change the current modes that affect future output and erasure. Some +simple applications can use these commands without knowing whether or +not they work by means of cookies. + + However, a program that maintains and updates a display needs to know +whether the terminal uses magic cookies, and exactly what their effect +is. This information comes from the `sg' capability. + + The `sg' capability is a numeric capability whose presence indicates +that the terminal uses magic cookies for appearance modes. Its value is +the number of character positions that a magic cookie occupies. Usually +the cookie occupies one or more character positions on the screen, and +these character positions are displayed as blank, but in some terminals +the cookie has zero width. + + The `sg' capability describes both the magic cookie to turn standout +on and the cookie to turn it off. This makes the assumption that both +kinds of cookie have the same width on the screen. If that is not true, +the narrower cookie must be "widened" with spaces until it has the same +width as the other. + + On some magic cookie terminals, each line always starts with normal +display; in other words, the scope of a magic cookie never extends over +more than one line. But on other terminals, one magic cookie affects +all the lines below it unless explicitly canceled. Termcap does not +define any way to distinguish these two ways magic cookies can work. +To be safe, it is best to put a cookie at the beginning of each line. + + On some per-character terminals, standout mode or other appearance +modes may be canceled by moving the cursor. On others, moving the +cursor has no effect on the state of the appearance modes. The latter +class of terminals are given the flag capability `ms' ("can move in +standout"). All programs that might have occasion to move the cursor +while appearance modes are turned on must check for this flag; if it is +not present, they should reset appearance modes to normal before doing +cursor motion. + + A program that has turned on only standout mode should use `se' to +reset the standout mode to normal. A program that has turned on only +alternate character set mode should use `ae' to return it to normal. +If it is possible that any other appearance modes are turned on, use the +`me' capability to return them to normal. + + Note that the commands to turn on one appearance mode, including `so' +and `mb' ... `mr', if used while some other appearance modes are turned +on, may combine the two modes on some terminals but may turn off the +mode previously enabled on other terminals. This is because some +terminals do not have a command to set or clear one appearance mode +without changing the others. Programs should not attempt to use +appearance modes in combination except with `sa', and when switching +from one single mode to another should always turn off the previously +enabled mode and then turn on the new desired mode. + + On some old terminals, the `so' and `se' commands may be the same +command, which has the effect of turning standout on if it is off, or +off it is on. It is therefore risky for a program to output extra `se' +commands for good measure. Fortunately, all these terminals are +obsolete. + + Programs that update displays in which standout-text may be replaced +with non-standout text must check for the `xs' flag. In a per-character +terminal, this flag says that the only way to remove standout once +written is to clear that portion of the line with the `ce' string or +something even more powerful (*note Clearing::.); just writing new +characters at those screen positions will not change the modes in +effect there. In a magic cookie terminal, `xs' says that the only way +to remove a cookie is to clear a portion of the line that includes the +cookie; writing a different cookie at the same position does not work. + + Such programs must also check for the `xt' flag, which means that the +terminal is a Teleray 1061. On this terminal it is impossible to +position the cursor at the front of a magic cookie, so the only two +ways to remove a cookie are (1) to delete the line it is on or (2) to +position the cursor at least one character before it (possibly on a +previous line) and output the `se' string, which on these terminals +finds and removes the next `so' magic cookie on the screen. (It may +also be possible to remove a cookie which is not at the beginning of a +line by clearing that line.) The `xt' capability also has implications +for the use of tab characters, but in that regard it is obsolete (*Note +Cursor Motion::). + +`so' + String of commands to enter standout mode. + +`se' + String of commands to leave standout mode. + +`sg' + Numeric capability, the width on the screen of the magic cookie. + This capability is absent in terminals that record appearance modes + character by character. + +`ms' + Flag whose presence means that it is safe to move the cursor while + the appearance modes are not in the normal state. If this flag is + absent, programs should always reset the appearance modes to + normal before moving the cursor. + +`xs' + Flag whose presence means that the only way to reset appearance + modes already on the screen is to clear to end of line. On a + per-character terminal, you must clear the area where the modes + are set. On a magic cookie terminal, you must clear an area + containing the cookie. See the discussion above. + +`xt' + Flag whose presence means that the cursor cannot be positioned + right in front of a magic cookie, and that `se' is a command to + delete the next magic cookie following the cursor. See discussion + above. + +`mb' + String of commands to enter blinking mode. + +`md' + String of commands to enter double-bright mode. + +`mh' + String of commands to enter half-bright mode. + +`mk' + String of commands to enter invisible mode. + +`mp' + String of commands to enter protected mode. + +`mr' + String of commands to enter reverse-video mode. + +`me' + String of commands to turn off all appearance modes, including + standout mode and underline mode. On some terminals it also turns + off alternate character set mode; on others, it may not. This + capability must be present if any of `mb' ... `mr' is present. + +`as' + String of commands to turn on alternate character set mode. This + mode assigns some or all graphic characters an alternate picture + on the screen. There is no standard as to what the alternate + pictures look like. + +`ae' + String of commands to turn off alternate character set mode. + +`sa' + String of commands to turn on an arbitrary combination of + appearance modes. It accepts 9 parameters, each of which controls + a particular kind of appearance mode. A parameter should be 1 to + turn its appearance mode on, or zero to turn that mode off. Most + terminals do not support the `sa' capability, even among those + that do have various appearance modes. + + The nine parameters are, in order, STANDOUT, UNDERLINE, REVERSE, + BLINK, HALF-BRIGHT, DOUBLE-BRIGHT, BLANK, PROTECT, ALT CHAR SET. + + +File: termcap.info, Node: Underlining, Next: Cursor Visibility, Prev: Standout, Up: Capabilities + +Underlining +=========== + + Underlining on most terminals is a kind of appearance mode, much like +standout mode. Therefore, it may be implemented using magic cookies or +as a flag in the terminal whose current state affects each character +that is output. *Note Standout::, for a full explanation. + + The `ug' capability is a numeric capability whose presence indicates +that the terminal uses magic cookies for underlining. Its value is the +number of character positions that a magic cookie for underlining +occupies; it is used for underlining just as `sg' is used for standout. +Aside from the simplest applications, it is impossible to use +underlining correctly without paying attention to the value of `ug'. + +`us' + String of commands to turn on underline mode or to output a magic + cookie to start underlining. + +`ue' + String of commands to turn off underline mode or to output a magic + cookie to stop underlining. + +`ug' + Width of magic cookie that represents a change of underline mode; + or missing, if the terminal does not use a magic cookie for this. + +`ms' + Flag whose presence means that it is safe to move the cursor while + the appearance modes are not in the normal state. Underlining is + an appearance mode. If this flag is absent, programs should + always turn off underlining before moving the cursor. + + There are two other, older ways of doing underlining: there can be a +command to underline a single character, or the output of `_', the +ASCII underscore character, as an overstrike could cause a character to +be underlined. New programs need not bother to handle these +capabilities unless the author cares strongly about the obscure +terminals which support them. However, terminal descriptions should +provide these capabilities when appropriate. + +`uc' + String of commands to underline the character under the cursor, and + move the cursor right. + +`ul' + Flag whose presence means that the terminal can underline by + overstriking an underscore character (`_'); some terminals can do + this even though they do not support overstriking in general. An + implication of this flag is that when outputting new text to + overwrite old text, underscore characters must be treated + specially lest they underline the old text instead. + + +File: termcap.info, Node: Cursor Visibility, Next: Bell, Prev: Underlining, Up: Capabilities + +Cursor Visibility +================= + + Some terminals have the ability to make the cursor invisible, or to +enhance it. Enhancing the cursor is often done by programs that plan +to use the cursor to indicate to the user a position of interest that +may be anywhere on the screen--for example, the Emacs editor enhances +the cursor on entry. Such programs should always restore the cursor to +normal on exit. + +`vs' + String of commands to enhance the cursor. + +`vi' + String of commands to make the cursor invisible. + +`ve' + String of commands to return the cursor to normal. + + If you define either `vs' or `vi', you must also define `ve'. + + +File: termcap.info, Node: Bell, Next: Keypad, Prev: Cursor Visibility, Up: Capabilities + +Bell +==== + + Here we describe commands to make the terminal ask for the user to +pay attention to it. + +`bl' + String of commands to cause the terminal to make an audible sound. + If this capability is absent, the terminal has no way to make a + suitable sound. + +`vb' + String of commands to cause the screen to flash to attract + attention ("visible bell"). If this capability is absent, the + terminal has no way to do such a thing. + + +File: termcap.info, Node: Keypad, Next: Meta Key, Prev: Bell, Up: Capabilities + +Keypad and Function Keys +======================== + + Many terminals have arrow and function keys that transmit specific +character sequences to the computer. Since the precise sequences used +depend on the terminal, termcap defines capabilities used to say what +the sequences are. Unlike most termcap string-valued capabilities, +these are not strings of commands to be sent to the terminal, rather +strings that are received from the terminal. + + Programs that expect to use keypad keys should check, initially, for +a `ks' capability and send it, to make the keypad actually transmit. +Such programs should also send the `ke' string when exiting. + +`ks' + String of commands to make the keypad keys transmit. If this + capability is not provided, but the others in this section are, + programs may assume that the keypad keys always transmit. + +`ke' + String of commands to make the keypad keys work locally. This + capability is provided only if `ks' is. + +`kl' + String of input characters sent by typing the left-arrow key. If + this capability is missing, you cannot expect the terminal to have + a left-arrow key that transmits anything to the computer. + +`kr' + String of input characters sent by typing the right-arrow key. + +`ku' + String of input characters sent by typing the up-arrow key. + +`kd' + String of input characters sent by typing the down-arrow key. + +`kh' + String of input characters sent by typing the "home-position" key. + +`K1' ... `K5' + Strings of input characters sent by the five other keys in a 3-by-3 + array that includes the arrow keys, if the keyboard has such a + 3-by-3 array. Note that one of these keys may be the + "home-position" key, in which case one of these capabilities will + have the same value as the `kh' key. + +`k0' + String of input characters sent by function key 10 (or 0, if the + terminal has one labeled 0). + +`k1' ... `k9' + Strings of input characters sent by function keys 1 through 9, + provided for those function keys that exist. + +`kn' + Number: the number of numbered function keys, if there are more + than 10. + +`l0' ... `l9' + Strings which are the labels appearing on the keyboard on the keys + described by the capabilities `k0' ... `l9'. These capabilities + should be left undefined if the labels are `f0' or `f10' and `f1' + ... `f9'. + +`kH' + String of input characters sent by the "home down" key, if there is + one. + +`kb' + String of input characters sent by the "backspace" key, if there is + one. + +`ka' + String of input characters sent by the "clear all tabs" key, if + there is one. + +`kt' + String of input characters sent by the "clear tab stop this column" + key, if there is one. + +`kC' + String of input characters sent by the "clear screen" key, if + there is one. + +`kD' + String of input characters sent by the "delete character" key, if + there is one. + +`kL' + String of input characters sent by the "delete line" key, if there + is one. + +`kM' + String of input characters sent by the "exit insert mode" key, if + there is one. + +`kE' + String of input characters sent by the "clear to end of line" key, + if there is one. + +`kS' + String of input characters sent by the "clear to end of screen" + key, if there is one. + +`kI' + String of input characters sent by the "insert character" or "enter + insert mode" key, if there is one. + +`kA' + String of input characters sent by the "insert line" key, if there + is one. + +`kN' + String of input characters sent by the "next page" key, if there is + one. + +`kP' + String of input characters sent by the "previous page" key, if + there is one. + +`kF' + String of input characters sent by the "scroll forward" key, if + there is one. + +`kR' + String of input characters sent by the "scroll reverse" key, if + there is one. + +`kT' + String of input characters sent by the "set tab stop in this + column" key, if there is one. + +`ko' + String listing the other function keys the terminal has. This is a + very obsolete way of describing the same information found in the + `kH' ... `kT' keys. The string contains a list of two-character + termcap capability names, separated by commas. The meaning is + that for each capability name listed, the terminal has a key which + sends the string which is the value of that capability. For + example, the value `:ko=cl,ll,sf,sr:' says that the terminal has + four function keys which mean "clear screen", "home down", "scroll + forward" and "scroll reverse". + + +File: termcap.info, Node: Meta Key, Next: Initialization, Prev: Keypad, Up: Capabilities + +Meta Key +======== + + A Meta key is a key on the keyboard that modifies each character you +type by controlling the 0200 bit. This bit is on if and only if the +Meta key is held down when the character is typed. Characters typed +using the Meta key are called Meta characters. Emacs uses Meta +characters as editing commands. + +`km' + Flag whose presence means that the terminal has a Meta key. + +`mm' + String of commands to enable the functioning of the Meta key. + +`mo' + String of commands to disable the functioning of the Meta key. + + If the terminal has `km' but does not have `mm' and `mo', it means +that the Meta key always functions. If it has `mm' and `mo', it means +that the Meta key can be turned on or off. Send the `mm' string to +turn it on, and the `mo' string to turn it off. I do not know why one +would ever not want it to be on. + + +File: termcap.info, Node: Initialization, Next: Pad Specs, Prev: Meta Key, Up: Capabilities + +Initialization +============== + +`ti' + String of commands to put the terminal into whatever special modes + are needed or appropriate for programs that move the cursor + nonsequentially around the screen. Programs that use termcap to do + full-screen display should output this string when they start up. + +`te' + String of commands to undo what is done by the `ti' string. + Programs that output the `ti' string on entry should output this + string when they exit. + +`is' + String of commands to initialize the terminal for each login + session. + +`if' + String which is the name of a file containing the string of + commands to initialize the terminal for each session of use. + Normally `is' and `if' are not both used. + +`i1' +`i3' + Two more strings of commands to initialize the terminal for each + login session. The `i1' string (if defined) is output before `is' + or `if', and the `i3' string (if defined) is output after. + + The reason for having three separate initialization strings is to + make it easier to define a group of related terminal types with + slightly different initializations. Define two or three of the + strings in the basic type; then the other types can override one + or two of the strings. + +`rs' + String of commands to reset the terminal from any strange mode it + may be in. Normally this includes the `is' string (or other + commands with the same effects) and more. What would go in the + `rs' string but not in the `is' string are annoying or slow + commands to bring the terminal back from strange modes that nobody + would normally use. + +`it' + Numeric value, the initial spacing between hardware tab stop + columns when the terminal is powered up. Programs to initialize + the terminal can use this to decide whether there is a need to set + the tab stops. If the initial width is 8, well and good; if it is + not 8, then the tab stops should be set; if they cannot be set, + the kernel is told to convert tabs to spaces, and other programs + will observe this and do likewise. + +`ct' + String of commands to clear all tab stops. + +`st' + String of commands to set tab stop at current cursor column on all + lines. + +`NF' + Flag whose presence means that the terminal does not support + XON/XOFF flow control. Programs should not send XON (`C-q') or + XOFF (`C-s') characters to the terminal. + + +File: termcap.info, Node: Pad Specs, Next: Status Line, Prev: Initialization, Up: Capabilities + +Padding Capabilities +==================== + + There are two terminal capabilities that exist just to explain the +proper way to obey the padding specifications in all the command string +capabilities. One, `pc', must be obeyed by all termcap-using programs. + +`pb' + Numeric value, the lowest baud rate at which padding is actually + needed. Programs may check this and refrain from doing any + padding at lower speeds. + +`pc' + String of commands for padding. The first character of this + string is to be used as the pad character, instead of using null + characters for padding. If `pc' is not provided, use null + characters. Every program that uses termcap must look up this + capability and use it to set the variable `PC' that is used by + `tputs'. *Note Padding::. + + Some termcap capabilities exist just to specify the amount of +padding that the kernel should give to cursor motion commands used in +ordinary sequential output. + +`dC' + Numeric value, the number of msec of padding needed for the + carriage-return character. + +`dN' + Numeric value, the number of msec of padding needed for the newline + (linefeed) character. + +`dB' + Numeric value, the number of msec of padding needed for the + backspace character. + +`dF' + Numeric value, the number of msec of padding needed for the + formfeed character. + +`dT' + Numeric value, the number of msec of padding needed for the tab + character. + + In some systems, the kernel uses the above capabilities; in other +systems, the kernel uses the paddings specified in the string +capabilities `cr', `sf', `le', `ff' and `ta'. Descriptions of +terminals which require such padding should contain the `dC' ... `dT' +capabilities and also specify the appropriate padding in the +corresponding string capabilities. Since no modern terminals require +padding for ordinary sequential output, you probably won't need to do +either of these things. + + +File: termcap.info, Node: Status Line, Next: Half-Line, Prev: Pad Specs, Up: Capabilities + +Status Line +=========== + + A "status line" is a line on the terminal that is not used for +ordinary display output but instead used for a special message. The +intended use is for a continuously updated description of what the +user's program is doing, and that is where the name "status line" comes +from, but in fact it could be used for anything. The distinguishing +characteristic of a status line is that ordinary output to the terminal +does not affect it; it changes only if the special status line commands +of this section are used. + +`hs' + Flag whose presence means that the terminal has a status line. If + a terminal description specifies that there is a status line, it + must provide the `ts' and `fs' capabilities. + +`ts' + String of commands to move the terminal cursor into the status + line. Usually these commands must specifically record the old + cursor position for the sake of the `fs' string. + +`fs' + String of commands to move the cursor back from the status line to + its previous position (outside the status line). + +`es' + Flag whose presence means that other display commands work while + writing the status line. In other words, one can clear parts of + it, insert or delete characters, move the cursor within it using + `ch' if there is a `ch' capability, enter and leave standout mode, + and so on. + +`ds' + String of commands to disable the display of the status line. This + may be absent, if there is no way to disable the status line + display. + +`ws' + Numeric value, the width of the status line. If this capability is + absent in a terminal that has a status line, it means the status + line is the same width as the other lines. + + Note that the value of `ws' is sometimes as small as 8. + + +File: termcap.info, Node: Half-Line, Next: Printer, Prev: Status Line, Up: Capabilities + +Half-Line Motion +================ + + Some terminals have commands for moving the cursor vertically by +half-lines, useful for outputting subscripts and superscripts. Mostly +it is hardcopy terminals that have such features. + +`hu' + String of commands to move the cursor up half a line. If the + terminal is a display, it is your responsibility to avoid moving + up past the top line; however, most likely the terminal that + supports this is a hardcopy terminal and there is nothing to be + concerned about. + +`hd' + String of commands to move the cursor down half a line. If the + terminal is a display, it is your responsibility to avoid moving + down past the bottom line, etc. + + +File: termcap.info, Node: Printer, Prev: Half-Line, Up: Capabilities + +Controlling Printers Attached to Terminals +========================================== + + Some terminals have attached hardcopy printer ports. They may be +able to copy the screen contents to the printer; they may also be able +to redirect output to the printer. Termcap does not have anything to +tell the program whether the redirected output appears also on the +screen; it does on some terminals but not all. + +`ps' + String of commands to cause the contents of the screen to be + printed. If it is absent, the screen contents cannot be printed. + +`po' + String of commands to redirect further output to the printer. + +`pf' + String of commands to terminate redirection of output to the + printer. This capability must be present in the description if + `po' is. + +`pO' + String of commands to redirect output to the printer for next N + characters of output, regardless of what they are. Redirection + will end automatically after N characters of further output. Until + then, nothing that is output can end redirection, not even the + `pf' string if there is one. The number N should not be more than + 255. + + One use of this capability is to send non-text byte sequences + (such as bit-maps) to the printer. + + Most terminals with printers do not support all of `ps', `po' and +`pO'; any one or two of them may be supported. To make a program that +can send output to all kinds of printers, it is necessary to check for +all three of these capabilities, choose the most convenient of the ones +that are provided, and use it in its own appropriate fashion. + + +File: termcap.info, Node: Summary, Next: Var Index, Prev: Capabilities, Up: Top + +Summary of Capability Names +*************************** + + Here are all the terminal capability names in alphabetical order +with a brief description of each. For cross references to their +definitions, see the index of capability names (*note Cap Index::.). + +`ae' + String to turn off alternate character set mode. + +`al' + String to insert a blank line before the cursor. + +`AL' + String to insert N blank lines before the cursor. + +`am' + Flag: output to last column wraps cursor to next line. + +`as' + String to turn on alternate character set mode.like. + +`bc' + Very obsolete alternative name for the `le' capability. + +`bl' + String to sound the bell. + +`bs' + Obsolete flag: ASCII backspace may be used for leftward motion. + +`bt' + String to move the cursor left to the previous hardware tab stop + column. + +`bw' + Flag: `le' at left margin wraps to end of previous line. + +`CC' + String to change terminal's command character. + +`cd' + String to clear the line the cursor is on, and following lines. + +`ce' + String to clear from the cursor to the end of the line. + +`ch' + String to position the cursor at column C in the same line. + +`cl' + String to clear the entire screen and put cursor at upper left + corner. + +`cm' + String to position the cursor at line L, column C. + +`CM' + String to position the cursor at line L, column C, relative to + display memory. + +`co' + Number: width of the screen. + +`cr' + String to move cursor sideways to left margin. + +`cs' + String to set the scroll region. + +`cS' + Alternate form of string to set the scroll region. + +`ct' + String to clear all tab stops. + +`cv' + String to position the cursor at line L in the same column. + +`da' + Flag: data scrolled off top of screen may be scrolled back. + +`db' + Flag: data scrolled off bottom of screen may be scrolled back. + +`dB' + Obsolete number: msec of padding needed for the backspace + character. + +`dc' + String to delete one character position at the cursor. + +`dC' + Obsolete number: msec of padding needed for the carriage-return + character. + +`DC' + String to delete N characters starting at the cursor. + +`dF' + Obsolete number: msec of padding needed for the formfeed character. + +`dl' + String to delete the line the cursor is on. + +`DL' + String to delete N lines starting with the cursor's line. + +`dm' + String to enter delete mode. + +`dN' + Obsolete number: msec of padding needed for the newline character. + +`do' + String to move the cursor vertically down one line. + +`DO' + String to move cursor vertically down N lines. + +`ds' + String to disable the display of the status line. + +`dT' + Obsolete number: msec of padding needed for the tab character. + +`ec' + String of commands to clear N characters at cursor. + +`ed' + String to exit delete mode. + +`ei' + String to leave insert mode. + +`eo' + Flag: output of a space can erase an overstrike. + +`es' + Flag: other display commands work while writing the status line. + +`ff' + String to advance to the next page, for a hardcopy terminal. + +`fs' + String to move the cursor back from the status line to its + previous position (outside the status line). + +`gn' + Flag: this terminal type is generic, not real. + +`hc' + Flag: hardcopy terminal. + +`hd' + String to move the cursor down half a line. + +`ho' + String to position cursor at upper left corner. + +`hs' + Flag: the terminal has a status line. + +`hu' + String to move the cursor up half a line. + +`hz' + Flag: terminal cannot accept `~' as output. + +`i1' + String to initialize the terminal for each login session. + +`i3' + String to initialize the terminal for each login session. + +`ic' + String to insert one character position at the cursor. + +`IC' + String to insert N character positions at the cursor. + +`if' + String naming a file of commands to initialize the terminal. + +`im' + String to enter insert mode. + +`in' + Flag: outputting a space is different from moving over empty + positions. + +`ip' + String to output following an inserted character in insert mode. + +`is' + String to initialize the terminal for each login session. + +`it' + Number: initial spacing between hardware tab stop columns. + +`k0' + String of input sent by function key 0 or 10. + +`k1 ... k9' + Strings of input sent by function keys 1 through 9. + +`K1 ... K5' + Strings sent by the five other keys in 3-by-3 array with arrows. + +`ka' + String of input sent by the "clear all tabs" key. + +`kA' + String of input sent by the "insert line" key. + +`kb' + String of input sent by the "backspace" key. + +`kC' + String of input sent by the "clear screen" key. + +`kd' + String of input sent by typing the down-arrow key. + +`kD' + String of input sent by the "delete character" key. + +`ke' + String to make the function keys work locally. + +`kE' + String of input sent by the "clear to end of line" key. + +`kF' + String of input sent by the "scroll forward" key. + +`kh' + String of input sent by typing the "home-position" key. + +`kH' + String of input sent by the "home down" key. + +`kI' + String of input sent by the "insert character" or "enter insert + mode" key. + +`kl' + String of input sent by typing the left-arrow key. + +`kL' + String of input sent by the "delete line" key. + +`km' + Flag: the terminal has a Meta key. + +`kM' + String of input sent by the "exit insert mode" key. + +`kn' + Numeric value, the number of numbered function keys. + +`kN' + String of input sent by the "next page" key. + +`ko' + Very obsolete string listing the terminal's named function keys. + +`kP' + String of input sent by the "previous page" key. + +`kr' + String of input sent by typing the right-arrow key. + +`kR' + String of input sent by the "scroll reverse" key. + +`ks' + String to make the function keys transmit. + +`kS' + String of input sent by the "clear to end of screen" key. + +`kt' + String of input sent by the "clear tab stop this column" key. + +`kT' + String of input sent by the "set tab stop in this column" key. + +`ku' + String of input sent by typing the up-arrow key. + +`l0' + String on keyboard labelling function key 0 or 10. + +`l1 ... l9' + Strings on keyboard labelling function keys 1 through 9. + +`le' + String to move the cursor left one column. + +`LE' + String to move cursor left N columns. + +`li' + Number: height of the screen. + +`ll' + String to position cursor at lower left corner. + +`lm' + Number: lines of display memory. + +`LP' + Flag: writing to last column of last line will not scroll. + +`mb' + String to enter blinking mode. + +`md' + String to enter double-bright mode. + +`me' + String to turn off all appearance modes + +`mh' + String to enter half-bright mode. + +`mi' + Flag: cursor motion in insert mode is safe. + +`mk' + String to enter invisible mode. + +`mm' + String to enable the functioning of the Meta key. + +`mo' + String to disable the functioning of the Meta key. + +`mp' + String to enter protected mode. + +`mr' + String to enter reverse-video mode. + +`ms' + Flag: cursor motion in standout mode is safe. + +`nc' + Obsolete flag: do not use ASCII carriage-return on this terminal. + +`nd' + String to move the cursor right one column. + +`NF' + Flag: do not use XON/XOFF flow control. + +`nl' + Obsolete alternative name for the `do' and `sf' capabilities. + +`ns' + Flag: the terminal does not normally scroll for sequential output. + +`nw' + String to move to start of next line, possibly clearing rest of + old line. + +`os' + Flag: terminal can overstrike. + +`pb' + Number: the lowest baud rate at which padding is actually needed. + +`pc' + String containing character for padding. + +`pf' + String to terminate redirection of output to the printer. + +`po' + String to redirect further output to the printer. + +`pO' + String to redirect N characters ofoutput to the printer. + +`ps' + String to print the screen on the attached printer. + +`rc' + String to move to last saved cursor position. + +`RI' + String to move cursor right N columns. + +`rp' + String to output character C repeated N times. + +`rs' + String to reset the terminal from any strange modes. + +`sa' + String to turn on an arbitrary combination of appearance modes. + +`sc' + String to save the current cursor position. + +`se' + String to leave standout mode. + +`sf' + String to scroll the screen one line up. + +`SF' + String to scroll the screen N lines up. + +`sg' + Number: width of magic standout cookie. Absent if magic cookies + are not used. + +`so' + String to enter standout mode. + +`sr' + String to scroll the screen one line down. + +`SR' + String to scroll the screen N line down. + +`st' + String to set tab stop at current cursor column on all lines. + programs. + +`ta' + String to move the cursor right to the next hardware tab stop + column. + +`te' + String to return terminal to settings for sequential output. + +`ti' + String to initialize terminal for random cursor motion. + +`ts' + String to move the terminal cursor into the status line. + +`uc' + String to underline one character and move cursor right. + +`ue' + String to turn off underline mode + +`ug' + Number: width of underlining magic cookie. Absent if underlining + doesn't use magic cookies. + +`ul' + Flag: underline by overstriking with an underscore. + +`up' + String to move the cursor vertically up one line. + +`UP' + String to move cursor vertically up N lines. + +`us' + String to turn on underline mode + +`vb' + String to make the screen flash. + +`ve' + String to return the cursor to normal. + +`vi' + String to make the cursor invisible. + +`vs' + String to enhance the cursor. + +`wi' + String to set the terminal output screen window. + +`ws' + Number: the width of the status line. + +`xb' + Flag: superbee terminal. + +`xn' + Flag: cursor wraps in a strange way. + +`xs' + Flag: clearing a line is the only way to clear the appearance + modes of positions in that line (or, only way to remove magic + cookies on that line). + +`xt' + Flag: Teleray 1061; several strange characteristics. + + +File: termcap.info, Node: Var Index, Next: Cap Index, Prev: Summary, Up: Top + +Variable and Function Index +*************************** + +* Menu: + +* BC: tgoto. +* ospeed: Output Padding. +* PC: Output Padding. +* tgetent: Find. +* tgetflag: Interrogate. +* tgetnum: Interrogate. +* tgetstr: Interrogate. +* tgoto: tgoto. +* tparam: tparam. +* tputs: Output Padding. +* UP: tgoto. + diff --git a/lib/termcap/grot/termcap.info-4 b/lib/termcap/grot/termcap.info-4 new file mode 100644 index 0000000..4b8bf79 --- /dev/null +++ b/lib/termcap/grot/termcap.info-4 @@ -0,0 +1,220 @@ +This is Info file ./termcap.info, produced by Makeinfo-1.55 from the +input file ./termcap.texi. + + This file documents the termcap library of the GNU system. + + Copyright (C) 1988 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: termcap.info, Node: Cap Index, Next: Index, Prev: Var Index, Up: Top + +Capability Index +**************** + +* Menu: + +* ae: Standout. +* al: Insdel Line. +* AL: Insdel Line. +* am: Wrapping. +* as: Standout. +* bc: Cursor Motion. +* bl: Bell. +* bs: Cursor Motion. +* bt: Cursor Motion. +* bw: Cursor Motion. +* CC: Basic. +* cd: Clearing. +* ce: Clearing. +* ch: Cursor Motion. +* cl: Clearing. +* cm: Cursor Motion. +* CM: Cursor Motion. +* co: Screen Size. +* cr: Cursor Motion. +* cS: Scrolling. +* cs: Scrolling. +* ct: Initialization. +* cv: Cursor Motion. +* da: Scrolling. +* dB: Pad Specs. +* db: Scrolling. +* dC: Pad Specs. +* DC: Insdel Char. +* dc: Insdel Char. +* dF: Pad Specs. +* dl: Insdel Line. +* DL: Insdel Line. +* dm: Insdel Char. +* dN: Pad Specs. +* do: Cursor Motion. +* DO: Cursor Motion. +* ds: Status Line. +* dT: Pad Specs. +* ec: Clearing. +* ed: Insdel Char. +* ei: Insdel Char. +* eo: Basic. +* es: Status Line. +* ff: Cursor Motion. +* fs: Status Line. +* gn: Basic. +* hc: Basic. +* hd: Half-Line. +* ho: Cursor Motion. +* hs: Status Line. +* hu: Half-Line. +* hz: Basic. +* i1: Initialization. +* i3: Initialization. +* IC: Insdel Char. +* ic: Insdel Char. +* if: Initialization. +* im: Insdel Char. +* in: Insdel Char. +* ip: Insdel Char. +* is: Initialization. +* it: Initialization. +* K1...K5: Keypad. +* k1...k9: Keypad. +* kA...kT: Keypad. +* ka...ku: Keypad. +* km: Meta Key. +* l0...l9: Keypad. +* le: Cursor Motion. +* LE: Cursor Motion. +* li: Screen Size. +* ll: Cursor Motion. +* lm: Scrolling. +* LP: Wrapping. +* mb: Standout. +* md: Standout. +* me: Standout. +* mh: Standout. +* mi: Insdel Char. +* mk: Standout. +* mm: Meta Key. +* mo: Meta Key. +* mp: Standout. +* mr: Standout. +* ms: Standout. +* ms: Underlining. +* nc: Cursor Motion. +* nd: Cursor Motion. +* NF: Initialization. +* nl: Cursor Motion. +* ns: Scrolling. +* nw: Cursor Motion. +* os: Basic. +* pb: Pad Specs. +* pc: Pad Specs. +* pf: Printer. +* pO: Printer. +* po: Printer. +* ps: Printer. +* rc: Cursor Motion. +* RI: Cursor Motion. +* rp: Basic. +* rs: Initialization. +* sa: Standout. +* sc: Cursor Motion. +* se: Standout. +* SF: Scrolling. +* sf: Scrolling. +* sg: Standout. +* so: Standout. +* SR: Scrolling. +* sr: Scrolling. +* st: Initialization. +* ta: Cursor Motion. +* te: Initialization. +* ti: Initialization. +* ts: Status Line. +* uc: Underlining. +* ue: Underlining. +* ug: Underlining. +* ul: Underlining. +* up: Cursor Motion. +* UP: Cursor Motion. +* us: Underlining. +* vb: Bell. +* ve: Cursor Visibility. +* vi: Cursor Visibility. +* vs: Cursor Visibility. +* wi: Windows. +* ws: Status Line. +* xb: Basic. +* xn: Wrapping. +* xs: Standout. +* xt: Cursor Motion. +* xt: Standout. + + +File: termcap.info, Node: Index, Prev: Cap Index, Up: Top + +Concept Index +************* + +* Menu: + +* %: Encode Parameters. +* appearance modes: Standout. +* bell: Bell. +* clearing the screen: Clearing. +* command character: Basic. +* cursor motion: Cursor Motion. +* delete character: Insdel Char. +* delete line: Insdel Line. +* delete mode: Insdel Char. +* description format: Format. +* erasing: Clearing. +* generic terminal type: Basic. +* home position: Cursor Motion. +* inheritance: Inheriting. +* initialization: Initialization. +* insert character: Insdel Char. +* insert line: Insdel Line. +* insert mode: Insdel Char. +* line speed: Output Padding. +* magic cookie: Standout. +* meta key: Meta Key. +* names of terminal types: Naming. +* overstrike: Basic. +* padding: Pad Specs. +* padding: Padding. +* parameters: Parameters. +* printer: Printer. +* repeat output: Basic. +* reset: Initialization. +* screen size: Screen Size. +* screen size: Naming. +* screen size: Screen Size. +* scrolling: Scrolling. +* standout: Standout. +* status line: Status Line. +* Superbee: Basic. +* tab stops: Initialization. +* termcap: Introduction. +* terminal flags (kernel): Initialize. +* underlining: Underlining. +* visibility: Cursor Visibility. +* visible bell: Bell. +* window: Windows. +* wrapping: Wrapping. +* wrapping: Naming. + + diff --git a/lib/termcap/grot/termcap.texi b/lib/termcap/grot/termcap.texi new file mode 100644 index 0000000..eab49e8 --- /dev/null +++ b/lib/termcap/grot/termcap.texi @@ -0,0 +1,3617 @@ +\input texinfo @c -*-texinfo-*- +@setfilename termcap.info +@settitle The Termcap Library +@smallbook + +@ifinfo +This file documents the termcap library of the GNU system. + +Copyright (C) 1988 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Foundation. +@end ifinfo + +@setchapternewpage odd + +@c @shorttitlepage The Termcap Manual + +@titlepage +@ignore +@sp 6 +@center @titlefont{Termcap} +@sp 1 +@center The Termcap Library and Data Base +@sp 4 +@center Second Edition +@sp 1 +@center December 1992 +@sp 5 +@center Richard M. Stallman +@sp 1 +@center Free Software Foundation +@end ignore + +@c Real title page +@title The Termcap Manual +@subtitle The Termcap Library and Data Base +@subtitle Second Edition +@subtitle December 1992 +@author Richard M. Stallman +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1988 Free Software Foundation, Inc. + +Published by the Free Software Foundation +(59 Temple Place, Suite 330, Boston, MA 02111 USA). +Printed copies are available for $10 each. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Foundation. +@sp 2 +Cover art by Etienne Suvasa. +@end titlepage +@page + +@synindex vr fn + +@node Top, Introduction, (dir), (dir) + +@menu +* Introduction:: What is termcap? Why this manual? +* Library:: The termcap library functions. +* Data Base:: What terminal descriptions in @file{/etc/termcap} look like. +* Capabilities:: Definitions of the individual terminal capabilities: + how to write them in descriptions, and how to use + their values to do display updating. +* Summary:: Brief table of capability names and their meanings. +* Var Index:: Index of C functions and variables. +* Cap Index:: Index of termcap capabilities. +* Index:: Concept index. + + --- The Detailed Node Listing --- + +The Termcap Library + +* Preparation:: Preparing to use the termcap library. +* Find:: Finding the description of the terminal being used. +* Interrogate:: Interrogating the description for particular capabilities. +* Initialize:: Initialization for output using termcap. +* Padding:: Outputting padding. +* Parameters:: Encoding parameters such as cursor positions. + +Padding + +* Why Pad:: Explanation of padding. +* Not Enough:: When there is not enough padding. +* Describe Padding:: The data base says how much padding a terminal needs. +* Output Padding:: Using @code{tputs} to output the needed padding. + +Filling In Parameters + +* Encode Parameters:: The language for encoding parameters. +* Using Parameters:: Outputting a string command with parameters. + +Sending Display Commands with Parameters + +* tparam:: The general case, for GNU termcap only. +* tgoto:: The special case of cursor motion. + +The Format of the Data Base + +* Format:: Overall format of a terminal description. +* Capability Format:: Format of capabilities within a description. +* Naming:: Naming conventions for terminal types. +* Inheriting:: Inheriting part of a description from +a related terminal type. +* Changing:: When changes in the data base take effect. + +Definitions of the Terminal Capabilities + +* Basic:: Basic characteristics. +* Screen Size:: Screen size, and what happens when it changes. +* Cursor Motion:: Various ways to move the cursor. +* Wrapping:: What happens if you write a character in the last column. +* Scrolling:: Pushing text up and down on the screen. +* Windows:: Limiting the part of the window that output affects. +* Clearing:: Erasing one or many lines. +* Insdel Line:: Making new blank lines in mid-screen; deleting lines. +* Insdel Char:: Inserting and deleting characters within a line. +* Standout:: Highlighting some of the text. +* Underlining:: Underlining some of the text. +* Cursor Visibility:: Making the cursor more or less easy to spot. +* Bell:: Attracts user's attention; not localized on the screen. +* Keypad:: Recognizing when function keys or arrows are typed. +* Meta Key:: @key{META} acts like an extra shift key. +* Initialization:: Commands used to initialize or reset the terminal. +* Pad Specs:: Info for the kernel on how much padding is needed. +* Status Line:: A status line displays ``background'' information. +* Half-Line:: Moving by half-lines, for superscripts and subscripts. +* Printer:: Controlling auxiliary printers of display terminals. +@end menu + +@node Introduction, Library, Top, Top +@unnumbered Introduction + +@cindex termcap +@dfn{Termcap} is a library and data base that enables programs to use +display terminals in a terminal-independent manner. It originated in +Berkeley Unix. + +The termcap data base describes the capabilities of hundreds of different +display terminals in great detail. Some examples of the information +recorded for a terminal could include how many columns wide it is, what +string to send to move the cursor to an arbitrary position (including how +to encode the row and column numbers), how to scroll the screen up one or +several lines, and how much padding is needed for such a scrolling +operation. + +The termcap library is provided for easy access this data base in programs +that want to do terminal-independent character-based display output. + +This manual describes the GNU version of the termcap library, which has +some extensions over the Unix version. All the extensions are identified +as such, so this manual also tells you how to use the Unix termcap. + +The GNU version of the termcap library is available free as source code, +for use in free programs, and runs on Unix and VMS systems (at least). You +can find it in the GNU Emacs distribution in the files @file{termcap.c} and +@file{tparam.c}. + +This manual was written for the GNU project, whose goal is to develop a +complete free operating system upward-compatible with Unix for user +programs. The project is approximately two thirds complete. For more +information on the GNU project, including the GNU Emacs editor and the +mostly-portable optimizing C compiler, send one dollar to + +@display +Free Software Foundation +675 Mass Ave +Cambridge, MA 02139 +@end display + +@node Library, Data Base, Introduction, Top +@chapter The Termcap Library + +The termcap library is the application programmer's interface to the +termcap data base. It contains functions for the following purposes: + +@itemize @bullet +@item +Finding the description of the user's terminal type (@code{tgetent}). + +@item +Interrogating the description for information on various topics +(@code{tgetnum}, @code{tgetflag}, @code{tgetstr}). + +@item +Computing and performing padding (@code{tputs}). + +@item +Encoding numeric parameters such as cursor positions into the +terminal-specific form required for display commands (@code{tparam}, +@code{tgoto}). +@end itemize + +@menu +* Preparation:: Preparing to use the termcap library. +* Find:: Finding the description of the terminal being used. +* Interrogate:: Interrogating the description for particular capabilities. +* Initialize:: Initialization for output using termcap. +* Padding:: Outputting padding. +* Parameters:: Encoding parameters such as cursor positions. +@end menu + +@node Preparation, Find, , Library +@section Preparing to Use the Termcap Library + +To use the termcap library in a program, you need two kinds of preparation: + +@itemize @bullet +@item +The compiler needs declarations of the functions and variables in the +library. + +On GNU systems, it suffices to include the header file +@file{termcap.h} in each source file that uses these functions and +variables.@refill + +On Unix systems, there is often no such header file. Then you must +explictly declare the variables as external. You can do likewise for +the functions, or let them be implicitly declared and cast their +values from type @code{int} to the appropriate type. + +We illustrate the declarations of the individual termcap library +functions with ANSI C prototypes because they show how to pass the +arguments. If you are not using the GNU C compiler, you probably +cannot use function prototypes, so omit the argument types and names +from your declarations. + +@item +The linker needs to search the library. Usually either +@samp{-ltermcap} or @samp{-ltermlib} as an argument when linking will +do this.@refill +@end itemize + +@node Find, Interrogate, Preparation, Library +@section Finding a Terminal Description: @code{tgetent} + +@findex tgetent +An application program that is going to use termcap must first look up the +description of the terminal type in use. This is done by calling +@code{tgetent}, whose declaration in ANSI Standard C looks like: + +@example +int tgetent (char *@var{buffer}, char *@var{termtype}); +@end example + +@noindent +This function finds the description and remembers it internally so that +you can interrogate it about specific terminal capabilities +(@pxref{Interrogate}). + +The argument @var{termtype} is a string which is the name for the type of +terminal to look up. Usually you would obtain this from the environment +variable @code{TERM} using @code{getenv ("TERM")}. + +If you are using the GNU version of termcap, you can alternatively ask +@code{tgetent} to allocate enough space. Pass a null pointer for +@var{buffer}, and @code{tgetent} itself allocates the storage using +@code{malloc}. There is no way to get the address that was allocated, +and you shouldn't try to free the storage.@refill + +With the Unix version of termcap, you must allocate space for the +description yourself and pass the address of the space as the argument +@var{buffer}. There is no way you can tell how much space is needed, so +the convention is to allocate a buffer 2048 characters long and assume that +is enough. (Formerly the convention was to allocate 1024 characters and +assume that was enough. But one day, for one kind of terminal, that was +not enough.) + +No matter how the space to store the description has been obtained, +termcap records its address internally for use when you later interrogate +the description with @code{tgetnum}, @code{tgetstr} or @code{tgetflag}. If +the buffer was allocated by termcap, it will be freed by termcap too if you +call @code{tgetent} again. If the buffer was provided by you, you must +make sure that its contents remain unchanged for as long as you still plan +to interrogate the description.@refill + +The return value of @code{tgetent} is @minus{}1 if there is some difficulty +accessing the data base of terminal types, 0 if the data base is accessible +but the specified type is not defined in it, and some other value +otherwise. + +Here is how you might use the function @code{tgetent}: + +@smallexample +#ifdef unix +static char term_buffer[2048]; +#else +#define term_buffer 0 +#endif + +init_terminal_data () +@{ + char *termtype = getenv ("TERM"); + int success; + + if (termtype == 0) + fatal ("Specify a terminal type with `setenv TERM <yourtype>'.\n"); + + success = tgetent (term_buffer, termtype); + if (success < 0) + fatal ("Could not access the termcap data base.\n"); + if (success == 0) + fatal ("Terminal type `%s' is not defined.\n", termtype); +@} +@end smallexample + +@noindent +Here we assume the function @code{fatal} prints an error message and exits. + +If the environment variable @code{TERMCAP} is defined, its value is used to +override the terminal type data base. The function @code{tgetent} checks +the value of @code{TERMCAP} automatically. If the value starts with +@samp{/} then it is taken as a file name to use as the data base file, +instead of @file{/etc/termcap} which is the standard data base. If the +value does not start with @samp{/} then it is itself used as the terminal +description, provided that the terminal type @var{termtype} is among the +types it claims to apply to. @xref{Data Base}, for information on the +format of a terminal description.@refill + +@node Interrogate, Initialize, Find, Library +@section Interrogating the Terminal Description + +Each piece of information recorded in a terminal description is called a +@dfn{capability}. Each defined terminal capability has a two-letter code +name and a specific meaning. For example, the number of columns is named +@samp{co}. @xref{Capabilities}, for definitions of all the standard +capability names. + +Once you have found the proper terminal description with @code{tgetent} +(@pxref{Find}), your application program must @dfn{interrogate} it for +various terminal capabilities. You must specify the two-letter code of +the capability whose value you seek. + +Capability values can be numeric, boolean (capability is either present or +absent) or strings. Any particular capability always has the same value +type; for example, @samp{co} always has a numeric value, while @samp{am} +(automatic wrap at margin) is always a flag, and @samp{cm} (cursor motion +command) always has a string value. The documentation of each capability +says which type of value it has.@refill + +There are three functions to use to get the value of a capability, +depending on the type of value the capability has. Here are their +declarations in ANSI C: + +@findex tgetnum +@findex tgetflag +@findex tgetstr +@example +int tgetnum (char *@var{name}); +int tgetflag (char *@var{name}); +char *tgetstr (char *@var{name}, char **@var{area}); +@end example + +@table @code +@item tgetnum +Use @code{tgetnum} to get a capability value that is numeric. The +argument @var{name} is the two-letter code name of the capability. If +the capability is present, @code{tgetnum} returns the numeric value +(which is nonnegative). If the capability is not mentioned in the +terminal description, @code{tgetnum} returns @minus{}1. + +@item tgetflag +Use @code{tgetflag} to get a boolean value. If the capability +@var{name} is present in the terminal description, @code{tgetflag} +returns 1; otherwise, it returns 0. + +@item tgetstr +Use @code{tgetstr} to get a string value. It returns a pointer to a +string which is the capability value, or a null pointer if the +capability is not present in the terminal description. + +There are two ways @code{tgetstr} can find space to store the string value: + +@itemize @bullet +@item +You can ask @code{tgetstr} to allocate the space. Pass a null +pointer for the argument @var{area}, and @code{tgetstr} will use +@code{malloc} to allocate storage big enough for the value. +Termcap will never free this storage or refer to it again; you +should free it when you are finished with it. + +This method is more robust, since there is no need to guess how +much space is needed. But it is supported only by the GNU +termcap library. + +@item +You can provide the space. Provide for the argument @var{area} the +address of a pointer variable of type @code{char *}. Before calling +@code{tgetstr}, initialize the variable to point at available space. +Then @code{tgetstr} will store the string value in that space and will +increment the pointer variable to point after the space that has been +used. You can use the same pointer variable for many calls to +@code{tgetstr}. + +There is no way to determine how much space is needed for a single +string, and no way for you to prevent or handle overflow of the area +you have provided. However, you can be sure that the total size of +all the string values you will obtain from the terminal description is +no greater than the size of the description (unless you get the same +capability twice). You can determine that size with @code{strlen} on +the buffer you provided to @code{tgetent}. See below for an example. + +Providing the space yourself is the only method supported by the Unix +version of termcap. +@end itemize +@end table + +Note that you do not have to specify a terminal type or terminal +description for the interrogation functions. They automatically use the +description found by the most recent call to @code{tgetent}. + +Here is an example of interrogating a terminal description for various +capabilities, with conditionals to select between the Unix and GNU methods +of providing buffer space. + +@example +char *tgetstr (); + +char *cl_string, *cm_string; +int height; +int width; +int auto_wrap; + +char PC; /* For tputs. */ +char *BC; /* For tgoto. */ +char *UP; + +interrogate_terminal () +@{ +#ifdef UNIX + /* Here we assume that an explicit term_buffer + was provided to tgetent. */ + char *buffer + = (char *) malloc (strlen (term_buffer)); +#define BUFFADDR &buffer +#else +#define BUFFADDR 0 +#endif + + char *temp; + + /* Extract information we will use. */ + cl_string = tgetstr ("cl", BUFFADDR); + cm_string = tgetstr ("cm", BUFFADDR); + auto_wrap = tgetflag ("am"); + height = tgetnum ("li"); + width = tgetnum ("co"); + + /* Extract information that termcap functions use. */ + temp = tgetstr ("pc", BUFFADDR); + PC = temp ? *temp : 0; + BC = tgetstr ("le", BUFFADDR); + UP = tgetstr ("up", BUFFADDR); +@} +@end example + +@noindent +@xref{Padding}, for information on the variable @code{PC}. @xref{Using +Parameters}, for information on @code{UP} and @code{BC}. + +@node Initialize, Padding, Interrogate, Library +@section Initialization for Use of Termcap +@cindex terminal flags (kernel) + +Before starting to output commands to a terminal using termcap, +an application program should do two things: + +@itemize @bullet +@item +Initialize various global variables which termcap library output +functions refer to. These include @code{PC} and @code{ospeed} for +padding (@pxref{Output Padding}) and @code{UP} and @code{BC} for +cursor motion (@pxref{tgoto}).@refill + +@item +Tell the kernel to turn off alteration and padding of horizontal-tab +characters sent to the terminal. +@end itemize + +To turn off output processing in Berkeley Unix you would use @code{ioctl} +with code @code{TIOCLSET} to set the bit named @code{LLITOUT}, and clear +the bits @code{ANYDELAY} using @code{TIOCSETN}. In POSIX or System V, you +must clear the bit named @code{OPOST}. Refer to the system documentation +for details.@refill + +If you do not set the terminal flags properly, some older terminals will +not work. This is because their commands may contain the characters that +normally signify newline, carriage return and horizontal tab---characters +which the kernel thinks it ought to modify before output. + +When you change the kernel's terminal flags, you must arrange to restore +them to their normal state when your program exits. This implies that the +program must catch fatal signals such as @code{SIGQUIT} and @code{SIGINT} +and restore the old terminal flags before actually terminating. + +Modern terminals' commands do not use these special characters, so if you +do not care about problems with old terminals, you can leave the kernel's +terminal flags unaltered. + +@node Padding, Parameters, Initialize, Library +@section Padding +@cindex padding + +@dfn{Padding} means outputting null characters following a terminal display +command that takes a long time to execute. The terminal description says +which commands require padding and how much; the function @code{tputs}, +described below, outputs a terminal command while extracting from it the +padding information, and then outputs the padding that is necessary. + +@menu +* Why Pad:: Explanation of padding. +* Not Enough:: When there is not enough padding. +* Describe Padding:: The data base says how much padding a terminal needs. +* Output Padding:: Using @code{tputs} to output the needed padding. +@end menu + +@node Why Pad, Not Enough, , Padding +@subsection Why Pad, and How + +Most types of terminal have commands that take longer to execute than they +do to send over a high-speed line. For example, clearing the screen may +take 20msec once the entire command is received. During that time, on a +9600 bps line, the terminal could receive about 20 additional output +characters while still busy clearing the screen. Every terminal has a +certain amount of buffering capacity to remember output characters that +cannot be processed yet, but too many slow commands in a row can cause the +buffer to fill up. Then any additional output that cannot be processed +immediately will be lost. + +To avoid this problem, we normally follow each display command with enough +useless charaters (usually null characters) to fill up the time that the +display command needs to execute. This does the job if the terminal throws +away null characters without using up space in the buffer (which most +terminals do). If enough padding is used, no output can ever be lost. The +right amount of padding avoids loss of output without slowing down +operation, since the time used to transmit padding is time that nothing +else could be done. + +The number of padding characters needed for an operation depends on the +line speed. In fact, it is proportional to the line speed. A 9600 baud +line transmits about one character per msec, so the clear screen command in +the example above would need about 20 characters of padding. At 1200 baud, +however, only about 3 characters of padding are needed to fill up 20msec. + +@node Not Enough, Describe Padding, Why Pad, Padding +@subsection When There Is Not Enough Padding + +There are several common manifestations of insufficient padding. + +@itemize @bullet +@item +Emacs displays @samp{I-search: ^Q-} at the bottom of the screen. + +This means that the terminal thought its buffer was getting full of +display commands, so it tried to tell the computer to stop sending +any. + +@item +The screen is garbled intermittently, or the details of garbling vary +when you repeat the action. (A garbled screen could be due to a +command which is simply incorrect, or to user option in the terminal +which doesn't match the assumptions of the terminal description, but +this usually leads to reproducible failure.) + +This means that the buffer did get full, and some commands were lost. +Many changeable factors can change which ones are lost. + +@item +Screen is garbled at high output speeds but not at low speeds. +Padding problems nearly always go away at low speeds, usually even at +1200 baud. + +This means that a high enough speed permits commands to arrive faster +than they can be executed. +@end itemize + +Although any obscure command on an obscure terminal might lack padding, +in practice problems arise most often from the clearing commands +@samp{cl} and @samp{cd} (@pxref{Clearing}), the scrolling commands +@samp{sf} and @samp{sr} (@pxref{Scrolling}), and the line insert/delete +commands @samp{al} and @samp{dl} (@pxref{Insdel Line}). + +Occasionally the terminal description fails to define @samp{sf} and some +programs will use @samp{do} instead, so you may get a problem with +@samp{do}. If so, first define @samp{sf} just like @samp{do}, then +add some padding to @samp{sf}. + +The best strategy is to add a lot of padding at first, perhaps 200 msec. +This is much more than enough; in fact, it should cause a visible slowdown. +(If you don't see a slowdown, the change has not taken effect; +@pxref{Changing}.) If this makes the problem go away, you have found the +right place to add padding; now reduce the amount until the problem comes +back, then increase it again. If the problem remains, either it is in some +other capability or it is not a matter of padding at all. + +Keep in mind that on many terminals the correct padding for insert/delete +line or for scrolling is cursor-position dependent. If you get problems +from scrolling a large region of the screen but not from scrolling a small +part (just a few lines moving), it may mean that fixed padding should be +replaced with position-dependent padding. + +@node Describe Padding, Output Padding, Not Enough, Padding +@subsection Specifying Padding in a Terminal Description + +In the terminal description, the amount of padding required by each display +command is recorded as a sequence of digits at the front of the command. +These digits specify the padding time in milliseconds (msec). They can be +followed optionally by a decimal point and one more digit, which is a +number of tenths of msec. + +Sometimes the padding needed by a command depends on the cursor position. +For example, the time taken by an ``insert line'' command is usually +proportional to the number of lines that need to be moved down or cleared. +An asterisk (@samp{*}) following the padding time says that the time +should be multiplied by the number of screen lines affected by the command. + +@example +:al=1.3*\E[L: +@end example + +@noindent +is used to describe the ``insert line'' command for a certain terminal. +The padding required is 1.3 msec per line affected. The command itself is +@samp{@key{ESC} [ L}. + +The padding time specified in this way tells @code{tputs} how many pad +characters to output. @xref{Output Padding}. + +Two special capability values affect padding for all commands. These are +the @samp{pc} and @samp{pb}. The variable @samp{pc} specifies the +character to pad with, and @samp{pb} the speed below which no padding is +needed. The defaults for these variables, a null character and 0, +are correct for most terminals. @xref{Pad Specs}. + +@node Output Padding, , Describe Padding, Padding +@subsection Performing Padding with @code{tputs} +@cindex line speed + +@findex tputs +Use the termcap function @code{tputs} to output a string containing an +optional padding spec of the form described above (@pxref{Describe +Padding}). The function @code{tputs} strips off and decodes the padding +spec, outputs the rest of the string, and then outputs the appropriate +padding. Here is its declaration in ANSI C: + +@example +char PC; +short ospeed; + +int tputs (char *@var{string}, int @var{nlines}, int (*@var{outfun}) ()); +@end example + +Here @var{string} is the string (including padding spec) to be output; +@var{nlines} is the number of lines affected by the operation, which is +used to multiply the amount of padding if the padding spec ends with a +@samp{*}. Finally, @var{outfun} is a function (such as @code{fputchar}) +that is called to output each character. When actually called, +@var{outfun} should expect one argument, a character. + +@vindex ospeed +@vindex PC +The operation of @code{tputs} is controlled by two global variables, +@code{ospeed} and @code{PC}. The value of @code{ospeed} is supposed to be +the terminal output speed, encoded as in the @code{ioctl} system call which +gets the speed information. This is needed to compute the number of +padding characters. The value of @code{PC} is the character used for +padding. + +You are responsible for storing suitable values into these variables before +using @code{tputs}. The value stored into the @code{PC} variable should be +taken from the @samp{pc} capability in the terminal description (@pxref{Pad +Specs}). Store zero in @code{PC} if there is no @samp{pc} +capability.@refill + +The argument @var{nlines} requires some thought. Normally, it should be +the number of lines whose contents will be cleared or moved by the command. +For cursor motion commands, or commands that do editing within one line, +use the value 1. For most commands that affect multiple lines, such as +@samp{al} (insert a line) and @samp{cd} (clear from the cursor to the end +of the screen), @var{nlines} should be the screen height minus the current +vertical position (origin 0). For multiple insert and scroll commands such +as @samp{AL} (insert multiple lines), that same value for @var{nlines} is +correct; the number of lines being inserted is @i{not} correct.@refill + +If a ``scroll window'' feature is used to reduce the number of lines +affected by a command, the value of @var{nlines} should take this into +account. This is because the delay time required depends on how much work +the terminal has to do, and the scroll window feature reduces the work. +@xref{Scrolling}. + +Commands such as @samp{ic} and @samp{dc} (insert or delete characters) are +problematical because the padding needed by these commands is proportional +to the number of characters affected, which is the number of columns from +the cursor to the end of the line. It would be nice to have a way to +specify such a dependence, and there is no need for dependence on vertical +position in these commands, so it is an obvious idea to say that for these +commands @var{nlines} should really be the number of columns affected. +However, the definition of termcap clearly says that @var{nlines} is always +the number of lines affected, even in this case, where it is always 1. It +is not easy to change this rule now, because too many programs and terminal +descriptions have been written to follow it. + +Because @var{nlines} is always 1 for the @samp{ic} and @samp{dc} strings, +there is no reason for them to use @samp{*}, but some of them do. These +should be corrected by deleting the @samp{*}. If, some day, such entries +have disappeared, it may be possible to change to a more useful convention +for the @var{nlines} argument for these operations without breaking any +programs. + +@node Parameters, , Padding, Library +@section Filling In Parameters +@cindex parameters + +Some terminal control strings require numeric @dfn{parameters}. For +example, when you move the cursor, you need to say what horizontal and +vertical positions to move it to. The value of the terminal's @samp{cm} +capability, which says how to move the cursor, cannot simply be a string of +characters; it must say how to express the cursor position numbers and +where to put them within the command. + +The specifications of termcap include conventions as to which string-valued +capabilities require parameters, how many parameters, and what the +parameters mean; for example, it defines the @samp{cm} string to take +two parameters, the vertical and horizontal positions, with 0,0 being the +upper left corner. These conventions are described where the individual +commands are documented. + +Termcap also defines a language used within the capability definition for +specifying how and where to encode the parameters for output. This language +uses character sequences starting with @samp{%}. (This is the same idea as +@code{printf}, but the details are different.) The language for parameter +encoding is described in this section. + +A program that is doing display output calls the functions @code{tparam} or +@code{tgoto} to encode parameters according to the specifications. These +functions produce a string containing the actual commands to be output (as +well a padding spec which must be processed with @code{tputs}; +@pxref{Padding}). + +@menu +* Encode Parameters:: The language for encoding parameters. +* Using Parameters:: Outputting a string command with parameters. +@end menu + +@node Encode Parameters, Using Parameters, , Parameters +@subsection Describing the Encoding +@cindex % + +A terminal command string that requires parameters contains special +character sequences starting with @samp{%} to say how to encode the +parameters. These sequences control the actions of @code{tparam} and +@code{tgoto}. + +The parameters values passed to @code{tparam} or @code{tgoto} are +considered to form a vector. A pointer into this vector determines +the next parameter to be processed. Some of the @samp{%}-sequences +encode one parameter and advance the pointer to the next parameter. +Other @samp{%}-sequences alter the pointer or alter the parameter +values without generating output. + +For example, the @samp{cm} string for a standard ANSI terminal is written +as @samp{\E[%i%d;%dH}. (@samp{\E} stands for @key{ESC}.) @samp{cm} by +convention always requires two parameters, the vertical and horizontal goal +positions, so this string specifies the encoding of two parameters. Here +@samp{%i} increments the two values supplied, and each @samp{%d} encodes +one of the values in decimal. If the cursor position values 20,58 are +encoded with this string, the result is @samp{\E[21;59H}. + +First, here are the @samp{%}-sequences that generate output. Except for +@samp{%%}, each of them encodes one parameter and advances the pointer +to the following parameter. + +@table @samp +@item %% +Output a single @samp{%}. This is the only way to represent a literal +@samp{%} in a terminal command with parameters. @samp{%%} does not +use up a parameter. + +@item %d +As in @code{printf}, output the next parameter in decimal. + +@item %2 +Like @samp{%02d} in @code{printf}: output the next parameter in +decimal, and always use at least two digits. + +@item %3 +Like @samp{%03d} in @code{printf}: output the next parameter in +decimal, and always use at least three digits. Note that @samp{%4} +and so on are @emph{not} defined. + +@item %. +Output the next parameter as a single character whose ASCII code is +the parameter value. Like @samp{%c} in @code{printf}. + +@item %+@var{char} +Add the next parameter to the character @var{char}, and output the +resulting character. For example, @samp{%+ } represents 0 as a space, +1 as @samp{!}, etc. +@end table + +The following @samp{%}-sequences specify alteration of the parameters +(their values, or their order) rather than encoding a parameter for output. +They generate no output; they are used only for their side effects +on the parameters. Also, they do not advance the ``next parameter'' pointer +except as explicitly stated. Only @samp{%i}, @samp{%r} and @samp{%>} are +defined in standard Unix termcap. The others are GNU extensions.@refill + +@table @samp +@item %i +Increment the next two parameters. This is used for terminals that +expect cursor positions in origin 1. For example, @samp{%i%d,%d} would +output two parameters with @samp{1} for 0, @samp{2} for 1, etc. + +@item %r +Interchange the next two parameters. This is used for terminals whose +cursor positioning command expects the horizontal position first. + +@item %s +Skip the next parameter. Do not output anything. + +@item %b +Back up one parameter. The last parameter used will become once again +the next parameter to be output, and the next output command will use +it. Using @samp{%b} more than once, you can back up any number of +parameters, and you can refer to each parameter any number of times. + +@item %>@var{c1}@var{c2} +Conditionally increment the next parameter. Here @var{c1} and +@var{c2} are characters which stand for their ASCII codes as numbers. +If the next parameter is greater than the ASCII code of @var{c1}, the +ASCII code of @var{c2} is added to it.@refill + +@item %a @var{op} @var{type} @var{pos} +Perform arithmetic on the next parameter, do not use it up, and do not +output anything. Here @var{op} specifies the arithmetic operation, +while @var{type} and @var{pos} together specify the other operand. + +Spaces are used above to separate the operands for clarity; the spaces +don't appear in the data base, where this sequence is exactly five +characters long. + +The character @var{op} says what kind of arithmetic operation to +perform. It can be any of these characters: + +@table @samp +@item = +assign a value to the next parameter, ignoring its old value. +The new value comes from the other operand. + +@item + +add the other operand to the next parameter. + +@item - +subtract the other operand from the next parameter. + +@item * +multiply the next parameter by the other operand. + +@item / +divide the next parameter by the other operand. +@end table + +The ``other operand'' may be another parameter's value or a constant; +the character @var{type} says which. It can be: + +@table @samp +@item p +Use another parameter. The character @var{pos} says which +parameter to use. Subtract 64 from its ASCII code to get the +position of the desired parameter relative to this one. Thus, +the character @samp{A} as @var{pos} means the parameter after the +next one; the character @samp{?} means the parameter before the +next one. + +@item c +Use a constant value. The character @var{pos} specifies the +value of the constant. The 0200 bit is cleared out, so that 0200 +can be used to represent zero. +@end table +@end table + +The following @samp{%}-sequences are special purpose hacks to compensate +for the weird designs of obscure terminals. They modify the next parameter +or the next two parameters but do not generate output and do not use up any +parameters. @samp{%m} is a GNU extension; the others are defined in +standard Unix termcap. + +@table @samp +@item %n +Exclusive-or the next parameter with 0140, and likewise the parameter +after next. + +@item %m +Complement all the bits of the next parameter and the parameter after next. + +@item %B +Encode the next parameter in BCD. It alters the value of the +parameter by adding six times the quotient of the parameter by ten. +Here is a C statement that shows how the new value is computed: + +@example +@var{parm} = (@var{parm} / 10) * 16 + @var{parm} % 10; +@end example + +@item %D +Transform the next parameter as needed by Delta Data terminals. +This involves subtracting twice the remainder of the parameter by 16. + +@example +@var{parm} -= 2 * (@var{parm} % 16); +@end example +@end table + +@node Using Parameters, , Encode Parameters, Parameters +@subsection Sending Display Commands with Parameters + +The termcap library functions @code{tparam} and @code{tgoto} serve as the +analog of @code{printf} for terminal string parameters. The newer function +@code{tparam} is a GNU extension, more general but missing from Unix +termcap. The original parameter-encoding function is @code{tgoto}, which +is preferable for cursor motion. + +@menu +* tparam:: The general case, for GNU termcap only. +* tgoto:: The special case of cursor motion. +@end menu + +@node tparam, tgoto, , Using Parameters +@subsubsection @code{tparam} + +@findex tparam +The function @code{tparam} can encode display commands with any number of +parameters and allows you to specify the buffer space. It is the preferred +function for encoding parameters for all but the @samp{cm} capability. Its +ANSI C declaration is as follows: + +@smallexample +char *tparam (char *@var{ctlstring}, char *@var{buffer}, int @var{size}, int @var{parm1},...) +@end smallexample + +The arguments are a control string @var{ctlstring} (the value of a terminal +capability, presumably), an output buffer @var{buffer} and @var{size}, and +any number of integer parameters to be encoded. The effect of +@code{tparam} is to copy the control string into the buffer, encoding +parameters according to the @samp{%} sequences in the control string. + +You describe the output buffer by its address, @var{buffer}, and its size +in bytes, @var{size}. If the buffer is not big enough for the data to be +stored in it, @code{tparam} calls @code{malloc} to get a larger buffer. In +either case, @code{tparam} returns the address of the buffer it ultimately +uses. If the value equals @var{buffer}, your original buffer was used. +Otherwise, a new buffer was allocated, and you must free it after you are +done with printing the results. If you pass zero for @var{size} and +@var{buffer}, @code{tparam} always allocates the space with @code{malloc}. + +All capabilities that require parameters also have the ability to specify +padding, so you should use @code{tputs} to output the string produced by +@code{tparam}. @xref{Padding}. Here is an example. + +@example +@{ +char *buf; +char buffer[40]; + +buf = tparam (command, buffer, 40, parm); +tputs (buf, 1, fputchar); +if (buf != buffer) +free (buf); +@} +@end example + +If a parameter whose value is zero is encoded with @samp{%.}-style +encoding, the result is a null character, which will confuse @code{tputs}. +This would be a serious problem, but luckily @samp{%.} encoding is used +only by a few old models of terminal, and only for the @samp{cm} +capability. To solve the problem, use @code{tgoto} rather than +@code{tparam} to encode the @samp{cm} capability.@refill + +@node tgoto, , tparam, Using Parameters +@subsubsection @code{tgoto} + +@findex tgoto +The special case of cursor motion is handled by @code{tgoto}. There +are two reasons why you might choose to use @code{tgoto}: + +@itemize @bullet +@item +For Unix compatibility, because Unix termcap does not have @code{tparam}. + +@item +For the @samp{cm} capability, since @code{tgoto} has a special feature +to avoid problems with null characters, tabs and newlines on certain old +terminal types that use @samp{%.} encoding for that capability. +@end itemize + +Here is how @code{tgoto} might be declared in ANSI C: + +@example +char *tgoto (char *@var{cstring}, int @var{hpos}, int @var{vpos}) +@end example + +There are three arguments, the terminal description's @samp{cm} string and +the two cursor position numbers; @code{tgoto} computes the parametrized +string in an internal static buffer and returns the address of that buffer. +The next time you use @code{tgoto} the same buffer will be reused. + +@vindex UP +@vindex BC +Parameters encoded with @samp{%.} encoding can generate null characters, +tabs or newlines. These might cause trouble: the null character because +@code{tputs} would think that was the end of the string, the tab because +the kernel or other software might expand it into spaces, and the newline +becaue the kernel might add a carriage-return, or padding characters +normally used for a newline. To prevent such problems, @code{tgoto} is +careful to avoid these characters. Here is how this works: if the target +cursor position value is such as to cause a problem (that is to say, zero, +nine or ten), @code{tgoto} increments it by one, then compensates by +appending a string to move the cursor back or up one position. + +The compensation strings to use for moving back or up are found in global +variables named @code{BC} and @code{UP}. These are actual external C +variables with upper case names; they are declared @code{char *}. It is up +to you to store suitable values in them, normally obtained from the +@samp{le} and @samp{up} terminal capabilities in the terminal description +with @code{tgetstr}. Alternatively, if these two variables are both zero, +the feature of avoiding nulls, tabs and newlines is turned off. + +It is safe to use @code{tgoto} for commands other than @samp{cm} only if +you have stored zero in @code{BC} and @code{UP}. + +Note that @code{tgoto} reverses the order of its operands: the horizontal +position comes before the vertical position in the arguments to +@code{tgoto}, even though the vertical position comes before the horizontal +in the parameters of the @samp{cm} string. If you use @code{tgoto} with a +command such as @samp{AL} that takes one parameter, you must pass the +parameter to @code{tgoto} as the ``vertical position''.@refill + +@node Data Base, Capabilities, Library, Top +@chapter The Format of the Data Base + +The termcap data base of terminal descriptions is stored in the file +@file{/etc/termcap}. It contains terminal descriptions, blank lines, and +comments. + +A terminal description starts with one or more names for the terminal type. +The information in the description is a series of @dfn{capability names} +and values. The capability names have standard meanings +(@pxref{Capabilities}) and their values describe the terminal. + +@menu +* Format:: Overall format of a terminal description. +* Capability Format:: Format of capabilities within a description. +* Naming:: Naming conventions for terminal types. +* Inheriting:: Inheriting part of a description from +a related terminal type. +* Changing:: When changes in the data base take effect. +@end menu + +@node Format, Capability Format, , Data Base +@section Terminal Description Format +@cindex description format + +Aside from comments (lines starting with @samp{#}, which are ignored), each +nonblank line in the termcap data base is a terminal description. +A terminal description is nominally a single line, but it can be split +into multiple lines by inserting the two characters @samp{\ newline}. +This sequence is ignored wherever it appears in a description. + +The preferred way to split the description is between capabilities: insert +the four characters @samp{: \ newline tab} immediately before any colon. +This allows each sub-line to start with some indentation. This works +because, after the @samp{\ newline} are ignored, the result is @samp{: tab +:}; the first colon ends the preceding capability and the second colon +starts the next capability. If you split with @samp{\ newline} alone, you +may not add any indentation after them. + +Here is a real example of a terminal description: + +@example +dw|vt52|DEC vt52:\ + :cr=^M:do=^J:nl=^J:bl=^G:\ + :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ + :cm=\EY%+ %+ :co#80:li#24:\ + :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ + :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: +@end example + +Each terminal description begins with several names for the terminal type. +The names are separated by @samp{|} characters, and a colon ends the last +name. The first name should be two characters long; it exists only for the +sake of very old Unix systems and is never used in modern systems. The +last name should be a fully verbose name such as ``DEC vt52'' or ``Ann +Arbor Ambassador with 48 lines''. The other names should include whatever +the user ought to be able to specify to get this terminal type, such as +@samp{vt52} or @samp{aaa-48}. @xref{Naming}, for information on how to +choose terminal type names. + +After the terminal type names come the terminal capabilities, separated by +colons and with a colon after the last one. Each capability has a +two-letter name, such as @samp{cm} for ``cursor motion string'' or @samp{li} +for ``number of display lines''. + +@node Capability Format, Naming, Format, Data Base +@section Writing the Capabilities + +There are three kinds of capabilities: flags, numbers, and strings. Each +kind has its own way of being written in the description. Each defined +capability has by convention a particular kind of value; for example, +@samp{li} always has a numeric value and @samp{cm} always a string value. + +A flag capability is thought of as having a boolean value: the value is +true if the capability is present, false if not. When the capability is +present, just write its name between two colons. + +A numeric capability has a value which is a nonnegative number. Write the +capability name, a @samp{#}, and the number, between two colons. For +example, @samp{@dots{}:li#48:@dots{}} is how you specify the @samp{li} +capability for 48 lines.@refill + +A string-valued capability has a value which is a sequence of characters. +Usually these are the characters used to perform some display operation. +Write the capability name, a @samp{=}, and the characters of the value, +between two colons. For example, @samp{@dots{}:cm=\E[%i%d;%dH:@dots{}} is +how the cursor motion command for a standard ANSI terminal would be +specified.@refill + +Special characters in the string value can be expressed using +@samp{\}-escape sequences as in C; in addition, @samp{\E} stands for +@key{ESC}. @samp{^} is also a kind of escape character; @samp{^} followed +by @var{char} stands for the control-equivalent of @var{char}. Thus, +@samp{^a} stands for the character control-a, just like @samp{\001}. +@samp{\} and @samp{^} themselves can be represented as @samp{\\} and +@samp{\^}.@refill + +To include a colon in the string, you must write @samp{\072}. You might +ask, ``Why can't @samp{\:} be used to represent a colon?'' The reason is +that the interrogation functions do not count slashes while looking for a +capability. Even if @samp{:ce=ab\:cd:} were interpreted as giving the +@samp{ce} capability the value @samp{ab:cd}, it would also appear to define +@samp{cd} as a flag. + +The string value will often contain digits at the front to specify padding +(@pxref{Padding}) and/or @samp{%}-sequences within to specify how to encode +parameters (@pxref{Parameters}). Although these things are not to be +output literally to the terminal, they are considered part of the value of +the capability. They are special only when the string value is processed +by @code{tputs}, @code{tparam} or @code{tgoto}. By contrast, @samp{\} and +@samp{^} are considered part of the syntax for specifying the characters +in the string. + +Let's look at the VT52 example again: + +@example +dw|vt52|DEC vt52:\ + :cr=^M:do=^J:nl=^J:bl=^G:\ + :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\ + :cm=\EY%+ %+ :co#80:li#24:\ + :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\ + :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H: +@end example + +Here we see the numeric-valued capabilities @samp{co} and @samp{li}, the +flags @samp{bs} and @samp{pt}, and many string-valued capabilities. Most +of the strings start with @key{ESC} represented as @samp{\E}. The rest +contain control characters represented using @samp{^}. The meanings of the +individual capabilities are defined elsewhere (@pxref{Capabilities}). + +@node Naming, Inheriting, Capability Format, Data Base +@section Terminal Type Name Conventions +@cindex names of terminal types + +There are conventions for choosing names of terminal types. For one thing, +all letters should be in lower case. The terminal type for a terminal in +its most usual or most fundamental mode of operation should not have a +hyphen in it. + +If the same terminal has other modes of operation which require +different terminal descriptions, these variant descriptions are given +names made by adding suffixes with hyphens. Such alternate descriptions +are used for two reasons: + +@itemize @bullet +@item +When the terminal has a switch that changes its behavior. Since the +computer cannot tell how the switch is set, the user must tell the +computer by choosing the appropriate terminal type name. + +@cindex wrapping +For example, the VT-100 has a setup flag that controls whether the +cursor wraps at the right margin. If this flag is set to ``wrap'', +you must use the terminal type @samp{vt100-am}. Otherwise you must +use @samp{vt100-nam}. Plain @samp{vt100} is defined as a synonym for +either @samp{vt100-am} or @samp{vt100-nam} depending on the +preferences of the local site.@refill + +The standard suffix @samp{-am} stands for ``automatic margins''. + +@item +To give the user a choice in how to use the terminal. This is done +when the terminal has a switch that the computer normally controls. + +@cindex screen size +For example, the Ann Arbor Ambassador can be configured with many +screen sizes ranging from 20 to 60 lines. Fewer lines make bigger +characters but more lines let you see more of what you are editing. +As a result, users have different preferences. Therefore, termcap +provides terminal types for many screen sizes. If you choose type +@samp{aaa-30}, the terminal will be configured to use 30 lines; if you +choose @samp{aaa-48}, 48 lines will be used, and so on. +@end itemize + +Here is a list of standard suffixes and their conventional meanings: + +@table @samp +@item -w +Short for ``wide''. This is a mode that gives the terminal more +columns than usual. This is normally a user option. + +@item -am +``Automatic margins''. This is an alternate description for use when +the terminal's margin-wrap switch is on; it contains the @samp{am} +flag. The implication is that normally the switch is off and the +usual description for the terminal says that the switch is off. + +@item -nam +``No automatic margins''. The opposite of @samp{-am}, this names an +alternative description which lacks the @samp{am} flag. This implies +that the terminal is normally operated with the margin-wrap switch +turned on, and the normal description of the terminal says so. + +@item -na +``No arrows''. This terminal description initializes the terminal to +keep its arrow keys in local mode. This is a user option. + +@item -rv +``Reverse video''. This terminal description causes text output for +normal video to appear as reverse, and text output for reverse video +to come out as normal. Often this description differs from the usual +one by interchanging the two strings which turn reverse video on and +off.@refill + +This is a user option; you can choose either the ``reverse video'' +variant terminal type or the normal terminal type, and termcap will +obey. + +@item -s +``Status''. Says to enable use of a status line which ordinary output +does not touch (@pxref{Status Line}). + +Some terminals have a special line that is used only as a status line. +For these terminals, there is no need for an @samp{-s} variant; the +status line commands should be defined by default. On other +terminals, enabling a status line means removing one screen line from +ordinary use and reducing the effective screen height. For these +terminals, the user can choose the @samp{-s} variant type to request +use of a status line. + +@item -@var{nlines} +Says to operate with @var{nlines} lines on the screen, for terminals +such as the Ambassador which provide this as an option. Normally this +is a user option; by choosing the terminal type, you control how many +lines termcap will use. + +@item -@var{npages}p +Says that the terminal has @var{npages} pages worth of screen memory, +for terminals where this is a hardware option. + +@item -unk +Says that description is not for direct use, but only for reference in +@samp{tc} capabilities. Such a description is a kind of subroutine, +because it describes the common characteristics of several variant +descriptions that would use other suffixes in place of @samp{-unk}. +@end table + +@node Inheriting, Changing, Naming, Data Base +@section Inheriting from Related Descriptions + +@cindex inheritance +When two terminal descriptions are similar, their identical parts do not +need to be given twice. Instead, one of the two can be defined in terms of +the other, using the @samp{tc} capability. We say that one description +@dfn{refers to} the other, or @dfn{inherits from} the other. + +The @samp{tc} capability must be the last one in the terminal description, +and its value is a string which is the name of another terminal type which +is referred to. For example, + +@example +N9|aaa|ambassador|aaa-30|ann arbor ambassador/30 lines:\ + :ti=\E[2J\E[30;0;0;30p:\ + :te=\E[60;0;0;30p\E[30;1H\E[J:\ + :li#30:tc=aaa-unk: +@end example + +@noindent +defines the terminal type @samp{aaa-30} (also known as plain @samp{aaa}) in +terms of @samp{aaa-unk}, which defines everything about the Ambassador that +is independent of screen height. The types @samp{aaa-36}, @samp{aaa-48} +and so on for other screen heights are likewise defined to inherit from +@samp{aaa-unk}. + +The capabilities overridden by @samp{aaa-30} include @samp{li}, which says +how many lines there are, and @samp{ti} and @samp{te}, which configure the +terminal to use that many lines. + +The effective terminal description for type @samp{aaa} consists of the text +shown above followed by the text of the description of @samp{aaa-unk}. The +@samp{tc} capability is handled automatically by @code{tgetent}, which +finds the description thus referenced and combines the two descriptions +(@pxref{Find}). Therefore, only the implementor of the terminal +descriptions needs to think about using @samp{tc}. Users and application +programmers do not need to be concerned with it. + +Since the reference terminal description is used last, capabilities +specified in the referring description override any specifications of the +same capabilities in the reference description. + +The referring description can cancel out a capability without specifying +any new value for it by means of a special trick. Write the capability in +the referring description, with the character @samp{@@} after the capability +name, as follows: + +@smallexample +NZ|aaa-30-nam|ann arbor ambassador/30 lines/no automatic-margins:\ + :am@@:tc=aaa-30: +@end smallexample + +@node Changing, , Inheriting, Data Base +@section When Changes in the Data Base Take Effect + +Each application program must read the terminal description from the +data base, so a change in the data base is effective for all jobs started +after the change is made. + +The change will usually have no effect on a job that have been in existence +since before the change. The program probably read the terminal description +once, when it was started, and is continuing to use what it read then. +If the program does not have a feature for reexamining the data base, then +you will need to run it again (probably killing the old job). + +If the description in use is coming from the @code{TERMCAP} environment +variable, then the data base file is effectively overridden, and changes in +it will have no effect until you change the @code{TERMCAP} variable as +well. For example, some users' @file{.login} files automatically copy the +terminal description into @code{TERMCAP} to speed startup of applications. +If you have done this, you will need to change the @code{TERMCAP} variable +to make the changed data base take effect. + +@node Capabilities, Summary, Data Base, Top +@chapter Definitions of the Terminal Capabilities + +This section is divided into many subsections, each for one aspect of +use of display terminals. For writing a display program, you usually need +only check the subsections for the operations you want to use. For writing +a terminal description, you must read each subsection and fill in the +capabilities described there. + +String capabilities that are display commands may require numeric +parameters (@pxref{Parameters}). Most such capabilities do not use +parameters. When a capability requires parameters, this is explicitly +stated at the beginning of its definition. In simple cases, the first or +second sentence of the definition mentions all the parameters, in the order +they should be given, using a name +@iftex +in italics +@end iftex +@ifinfo +in upper case +@end ifinfo +for each one. For example, the @samp{rp} capability is a command that +requires two parameters; its definition begins as follows: + +@quotation +String of commands to output a graphic character @var{c}, repeated @var{n} +times. +@end quotation + +In complex cases or when there are many parameters, they are described +explicitly. + +When a capability is described as obsolete, this means that programs should +not be written to look for it, but terminal descriptions should still be +written to provide it. + +When a capability is described as very obsolete, this means that it should +be omitted from terminal descriptions as well. + +@menu +* Basic:: Basic characteristics. +* Screen Size:: Screen size, and what happens when it changes. +* Cursor Motion:: Various ways to move the cursor. +* Wrapping:: What happens if you write a character in the last column. +* Scrolling:: Pushing text up and down on the screen. +* Windows:: Limiting the part of the window that output affects. +* Clearing:: Erasing one or many lines. +* Insdel Line:: Making new blank lines in mid-screen; deleting lines. +* Insdel Char:: Inserting and deleting characters within a line. +* Standout:: Highlighting some of the text. +* Underlining:: Underlining some of the text. +* Cursor Visibility:: Making the cursor more or less easy to spot. +* Bell:: Attracts user's attention; not localized on the screen. +* Keypad:: Recognizing when function keys or arrows are typed. +* Meta Key:: @key{META} acts like an extra shift key. +* Initialization:: Commands used to initialize or reset the terminal. +* Pad Specs:: Info for the kernel on how much padding is needed. +* Status Line:: A status line displays ``background'' information. +* Half-Line:: Moving by half-lines, for superscripts and subscripts. +* Printer:: Controlling auxiliary printers of display terminals. +@end menu + +@node Basic, Screen Size, , Capabilities +@section Basic Characteristics + +This section documents the capabilities that describe the basic and +nature of the terminal, and also those that are relevant to the output +of graphic characters. + +@table @samp +@item os +@kindex os +@cindex overstrike +Flag whose presence means that the terminal can overstrike. This +means that outputting a graphic character does not erase whatever was +present in the same character position before. The terminals that can +overstrike include printing terminals, storage tubes (all obsolete +nowadays), and many bit-map displays. + +@item eo +@kindex eo +Flag whose presence means that outputting a space erases a character +position even if the terminal supports overstriking. If this flag is +not present and overstriking is supported, output of a space has no +effect except to move the cursor. + +(On terminals that do not support overstriking, you can always assume +that outputting a space at a position erases whatever character was +previously displayed there.) + +@item gn +@kindex gn +@cindex generic terminal type +Flag whose presence means that this terminal type is a generic type +which does not really describe any particular terminal. Generic types +are intended for use as the default type assigned when the user +connects to the system, with the intention that the user should +specify what type he really has. One example of a generic type +is the type @samp{network}. + +Since the generic type cannot say how to do anything interesting with +the terminal, termcap-using programs will always find that the +terminal is too weak to be supported if the user has failed to specify +a real terminal type in place of the generic one. The @samp{gn} flag +directs these programs to use a different error message: ``You have +not specified your real terminal type'', rather than ``Your terminal +is not powerful enough to be used''. + +@item hc +@kindex hc +Flag whose presence means this is a hardcopy terminal. + +@item rp +@kindex rp +@cindex repeat output +String of commands to output a graphic character @var{c}, repeated @var{n} +times. The first parameter value is the ASCII code for the desired +character, and the second parameter is the number of times to repeat the +character. Often this command requires padding proportional to the +number of times the character is repeated. This effect can be had by +using parameter arithmetic with @samp{%}-sequences to compute the +amount of padding, then generating the result as a number at the front +of the string so that @code{tputs} will treat it as padding. + +@item hz +@kindex hz +Flag whose presence means that the ASCII character @samp{~} cannot be +output on this terminal because it is used for display commands. + +Programs handle this flag by checking all text to be output and +replacing each @samp{~} with some other character(s). If this is not +done, the screen will be thoroughly garbled. + +The old Hazeltine terminals that required such treatment are probably +very rare today, so you might as well not bother to support this flag. + +@item CC +@kindex CC +@cindex command character +String whose presence means the terminal has a settable command +character. The value of the string is the default command character +(which is usually @key{ESC}). + +All the strings of commands in the terminal description should be +written to use the default command character. If you are writing an +application program that changes the command character, use the +@samp{CC} capability to figure out how to translate all the display +commands to work with the new command character. + +Most programs have no reason to look at the @samp{CC} capability. + +@item xb +@kindex xb +@cindex Superbee +Flag whose presence identifies Superbee terminals which are unable to +transmit the characters @key{ESC} and @kbd{Control-C}. Programs which +support this flag are supposed to check the input for the code sequences +sent by the @key{F1} and @key{F2} keys, and pretend that @key{ESC} +or @kbd{Control-C} (respectively) had been read. But this flag is +obsolete, and not worth supporting. +@end table + +@node Screen Size, Cursor Motion, Basic, Capabilities +@section Screen Size +@cindex screen size + +A terminal description has two capabilities, @samp{co} and @samp{li}, +that describe the screen size in columns and lines. But there is more +to the question of screen size than this. + +On some operating systems the ``screen'' is really a window and the +effective width can vary. On some of these systems, @code{tgetnum} +uses the actual width of the window to decide what value to return for +the @samp{co} capability, overriding what is actually written in the +terminal description. On other systems, it is up to the application +program to check the actual window width using a system call. For +example, on BSD 4.3 systems, the system call @code{ioctl} with code +@code{TIOCGWINSZ} will tell you the current screen size. + +On all window systems, termcap is powerless to advise the application +program if the user resizes the window. Application programs must +deal with this possibility in a system-dependent fashion. On some +systems the C shell handles part of the problem by detecting changes +in window size and setting the @code{TERMCAP} environment variable +appropriately. This takes care of application programs that are +started subsequently. It does not help application programs already +running. + +On some systems, including BSD 4.3, all programs using a terminal get +a signal named @code{SIGWINCH} whenever the screen size changes. +Programs that use termcap should handle this signal by using +@code{ioctl TIOCGWINSZ} to learn the new screen size. + +@table @samp +@item co +@kindex co +@cindex screen size +Numeric value, the width of the screen in character positions. Even +hardcopy terminals normally have a @samp{co} capability. + +@item li +@kindex li +Numeric value, the height of the screen in lines. +@end table + +@node Cursor Motion, Wrapping, Screen Size, Capabilities +@section Cursor Motion +@cindex cursor motion + +Termcap assumes that the terminal has a @dfn{cursor}, a spot on the screen +where a visible mark is displayed, and that most display commands take +effect at the position of the cursor. It follows that moving the cursor +to a specified location is very important. + +There are many terminal capabilities for different cursor motion +operations. A terminal description should define as many as possible, but +most programs do not need to use most of them. One capability, @samp{cm}, +moves the cursor to an arbitrary place on the screen; this by itself is +sufficient for any application as long as there is no need to support +hardcopy terminals or certain old, weak displays that have only relative +motion commands. Use of other cursor motion capabilities is an +optimization, enabling the program to output fewer characters in some +common cases. + +If you plan to use the relative cursor motion commands in an application +program, you must know what the starting cursor position is. To do this, +you must keep track of the cursor position and update the records each +time anything is output to the terminal, including graphic characters. +In addition, it is necessary to know whether the terminal wraps after +writing in the rightmost column. @xref{Wrapping}. + +One other motion capability needs special mention: @samp{nw} moves the +cursor to the beginning of the following line, perhaps clearing all the +starting line after the cursor, or perhaps not clearing at all. This +capability is a least common denominator that is probably supported even by +terminals that cannot do most other things such as @samp{cm} or @samp{do}. +Even hardcopy terminals can support @samp{nw}. + +@table @asis +@item @samp{cm} +@kindex cm +String of commands to position the cursor at line @var{l}, column @var{c}. +Both parameters are origin-zero, and are defined relative to the +screen, not relative to display memory. + +All display terminals except a few very obsolete ones support @samp{cm}, +so it is acceptable for an application program to refuse to operate on +terminals lacking @samp{cm}. + +@item @samp{ho} +@kindex ho +@cindex home position +String of commands to move the cursor to the upper left corner of the +screen (this position is called the @dfn{home position}). In +terminals where the upper left corner of the screen is not the same as +the beginning of display memory, this command must go to the upper +left corner of the screen, not the beginning of display memory. + +Every display terminal supports this capability, and many application +programs refuse to operate if the @samp{ho} capability is missing. + +@item @samp{ll} +@kindex ll +String of commands to move the cursor to the lower left corner of the +screen. On some terminals, moving up from home position does this, +but programs should never assume that will work. Just output the +@samp{ll} string (if it is provided); if moving to home position and +then moving up is the best way to get there, the @samp{ll} command +will do that. + +@item @samp{cr} +@kindex cr +String of commands to move the cursor to the beginning of the line it +is on. If this capability is not specified, many programs assume +they can use the ASCII carriage return character for this. + +@item @samp{le} +@kindex le +String of commands to move the cursor left one column. Unless the +@samp{bw} flag capability is specified, the effect is undefined if the +cursor is at the left margin; do not use this command there. If +@samp{bw} is present, this command may be used at the left margin, and +it wraps the cursor to the last column of the preceding line. + +@item @samp{nd} +@kindex nd +String of commands to move the cursor right one column. The effect is +undefined if the cursor is at the right margin; do not use this +command there, not even if @samp{am} is present. + +@item @samp{up} +@kindex up +String of commands to move the cursor vertically up one line. The +effect of sending this string when on the top line is undefined; +programs should never use it that way. + +@item @samp{do} +@kindex do +String of commands to move the cursor vertically down one line. The +effect of sending this string when on the bottom line is undefined; +programs should never use it that way. + +Some programs do use @samp{do} to scroll up one line if used at the +bottom line, if @samp{sf} is not defined but @samp{sr} is. This is +only to compensate for certain old, incorrect terminal descriptions. +(In principle this might actually lead to incorrect behavior on other +terminals, but that seems to happen rarely if ever.) But the proper +solution is that the terminal description should define @samp{sf} as +well as @samp{do} if the command is suitable for scrolling. + +The original idea was that this string would not contain a newline +character and therefore could be used without disabling the kernel's +usual habit of converting of newline into a carriage-return newline +sequence. But many terminal descriptions do use newline in the +@samp{do} string, so this is not possible; a program which sends the +@samp{do} string must disable output conversion in the kernel +(@pxref{Initialize}). + +@item @samp{bw} +@kindex bw +Flag whose presence says that @samp{le} may be used in column zero +to move to the last column of the preceding line. If this flag +is not present, @samp{le} should not be used in column zero. + +@item @samp{nw} +@kindex nw +String of commands to move the cursor to start of next line, possibly +clearing rest of line (following the cursor) before moving. + +@item @samp{DO}, @samp{UP}, @samp{LE}, @samp{RI} +@kindex DO +@kindex LE +@kindex RI +@kindex UP +Strings of commands to move the cursor @var{n} lines down vertically, +up vertically, or @var{n} columns left or right. Do not attempt to +move past any edge of the screen with these commands; the effect of +trying that is undefined. Only a few terminal descriptions provide +these commands, and most programs do not use them. + +@item @samp{CM} +@kindex CM +String of commands to position the cursor at line @var{l}, column +@var{c}, relative to display memory. Both parameters are origin-zero. +This capability is present only in terminals where there is a +difference between screen-relative and memory-relative addressing, and +not even in all such terminals. + +@item @samp{ch} +@kindex ch +String of commands to position the cursor at column @var{c} in the +same line it is on. This is a special case of @samp{cm} in which the +vertical position is not changed. The @samp{ch} capability is +provided only when it is faster to output than @samp{cm} would be in +this special case. Programs should not assume most display terminals +have @samp{ch}. + +@item @samp{cv} +@kindex cv +String of commands to position the cursor at line @var{l} in the same +column. This is a special case of @samp{cm} in which the horizontal +position is not changed. The @samp{cv} capability is provided only +when it is faster to output than @samp{cm} would be in this special +case. Programs should not assume most display terminals have +@samp{cv}. + +@item @samp{sc} +@kindex sc +String of commands to make the terminal save the current cursor +position. Only the last saved position can be used. If this +capability is present, @samp{rc} should be provided also. Most +terminals have neither. + +@item @samp{rc} +@kindex rc +String of commands to make the terminal restore the last saved cursor +position. If this capability is present, @samp{sc} should be provided +also. Most terminals have neither. + +@item @samp{ff} +@kindex ff +String of commands to advance to the next page, for a hardcopy +terminal. + +@item @samp{ta} +@kindex ta +String of commands to move the cursor right to the next hardware tab +stop column. Missing if the terminal does not have any kind of +hardware tabs. Do not send this command if the kernel's terminal +modes say that the kernel is expanding tabs into spaces. + +@item @samp{bt} +@kindex bt +String of commands to move the cursor left to the previous hardware +tab stop column. Missing if the terminal has no such ability; many +terminals do not. Do not send this command if the kernel's terminal +modes say that the kernel is expanding tabs into spaces. +@end table + +The following obsolete capabilities should be included in terminal +descriptions when appropriate, but should not be looked at by new programs. + +@table @samp +@item nc +@kindex nc +Flag whose presence means the terminal does not support the ASCII +carriage return character as @samp{cr}. This flag is needed because +old programs assume, when the @samp{cr} capability is missing, that +ASCII carriage return can be used for the purpose. We use @samp{nc} +to tell the old programs that carriage return may not be used. + +New programs should not assume any default for @samp{cr}, so they need +not look at @samp{nc}. However, descriptions should contain @samp{nc} +whenever they do not contain @samp{cr}. + +@item xt +@kindex xt +Flag whose presence means that the ASCII tab character may not be used +for cursor motion. This flag exists because old programs assume, when +the @samp{ta} capability is missing, that ASCII tab can be used for +the purpose. We use @samp{xt} to tell the old programs not to use tab. + +New programs should not assume any default for @samp{ta}, so they need +not look at @samp{xt} in connection with cursor motion. Note that +@samp{xt} also has implications for standout mode (@pxref{Standout}). +It is obsolete in regard to cursor motion but not in regard to +standout. + +In fact, @samp{xt} means that the terminal is a Teleray 1061. + +@item bc +@kindex bc +Very obsolete alternative name for the @samp{le} capability. + +@item bs +@kindex bs +Flag whose presence means that the ASCII character backspace may be +used to move the cursor left. Obsolete; look at @samp{le} instead. + +@item nl +@kindex nl +Obsolete capability which is a string that can either be used to move +the cursor down or to scroll. The same string must scroll when used +on the bottom line and move the cursor when used on any other line. +New programs should use @samp{do} or @samp{sf}, and ignore @samp{nl}. + +If there is no @samp{nl} capability, some old programs assume they can +use the newline character for this purpose. These programs follow a +bad practice, but because they exist, it is still desirable to define +the @samp{nl} capability in a terminal description if the best way to +move down is @emph{not} a newline. +@end table + +@node Wrapping, Scrolling, Cursor Motion, Capabilities +@section Wrapping +@cindex wrapping + +@dfn{Wrapping} means moving the cursor from the right margin to the left +margin of the following line. Some terminals wrap automatically when a +graphic character is output in the last column, while others do not. Most +application programs that use termcap need to know whether the terminal +wraps. There are two special flag capabilities to describe what the +terminal does when a graphic character is output in the last column. + +@table @samp +@item am +@kindex am +Flag whose presence means that writing a character in the last column +causes the cursor to wrap to the beginning of the next line. + +If @samp{am} is not present, writing in the last column leaves the +cursor at the place where the character was written. + +Writing in the last column of the last line should be avoided on +terminals with @samp{am}, as it may or may not cause scrolling to +occur (@pxref{Scrolling}). Scrolling is surely not what you would +intend. + +If your program needs to check the @samp{am} flag, then it also needs +to check the @samp{xn} flag which indicates that wrapping happens in a +strange way. Many common terminals have the @samp{xn} flag. + +@item xn +@kindex xn +Flag whose presence means that the cursor wraps in a strange way. At +least two distinct kinds of strange behavior are known; the termcap +data base does not contain anything to distinguish the two. + +On Concept-100 terminals, output in the last column wraps the cursor +almost like an ordinary @samp{am} terminal. But if the next thing +output is a newline, it is ignored. + +DEC VT-100 terminals (when the wrap switch is on) do a different +strange thing: the cursor wraps only if the next thing output is +another graphic character. In fact, the wrap occurs when the +following graphic character is received by the terminal, before the +character is placed on the screen. + +On both of these terminals, after writing in the last column a +following graphic character will be displayed in the first column of +the following line. But the effect of relative cursor motion +characters such as newline or backspace at such a time depends on the +terminal. The effect of erase or scrolling commands also depends on +the terminal. You can't assume anything about what they will do on a +terminal that has @samp{xn}. So, to be safe, you should never do +these things at such a time on such a terminal. + +To be sure of reliable results on a terminal which has the @samp{xn} +flag, output a @samp{cm} absolute positioning command after writing in +the last column. Another safe thing to do is to output carriage-return +newline, which will leave the cursor at the beginning of the following +line. + +@item LP +@kindex LP +Flag whose presence means that it is safe to write in the last column of +the last line without worrying about undesired scrolling. @samp{LP} +indicates the DEC flavor of @samp{xn} strangeness. +@end table + +@node Scrolling, Windows, Wrapping, Capabilities +@section Scrolling +@cindex scrolling + +@dfn{Scrolling} means moving the contents of the screen up or down one or +more lines. Moving the contents up is @dfn{forward scrolling}; moving them +down is @dfn{reverse scrolling}. + +Scrolling happens after each line of output during ordinary output on most +display terminals. But in an application program that uses termcap for +random-access output, scrolling happens only when explicitly requested with +the commands in this section. + +Some terminals have a @dfn{scroll region} feature. This lets you limit +the effect of scrolling to a specified range of lines. Lines outside the +range are unaffected when scrolling happens. The scroll region feature +is available if either @samp{cs} or @samp{cS} is present. + +@table @samp +@item sf +@kindex sf +String of commands to scroll the screen one line up, assuming it is +output with the cursor at the beginning of the bottom line. + +@item sr +@kindex sr +String of commands to scroll the screen one line down, assuming it is +output with the cursor at the beginning of the top line. + +@item do +A few programs will try to use @samp{do} to do the work of @samp{sf}. +This is not really correct---it is an attempt to compensate for the +absence of a @samp{sf} command in some old terminal descriptions. + +Since these terminal descriptions do define @samp{sr}, perhaps at one +time the definition of @samp{do} was different and it could be used +for scrolling as well. But it isn't desirable to combine these two +functions in one capability, since scrolling often requires more +padding than simply moving the cursor down. Defining @samp{sf} and +@samp{do} separately allows you to specify the padding properly. +Also, all sources agree that @samp{do} should not be relied on to do +scrolling. + +So the best approach is to add @samp{sf} capabilities to the +descriptions of these terminals, copying the definition of @samp{do} +if that does scroll. + +@item SF +@kindex SF +String of commands to scroll the screen @var{n} lines up, assuming it +is output with the cursor at the beginning of the bottom line. + +@item SR +@kindex SR +String of commands to scroll the screen @var{n} lines down, assuming it +is output with the cursor at the beginning of the top line. + +@item cs +@kindex cs +String of commands to set the scroll region. This command takes two +parameters, @var{start} and @var{end}, which are the line numbers +(origin-zero) of the first line to include in the scroll region and of +the last line to include in it. When a scroll region is set, +scrolling is limited to the specified range of lines; lines outside +the range are not affected by scroll commands. + +Do not try to move the cursor outside the scroll region. The region +remains set until explicitly removed. To remove the scroll region, +use another @samp{cs} command specifying the full height of the +screen. + +The cursor position is undefined after the @samp{cs} command is set, +so position the cursor with @samp{cm} immediately afterward. + +@item cS +@kindex cS +String of commands to set the scroll region using parameters in +different form. The effect is the same as if @samp{cs} were used. +Four parameters are required: + +@enumerate +@item +Total number of lines on the screen. +@item +Number of lines above desired scroll region. +@item +Number of lines below (outside of) desired scroll region. +@item +Total number of lines on the screen, the same as the first parameter. +@end enumerate + +This capability is a GNU extension that was invented to allow the Ann +Arbor Ambassador's scroll-region command to be described; it could +also be done by putting non-Unix @samp{%}-sequences into a @samp{cs} +string, but that would have confused Unix programs that used the +@samp{cs} capability with the Unix termcap. Currently only GNU Emacs +uses the @samp{cS} capability. + +@item ns +@kindex ns +Flag which means that the terminal does not normally scroll for +ordinary sequential output. For modern terminals, this means that +outputting a newline in ordinary sequential output with the cursor on +the bottom line wraps to the top line. For some obsolete terminals, +other things may happen. + +The terminal may be able to scroll even if it does not normally do so. +If the @samp{sf} capability is provided, it can be used for scrolling +regardless of @samp{ns}. + +@item da +@kindex da +Flag whose presence means that lines scrolled up off the top of the +screen may come back if scrolling down is done subsequently. + +The @samp{da} and @samp{db} flags do not, strictly speaking, affect +how to scroll. But programs that scroll usually need to clear the +lines scrolled onto the screen, if these flags are present. + +@item db +@kindex db +Flag whose presence means that lines scrolled down off the bottom of +the screen may come back if scrolling up is done subsequently. + +@item lm +@kindex lm +Numeric value, the number of lines of display memory that the terminal +has. A value of zero means that the terminal has more display memory +than can fit on the screen, but no fixed number of lines. (The number +of lines may depend on the amount of text in each line.) +@end table + +Any terminal description that defines @samp{SF} should also define @samp{sf}; +likewise for @samp{SR} and @samp{sr}. However, many terminals can only +scroll by one line at a time, so it is common to find @samp{sf} and not +@samp{SF}, or @samp{sr} without @samp{SR}.@refill + +Therefore, all programs that use the scrolling facilities should be +prepared to work with @samp{sf} in the case that @samp{SF} is absent, and +likewise with @samp{sr}. On the other hand, an application program that +uses only @samp{sf} and not @samp{SF} is acceptable, though slow on some +terminals.@refill + +When outputting a scroll command with @code{tputs}, the @var{nlines} +argument should be the total number of lines in the portion of the screen +being scrolled. Very often these commands require padding proportional to +this number of lines. @xref{Padding}. + +@node Windows, Clearing, Scrolling, Capabilities +@section Windows +@cindex window + +A @dfn{window}, in termcap, is a rectangular portion of the screen to which +all display operations are restricted. Wrapping, clearing, scrolling, +insertion and deletion all operate as if the specified window were all the +screen there was. + +@table @samp +@item wi +@kindex wi +String of commands to set the terminal output screen window. +This string requires four parameters, all origin-zero: +@enumerate +@item +The first line to include in the window. +@item +The last line to include in the window. +@item +The first column to include in the window. +@item +The last column to include in the window. +@end enumerate +@end table + +Most terminals do not support windows. + +@node Clearing, Insdel Line, Windows, Capabilities +@section Clearing Parts of the Screen +@cindex erasing +@cindex clearing the screen + +There are several terminal capabilities for clearing parts of the screen +to blank. All display terminals support the @samp{cl} string, and most +display terminals support all of these capabilities. + +@table @samp +@item cl +@kindex cl +String of commands to clear the entire screen and position the cursor +at the upper left corner. + +@item cd +@kindex cd +String of commands to clear the line the cursor is on, and all the +lines below it, down to the bottom of the screen. This command string +should be used only with the cursor in column zero; their effect is +undefined if the cursor is elsewhere. + +@item ce +@kindex ce +String of commands to clear from the cursor to the end of the current +line. + +@item ec +@kindex ec +String of commands to clear @var{n} characters, starting with the +character that the cursor is on. This command string is expected to +leave the cursor position unchanged. The parameter @var{n} should never +be large enough to reach past the right margin; the effect of such a +large parameter would be undefined. +@end table + +Clear to end of line (@samp{ce}) is extremely important in programs that +maintain an updating display. Nearly all display terminals support this +operation, so it is acceptable for a an application program to refuse to +work if @samp{ce} is not present. However, if you do not want this +limitation, you can accomplish clearing to end of line by outputting spaces +until you reach the right margin. In order to do this, you must know the +current horizontal position. Also, this technique assumes that writing a +space will erase. But this happens to be true on all the display terminals +that fail to support @samp{ce}. + +@node Insdel Line, Insdel Char, Clearing, Capabilities +@section Insert/Delete Line + +@cindex insert line +@cindex delete line +@dfn{Inserting a line} means creating a blank line in the middle +of the screen, and pushing the existing lines of text apart. In fact, +the lines above the insertion point do not change, while the lines below +move down, and one is normally lost at the bottom of the screen. + +@dfn{Deleting a line} means causing the line to disappear from the screen, +closing up the gap by moving the lines below it upward. A new line +appears at the bottom of the screen. Usually this line is blank, but +on terminals with the @samp{db} flag it may be a line previously moved +off the screen bottom by scrolling or line insertion. + +Insertion and deletion of lines is useful in programs that maintain an +updating display some parts of which may get longer or shorter. They are +also useful in editors for scrolling parts of the screen, and for +redisplaying after lines of text are killed or inserted. + +Many terminals provide commands to insert or delete a single line at the +cursor position. Some provide the ability to insert or delete several +lines with one command, using the number of lines to insert or delete as a +parameter. Always move the cursor to column zero before using any of +these commands. + +@table @samp +@item al +@kindex al +String of commands to insert a blank line before the line the cursor +is on. The existing line, and all lines below it, are moved down. +The last line in the screen (or in the scroll region, if one is set) +disappears and in most circumstances is discarded. It may not be +discarded if the @samp{db} is present (@pxref{Scrolling}). + +The cursor must be at the left margin before this command is used. +This command does not move the cursor. + +@item dl +@kindex dl +String of commands to delete the line the cursor is on. The following +lines move up, and a blank line appears at the bottom of the screen +(or bottom of the scroll region). If the terminal has the @samp{db} +flag, a nonblank line previously pushed off the screen bottom may +reappear at the bottom. + +The cursor must be at the left margin before this command is used. +This command does not move the cursor. + +@item AL +@kindex AL +String of commands to insert @var{n} blank lines before the line that +the cursor is on. It is like @samp{al} repeated @var{n} times, except +that it is as fast as one @samp{al}. + +@item DL +@kindex DL +String of commands to delete @var{n} lines starting with the line that +the cursor is on. It is like @samp{dl} repeated @var{n} times, except +that it is as fast as one @samp{dl}. +@end table + +Any terminal description that defines @samp{AL} should also define +@samp{al}; likewise for @samp{DL} and @samp{dl}. However, many terminals +can only insert or delete one line at a time, so it is common to find +@samp{al} and not @samp{AL}, or @samp{dl} without @samp{DL}.@refill + +Therefore, all programs that use the insert and delete facilities should be +prepared to work with @samp{al} in the case that @samp{AL} is absent, and +likewise with @samp{dl}. On the other hand, it is acceptable to write +an application that uses only @samp{al} and @samp{dl} and does not look +for @samp{AL} or @samp{DL} at all.@refill + +If a terminal does not support line insertion and deletion directly, +but does support a scroll region, the effect of insertion and deletion +can be obtained with scrolling. However, it is up to the individual +user program to check for this possibility and use the scrolling +commands to get the desired result. It is fairly important to implement +this alternate strategy, since it is the only way to get the effect of +line insertion and deletion on the popular VT100 terminal. + +Insertion and deletion of lines is affected by the scroll region on +terminals that have a settable scroll region. This is useful when it is +desirable to move any few consecutive lines up or down by a few lines. +@xref{Scrolling}. + +The line pushed off the bottom of the screen is not lost if the terminal +has the @samp{db} flag capability; instead, it is pushed into display +memory that does not appear on the screen. This is the same thing that +happens when scrolling pushes a line off the bottom of the screen. +Either reverse scrolling or deletion of a line can bring the apparently +lost line back onto the bottom of the screen. If the terminal has the +scroll region feature as well as @samp{db}, the pushed-out line really +is lost if a scroll region is in effect. + +When outputting an insert or delete command with @code{tputs}, the +@var{nlines} argument should be the total number of lines from the cursor +to the bottom of the screen (or scroll region). Very often these commands +require padding proportional to this number of lines. @xref{Padding}. + +For @samp{AL} and @samp{DL} the @var{nlines} argument should @emph{not} +depend on the number of lines inserted or deleted; only the total number of +lines affected. This is because it is just as fast to insert two or +@var{n} lines with @samp{AL} as to insert one line with @samp{al}. + +@node Insdel Char, Standout, Insdel Line, Capabilities +@section Insert/Delete Character +@cindex insert character +@cindex delete character + +@dfn{Inserting a character} means creating a blank space in the middle of a +line, and pushing the rest of the line rightward. The character in the +rightmost column is lost. + +@dfn{Deleting a character} means causing the character to disappear from +the screen, closing up the gap by moving the rest of the line leftward. A +blank space appears in the rightmost column. + +Insertion and deletion of characters is useful in programs that maintain an +updating display some parts of which may get longer or shorter. It is also +useful in editors for redisplaying the results of editing within a line. + +Many terminals provide commands to insert or delete a single character at +the cursor position. Some provide the ability to insert or delete several +characters with one command, using the number of characters to insert or +delete as a parameter. + +@cindex insert mode +Many terminals provide an insert mode in which outputting a graphic +character has the added effect of inserting a position for that character. +A special command string is used to enter insert mode and another is used +to exit it. The reason for designing a terminal with an insert mode rather +than an insert command is that inserting character positions is usually +followed by writing characters into them. With insert mode, this is as +fast as simply writing the characters, except for the fixed overhead of +entering and leaving insert mode. However, when the line speed is great +enough, padding may be required for the graphic characters output in insert +mode. + +Some terminals require you to enter insert mode and then output a special +command for each position to be inserted. Or they may require special +commands to be output before or after each graphic character to be +inserted. + +@cindex delete mode +Deletion of characters is usually accomplished by a straightforward command +to delete one or several positions; but on some terminals, it is necessary +to enter a special delete mode before using the delete command, and leave +delete mode afterward. Sometimes delete mode and insert mode are the same +mode. + +Some terminals make a distinction between character positions in which a +space character has been output and positions which have been cleared. On +these terminals, the effect of insert or delete character runs to the first +cleared position rather than to the end of the line. In fact, the effect +may run to more than one line if there is no cleared position to stop the +shift on the first line. These terminals are identified by the @samp{in} +flag capability. + +On terminals with the @samp{in} flag, the technique of skipping over +characters that you know were cleared, and then outputting text later on in +the same line, causes later insert and delete character operations on that +line to do nonstandard things. A program that has any chance of doing this +must check for the @samp{in} flag and must be careful to write explicit +space characters into the intermediate columns when @samp{in} is present. + +A plethora of terminal capabilities are needed to describe all of this +complexity. Here is a list of them all. Following the list, we present +an algorithm for programs to use to take proper account of all of these +capabilities. + +@table @samp +@item im +@kindex im +String of commands to enter insert mode. + +If the terminal has no special insert mode, but it can insert +characters with a special command, @samp{im} should be defined with a +null value, because the @samp{vi} editor assumes that insertion of a +character is impossible if @samp{im} is not provided. + +New programs should not act like @samp{vi}. They should pay attention +to @samp{im} only if it is defined. + +@item ei +@kindex ei +String of commands to leave insert mode. This capability must be +present if @samp{im} is. + +On a few old terminals the same string is used to enter and exit +insert mode. This string turns insert mode on if it was off, and off +it it was on. You can tell these terminals because the @samp{ei} +string equals the @samp{im} string. If you want to support these +terminals, you must always remember accurately whether insert mode is +in effect. However, these terminals are obsolete, and it is +reasonable to refuse to support them. On all modern terminals, you +can safely output @samp{ei} at any time to ensure that insert mode is +turned off. + +@item ic +@kindex ic +String of commands to insert one character position at the cursor. +The cursor does not move. + +If outputting a graphic character while in insert mode is sufficient +to insert the character, then the @samp{ic} capability should be +defined with a null value. + +If your terminal offers a choice of ways to insert---either use insert +mode or use a special command---then define @samp{im} and do not define +@samp{ic}, since this gives the most efficient operation when several +characters are to be inserted. @emph{Do not} define both strings, for +that means that @emph{both} must be used each time insertion is done. + +@item ip +@kindex ip +String of commands to output following an inserted graphic character +in insert mode. Often it is used just for a padding spec, when padding +is needed after an inserted character (@pxref{Padding}). + +@item IC +@kindex IC +String of commands to insert @var{n} character positions at and after +the cursor. It has the same effect as repeating the @samp{ic} string +and a space, @var{n} times. + +If @samp{IC} is provided, application programs may use it without first +entering insert mode. + +@item mi +@kindex mi +Flag whose presence means it is safe to move the cursor while in insert +mode and assume the terminal remains in insert mode. + +@item in +@kindex in +Flag whose presence means that the terminal distinguishes between +character positions in which space characters have been output and +positions which have been cleared. +@end table + +An application program can assume that the terminal can do character +insertion if @emph{any one of} the capabilities @samp{IC}, @samp{im}, +@samp{ic} or @samp{ip} is provided. + +To insert @var{n} blank character positions, move the cursor to the place +to insert them and follow this algorithm: + +@enumerate +@item +If an @samp{IC} string is provided, output it with parameter @var{n} +and you are finished. Otherwise (or if you don't want to bother to +look for an @samp{IC} string) follow the remaining steps. + +@item +Output the @samp{im} string, if there is one, unless the terminal is +already in insert mode. + +@item +Repeat steps 4 through 6, @var{n} times. + +@item +Output the @samp{ic} string if any. + +@item +Output a space. + +@item +Output the @samp{ip} string if any. + +@item +Output the @samp{ei} string, eventually, to exit insert mode. There +is no need to do this right away. If the @samp{mi} flag is present, +you can move the cursor and the cursor will remain in insert mode; +then you can do more insertion elsewhere without reentering insert +mode. +@end enumerate + +To insert @var{n} graphic characters, position the cursor and follow this +algorithm: + +@enumerate +@item +If an @samp{IC} string is provided, output it with parameter @var{n}, +then output the graphic characters, and you are finished. Otherwise +(or if you don't want to bother to look for an @samp{IC} string) +follow the remaining steps. + +@item +Output the @samp{im} string, if there is one, unless the terminal is +already in insert mode. + +@item +For each character to be output, repeat steps 4 through 6. + +@item +Output the @samp{ic} string if any. + +@item +Output the next graphic character. + +@item +Output the @samp{ip} string if any. + +@item +Output the @samp{ei} string, eventually, to exit insert mode. There +is no need to do this right away. If the @samp{mi} flag is present, +you can move the cursor and the cursor will remain in insert mode; +then you can do more insertion elsewhere without reentering insert +mode. +@end enumerate + +Note that this is not the same as the original Unix termcap specifications +in one respect: it assumes that the @samp{IC} string can be used without +entering insert mode. This is true as far as I know, and it allows you be +able to avoid entering and leaving insert mode, and also to be able to +avoid the inserted-character padding after the characters that go into the +inserted positions. + +Deletion of characters is less complicated; deleting one column is done by +outputting the @samp{dc} string. However, there may be a delete mode that +must be entered with @samp{dm} in order to make @samp{dc} work. + +@table @samp +@item dc +@kindex dc +String of commands to delete one character position at the cursor. If +@samp{dc} is not present, the terminal cannot delete characters. + +@item DC +@kindex DC +String of commands to delete @var{n} characters starting at the cursor. +It has the same effect as repeating the @samp{dc} string @var{n} times. +Any terminal description that has @samp{DC} also has @samp{dc}. + +@item dm +@kindex dm +String of commands to enter delete mode. If not present, there is no +delete mode, and @samp{dc} can be used at any time (assuming there is +a @samp{dc}). + +@item ed +@kindex ed +String of commands to exit delete mode. This must be present if +@samp{dm} is. +@end table + +To delete @var{n} character positions, position the cursor and follow these +steps: + +@enumerate +@item +If the @samp{DC} string is present, output it with parameter @var{n} +and you are finished. Otherwise, follow the remaining steps. + +@item +Output the @samp{dm} string, unless you know the terminal is already +in delete mode. + +@item +Output the @samp{dc} string @var{n} times. + +@item +Output the @samp{ed} string eventually. If the flag capability +@samp{mi} is present, you can move the cursor and do more deletion +without leaving and reentering delete mode. +@end enumerate + +As with the @samp{IC} string, we have departed from the original termcap +specifications by assuming that @samp{DC} works without entering delete +mode even though @samp{dc} would not. + +If the @samp{dm} and @samp{im} capabilities are both present and have the +same value, it means that the terminal has one mode for both insertion and +deletion. It is useful for a program to know this, because then it can do +insertions after deletions, or vice versa, without leaving insert/delete +mode and reentering it. + +@node Standout, Underlining, Insdel Char, Capabilities +@section Standout and Appearance Modes +@cindex appearance modes +@cindex standout +@cindex magic cookie + +@dfn{Appearance modes} are modifications to the ways characters are +displayed. Typical appearance modes include reverse video, dim, bright, +blinking, underlined, invisible, and alternate character set. Each kind of +terminal supports various among these, or perhaps none. + +For each type of terminal, one appearance mode or combination of them that +looks good for highlighted text is chosen as the @dfn{standout mode}. The +capabilities @samp{so} and @samp{se} say how to enter and leave standout +mode. Programs that use appearance modes only to highlight some text +generally use the standout mode so that they can work on as many terminals +as possible. Use of specific appearance modes other than ``underlined'' +and ``alternate character set'' is rare. + +Terminals that implement appearance modes fall into two general classes as +to how they do it. + +In some terminals, the presence or absence of any appearance mode is +recorded separately for each character position. In these terminals, each +graphic character written is given the appearance modes current at the time +it is written, and keeps those modes until it is erased or overwritten. +There are special commands to turn the appearance modes on or off for +characters to be written in the future. + +In other terminals, the change of appearance modes is represented by a +marker that belongs to a certain screen position but affects all following +screen positions until the next marker. These markers are traditionally +called @dfn{magic cookies}. + +The same capabilities (@samp{so}, @samp{se}, @samp{mb} and so on) for +turning appearance modes on and off are used for both magic-cookie +terminals and per-character terminals. On magic cookie terminals, these +give the commands to write the magic cookies. On per-character terminals, +they change the current modes that affect future output and erasure. Some +simple applications can use these commands without knowing whether or not +they work by means of cookies. + +However, a program that maintains and updates a display needs to know +whether the terminal uses magic cookies, and exactly what their effect is. +This information comes from the @samp{sg} capability. + +The @samp{sg} capability is a numeric capability whose presence indicates +that the terminal uses magic cookies for appearance modes. Its value is +the number of character positions that a magic cookie occupies. Usually +the cookie occupies one or more character positions on the screen, and these +character positions are displayed as blank, but in some terminals the +cookie has zero width. + +The @samp{sg} capability describes both the magic cookie to turn standout +on and the cookie to turn it off. This makes the assumption that both +kinds of cookie have the same width on the screen. If that is not true, +the narrower cookie must be ``widened'' with spaces until it has the same +width as the other. + +On some magic cookie terminals, each line always starts with normal +display; in other words, the scope of a magic cookie never extends over +more than one line. But on other terminals, one magic cookie affects all +the lines below it unless explicitly canceled. Termcap does not define any +way to distinguish these two ways magic cookies can work. To be safe, it +is best to put a cookie at the beginning of each line. + +On some per-character terminals, standout mode or other appearance modes +may be canceled by moving the cursor. On others, moving the cursor has no +effect on the state of the appearance modes. The latter class of terminals +are given the flag capability @samp{ms} (``can move in standout''). All +programs that might have occasion to move the cursor while appearance modes +are turned on must check for this flag; if it is not present, they should +reset appearance modes to normal before doing cursor motion. + +A program that has turned on only standout mode should use @samp{se} to +reset the standout mode to normal. A program that has turned on only +alternate character set mode should use @samp{ae} to return it to normal. +If it is possible that any other appearance modes are turned on, use the +@samp{me} capability to return them to normal. + +Note that the commands to turn on one appearance mode, including @samp{so} +and @samp{mb} @dots{} @samp{mr}, if used while some other appearance modes +are turned on, may combine the two modes on some terminals but may turn off +the mode previously enabled on other terminals. This is because some +terminals do not have a command to set or clear one appearance mode without +changing the others. Programs should not attempt to use appearance modes +in combination except with @samp{sa}, and when switching from one single +mode to another should always turn off the previously enabled mode and then +turn on the new desired mode. + +On some old terminals, the @samp{so} and @samp{se} commands may be the same +command, which has the effect of turning standout on if it is off, or off +it is on. It is therefore risky for a program to output extra @samp{se} +commands for good measure. Fortunately, all these terminals are obsolete. + +Programs that update displays in which standout-text may be replaced with +non-standout text must check for the @samp{xs} flag. In a per-character +terminal, this flag says that the only way to remove standout once written is +to clear that portion of the line with the @samp{ce} string or something +even more powerful (@pxref{Clearing}); just writing new characters at those +screen positions will not change the modes in effect there. In a magic +cookie terminal, @samp{xs} says that the only way to remove a cookie is to +clear a portion of the line that includes the cookie; writing a different +cookie at the same position does not work. + +Such programs must also check for the @samp{xt} flag, which means that the +terminal is a Teleray 1061. On this terminal it is impossible to position +the cursor at the front of a magic cookie, so the only two ways to remove a +cookie are (1) to delete the line it is on or (2) to position the cursor at +least one character before it (possibly on a previous line) and output the +@samp{se} string, which on these terminals finds and removes the next +@samp{so} magic cookie on the screen. (It may also be possible to remove a +cookie which is not at the beginning of a line by clearing that line.) The +@samp{xt} capability also has implications for the use of tab characters, +but in that regard it is obsolete (@xref{Cursor Motion}). + +@table @samp +@item so +@kindex so +String of commands to enter standout mode. + +@item se +@kindex se +String of commands to leave standout mode. + +@item sg +@kindex sg +Numeric capability, the width on the screen of the magic cookie. This +capability is absent in terminals that record appearance modes +character by character. + +@item ms +@kindex ms +Flag whose presence means that it is safe to move the cursor while the +appearance modes are not in the normal state. If this flag is absent, +programs should always reset the appearance modes to normal before +moving the cursor. + +@item xs +@kindex xs +Flag whose presence means that the only way to reset appearance modes +already on the screen is to clear to end of line. On a per-character +terminal, you must clear the area where the modes are set. On a magic +cookie terminal, you must clear an area containing the cookie. +See the discussion above. + +@item xt +@kindex xt +Flag whose presence means that the cursor cannot be positioned right +in front of a magic cookie, and that @samp{se} is a command to delete +the next magic cookie following the cursor. See discussion above. + +@item mb +@kindex mb +String of commands to enter blinking mode. + +@item md +@kindex md +String of commands to enter double-bright mode. + +@item mh +@kindex mh +String of commands to enter half-bright mode. + +@item mk +@kindex mk +String of commands to enter invisible mode. + +@item mp +@kindex mp +String of commands to enter protected mode. + +@item mr +@kindex mr +String of commands to enter reverse-video mode. + +@item me +@kindex me +String of commands to turn off all appearance modes, including +standout mode and underline mode. On some terminals it also turns off +alternate character set mode; on others, it may not. This capability +must be present if any of @samp{mb} @dots{} @samp{mr} is present. + +@item as +@kindex as +String of commands to turn on alternate character set mode. This mode +assigns some or all graphic characters an alternate picture on the +screen. There is no standard as to what the alternate pictures look +like. + +@item ae +@kindex ae +String of commands to turn off alternate character set mode. + +@item sa +@kindex sa +String of commands to turn on an arbitrary combination of appearance +modes. It accepts 9 parameters, each of which controls a particular +kind of appearance mode. A parameter should be 1 to turn its appearance +mode on, or zero to turn that mode off. Most terminals do not support +the @samp{sa} capability, even among those that do have various +appearance modes. + +The nine parameters are, in order, @var{standout}, @var{underline}, +@var{reverse}, @var{blink}, @var{half-bright}, @var{double-bright}, +@var{blank}, @var{protect}, @var{alt char set}. +@end table + +@node Underlining, Cursor Visibility, Standout, Capabilities +@section Underlining +@cindex underlining + +Underlining on most terminals is a kind of appearance mode, much like +standout mode. Therefore, it may be implemented using magic cookies or as +a flag in the terminal whose current state affects each character that is +output. @xref{Standout}, for a full explanation. + +The @samp{ug} capability is a numeric capability whose presence indicates +that the terminal uses magic cookies for underlining. Its value is the +number of character positions that a magic cookie for underlining occupies; +it is used for underlining just as @samp{sg} is used for standout. Aside +from the simplest applications, it is impossible to use underlining +correctly without paying attention to the value of @samp{ug}. + +@table @samp +@item us +@kindex us +String of commands to turn on underline mode or to output a magic cookie +to start underlining. + +@item ue +@kindex ue +String of commands to turn off underline mode or to output a magic +cookie to stop underlining. + +@item ug +@kindex ug +Width of magic cookie that represents a change of underline mode; +or missing, if the terminal does not use a magic cookie for this. + +@item ms +@kindex ms +Flag whose presence means that it is safe to move the cursor while the +appearance modes are not in the normal state. Underlining is an +appearance mode. If this flag is absent, programs should always turn +off underlining before moving the cursor. +@end table + +There are two other, older ways of doing underlining: there can be a +command to underline a single character, or the output of @samp{_}, the +ASCII underscore character, as an overstrike could cause a character to be +underlined. New programs need not bother to handle these capabilities +unless the author cares strongly about the obscure terminals which support +them. However, terminal descriptions should provide these capabilities +when appropriate. + +@table @samp +@item uc +@kindex uc +String of commands to underline the character under the cursor, and +move the cursor right. + +@item ul +@kindex ul +Flag whose presence means that the terminal can underline by +overstriking an underscore character (@samp{_}); some terminals can do +this even though they do not support overstriking in general. An +implication of this flag is that when outputting new text to overwrite +old text, underscore characters must be treated specially lest they +underline the old text instead. +@end table + +@node Cursor Visibility, Bell, Underlining, Capabilities +@section Cursor Visibility +@cindex visibility + +Some terminals have the ability to make the cursor invisible, or to enhance +it. Enhancing the cursor is often done by programs that plan to use the +cursor to indicate to the user a position of interest that may be anywhere +on the screen---for example, the Emacs editor enhances the cursor on entry. +Such programs should always restore the cursor to normal on exit. + +@table @samp +@item vs +@kindex vs +String of commands to enhance the cursor. + +@item vi +@kindex vi +String of commands to make the cursor invisible. + +@item ve +@kindex ve +String of commands to return the cursor to normal. +@end table + +If you define either @samp{vs} or @samp{vi}, you must also define @samp{ve}. + +@node Bell, Keypad, Cursor Visibility, Capabilities +@section Bell +@cindex bell +@cindex visible bell + +Here we describe commands to make the terminal ask for the user to pay +attention to it. + +@table @samp +@item bl +@kindex bl +String of commands to cause the terminal to make an audible sound. If +this capability is absent, the terminal has no way to make a suitable +sound. + +@item vb +@kindex vb +String of commands to cause the screen to flash to attract attention +(``visible bell''). If this capability is absent, the terminal has no +way to do such a thing. +@end table + +@node Keypad, Meta Key, Bell, Capabilities +@section Keypad and Function Keys + +Many terminals have arrow and function keys that transmit specific +character sequences to the computer. Since the precise sequences used +depend on the terminal, termcap defines capabilities used to say what the +sequences are. Unlike most termcap string-valued capabilities, these are +not strings of commands to be sent to the terminal, rather strings that +are received from the terminal. + +Programs that expect to use keypad keys should check, initially, for a +@samp{ks} capability and send it, to make the keypad actually transmit. +Such programs should also send the @samp{ke} string when exiting. + +@table @asis +@item @samp{ks} +@kindex ka@dots{}ku +String of commands to make the keypad keys transmit. If this +capability is not provided, but the others in this section are, +programs may assume that the keypad keys always transmit. + +@item @samp{ke} +String of commands to make the keypad keys work locally. This +capability is provided only if @samp{ks} is. + +@item @samp{kl} +String of input characters sent by typing the left-arrow key. If this +capability is missing, you cannot expect the terminal to have a +left-arrow key that transmits anything to the computer. + +@item @samp{kr} +String of input characters sent by typing the right-arrow key. + +@item @samp{ku} +String of input characters sent by typing the up-arrow key. + +@item @samp{kd} +String of input characters sent by typing the down-arrow key. + +@item @samp{kh} +String of input characters sent by typing the ``home-position'' key. + +@item @samp{K1} @dots{} @samp{K5} +@kindex K1@dots{}K5 +Strings of input characters sent by the five other keys in a 3-by-3 +array that includes the arrow keys, if the keyboard has such a 3-by-3 +array. Note that one of these keys may be the ``home-position'' key, +in which case one of these capabilities will have the same value as +the @samp{kh} key. + +@item @samp{k0} +String of input characters sent by function key 10 (or 0, if the terminal +has one labeled 0). + +@item @samp{k1} @dots{} @samp{k9} +@kindex k1@dots{}k9 +Strings of input characters sent by function keys 1 through 9, +provided for those function keys that exist. + +@item @samp{kn} +Number: the number of numbered function keys, if there are more than +10. + +@item @samp{l0} @dots{} @samp{l9} +@kindex l0@dots{}l9 +Strings which are the labels appearing on the keyboard on the keys +described by the capabilities @samp{k0} @dots{} @samp{l9}. These +capabilities should be left undefined if the labels are @samp{f0} or +@samp{f10} and @samp{f1} @dots{} @samp{f9}.@refill + +@item @samp{kH} +@kindex kA@dots{}kT +String of input characters sent by the ``home down'' key, if there is +one. + +@item @samp{kb} +String of input characters sent by the ``backspace'' key, if there is +one. + +@item @samp{ka} +String of input characters sent by the ``clear all tabs'' key, if there +is one. + +@item @samp{kt} +String of input characters sent by the ``clear tab stop this column'' +key, if there is one. + +@item @samp{kC} +String of input characters sent by the ``clear screen'' key, if there is +one. + +@item @samp{kD} +String of input characters sent by the ``delete character'' key, if +there is one. + +@item @samp{kL} +String of input characters sent by the ``delete line'' key, if there is +one. + +@item @samp{kM} +String of input characters sent by the ``exit insert mode'' key, if +there is one. + +@item @samp{kE} +String of input characters sent by the ``clear to end of line'' key, if +there is one. + +@item @samp{kS} +String of input characters sent by the ``clear to end of screen'' key, +if there is one. + +@item @samp{kI} +String of input characters sent by the ``insert character'' or ``enter +insert mode'' key, if there is one. + +@item @samp{kA} +String of input characters sent by the ``insert line'' key, if there is +one. + +@item @samp{kN} +String of input characters sent by the ``next page'' key, if there is +one. + +@item @samp{kP} +String of input characters sent by the ``previous page'' key, if there is +one. + +@item @samp{kF} +String of input characters sent by the ``scroll forward'' key, if there +is one. + +@item @samp{kR} +String of input characters sent by the ``scroll reverse'' key, if there +is one. + +@item @samp{kT} +String of input characters sent by the ``set tab stop in this column'' +key, if there is one. + +@item @samp{ko} +String listing the other function keys the terminal has. This is a +very obsolete way of describing the same information found in the +@samp{kH} @dots{} @samp{kT} keys. The string contains a list of +two-character termcap capability names, separated by commas. The +meaning is that for each capability name listed, the terminal has a +key which sends the string which is the value of that capability. For +example, the value @samp{:ko=cl,ll,sf,sr:} says that the terminal has +four function keys which mean ``clear screen'', ``home down'', +``scroll forward'' and ``scroll reverse''.@refill +@end table + +@node Meta Key, Initialization, Keypad, Capabilities +@section Meta Key + +@cindex meta key +A Meta key is a key on the keyboard that modifies each character you type +by controlling the 0200 bit. This bit is on if and only if the Meta key is +held down when the character is typed. Characters typed using the Meta key +are called Meta characters. Emacs uses Meta characters as editing +commands. + +@table @samp +@item km +@kindex km +Flag whose presence means that the terminal has a Meta key. + +@item mm +@kindex mm +String of commands to enable the functioning of the Meta key. + +@item mo +@kindex mo +String of commands to disable the functioning of the Meta key. +@end table + +If the terminal has @samp{km} but does not have @samp{mm} and @samp{mo}, it +means that the Meta key always functions. If it has @samp{mm} and +@samp{mo}, it means that the Meta key can be turned on or off. Send the +@samp{mm} string to turn it on, and the @samp{mo} string to turn it off. +I do not know why one would ever not want it to be on. + +@node Initialization, Pad Specs, Meta Key, Capabilities +@section Initialization +@cindex reset +@cindex initialization +@cindex tab stops + +@table @samp +@item ti +@kindex ti +String of commands to put the terminal into whatever special modes are +needed or appropriate for programs that move the cursor +nonsequentially around the screen. Programs that use termcap to do +full-screen display should output this string when they start up. + +@item te +@kindex te +String of commands to undo what is done by the @samp{ti} string. +Programs that output the @samp{ti} string on entry should output this +string when they exit. + +@item is +@kindex is +String of commands to initialize the terminal for each login session. + +@item if +@kindex if +String which is the name of a file containing the string of commands +to initialize the terminal for each session of use. Normally @samp{is} +and @samp{if} are not both used. + +@item i1 +@itemx i3 +@kindex i1 +@kindex i3 +Two more strings of commands to initialize the terminal for each login +session. The @samp{i1} string (if defined) is output before @samp{is} +or @samp{if}, and the @samp{i3} string (if defined) is output after. + +The reason for having three separate initialization strings is to make +it easier to define a group of related terminal types with slightly +different initializations. Define two or three of the strings in the +basic type; then the other types can override one or two of the +strings. + +@item rs +@kindex rs +String of commands to reset the terminal from any strange mode it may +be in. Normally this includes the @samp{is} string (or other commands +with the same effects) and more. What would go in the @samp{rs} +string but not in the @samp{is} string are annoying or slow commands +to bring the terminal back from strange modes that nobody would +normally use. + +@item it +@kindex it +Numeric value, the initial spacing between hardware tab stop columns +when the terminal is powered up. Programs to initialize the terminal +can use this to decide whether there is a need to set the tab stops. +If the initial width is 8, well and good; if it is not 8, then the +tab stops should be set; if they cannot be set, the kernel is told +to convert tabs to spaces, and other programs will observe this and do +likewise. + +@item ct +@kindex ct +String of commands to clear all tab stops. + +@item st +@kindex st +String of commands to set tab stop at current cursor column on all +lines. + +@item NF +@kindex NF +Flag whose presence means that the terminal does not support XON/XOFF +flow control. Programs should not send XON (@kbd{C-q}) or XOFF +(@kbd{C-s}) characters to the terminal. +@end table + +@node Pad Specs, Status Line, Initialization, Capabilities +@section Padding Capabilities +@cindex padding + +There are two terminal capabilities that exist just to explain the proper +way to obey the padding specifications in all the command string +capabilities. One, @samp{pc}, must be obeyed by all termcap-using +programs. + +@table @samp +@item pb +@kindex pb +Numeric value, the lowest baud rate at which padding is actually +needed. Programs may check this and refrain from doing any padding at +lower speeds. + +@item pc +@kindex pc +String of commands for padding. The first character of this string is +to be used as the pad character, instead of using null characters for +padding. If @samp{pc} is not provided, use null characters. Every +program that uses termcap must look up this capability and use it to +set the variable @code{PC} that is used by @code{tputs}. +@xref{Padding}. +@end table + +Some termcap capabilities exist just to specify the amount of padding that +the kernel should give to cursor motion commands used in ordinary +sequential output. + +@table @samp +@item dC +@kindex dC +Numeric value, the number of msec of padding needed for the +carriage-return character. + +@item dN +@kindex dN +Numeric value, the number of msec of padding needed for the newline +(linefeed) character. + +@item dB +@kindex dB +Numeric value, the number of msec of padding needed for the backspace +character. + +@item dF +@kindex dF +Numeric value, the number of msec of padding needed for the formfeed +character. + +@item dT +@kindex dT +Numeric value, the number of msec of padding needed for the tab +character. +@end table + +In some systems, the kernel uses the above capabilities; in other systems, +the kernel uses the paddings specified in the string capabilities +@samp{cr}, @samp{sf}, @samp{le}, @samp{ff} and @samp{ta}. Descriptions of +terminals which require such padding should contain the @samp{dC} @dots{} +@samp{dT} capabilities and also specify the appropriate padding in the +corresponding string capabilities. Since no modern terminals require +padding for ordinary sequential output, you probably won't need to do +either of these things. + +@node Status Line, Half-Line, Pad Specs, Capabilities +@section Status Line + +@cindex status line +A @dfn{status line} is a line on the terminal that is not used for ordinary +display output but instead used for a special message. The intended use is +for a continuously updated description of what the user's program is doing, +and that is where the name ``status line'' comes from, but in fact it could +be used for anything. The distinguishing characteristic of a status line +is that ordinary output to the terminal does not affect it; it changes only +if the special status line commands of this section are used. + +@table @samp +@item hs +@kindex hs +Flag whose presence means that the terminal has a status line. If a +terminal description specifies that there is a status line, it must +provide the @samp{ts} and @samp{fs} capabilities. + +@item ts +@kindex ts +String of commands to move the terminal cursor into the status line. +Usually these commands must specifically record the old cursor +position for the sake of the @samp{fs} string. + +@item fs +@kindex fs +String of commands to move the cursor back from the status line to its +previous position (outside the status line). + +@item es +@kindex es +Flag whose presence means that other display commands work while +writing the status line. In other words, one can clear parts of it, +insert or delete characters, move the cursor within it using @samp{ch} +if there is a @samp{ch} capability, enter and leave standout mode, and +so on. + +@item ds +@kindex ds +String of commands to disable the display of the status line. This +may be absent, if there is no way to disable the status line display. + +@item ws +@kindex ws +Numeric value, the width of the status line. If this capability is +absent in a terminal that has a status line, it means the status line +is the same width as the other lines. + +Note that the value of @samp{ws} is sometimes as small as 8. +@end table + +@node Half-Line, Printer, Status Line, Capabilities +@section Half-Line Motion + +Some terminals have commands for moving the cursor vertically by half-lines, +useful for outputting subscripts and superscripts. Mostly it is hardcopy +terminals that have such features. + +@table @samp +@item hu +@kindex hu +String of commands to move the cursor up half a line. If the terminal +is a display, it is your responsibility to avoid moving up past the +top line; however, most likely the terminal that supports this is a +hardcopy terminal and there is nothing to be concerned about. + +@item hd +@kindex hd +String of commands to move the cursor down half a line. If the +terminal is a display, it is your responsibility to avoid moving down +past the bottom line, etc. +@end table + +@node Printer, , Half-Line, Capabilities +@section Controlling Printers Attached to Terminals +@cindex printer + +Some terminals have attached hardcopy printer ports. They may be able to +copy the screen contents to the printer; they may also be able to redirect +output to the printer. Termcap does not have anything to tell the program +whether the redirected output appears also on the screen; it does on some +terminals but not all. + +@table @samp +@item ps +@kindex ps +String of commands to cause the contents of the screen to be printed. +If it is absent, the screen contents cannot be printed. + +@item po +@kindex po +String of commands to redirect further output to the printer. + +@item pf +@kindex pf +String of commands to terminate redirection of output to the printer. +This capability must be present in the description if @samp{po} is. + +@item pO +@kindex pO +String of commands to redirect output to the printer for next @var{n} +characters of output, regardless of what they are. Redirection will +end automatically after @var{n} characters of further output. Until +then, nothing that is output can end redirection, not even the +@samp{pf} string if there is one. The number @var{n} should not be +more than 255. + +One use of this capability is to send non-text byte sequences (such as +bit-maps) to the printer. +@end table + +Most terminals with printers do not support all of @samp{ps}, @samp{po} and +@samp{pO}; any one or two of them may be supported. To make a program that +can send output to all kinds of printers, it is necessary to check for all +three of these capabilities, choose the most convenient of the ones that +are provided, and use it in its own appropriate fashion. + +@node Summary, Var Index, Capabilities, Top +@chapter Summary of Capability Names + +Here are all the terminal capability names in alphabetical order +with a brief description of each. For cross references to their definitions, +see the index of capability names (@pxref{Cap Index}). + +@table @samp +@item ae +String to turn off alternate character set mode. +@item al +String to insert a blank line before the cursor. +@item AL +String to insert @var{n} blank lines before the cursor. +@item am +Flag: output to last column wraps cursor to next line. +@item as +String to turn on alternate character set mode.like. +@item bc +Very obsolete alternative name for the @samp{le} capability. +@item bl +String to sound the bell. +@item bs +Obsolete flag: ASCII backspace may be used for leftward motion. +@item bt +String to move the cursor left to the previous hardware tab stop column. +@item bw +Flag: @samp{le} at left margin wraps to end of previous line. +@item CC +String to change terminal's command character. +@item cd +String to clear the line the cursor is on, and following lines. +@item ce +String to clear from the cursor to the end of the line. +@item ch +String to position the cursor at column @var{c} in the same line. +@item cl +String to clear the entire screen and put cursor at upper left corner. +@item cm +String to position the cursor at line @var{l}, column @var{c}. +@item CM +String to position the cursor at line @var{l}, column +@var{c}, relative to display memory. +@item co +Number: width of the screen. +@item cr +String to move cursor sideways to left margin. +@item cs +String to set the scroll region. +@item cS +Alternate form of string to set the scroll region. +@item ct +String to clear all tab stops. +@item cv +String to position the cursor at line @var{l} in the same column. +@item da +Flag: data scrolled off top of screen may be scrolled back. +@item db +Flag: data scrolled off bottom of screen may be scrolled back. +@item dB +Obsolete number: msec of padding needed for the backspace character. +@item dc +String to delete one character position at the cursor. +@item dC +Obsolete number: msec of padding needed for the carriage-return character. +@item DC +String to delete @var{n} characters starting at the cursor. +@item dF +Obsolete number: msec of padding needed for the formfeed character. +@item dl +String to delete the line the cursor is on. +@item DL +String to delete @var{n} lines starting with the cursor's line. +@item dm +String to enter delete mode. +@item dN +Obsolete number: msec of padding needed for the newline character. +@item do +String to move the cursor vertically down one line. +@item DO +String to move cursor vertically down @var{n} lines. +@item ds +String to disable the display of the status line. +@item dT +Obsolete number: msec of padding needed for the tab character. +@item ec +String of commands to clear @var{n} characters at cursor. +@item ed +String to exit delete mode. +@item ei +String to leave insert mode. +@item eo +Flag: output of a space can erase an overstrike. +@item es +Flag: other display commands work while writing the status line. +@item ff +String to advance to the next page, for a hardcopy terminal. +@item fs +String to move the cursor back from the status line to its +previous position (outside the status line). +@item gn +Flag: this terminal type is generic, not real. +@item hc +Flag: hardcopy terminal. +@item hd +String to move the cursor down half a line. +@item ho +String to position cursor at upper left corner. +@item hs +Flag: the terminal has a status line. +@item hu +String to move the cursor up half a line. +@item hz +Flag: terminal cannot accept @samp{~} as output. +@item i1 +String to initialize the terminal for each login session. +@item i3 +String to initialize the terminal for each login session. +@item ic +String to insert one character position at the cursor. +@item IC +String to insert @var{n} character positions at the cursor. +@item if +String naming a file of commands to initialize the terminal. +@item im +String to enter insert mode. +@item in +Flag: outputting a space is different from moving over empty positions. +@item ip +String to output following an inserted character in insert mode. +@item is +String to initialize the terminal for each login session. +@item it +Number: initial spacing between hardware tab stop columns. +@item k0 +String of input sent by function key 0 or 10. +@item k1 @dots{} k9 +Strings of input sent by function keys 1 through 9. +@item K1 @dots{} K5 +Strings sent by the five other keys in 3-by-3 array with arrows. +@item ka +String of input sent by the ``clear all tabs'' key. +@item kA +String of input sent by the ``insert line'' key. +@item kb +String of input sent by the ``backspace'' key. +@item kC +String of input sent by the ``clear screen'' key. +@item kd +String of input sent by typing the down-arrow key. +@item kD +String of input sent by the ``delete character'' key. +@item ke +String to make the function keys work locally. +@item kE +String of input sent by the ``clear to end of line'' key. +@item kF +String of input sent by the ``scroll forward'' key. +@item kh +String of input sent by typing the ``home-position'' key. +@item kH +String of input sent by the ``home down'' key. +@item kI +String of input sent by the ``insert character'' or ``enter +insert mode'' key. +@item kl +String of input sent by typing the left-arrow key. +@item kL +String of input sent by the ``delete line'' key. +@item km +Flag: the terminal has a Meta key. +@item kM +String of input sent by the ``exit insert mode'' key. +@item kn +Numeric value, the number of numbered function keys. +@item kN +String of input sent by the ``next page'' key. +@item ko +Very obsolete string listing the terminal's named function keys. +@item kP +String of input sent by the ``previous page'' key. +@item kr +String of input sent by typing the right-arrow key. +@item kR +String of input sent by the ``scroll reverse'' key. +@item ks +String to make the function keys transmit. +@item kS +String of input sent by the ``clear to end of screen'' key. +@item kt +String of input sent by the ``clear tab stop this column'' key. +@item kT +String of input sent by the ``set tab stop in this column'' key. +@item ku +String of input sent by typing the up-arrow key. +@item l0 +String on keyboard labelling function key 0 or 10. +@item l1 @dots{} l9 +Strings on keyboard labelling function keys 1 through 9. +@item le +String to move the cursor left one column. +@item LE +String to move cursor left @var{n} columns. +@item li +Number: height of the screen. +@item ll +String to position cursor at lower left corner. +@item lm +Number: lines of display memory. +@item LP +Flag: writing to last column of last line will not scroll. +@item mb +String to enter blinking mode. +@item md +String to enter double-bright mode. +@item me +String to turn off all appearance modes +@item mh +String to enter half-bright mode. +@item mi +Flag: cursor motion in insert mode is safe. +@item mk +String to enter invisible mode. +@item mm +String to enable the functioning of the Meta key. +@item mo +String to disable the functioning of the Meta key. +@item mp +String to enter protected mode. +@item mr +String to enter reverse-video mode. +@item ms +Flag: cursor motion in standout mode is safe. +@item nc +Obsolete flag: do not use ASCII carriage-return on this terminal. +@item nd +String to move the cursor right one column. +@item NF +Flag: do not use XON/XOFF flow control. +@item nl +Obsolete alternative name for the @samp{do} and @samp{sf} capabilities. +@item ns +Flag: the terminal does not normally scroll for sequential output. +@item nw +String to move to start of next line, possibly clearing rest of old line. +@item os +Flag: terminal can overstrike. +@item pb +Number: the lowest baud rate at which padding is actually needed. +@item pc +String containing character for padding. +@item pf +String to terminate redirection of output to the printer. +@item po +String to redirect further output to the printer. +@item pO +String to redirect @var{n} characters ofoutput to the printer. +@item ps +String to print the screen on the attached printer. +@item rc +String to move to last saved cursor position. +@item RI +String to move cursor right @var{n} columns. +@item rp +String to output character @var{c} repeated @var{n} times. +@item rs +String to reset the terminal from any strange modes. +@item sa +String to turn on an arbitrary combination of appearance modes. +@item sc +String to save the current cursor position. +@item se +String to leave standout mode. +@item sf +String to scroll the screen one line up. +@item SF +String to scroll the screen @var{n} lines up. +@item sg +Number: width of magic standout cookie. Absent if magic cookies are +not used. +@item so +String to enter standout mode. +@item sr +String to scroll the screen one line down. +@item SR +String to scroll the screen @var{n} line down. +@item st +String to set tab stop at current cursor column on all lines. +programs. +@item ta +String to move the cursor right to the next hardware tab stop column. +@item te +String to return terminal to settings for sequential output. +@item ti +String to initialize terminal for random cursor motion. +@item ts +String to move the terminal cursor into the status line. +@item uc +String to underline one character and move cursor right. +@item ue +String to turn off underline mode +@item ug +Number: width of underlining magic cookie. Absent if underlining +doesn't use magic cookies. +@item ul +Flag: underline by overstriking with an underscore. +@item up +String to move the cursor vertically up one line. +@item UP +String to move cursor vertically up @var{n} lines. +@item us +String to turn on underline mode +@item vb +String to make the screen flash. +@item ve +String to return the cursor to normal. +@item vi +String to make the cursor invisible. +@item vs +String to enhance the cursor. +@item wi +String to set the terminal output screen window. +@item ws +Number: the width of the status line. +@item xb +Flag: superbee terminal. +@item xn +Flag: cursor wraps in a strange way. +@item xs +Flag: clearing a line is the only way to clear the appearance modes of +positions in that line (or, only way to remove magic cookies on that +line). +@item xt +Flag: Teleray 1061; several strange characteristics. +@end table + +@node Var Index, Cap Index, Summary, Top +@unnumbered Variable and Function Index + +@printindex fn + +@node Cap Index, Index, Var Index, Top +@unnumbered Capability Index + +@printindex ky + +@node Index, , Cap Index, Top +@unnumbered Concept Index + +@printindex cp + +@contents +@bye diff --git a/lib/termcap/grot/texinfo.tex b/lib/termcap/grot/texinfo.tex new file mode 100644 index 0000000..f62e9f5 --- /dev/null +++ b/lib/termcap/grot/texinfo.tex @@ -0,0 +1,4422 @@ +%% TeX macros to handle texinfo files + +% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 1994 Free Software Foundation, Inc. + +%This texinfo.tex file is free software; you can redistribute it and/or +%modify it under the terms of the GNU General Public License as +%published by the Free Software Foundation; either version 2, or (at +%your option) any later version. + +%This texinfo.tex file is distributed in the hope that it will be +%useful, but WITHOUT ANY WARRANTY; without even the implied warranty +%of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%General Public License for more details. + +%You should have received a copy of the GNU General Public License +%along with this texinfo.tex file; see the file COPYING. If not, write +%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, +%USA. + + +%In other words, you are welcome to use, share and improve this program. +%You are forbidden to forbid anyone else to use, share and improve +%what you give them. Help stamp out software-hoarding! + + +% Send bug reports to bug-texinfo@prep.ai.mit.edu. +% Please include a *precise* test case in each bug report. + + +% Make it possible to create a .fmt file just by loading this file: +% if the underlying format is not loaded, start by loading it now. +% Added by gildea November 1993. +\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi + +% This automatically updates the version number based on RCS. +\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} +\deftexinfoversion$Revision: 2.146 $ +\message{Loading texinfo package [Version \texinfoversion]:} + +% If in a .fmt file, print the version number +% and turn on active characters that we couldn't do earlier because +% they might have appeared in the input file name. +\everyjob{\message{[Texinfo version \texinfoversion]}\message{} + \catcode`+=\active \catcode`\_=\active} + +% Save some parts of plain tex whose names we will redefine. + +\let\ptextilde=\~ +\let\ptexlbrace=\{ +\let\ptexrbrace=\} +\let\ptexdots=\dots +\let\ptexdot=\. +\let\ptexstar=\* +\let\ptexend=\end +\let\ptexbullet=\bullet +\let\ptexb=\b +\let\ptexc=\c +\let\ptexi=\i +\let\ptext=\t +\let\ptexl=\l +\let\ptexL=\L + +% Be sure we're in horizontal mode when doing a tie, since we make space +% equivalent to this in @example-like environments. Otherwise, a space +% at the beginning of a line will start with \penalty -- and +% since \penalty is valid in vertical mode, we'd end up putting the +% penalty on the vertical list instead of in the new paragraph. +{\catcode`@ = 11 + \gdef\tie{\leavevmode\penalty\@M\ } +} +\let\~ = \tie % And make it available as @~. + +\message{Basics,} +\chardef\other=12 + +% If this character appears in an error message or help string, it +% starts a new line in the output. +\newlinechar = `^^J + +% Set up fixed words for English. +\ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi% +\def\putwordInfo{Info}% +\ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi% +\ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi% +\ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi% +\ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi% +\ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi% +\ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi% +\ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi% +\ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi% +\ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi% + +% Ignore a token. +% +\def\gobble#1{} + +\hyphenation{ap-pen-dix} +\hyphenation{mini-buf-fer mini-buf-fers} +\hyphenation{eshell} + +% Margin to add to right of even pages, to left of odd pages. +\newdimen \bindingoffset \bindingoffset=0pt +\newdimen \normaloffset \normaloffset=\hoffset +\newdimen\pagewidth \newdimen\pageheight +\pagewidth=\hsize \pageheight=\vsize + +% Sometimes it is convenient to have everything in the transcript file +% and nothing on the terminal. We don't just call \tracingall here, +% since that produces some useless output on the terminal. +% +\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% +\def\loggingall{\tracingcommands2 \tracingstats2 + \tracingpages1 \tracingoutput1 \tracinglostchars1 + \tracingmacros2 \tracingparagraphs1 \tracingrestores1 + \showboxbreadth\maxdimen\showboxdepth\maxdimen +}% + +%---------------------Begin change----------------------- +% +%%%% For @cropmarks command. +% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 +% +\newdimen\cornerlong \newdimen\cornerthick +\newdimen \topandbottommargin +\newdimen \outerhsize \newdimen \outervsize +\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks +\outerhsize=7in +%\outervsize=9.5in +% Alternative @smallbook page size is 9.25in +\outervsize=9.25in +\topandbottommargin=.75in +% +%---------------------End change----------------------- + +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions itself, but you have to call it yourself. +\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} +\def\onepageout#1{\hoffset=\normaloffset +\ifodd\pageno \advance\hoffset by \bindingoffset +\else \advance\hoffset by -\bindingoffset\fi +{\escapechar=`\\\relax % makes sure backslash is used in output files. +\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% +{\let\hsize=\pagewidth \makefootline}}}% +\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} + +%%%% For @cropmarks command %%%% + +% Here is a modification of the main output routine for Near East Publications +% This provides right-angle cropmarks at all four corners. +% The contents of the page are centerlined into the cropmarks, +% and any desired binding offset is added as an \hskip on either +% site of the centerlined box. (P. A. MacKay, 12 November, 1986) +% +\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up +{\escapechar=`\\\relax % makes sure backslash is used in output files. + \shipout + \vbox to \outervsize{\hsize=\outerhsize + \vbox{\line{\ewtop\hfill\ewtop}} + \nointerlineskip + \line{\vbox{\moveleft\cornerthick\nstop} + \hfill + \vbox{\moveright\cornerthick\nstop}} + \vskip \topandbottommargin + \centerline{\ifodd\pageno\hskip\bindingoffset\fi + \vbox{ + {\let\hsize=\pagewidth \makeheadline} + \pagebody{#1} + {\let\hsize=\pagewidth \makefootline}} + \ifodd\pageno\else\hskip\bindingoffset\fi} + \vskip \topandbottommargin plus1fill minus1fill + \boxmaxdepth\cornerthick + \line{\vbox{\moveleft\cornerthick\nsbot} + \hfill + \vbox{\moveright\cornerthick\nsbot}} + \nointerlineskip + \vbox{\line{\ewbot\hfill\ewbot}} + }} + \advancepageno + \ifnum\outputpenalty>-20000 \else\dosupereject\fi} +% +% Do @cropmarks to get crop marks +\def\cropmarks{\let\onepageout=\croppageout } + +\newinsert\margin \dimen\margin=\maxdimen + +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} +{\catcode`\@ =11 +\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi +% marginal hacks, juha@viisa.uucp (Juha Takala) +\ifvoid\margin\else % marginal info is present + \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi +\dimen@=\dp#1 \unvbox#1 +\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi +\ifr@ggedbottom \kern-\dimen@ \vfil \fi} +} + +% +% Here are the rules for the cropmarks. Note that they are +% offset so that the space between them is truly \outerhsize or \outervsize +% (P. A. MacKay, 12 November, 1986) +% +\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} +\def\nstop{\vbox + {\hrule height\cornerthick depth\cornerlong width\cornerthick}} +\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} +\def\nsbot{\vbox + {\hrule height\cornerlong depth\cornerthick width\cornerthick}} + +% Parse an argument, then pass it to #1. The argument is the rest of +% the input line (except we remove a trailing comment). #1 should be a +% macro which expects an ordinary undelimited TeX argument. +% +\def\parsearg#1{% + \let\next = #1% + \begingroup + \obeylines + \futurelet\temp\parseargx +} + +% If the next token is an obeyed space (from an @example environment or +% the like), remove it and recurse. Otherwise, we're done. +\def\parseargx{% + % \obeyedspace is defined far below, after the definition of \sepspaces. + \ifx\obeyedspace\temp + \expandafter\parseargdiscardspace + \else + \expandafter\parseargline + \fi +} + +% Remove a single space (as the delimiter token to the macro call). +{\obeyspaces % + \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} + +{\obeylines % + \gdef\parseargline#1^^M{% + \endgroup % End of the group started in \parsearg. + % + % First remove any @c comment, then any @comment. + % Result of each macro is put in \toks0. + \argremovec #1\c\relax % + \expandafter\argremovecomment \the\toks0 \comment\relax % + % + % Call the caller's macro, saved as \next in \parsearg. + \expandafter\next\expandafter{\the\toks0}% + }% +} + +% Since all \c{,omment} does is throw away the argument, we can let TeX +% do that for us. The \relax here is matched by the \relax in the call +% in \parseargline; it could be more or less anything, its purpose is +% just to delimit the argument to the \c. +\def\argremovec#1\c#2\relax{\toks0 = {#1}} +\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} + +% \argremovec{,omment} might leave us with trailing spaces, though; e.g., +% @end itemize @c foo +% will have two active spaces as part of the argument with the +% `itemize'. Here we remove all active spaces from #1, and assign the +% result to \toks0. +% +% This loses if there are any *other* active characters besides spaces +% in the argument -- _ ^ +, for example -- since they get expanded. +% Fortunately, Texinfo does not define any such commands. (If it ever +% does, the catcode of the characters in questionwill have to be changed +% here.) But this means we cannot call \removeactivespaces as part of +% \argremovec{,omment}, since @c uses \parsearg, and thus the argument +% that \parsearg gets might well have any character at all in it. +% +\def\removeactivespaces#1{% + \begingroup + \ignoreactivespaces + \edef\temp{#1}% + \global\toks0 = \expandafter{\temp}% + \endgroup +} + +% Change the active space to expand to nothing. +% +\begingroup + \obeyspaces + \gdef\ignoreactivespaces{\obeyspaces\let =\empty} +\endgroup + + +\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} + +%% These are used to keep @begin/@end levels from running away +%% Call \inENV within environments (after a \begingroup) +\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} +\def\ENVcheck{% +\ifENV\errmessage{Still within an environment. Type Return to continue.} +\endgroup\fi} % This is not perfect, but it should reduce lossage + +% @begin foo is the same as @foo, for now. +\newhelp\EMsimple{Type <Return> to continue.} + +\outer\def\begin{\parsearg\beginxxx} + +\def\beginxxx #1{% +\expandafter\ifx\csname #1\endcsname\relax +{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else +\csname #1\endcsname\fi} + +% @end foo executes the definition of \Efoo. +% +\def\end{\parsearg\endxxx} +\def\endxxx #1{% + \removeactivespaces{#1}% + \edef\endthing{\the\toks0}% + % + \expandafter\ifx\csname E\endthing\endcsname\relax + \expandafter\ifx\csname \endthing\endcsname\relax + % There's no \foo, i.e., no ``environment'' foo. + \errhelp = \EMsimple + \errmessage{Undefined command `@end \endthing'}% + \else + \unmatchedenderror\endthing + \fi + \else + % Everything's ok; the right environment has been started. + \csname E\endthing\endcsname + \fi +} + +% There is an environment #1, but it hasn't been started. Give an error. +% +\def\unmatchedenderror#1{% + \errhelp = \EMsimple + \errmessage{This `@end #1' doesn't have a matching `@#1'}% +} + +% Define the control sequence \E#1 to give an unmatched @end error. +% +\def\defineunmatchedend#1{% + \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% +} + + +% Single-spacing is done by various environments (specifically, in +% \nonfillstart and \quotations). +\newskip\singlespaceskip \singlespaceskip = 12.5pt +\def\singlespace{% + % Why was this kern here? It messes up equalizing space above and below + % environments. --karl, 6may93 + %{\advance \baselineskip by -\singlespaceskip + %\kern \baselineskip}% + \setleading \singlespaceskip +} + +%% Simple single-character @ commands + +% @@ prints an @ +% Kludge this until the fonts are right (grr). +\def\@{{\tt \char '100}} + +% This is turned off because it was never documented +% and you can use @w{...} around a quote to suppress ligatures. +%% Define @` and @' to be the same as ` and ' +%% but suppressing ligatures. +%\def\`{{`}} +%\def\'{{'}} + +% Used to generate quoted braces. + +\def\mylbrace {{\tt \char '173}} +\def\myrbrace {{\tt \char '175}} +\let\{=\mylbrace +\let\}=\myrbrace + +% @: forces normal size whitespace following. +\def\:{\spacefactor=1000 } + +% @* forces a line break. +\def\*{\hfil\break\hbox{}\ignorespaces} + +% @. is an end-of-sentence period. +\def\.{.\spacefactor=3000 } + +% @enddots{} is an end-of-sentence ellipsis. +\gdef\enddots{$\mathinner{\ldotp\ldotp\ldotp\ldotp}$\spacefactor=3000} + +% @! is an end-of-sentence bang. +\gdef\!{!\spacefactor=3000 } + +% @? is an end-of-sentence query. +\gdef\?{?\spacefactor=3000 } + +% @w prevents a word break. Without the \leavevmode, @w at the +% beginning of a paragraph, when TeX is still in vertical mode, would +% produce a whole line of output instead of starting the paragraph. +\def\w#1{\leavevmode\hbox{#1}} + +% @group ... @end group forces ... to be all on one page, by enclosing +% it in a TeX vbox. We use \vtop instead of \vbox to construct the box +% to keep its height that of a normal line. According to the rules for +% \topskip (p.114 of the TeXbook), the glue inserted is +% max (\topskip - \ht (first item), 0). If that height is large, +% therefore, no glue is inserted, and the space between the headline and +% the text is small, which looks bad. +% +\def\group{\begingroup + \ifnum\catcode13=\active \else + \errhelp = \groupinvalidhelp + \errmessage{@group invalid in context where filling is enabled}% + \fi + % + % The \vtop we start below produces a box with normal height and large + % depth; thus, TeX puts \baselineskip glue before it, and (when the + % next line of text is done) \lineskip glue after it. (See p.82 of + % the TeXbook.) Thus, space below is not quite equal to space + % above. But it's pretty close. + \def\Egroup{% + \egroup % End the \vtop. + \endgroup % End the \group. + }% + % + \vtop\bgroup + % We have to put a strut on the last line in case the @group is in + % the midst of an example, rather than completely enclosing it. + % Otherwise, the interline space between the last line of the group + % and the first line afterwards is too small. But we can't put the + % strut in \Egroup, since there it would be on a line by itself. + % Hence this just inserts a strut at the beginning of each line. + \everypar = {\strut}% + % + % Since we have a strut on every line, we don't need any of TeX's + % normal interline spacing. + \offinterlineskip + % + % OK, but now we have to do something about blank + % lines in the input in @example-like environments, which normally + % just turn into \lisppar, which will insert no space now that we've + % turned off the interline space. Simplest is to make them be an + % empty paragraph. + \ifx\par\lisppar + \edef\par{\leavevmode \par}% + % + % Reset ^^M's definition to new definition of \par. + \obeylines + \fi + % + % Do @comment since we are called inside an environment such as + % @example, where each end-of-line in the input causes an + % end-of-line in the output. We don't want the end-of-line after + % the `@group' to put extra space in the output. Since @group + % should appear on a line by itself (according to the Texinfo + % manual), we don't worry about eating any user text. + \comment +} +% +% TeX puts in an \escapechar (i.e., `@') at the beginning of the help +% message, so this ends up printing `@group can only ...'. +% +\newhelp\groupinvalidhelp{% +group can only be used in environments such as @example,^^J% +where each line of input produces a line of output.} + +% @need space-in-mils +% forces a page break if there is not space-in-mils remaining. + +\newdimen\mil \mil=0.001in + +\def\need{\parsearg\needx} + +% Old definition--didn't work. +%\def\needx #1{\par % +%% This method tries to make TeX break the page naturally +%% if the depth of the box does not fit. +%{\baselineskip=0pt% +%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 +%\prevdepth=-1000pt +%}} + +\def\needx#1{% + % Go into vertical mode, so we don't make a big box in the middle of a + % paragraph. + \par + % + % Don't add any leading before our big empty box, but allow a page + % break, since the best break might be right here. + \allowbreak + \nointerlineskip + \vtop to #1\mil{\vfil}% + % + % TeX does not even consider page breaks if a penalty added to the + % main vertical list is 10000 or more. But in order to see if the + % empty box we just added fits on the page, we must make it consider + % page breaks. On the other hand, we don't want to actually break the + % page after the empty box. So we use a penalty of 9999. + % + % There is an extremely small chance that TeX will actually break the + % page at this \penalty, if there are no other feasible breakpoints in + % sight. (If the user is using lots of big @group commands, which + % almost-but-not-quite fill up a page, TeX will have a hard time doing + % good page breaking, for example.) However, I could not construct an + % example where a page broke at this \penalty; if it happens in a real + % document, then we can reconsider our strategy. + \penalty9999 + % + % Back up by the size of the box, whether we did a page break or not. + \kern -#1\mil + % + % Do not allow a page break right after this kern. + \nobreak +} + +% @br forces paragraph break + +\let\br = \par + +% @dots{} output some dots + +\def\dots{$\ldots$} + +% @page forces the start of a new page + +\def\page{\par\vfill\supereject} + +% @exdent text.... +% outputs text on separate line in roman font, starting at standard page margin + +% This records the amount of indent in the innermost environment. +% That's how much \exdent should take out. +\newskip\exdentamount + +% This defn is used inside fill environments such as @defun. +\def\exdent{\parsearg\exdentyyy} +\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} + +% This defn is used inside nofill environments such as @example. +\def\nofillexdent{\parsearg\nofillexdentyyy} +\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount +\leftline{\hskip\leftskip{\rm#1}}}} + +%\hbox{{\rm#1}}\hfil\break}} + +% @include file insert text of that file as input. + +\def\include{\parsearg\includezzz} +%Use \input\thisfile to avoid blank after \input, which may be an active +%char (in which case the blank would become the \input argument). +%The grouping keeps the value of \thisfile correct even when @include +%is nested. +\def\includezzz #1{\begingroup +\def\thisfile{#1}\input\thisfile +\endgroup} + +\def\thisfile{} + +% @center line outputs that line, centered + +\def\center{\parsearg\centerzzz} +\def\centerzzz #1{{\advance\hsize by -\leftskip +\advance\hsize by -\rightskip +\centerline{#1}}} + +% @sp n outputs n lines of vertical space + +\def\sp{\parsearg\spxxx} +\def\spxxx #1{\par \vskip #1\baselineskip} + +% @comment ...line which is ignored... +% @c is the same as @comment +% @ignore ... @end ignore is another way to write a comment + +\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% +\parsearg \commentxxx} + +\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } + +\let\c=\comment + +% Prevent errors for section commands. +% Used in @ignore and in failing conditionals. +\def\ignoresections{% +\let\chapter=\relax +\let\unnumbered=\relax +\let\top=\relax +\let\unnumberedsec=\relax +\let\unnumberedsection=\relax +\let\unnumberedsubsec=\relax +\let\unnumberedsubsection=\relax +\let\unnumberedsubsubsec=\relax +\let\unnumberedsubsubsection=\relax +\let\section=\relax +\let\subsec=\relax +\let\subsubsec=\relax +\let\subsection=\relax +\let\subsubsection=\relax +\let\appendix=\relax +\let\appendixsec=\relax +\let\appendixsection=\relax +\let\appendixsubsec=\relax +\let\appendixsubsection=\relax +\let\appendixsubsubsec=\relax +\let\appendixsubsubsection=\relax +\let\contents=\relax +\let\smallbook=\relax +\let\titlepage=\relax +} + +% Used in nested conditionals, where we have to parse the Texinfo source +% and so want to turn off most commands, in case they are used +% incorrectly. +% +\def\ignoremorecommands{% + \let\defcv = \relax + \let\deffn = \relax + \let\deffnx = \relax + \let\defindex = \relax + \let\defivar = \relax + \let\defmac = \relax + \let\defmethod = \relax + \let\defop = \relax + \let\defopt = \relax + \let\defspec = \relax + \let\deftp = \relax + \let\deftypefn = \relax + \let\deftypefun = \relax + \let\deftypevar = \relax + \let\deftypevr = \relax + \let\defun = \relax + \let\defvar = \relax + \let\defvr = \relax + \let\ref = \relax + \let\xref = \relax + \let\printindex = \relax + \let\pxref = \relax + \let\settitle = \relax + \let\include = \relax + \let\lowersections = \relax + \let\down = \relax + \let\raisesections = \relax + \let\up = \relax + \let\set = \relax + \let\clear = \relax + \let\item = \relax + \let\message = \relax +} + +% Ignore @ignore ... @end ignore. +% +\def\ignore{\doignore{ignore}} + +% Also ignore @ifinfo, @ifhtml, @html, @menu, and @direntry text. +% +\def\ifinfo{\doignore{ifinfo}} +\def\ifhtml{\doignore{ifhtml}} +\def\html{\doignore{html}} +\def\menu{\doignore{menu}} +\def\direntry{\doignore{direntry}} + +% Ignore text until a line `@end #1'. +% +\def\doignore#1{\begingroup + % Don't complain about control sequences we have declared \outer. + \ignoresections + % + % Define a command to swallow text until we reach `@end #1'. + \long\def\doignoretext##1\end #1{\enddoignore}% + % + % Make sure that spaces turn into tokens that match what \doignoretext wants. + \catcode32 = 10 + % + % And now expand that command. + \doignoretext +} + +% What we do to finish off ignored text. +% +\def\enddoignore{\endgroup\ignorespaces}% + +\newif\ifwarnedobs\warnedobsfalse +\def\obstexwarn{% + \ifwarnedobs\relax\else + % We need to warn folks that they may have trouble with TeX 3.0. + % This uses \immediate\write16 rather than \message to get newlines. + \immediate\write16{} + \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} + \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} + \immediate\write16{If you are running another version of TeX, relax.} + \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} + \immediate\write16{ Then upgrade your TeX installation if you can.} + \immediate\write16{If you are stuck with version 3.0, run the} + \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} + \immediate\write16{ to use a workaround.} + \immediate\write16{} + \warnedobstrue + \fi +} + +% **In TeX 3.0, setting text in \nullfont hangs tex. For a +% workaround (which requires the file ``dummy.tfm'' to be installed), +% uncomment the following line: +%%%%%\font\nullfont=dummy\let\obstexwarn=\relax + +% Ignore text, except that we keep track of conditional commands for +% purposes of nesting, up to an `@end #1' command. +% +\def\nestedignore#1{% + \obstexwarn + % We must actually expand the ignored text to look for the @end + % command, so that nested ignore constructs work. Thus, we put the + % text into a \vbox and then do nothing with the result. To minimize + % the change of memory overflow, we follow the approach outlined on + % page 401 of the TeXbook: make the current font be a dummy font. + % + \setbox0 = \vbox\bgroup + % Don't complain about control sequences we have declared \outer. + \ignoresections + % + % Define `@end #1' to end the box, which will in turn undefine the + % @end command again. + \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% + % + % We are going to be parsing Texinfo commands. Most cause no + % trouble when they are used incorrectly, but some commands do + % complicated argument parsing or otherwise get confused, so we + % undefine them. + % + % We can't do anything about stray @-signs, unfortunately; + % they'll produce `undefined control sequence' errors. + \ignoremorecommands + % + % Set the current font to be \nullfont, a TeX primitive, and define + % all the font commands to also use \nullfont. We don't use + % dummy.tfm, as suggested in the TeXbook, because not all sites + % might have that installed. Therefore, math mode will still + % produce output, but that should be an extremely small amount of + % stuff compared to the main input. + % + \nullfont + \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont + \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont + \let\tensf = \nullfont + % Similarly for index fonts (mostly for their use in + % smallexample) + \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont + \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont + \let\indsf = \nullfont + % + % Don't complain when characters are missing from the fonts. + \tracinglostchars = 0 + % + % Don't bother to do space factor calculations. + \frenchspacing + % + % Don't report underfull hboxes. + \hbadness = 10000 + % + % Do minimal line-breaking. + \pretolerance = 10000 + % + % Do not execute instructions in @tex + \def\tex{\doignore{tex}} +} + +% @set VAR sets the variable VAR to an empty value. +% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. +% +% Since we want to separate VAR from REST-OF-LINE (which might be +% empty), we can't just use \parsearg; we have to insert a space of our +% own to delimit the rest of the line, and then take it out again if we +% didn't need it. +% +\def\set{\parsearg\setxxx} +\def\setxxx#1{\setyyy#1 \endsetyyy} +\def\setyyy#1 #2\endsetyyy{% + \def\temp{#2}% + \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty + \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. + \fi +} +% Can't use \xdef to pre-expand #2 and save some time, since \temp or +% \next or other control sequences that we've defined might get us into +% an infinite loop. Consider `@set foo @cite{bar}'. +\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} + +% @clear VAR clears (i.e., unsets) the variable VAR. +% +\def\clear{\parsearg\clearxxx} +\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} + +% @value{foo} gets the text saved in variable foo. +% +\def\value#1{\expandafter + \ifx\csname SET#1\endcsname\relax + {\{No value for ``#1''\}} + \else \csname SET#1\endcsname \fi} + +% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined +% with @set. +% +\def\ifset{\parsearg\ifsetxxx} +\def\ifsetxxx #1{% + \expandafter\ifx\csname SET#1\endcsname\relax + \expandafter\ifsetfail + \else + \expandafter\ifsetsucceed + \fi +} +\def\ifsetsucceed{\conditionalsucceed{ifset}} +\def\ifsetfail{\nestedignore{ifset}} +\defineunmatchedend{ifset} + +% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been +% defined with @set, or has been undefined with @clear. +% +\def\ifclear{\parsearg\ifclearxxx} +\def\ifclearxxx #1{% + \expandafter\ifx\csname SET#1\endcsname\relax + \expandafter\ifclearsucceed + \else + \expandafter\ifclearfail + \fi +} +\def\ifclearsucceed{\conditionalsucceed{ifclear}} +\def\ifclearfail{\nestedignore{ifclear}} +\defineunmatchedend{ifclear} + +% @iftex always succeeds; we read the text following, through @end +% iftex). But `@end iftex' should be valid only after an @iftex. +% +\def\iftex{\conditionalsucceed{iftex}} +\defineunmatchedend{iftex} + +% We can't just want to start a group at @iftex (for example) and end it +% at @end iftex, since then @set commands inside the conditional have no +% effect (they'd get reverted at the end of the group). So we must +% define \Eiftex to redefine itself to be its previous value. (We can't +% just define it to fail again with an ``unmatched end'' error, since +% the @ifset might be nested.) +% +\def\conditionalsucceed#1{% + \edef\temp{% + % Remember the current value of \E#1. + \let\nece{prevE#1} = \nece{E#1}% + % + % At the `@end #1', redefine \E#1 to be its previous value. + \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% + }% + \temp +} + +% We need to expand lots of \csname's, but we don't want to expand the +% control sequences after we've constructed them. +% +\def\nece#1{\expandafter\noexpand\csname#1\endcsname} + +% @asis just yields its argument. Used with @table, for example. +% +\def\asis#1{#1} + +% @math means output in math mode. +% We don't use $'s directly in the definition of \math because control +% sequences like \math are expanded when the toc file is written. Then, +% we read the toc file back, the $'s will be normal characters (as they +% should be, according to the definition of Texinfo). So we must use a +% control sequence to switch into and out of math mode. +% +% This isn't quite enough for @math to work properly in indices, but it +% seems unlikely it will ever be needed there. +% +\let\implicitmath = $ +\def\math#1{\implicitmath #1\implicitmath} + +% @bullet and @minus need the same treatment as @math, just above. +\def\bullet{\implicitmath\ptexbullet\implicitmath} +\def\minus{\implicitmath-\implicitmath} + +\def\node{\ENVcheck\parsearg\nodezzz} +\def\nodezzz#1{\nodexxx [#1,]} +\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} +\let\nwnode=\node +\let\lastnode=\relax + +\def\donoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\setref{\lastnode}\fi +\global\let\lastnode=\relax} + +\def\unnumbnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi +\global\let\lastnode=\relax} + +\def\appendixnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi +\global\let\lastnode=\relax} + +\let\refill=\relax + +% @setfilename is done at the beginning of every texinfo file. +% So open here the files we need to have open while reading the input. +% This makes it possible to make a .fmt file for texinfo. +\def\setfilename{% + \readauxfile + \opencontents + \openindices + \fixbackslash % Turn off hack to swallow `\input texinfo'. + \global\let\setfilename=\comment % Ignore extra @setfilename cmds. + \comment % Ignore the actual filename. +} + +\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} + +\def\inforef #1{\inforefzzz #1,,,,**} +\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, + node \samp{\ignorespaces#1{}}} + +\message{fonts,} + +% Font-change commands. + +% Texinfo supports the sans serif font style, which plain TeX does not. +% So we set up a \sf analogous to plain's \rm, etc. +\newfam\sffam +\def\sf{\fam=\sffam \tensf} +\let\li = \sf % Sometimes we call it \li, not \sf. + +%% Try out Computer Modern fonts at \magstephalf +\let\mainmagstep=\magstephalf + +% Set the font macro #1 to the font named #2, adding on the +% specified font prefix (normally `cm'). +\def\setfont#1#2{\font#1=\fontprefix#2} + +% Use cm as the default font prefix. +% To specify the font prefix, you must define \fontprefix +% before you read in texinfo.tex. +\ifx\fontprefix\undefined +\def\fontprefix{cm} +\fi + +\ifx\bigger\relax +\let\mainmagstep=\magstep1 +\setfont\textrm{r12} +\setfont\texttt{tt12} +\else +\setfont\textrm{r10 scaled \mainmagstep} +\setfont\texttt{tt10 scaled \mainmagstep} +\fi +% Instead of cmb10, you many want to use cmbx10. +% cmbx10 is a prettier font on its own, but cmb10 +% looks better when embedded in a line with cmr10. +\setfont\textbf{b10 scaled \mainmagstep} +\setfont\textit{ti10 scaled \mainmagstep} +\setfont\textsl{sl10 scaled \mainmagstep} +\setfont\textsf{ss10 scaled \mainmagstep} +\setfont\textsc{csc10 scaled \mainmagstep} +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep + +% A few fonts for @defun, etc. +\setfont\defbf{bx10 scaled \magstep1} %was 1314 +\setfont\deftt{tt10 scaled \magstep1} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} + +% Fonts for indices and small examples. +% We actually use the slanted font rather than the italic, +% because texinfo normally uses the slanted fonts for that. +% Do not make many font distinctions in general in the index, since they +% aren't very useful. +\setfont\ninett{tt9} +\setfont\indrm{r9} +\setfont\indit{sl9} +\let\indsl=\indit +\let\indtt=\ninett +\let\indsf=\indrm +\let\indbf=\indrm +\setfont\indsc{csc10 at 9pt} +\font\indi=cmmi9 +\font\indsy=cmsy9 + +% Fonts for headings +\setfont\chaprm{bx12 scaled \magstep2} +\setfont\chapit{ti12 scaled \magstep2} +\setfont\chapsl{sl12 scaled \magstep2} +\setfont\chaptt{tt12 scaled \magstep2} +\setfont\chapsf{ss12 scaled \magstep2} +\let\chapbf=\chaprm +\setfont\chapsc{csc10 scaled\magstep3} +\font\chapi=cmmi12 scaled \magstep2 +\font\chapsy=cmsy10 scaled \magstep3 + +\setfont\secrm{bx12 scaled \magstep1} +\setfont\secit{ti12 scaled \magstep1} +\setfont\secsl{sl12 scaled \magstep1} +\setfont\sectt{tt12 scaled \magstep1} +\setfont\secsf{ss12 scaled \magstep1} +\setfont\secbf{bx12 scaled \magstep1} +\setfont\secsc{csc10 scaled\magstep2} +\font\seci=cmmi12 scaled \magstep1 +\font\secsy=cmsy10 scaled \magstep2 + +% \setfont\ssecrm{bx10 scaled \magstep1} % This size an font looked bad. +% \setfont\ssecit{cmti10 scaled \magstep1} % The letters were too crowded. +% \setfont\ssecsl{sl10 scaled \magstep1} +% \setfont\ssectt{tt10 scaled \magstep1} +% \setfont\ssecsf{ss10 scaled \magstep1} + +%\setfont\ssecrm{b10 scaled 1315} % Note the use of cmb rather than cmbx. +%\setfont\ssecit{ti10 scaled 1315} % Also, the size is a little larger than +%\setfont\ssecsl{sl10 scaled 1315} % being scaled magstep1. +%\setfont\ssectt{tt10 scaled 1315} +%\setfont\ssecsf{ss10 scaled 1315} + +%\let\ssecbf=\ssecrm + +\setfont\ssecrm{bx12 scaled \magstephalf} +\setfont\ssecit{ti12 scaled \magstephalf} +\setfont\ssecsl{sl12 scaled \magstephalf} +\setfont\ssectt{tt12 scaled \magstephalf} +\setfont\ssecsf{ss12 scaled \magstephalf} +\setfont\ssecbf{bx12 scaled \magstephalf} +\setfont\ssecsc{csc10 scaled \magstep1} +\font\sseci=cmmi12 scaled \magstephalf +\font\ssecsy=cmsy10 scaled \magstep1 +% The smallcaps and symbol fonts should actually be scaled \magstep1.5, +% but that is not a standard magnification. + +% Fonts for title page: +\setfont\titlerm{bx12 scaled \magstep3} +\let\authorrm = \secrm + +% In order for the font changes to affect most math symbols and letters, +% we have to define the \textfont of the standard families. Since +% texinfo doesn't allow for producing subscripts and superscripts, we +% don't bother to reset \scriptfont and \scriptscriptfont (which would +% also require loading a lot more fonts). +% +\def\resetmathfonts{% + \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy + \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf + \textfont\ttfam = \tentt \textfont\sffam = \tensf +} + + +% The font-changing commands redefine the meanings of \tenSTYLE, instead +% of just \STYLE. We do this so that font changes will continue to work +% in math mode, where it is the current \fam that is relevant in most +% cases, not the current. Plain TeX does, for example, +% \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need +% to redefine \bf itself. +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy + \resetmathfonts} +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy + \resetmathfonts} +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy + \resetmathfonts} +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy + \resetmathfonts} +\def\indexfonts{% + \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl + \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc + \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy + \resetmathfonts} + +% Set up the default fonts, so we can use them for creating boxes. +% +\textfonts + +% Count depth in font-changes, for error checks +\newcount\fontdepth \fontdepth=0 + +% Fonts for short table of contents. +\setfont\shortcontrm{r12} +\setfont\shortcontbf{bx12} +\setfont\shortcontsl{sl12} + +%% Add scribe-like font environments, plus @l for inline lisp (usually sans +%% serif) and @ii for TeX italic + +% \smartitalic{ARG} outputs arg in italics, followed by an italic correction +% unless the following character is such as not to need one. +\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} +\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} + +\let\i=\smartitalic +\let\var=\smartitalic +\let\dfn=\smartitalic +\let\emph=\smartitalic +\let\cite=\smartitalic + +\def\b#1{{\bf #1}} +\let\strong=\b + +% We can't just use \exhyphenpenalty, because that only has effect at +% the end of a paragraph. Restore normal hyphenation at the end of the +% group within which \nohyphenation is presumably called. +% +\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} +\def\restorehyphenation{\hyphenchar\font = `- } + +\def\t#1{% + {\tt \rawbackslash \frenchspacing #1}% + \null +} +\let\ttfont=\t +\def\samp #1{`\tclose{#1}'\null} +\def\key #1{{\tt \nohyphenation \uppercase{#1}}\null} +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + +\let\file=\samp + +% @code is a modification of @t, +% which makes spaces the same size as normal in the surrounding text. +\def\tclose#1{% + {% + % Change normal interword space to be same as for the current font. + \spaceskip = \fontdimen2\font + % + % Switch to typewriter. + \tt + % + % But `\ ' produces the large typewriter interword space. + \def\ {{\spaceskip = 0pt{} }}% + % + % Turn off hyphenation. + \nohyphenation + % + \rawbackslash + \frenchspacing + #1% + }% + \null +} + +% We *must* turn on hyphenation at `-' and `_' in \code. +% Otherwise, it is too hard to avoid overful hboxes +% in the Emacs manual, the Library manual, etc. + +% Unfortunately, TeX uses one parameter (\hyphenchar) to control +% both hyphenation at - and hyphenation within words. +% We must therefore turn them both off (\tclose does that) +% and arrange explicitly to hyphenate an a dash. +% -- rms. +{ +\catcode`\-=\active +\catcode`\_=\active +\global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex} +% The following is used by \doprintindex to insure that long function names +% wrap around. It is necessary for - and _ to be active before the index is +% read from the file, as \entry parses the arguments long before \code is +% ever called. -- mycroft +\global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder} +} + +\def\realdash{-} +\def\realunder{_} +\def\codedash{-\discretionary{}{}{}} +\def\codeunder{\normalunderscore\discretionary{}{}{}} +\def\codex #1{\tclose{#1}\endgroup} + +%\let\exp=\tclose %Was temporary + +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. + +\def\xkey{\key} +\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% +\ifx\one\xkey\ifx\threex\three \key{#2}% +\else\tclose{\look}\fi +\else\tclose{\look}\fi} + +% Typeset a dimension, e.g., `in' or `pt'. The only reason for the +% argument is to make the input look right: @dmn{pt} instead of +% @dmn{}pt. +% +\def\dmn#1{\thinspace #1} + +\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} + +\def\l#1{{\li #1}\null} % + +\def\r#1{{\rm #1}} % roman font +% Use of \lowercase was suggested. +\def\sc#1{{\smallcaps#1}} % smallcaps font +\def\ii#1{{\it #1}} % italic font + +\message{page headings,} + +\newskip\titlepagetopglue \titlepagetopglue = 1.5in +\newskip\titlepagebottomglue \titlepagebottomglue = 2pc + +% First the title page. Must do @settitle before @titlepage. +\def\titlefont#1{{\titlerm #1}} + +\newif\ifseenauthor +\newif\iffinishedtitlepage + +\def\shorttitlepage{\parsearg\shorttitlepagezzz} +\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% + \endgroup\page\hbox{}\page} + +\def\titlepage{\begingroup \parindent=0pt \textfonts + \let\subtitlerm=\tenrm +% I deinstalled the following change because \cmr12 is undefined. +% This change was not in the ChangeLog anyway. --rms. +% \let\subtitlerm=\cmr12 + \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% + % + \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% + % + % Leave some space at the very top of the page. + \vglue\titlepagetopglue + % + % Now you can print the title using @title. + \def\title{\parsearg\titlezzz}% + \def\titlezzz##1{\leftline{\titlefont{##1}} + % print a rule at the page bottom also. + \finishedtitlepagefalse + \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% + % No rule at page bottom unless we print one at the top with @title. + \finishedtitlepagetrue + % + % Now you can put text using @subtitle. + \def\subtitle{\parsearg\subtitlezzz}% + \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% + % + % @author should come last, but may come many times. + \def\author{\parsearg\authorzzz}% + \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi + {\authorfont \leftline{##1}}}% + % + % Most title ``pages'' are actually two pages long, with space + % at the top of the second. We don't want the ragged left on the second. + \let\oldpage = \page + \def\page{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + \oldpage + \let\page = \oldpage + \hbox{}}% +% \def\page{\oldpage \hbox{}} +} + +\def\Etitlepage{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + % It is important to do the page break before ending the group, + % because the headline and footline are only empty inside the group. + % If we use the new definition of \page, we always get a blank page + % after the title page, which we certainly don't want. + \oldpage + \endgroup + \HEADINGSon +} + +\def\finishtitlepage{% + \vskip4pt \hrule height 2pt width \hsize + \vskip\titlepagebottomglue + \finishedtitlepagetrue +} + +%%% Set up page headings and footings. + +\let\thispage=\folio + +\newtoks \evenheadline % Token sequence for heading line of even pages +\newtoks \oddheadline % Token sequence for heading line of odd pages +\newtoks \evenfootline % Token sequence for footing line of even pages +\newtoks \oddfootline % Token sequence for footing line of odd pages + +% Now make Tex use those variables +\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline + \else \the\evenheadline \fi}} +\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline + \else \the\evenfootline \fi}\HEADINGShook} +\let\HEADINGShook=\relax + +% Commands to set those variables. +% For example, this is what @headings on does +% @evenheading @thistitle|@thispage|@thischapter +% @oddheading @thischapter|@thispage|@thistitle +% @evenfooting @thisfile|| +% @oddfooting ||@thisfile + +\def\evenheading{\parsearg\evenheadingxxx} +\def\oddheading{\parsearg\oddheadingxxx} +\def\everyheading{\parsearg\everyheadingxxx} + +\def\evenfooting{\parsearg\evenfootingxxx} +\def\oddfooting{\parsearg\oddfootingxxx} +\def\everyfooting{\parsearg\everyfootingxxx} + +{\catcode`\@=0 % + +\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} +\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} +\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} +\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} +\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} +\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% +\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} +\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} +\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} +% +}% unbind the catcode of @. + +% @headings double turns headings on for double-sided printing. +% @headings single turns headings on for single-sided printing. +% @headings off turns them off. +% @headings on same as @headings double, retained for compatibility. +% @headings after turns on double-sided headings after this page. +% @headings doubleafter turns on double-sided headings after this page. +% @headings singleafter turns on single-sided headings after this page. +% By default, they are off. + +\def\headings #1 {\csname HEADINGS#1\endcsname} + +\def\HEADINGSoff{ +\global\evenheadline={\hfil} \global\evenfootline={\hfil} +\global\oddheadline={\hfil} \global\oddfootline={\hfil}} +\HEADINGSoff +% When we turn headings on, set the page number to 1. +% For double-sided printing, put current file name in lower left corner, +% chapter name on inside top of right hand pages, document +% title on inside top of left hand pages, and page numbers on outside top +% edge of all pages. +\def\HEADINGSdouble{ +%\pagealignmacro +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} +% For single-sided printing, chapter title goes across top left of page, +% page number on top right. +\def\HEADINGSsingle{ +%\pagealignmacro +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} +\def\HEADINGSon{\HEADINGSdouble} + +\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} +\let\HEADINGSdoubleafter=\HEADINGSafter +\def\HEADINGSdoublex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} + +\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} +\def\HEADINGSsinglex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} + +% Subroutines used in generating headings +% Produces Day Month Year style of output. +\def\today{\number\day\space +\ifcase\month\or +January\or February\or March\or April\or May\or June\or +July\or August\or September\or October\or November\or December\fi +\space\number\year} + +% Use this if you want the Month Day, Year style of output. +%\def\today{\ifcase\month\or +%January\or February\or March\or April\or May\or June\or +%July\or August\or September\or October\or November\or December\fi +%\space\number\day, \number\year} + +% @settitle line... specifies the title of the document, for headings +% It generates no output of its own + +\def\thistitle{No Title} +\def\settitle{\parsearg\settitlezzz} +\def\settitlezzz #1{\gdef\thistitle{#1}} + +\message{tables,} + +% @tabs -- simple alignment + +% These don't work. For one thing, \+ is defined as outer. +% So these macros cannot even be defined. + +%\def\tabs{\parsearg\tabszzz} +%\def\tabszzz #1{\settabs\+#1\cr} +%\def\tabline{\parsearg\tablinezzz} +%\def\tablinezzz #1{\+#1\cr} +%\def\&{&} + +% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). + +% default indentation of table text +\newdimen\tableindent \tableindent=.8in +% default indentation of @itemize and @enumerate text +\newdimen\itemindent \itemindent=.3in +% margin between end of table item and start of table text. +\newdimen\itemmargin \itemmargin=.1in + +% used internally for \itemindent minus \itemmargin +\newdimen\itemmax + +% Note @table, @vtable, and @vtable define @item, @itemx, etc., with +% these defs. +% They also define \itemindex +% to index the item name in whatever manner is desired (perhaps none). + +\newif\ifitemxneedsnegativevskip + +\def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi} + +\def\internalBitem{\smallbreak \parsearg\itemzzz} +\def\internalBitemx{\itemxpar \parsearg\itemzzz} + +\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} +\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} + +\def\internalBkitem{\smallbreak \parsearg\kitemzzz} +\def\internalBkitemx{\itemxpar \parsearg\kitemzzz} + +\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% + \itemzzz {#1}} + +\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% + \itemzzz {#1}} + +\def\itemzzz #1{\begingroup % + \advance\hsize by -\rightskip + \advance\hsize by -\tableindent + \setbox0=\hbox{\itemfont{#1}}% + \itemindex{#1}% + \nobreak % This prevents a break before @itemx. + % + % Be sure we are not still in the middle of a paragraph. + %{\parskip = 0in + %\par + %}% + % + % If the item text does not fit in the space we have, put it on a line + % by itself, and do not allow a page break either before or after that + % line. We do not start a paragraph here because then if the next + % command is, e.g., @kindex, the whatsit would get put into the + % horizontal list on a line by itself, resulting in extra blank space. + \ifdim \wd0>\itemmax + % + % Make this a paragraph so we get the \parskip glue and wrapping, + % but leave it ragged-right. + \begingroup + \advance\leftskip by-\tableindent + \advance\hsize by\tableindent + \advance\rightskip by0pt plus1fil + \leavevmode\unhbox0\par + \endgroup + % + % We're going to be starting a paragraph, but we don't want the + % \parskip glue -- logically it's part of the @item we just started. + \nobreak \vskip-\parskip + % + % Stop a page break at the \parskip glue coming up. Unfortunately + % we can't prevent a possible page break at the following + % \baselineskip glue. + \nobreak + \endgroup + \itemxneedsnegativevskipfalse + \else + % The item text fits into the space. Start a paragraph, so that the + % following text (if any) will end up on the same line. Since that + % text will be indented by \tableindent, we make the item text be in + % a zero-width box. + \noindent + \rlap{\hskip -\tableindent\box0}\ignorespaces% + \endgroup% + \itemxneedsnegativevskiptrue% + \fi +} + +\def\item{\errmessage{@item while not in a table}} +\def\itemx{\errmessage{@itemx while not in a table}} +\def\kitem{\errmessage{@kitem while not in a table}} +\def\kitemx{\errmessage{@kitemx while not in a table}} +\def\xitem{\errmessage{@xitem while not in a table}} +\def\xitemx{\errmessage{@xitemx while not in a table}} + +%% Contains a kludge to get @end[description] to work +\def\description{\tablez{\dontindex}{1}{}{}{}{}} + +\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} +{\obeylines\obeyspaces% +\gdef\tablex #1^^M{% +\tabley\dontindex#1 \endtabley}} + +\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} +{\obeylines\obeyspaces% +\gdef\ftablex #1^^M{% +\tabley\fnitemindex#1 \endtabley +\def\Eftable{\endgraf\afterenvbreak\endgroup}% +\let\Etable=\relax}} + +\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} +{\obeylines\obeyspaces% +\gdef\vtablex #1^^M{% +\tabley\vritemindex#1 \endtabley +\def\Evtable{\endgraf\afterenvbreak\endgroup}% +\let\Etable=\relax}} + +\def\dontindex #1{} +\def\fnitemindex #1{\doind {fn}{\code{#1}}}% +\def\vritemindex #1{\doind {vr}{\code{#1}}}% + +{\obeyspaces % +\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% +\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} + +\def\tablez #1#2#3#4#5#6{% +\aboveenvbreak % +\begingroup % +\def\Edescription{\Etable}% Neccessary kludge. +\let\itemindex=#1% +\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % +\ifnum 0#4>0 \tableindent=#4\mil \fi % +\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % +\def\itemfont{#2}% +\itemmax=\tableindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \tableindent % +\exdentamount=\tableindent +\parindent = 0pt +\parskip = \smallskipamount +\ifdim \parskip=0pt \parskip=2pt \fi% +\def\Etable{\endgraf\afterenvbreak\endgroup}% +\let\item = \internalBitem % +\let\itemx = \internalBitemx % +\let\kitem = \internalBkitem % +\let\kitemx = \internalBkitemx % +\let\xitem = \internalBxitem % +\let\xitemx = \internalBxitemx % +} + +% This is the counter used by @enumerate, which is really @itemize + +\newcount \itemno + +\def\itemize{\parsearg\itemizezzz} + +\def\itemizezzz #1{% + \begingroup % ended by the @end itemsize + \itemizey {#1}{\Eitemize} +} + +\def\itemizey #1#2{% +\aboveenvbreak % +\itemmax=\itemindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \itemindent % +\exdentamount=\itemindent +\parindent = 0pt % +\parskip = \smallskipamount % +\ifdim \parskip=0pt \parskip=2pt \fi% +\def#2{\endgraf\afterenvbreak\endgroup}% +\def\itemcontents{#1}% +\let\item=\itemizeitem} + +% Set sfcode to normal for the chars that usually have another value. +% These are `.?!:;,' +\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 + \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } + +% \splitoff TOKENS\endmark defines \first to be the first token in +% TOKENS, and \rest to be the remainder. +% +\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% + +% Allow an optional argument of an uppercase letter, lowercase letter, +% or number, to specify the first label in the enumerated list. No +% argument is the same as `1'. +% +\def\enumerate{\parsearg\enumeratezzz} +\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} +\def\enumeratey #1 #2\endenumeratey{% + \begingroup % ended by the @end enumerate + % + % If we were given no argument, pretend we were given `1'. + \def\thearg{#1}% + \ifx\thearg\empty \def\thearg{1}\fi + % + % Detect if the argument is a single token. If so, it might be a + % letter. Otherwise, the only valid thing it can be is a number. + % (We will always have one token, because of the test we just made. + % This is a good thing, since \splitoff doesn't work given nothing at + % all -- the first parameter is undelimited.) + \expandafter\splitoff\thearg\endmark + \ifx\rest\empty + % Only one token in the argument. It could still be anything. + % A ``lowercase letter'' is one whose \lccode is nonzero. + % An ``uppercase letter'' is one whose \lccode is both nonzero, and + % not equal to itself. + % Otherwise, we assume it's a number. + % + % We need the \relax at the end of the \ifnum lines to stop TeX from + % continuing to look for a <number>. + % + \ifnum\lccode\expandafter`\thearg=0\relax + \numericenumerate % a number (we hope) + \else + % It's a letter. + \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax + \lowercaseenumerate % lowercase letter + \else + \uppercaseenumerate % uppercase letter + \fi + \fi + \else + % Multiple tokens in the argument. We hope it's a number. + \numericenumerate + \fi +} + +% An @enumerate whose labels are integers. The starting integer is +% given in \thearg. +% +\def\numericenumerate{% + \itemno = \thearg + \startenumeration{\the\itemno}% +} + +% The starting (lowercase) letter is in \thearg. +\def\lowercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more lowercase letters in @enumerate; get a bigger + alphabet}% + \fi + \char\lccode\itemno + }% +} + +% The starting (uppercase) letter is in \thearg. +\def\uppercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more uppercase letters in @enumerate; get a bigger + alphabet} + \fi + \char\uccode\itemno + }% +} + +% Call itemizey, adding a period to the first argument and supplying the +% common last two arguments. Also subtract one from the initial value in +% \itemno, since @item increments \itemno. +% +\def\startenumeration#1{% + \advance\itemno by -1 + \itemizey{#1.}\Eenumerate\flushcr +} + +% @alphaenumerate and @capsenumerate are abbreviations for giving an arg +% to @enumerate. +% +\def\alphaenumerate{\enumerate{a}} +\def\capsenumerate{\enumerate{A}} +\def\Ealphaenumerate{\Eenumerate} +\def\Ecapsenumerate{\Eenumerate} + +% Definition of @item while inside @itemize. + +\def\itemizeitem{% +\advance\itemno by 1 +{\let\par=\endgraf \smallbreak}% +\ifhmode \errmessage{\in hmode at itemizeitem}\fi +{\parskip=0in \hskip 0pt +\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% +\vadjust{\penalty 1200}}% +\flushcr} + +% @multitable macros +% Amy Hendrickson, 8/18/94 +% +% @multitable ... @endmultitable will make as many columns as desired. +% Contents of each column will wrap at width given in preamble. Width +% can be specified either with sample text given in a template line, +% or in percent of \hsize, the current width of text on page. + +% Table can continue over pages but will only break between lines. + +% To make preamble: +% +% Either define widths of columns in terms of percent of \hsize: +% @multitable @percentofhsize .2 .3 .5 +% @item ... +% +% Numbers following @percentofhsize are the percent of the total +% current hsize to be used for each column. You may use as many +% columns as desired. + +% Or use a template: +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item ... +% using the widest term desired in each column. + + +% Each new table line starts with @item, each subsequent new column +% starts with @tab. Empty columns may be produced by supplying @tab's +% with nothing between them for as many times as empty columns are needed, +% ie, @tab@tab@tab will produce two empty columns. + +% @item, @tab, @multicolumn or @endmulticolumn do not need to be on their +% own lines, but it will not hurt if they are. + +% Sample multitable: + +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item first col stuff @tab second col stuff @tab third col +% @item +% first col stuff +% @tab +% second col stuff +% @tab +% third col +% @item first col stuff @tab second col stuff +% @tab Many paragraphs of text may be used in any column. +% +% They will wrap at the width determined by the template. +% @item@tab@tab This will be in third column. +% @endmultitable + +% Default dimensions may be reset by user. +% @intableparskip will set vertical space between paragraphs in table. +% @intableparindent will set paragraph indent in table. +% @spacebetweencols will set horizontal space to be left between columns. +% @spacebetweenlines will set vertical space to be left between lines. + +%%%% +% Dimensions + +\newdimen\intableparskip +\newdimen\intableparindent +\newdimen\spacebetweencols +\newdimen\spacebetweenlines +\intableparskip=0pt +\intableparindent=6pt +\spacebetweencols=12pt +\spacebetweenlines=12pt + +%%%% +% Macros used to set up halign preamble: +\let\endsetuptable\relax +\def\xendsetuptable{\endsetuptable} +\let\percentofhsize\relax +\def\xpercentofhsize{\percentofhsize} +\newif\ifsetpercent + +\newcount\colcount +\def\setuptable#1{\def\firstarg{#1}% +\ifx\firstarg\xendsetuptable\let\go\relax% +\else + \ifx\firstarg\xpercentofhsize\global\setpercenttrue% + \else + \ifsetpercent + \if#1.\else% + \global\advance\colcount by1 % + \expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}% + \fi + \else + \global\advance\colcount by1 + \setbox0=\hbox{#1}% + \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% + \fi% + \fi% + \let\go\setuptable% +\fi\go} +%%%% +% multitable syntax +\def\tab{&} + +%%%% +% @multitable ... @endmultitable definitions: + +\def\multitable#1\item{\bgroup +\let\item\cr +\tolerance=9500 +\hbadness=9500 +\parskip=\intableparskip +\parindent=\intableparindent +\overfullrule=0pt +\global\colcount=0\relax% +\def\Emultitable{\global\setpercentfalse\global\everycr{}\cr\egroup\egroup}% + % To parse everything between @multitable and @item : +\def\one{#1}\expandafter\setuptable\one\endsetuptable + % Need to reset this to 0 after \setuptable. +\global\colcount=0\relax% + % + % This preamble sets up a generic column definition, which will + % be used as many times as user calls for columns. + % \vtop will set a single line and will also let text wrap and + % continue for many paragraphs if desired. +\halign\bgroup&\global\advance\colcount by 1\relax% +\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname + % In order to keep entries from bumping into each other + % we will add a \leftskip of \spacebetweencols to all columns after + % the first one. + % If a template has been used, we will add \spacebetweencols + % to the width of each template entry. + % If user has set preamble in terms of percent of \hsize + % we will use that dimension as the width of the column, and + % the \leftskip will keep entries from bumping into each other. + % Table will start at left margin and final column will justify at + % right margin. +\ifnum\colcount=1 +\else + \ifsetpercent + \else + % If user has <not> set preamble in terms of percent of \hsize + % we will advance \hsize by \spacebetweencols + \advance\hsize by \spacebetweencols + \fi + % In either case we will make \leftskip=\spacebetweencols: +\leftskip=\spacebetweencols +\fi +\noindent##}\cr% + % \everycr will reset column counter, \colcount, at the end of + % each line. Every column entry will cause \colcount to advance by one. + % The table preamble + % looks at the current \colcount to find the correct column width. +\global\everycr{\noalign{\nointerlineskip\vskip\spacebetweenlines +\filbreak%% keeps underfull box messages off when table breaks over pages. +\global\colcount=0\relax}}} + +\message{indexing,} +% Index generation facilities + +% Define \newwrite to be identical to plain tex's \newwrite +% except not \outer, so it can be used within \newindex. +{\catcode`\@=11 +\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} + +% \newindex {foo} defines an index named foo. +% It automatically defines \fooindex such that +% \fooindex ...rest of line... puts an entry in the index foo. +% It also defines \fooindfile to be the number of the output channel for +% the file that accumulates this index. The file's extension is foo. +% The name of an index should be no more than 2 characters long +% for the sake of vms. + +\def\newindex #1{ +\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file +\openout \csname#1indfile\endcsname \jobname.#1 % Open the file +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\doindex {#1}} +} + +% @defindex foo == \newindex{foo} + +\def\defindex{\parsearg\newindex} + +% Define @defcodeindex, like @defindex except put all entries in @code. + +\def\newcodeindex #1{ +\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file +\openout \csname#1indfile\endcsname \jobname.#1 % Open the file +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\docodeindex {#1}} +} + +\def\defcodeindex{\parsearg\newcodeindex} + +% @synindex foo bar makes index foo feed into index bar. +% Do this instead of @defindex foo if you don't want it as a separate index. +\def\synindex #1 #2 {% +\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname +\expandafter\let\csname#1indfile\endcsname=\synindexfoo +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\doindex {#2}}% +} + +% @syncodeindex foo bar similar, but put all entries made for index foo +% inside @code. +\def\syncodeindex #1 #2 {% +\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname +\expandafter\let\csname#1indfile\endcsname=\synindexfoo +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\docodeindex {#2}}% +} + +% Define \doindex, the driver for all \fooindex macros. +% Argument #1 is generated by the calling \fooindex macro, +% and it is "foo", the name of the index. + +% \doindex just uses \parsearg; it calls \doind for the actual work. +% This is because \doind is more useful to call from other macros. + +% There is also \dosubind {index}{topic}{subtopic} +% which makes an entry in a two-level index such as the operation index. + +\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} +\def\singleindexer #1{\doind{\indexname}{#1}} + +% like the previous two, but they put @code around the argument. +\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} +\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} + +\def\indexdummies{% +% Take care of the plain tex accent commands. +\def\"{\realbackslash "}% +\def\`{\realbackslash `}% +\def\'{\realbackslash '}% +\def\^{\realbackslash ^}% +\def\~{\realbackslash ~}% +\def\={\realbackslash =}% +\def\b{\realbackslash b}% +\def\c{\realbackslash c}% +\def\d{\realbackslash d}% +\def\u{\realbackslash u}% +\def\v{\realbackslash v}% +\def\H{\realbackslash H}% +% Take care of the plain tex special European modified letters. +\def\oe{\realbackslash oe}% +\def\ae{\realbackslash ae}% +\def\aa{\realbackslash aa}% +\def\OE{\realbackslash OE}% +\def\AE{\realbackslash AE}% +\def\AA{\realbackslash AA}% +\def\o{\realbackslash o}% +\def\O{\realbackslash O}% +\def\l{\realbackslash l}% +\def\L{\realbackslash L}% +\def\ss{\realbackslash ss}% +% Take care of texinfo commands likely to appear in an index entry. +\def\_{{\realbackslash _}}% +\def\w{\realbackslash w }% +\def\bf{\realbackslash bf }% +\def\rm{\realbackslash rm }% +\def\sl{\realbackslash sl }% +\def\sf{\realbackslash sf}% +\def\tt{\realbackslash tt}% +\def\gtr{\realbackslash gtr}% +\def\less{\realbackslash less}% +\def\hat{\realbackslash hat}% +\def\char{\realbackslash char}% +\def\TeX{\realbackslash TeX}% +\def\dots{\realbackslash dots }% +\def\copyright{\realbackslash copyright }% +\def\tclose##1{\realbackslash tclose {##1}}% +\def\code##1{\realbackslash code {##1}}% +\def\samp##1{\realbackslash samp {##1}}% +\def\t##1{\realbackslash r {##1}}% +\def\r##1{\realbackslash r {##1}}% +\def\i##1{\realbackslash i {##1}}% +\def\b##1{\realbackslash b {##1}}% +\def\cite##1{\realbackslash cite {##1}}% +\def\key##1{\realbackslash key {##1}}% +\def\file##1{\realbackslash file {##1}}% +\def\var##1{\realbackslash var {##1}}% +\def\kbd##1{\realbackslash kbd {##1}}% +\def\dfn##1{\realbackslash dfn {##1}}% +\def\emph##1{\realbackslash emph {##1}}% +} + +% \indexnofonts no-ops all font-change commands. +% This is used when outputting the strings to sort the index by. +\def\indexdummyfont#1{#1} +\def\indexdummytex{TeX} +\def\indexdummydots{...} + +\def\indexnofonts{% +% Just ignore accents. +\let\"=\indexdummyfont +\let\`=\indexdummyfont +\let\'=\indexdummyfont +\let\^=\indexdummyfont +\let\~=\indexdummyfont +\let\==\indexdummyfont +\let\b=\indexdummyfont +\let\c=\indexdummyfont +\let\d=\indexdummyfont +\let\u=\indexdummyfont +\let\v=\indexdummyfont +\let\H=\indexdummyfont +% Take care of the plain tex special European modified letters. +\def\oe{oe}% +\def\ae{ae}% +\def\aa{aa}% +\def\OE{OE}% +\def\AE{AE}% +\def\AA{AA}% +\def\o{o}% +\def\O{O}% +\def\l{l}% +\def\L{L}% +\def\ss{ss}% +\let\w=\indexdummyfont +\let\t=\indexdummyfont +\let\r=\indexdummyfont +\let\i=\indexdummyfont +\let\b=\indexdummyfont +\let\emph=\indexdummyfont +\let\strong=\indexdummyfont +\let\cite=\indexdummyfont +\let\sc=\indexdummyfont +%Don't no-op \tt, since it isn't a user-level command +% and is used in the definitions of the active chars like <, >, |... +%\let\tt=\indexdummyfont +\let\tclose=\indexdummyfont +\let\code=\indexdummyfont +\let\file=\indexdummyfont +\let\samp=\indexdummyfont +\let\kbd=\indexdummyfont +\let\key=\indexdummyfont +\let\var=\indexdummyfont +\let\TeX=\indexdummytex +\let\dots=\indexdummydots +} + +% To define \realbackslash, we must make \ not be an escape. +% We must first make another character (@) an escape +% so we do not become unable to do a definition. + +{\catcode`\@=0 \catcode`\\=\other +@gdef@realbackslash{\}} + +\let\indexbackslash=0 %overridden during \printindex. + +\let\SETmarginindex=\relax %initialize! +% workhorse for all \fooindexes +% #1 is name of index, #2 is stuff to put there +\def\doind #1#2{% +% Put the index entry in the margin if desired. +\ifx\SETmarginindex\relax\else% +\insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% +\fi% +{\count10=\lastpenalty % +{\indexdummies % Must do this here, since \bf, etc expand at this stage +\escapechar=`\\% +{\let\folio=0% Expand all macros now EXCEPT \folio +\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now +% so it will be output as is; and it will print as backslash in the indx. +% +% Now process the index-string once, with all font commands turned off, +% to get the string to sort the index by. +{\indexnofonts +\xdef\temp1{#2}% +}% +% Now produce the complete index entry. We process the index-string again, +% this time with font commands expanded, to get what to print in the index. +\edef\temp{% +\write \csname#1indfile\endcsname{% +\realbackslash entry {\temp1}{\folio}{#2}}}% +\temp }% +}\penalty\count10}} + +\def\dosubind #1#2#3{% +{\count10=\lastpenalty % +{\indexdummies % Must do this here, since \bf, etc expand at this stage +\escapechar=`\\% +{\let\folio=0% +\def\rawbackslashxx{\indexbackslash}% +% +% Now process the index-string once, with all font commands turned off, +% to get the string to sort the index by. +{\indexnofonts +\xdef\temp1{#2 #3}% +}% +% Now produce the complete index entry. We process the index-string again, +% this time with font commands expanded, to get what to print in the index. +\edef\temp{% +\write \csname#1indfile\endcsname{% +\realbackslash entry {\temp1}{\folio}{#2}{#3}}}% +\temp }% +}\penalty\count10}} + +% The index entry written in the file actually looks like +% \entry {sortstring}{page}{topic} +% or +% \entry {sortstring}{page}{topic}{subtopic} +% The texindex program reads in these files and writes files +% containing these kinds of lines: +% \initial {c} +% before the first topic whose initial is c +% \entry {topic}{pagelist} +% for a topic that is used without subtopics +% \primary {topic} +% for the beginning of a topic that is used with subtopics +% \secondary {subtopic}{pagelist} +% for each subtopic. + +% Define the user-accessible indexing commands +% @findex, @vindex, @kindex, @cindex. + +\def\findex {\fnindex} +\def\kindex {\kyindex} +\def\cindex {\cpindex} +\def\vindex {\vrindex} +\def\tindex {\tpindex} +\def\pindex {\pgindex} + +\def\cindexsub {\begingroup\obeylines\cindexsub} +{\obeylines % +\gdef\cindexsub "#1" #2^^M{\endgroup % +\dosubind{cp}{#2}{#1}}} + +% Define the macros used in formatting output of the sorted index material. + +% This is what you call to cause a particular index to get printed. +% Write +% @unnumbered Function Index +% @printindex fn + +\def\printindex{\parsearg\doprintindex} + +\def\doprintindex#1{% + \tex + \dobreak \chapheadingskip {10000} + \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other + \catcode`\$=\other + \catcode`\~=\other + \indexbreaks + % + % The following don't help, since the chars were translated + % when the raw index was written, and their fonts were discarded + % due to \indexnofonts. + %\catcode`\"=\active + %\catcode`\^=\active + %\catcode`\_=\active + %\catcode`\|=\active + %\catcode`\<=\active + %\catcode`\>=\active + % % + \def\indexbackslash{\rawbackslashxx} + \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt + \begindoublecolumns + % + % See if the index file exists and is nonempty. + \openin 1 \jobname.#1s + \ifeof 1 + % \enddoublecolumns gets confused if there is no text in the index, + % and it loses the chapter title and the aux file entries for the + % index. The easiest way to prevent this problem is to make sure + % there is some text. + (Index is nonexistent) + \else + % + % If the index file exists but is empty, then \openin leaves \ifeof + % false. We have to make TeX try to read something from the file, so + % it can discover if there is anything in it. + \read 1 to \temp + \ifeof 1 + (Index is empty) + \else + \input \jobname.#1s + \fi + \fi + \closein 1 + \enddoublecolumns + \Etex +} + +% These macros are used by the sorted index file itself. +% Change them to control the appearance of the index. + +% Same as \bigskipamount except no shrink. +% \balancecolumns gets confused if there is any shrink. +\newskip\initialskipamount \initialskipamount 12pt plus4pt + +\def\initial #1{% +{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt +\ifdim\lastskip<\initialskipamount +\removelastskip \penalty-200 \vskip \initialskipamount\fi +\line{\secbf#1\hfill}\kern 2pt\penalty10000}} + +% This typesets a paragraph consisting of #1, dot leaders, and then #2 +% flush to the right margin. It is used for index and table of contents +% entries. The paragraph is indented by \leftskip. +% +\def\entry #1#2{\begingroup + % + % Start a new paragraph if necessary, so our assignments below can't + % affect previous text. + \par + % + % Do not fill out the last line with white space. + \parfillskip = 0in + % + % No extra space above this paragraph. + \parskip = 0in + % + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % \hangindent is only relevant when the entry text and page number + % don't both fit on one line. In that case, bob suggests starting the + % dots pretty far over on the line. Unfortunately, a large + % indentation looks wrong when the entry text itself is broken across + % lines. So we use a small indentation and put up with long leaders. + % + % \hangafter is reset to 1 (which is the value we want) at the start + % of each paragraph, so we need not do anything with that. + \hangindent=2em + % + % When the entry text needs to be broken, just fill out the first line + % with blank space. + \rightskip = 0pt plus1fil + % + % Start a ``paragraph'' for the index entry so the line breaking + % parameters we've set above will have an effect. + \noindent + % + % Insert the text of the index entry. TeX will do line-breaking on it. + #1% + % The following is kluged to not output a line of dots in the index if + % there are no page numbers. The next person who breaks this will be + % cursed by a Unix daemon. + \def\tempa{{\rm }}% + \def\tempb{#2}% + \edef\tempc{\tempa}% + \edef\tempd{\tempb}% + \ifx\tempc\tempd\ \else% + % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 + \null\nobreak\indexdotfill % Have leaders before the page number. + % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without it, a spurious underfull + % \hbox ensues. + \ #2% The page number ends the paragraph. + \fi% + \par +\endgroup} + +% Like \dotfill except takes at least 1 em. +\def\indexdotfill{\cleaders + \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} + +\def\primary #1{\line{#1\hfil}} + +\newskip\secondaryindent \secondaryindent=0.5cm + +\def\secondary #1#2{ +{\parfillskip=0in \parskip=0in +\hangindent =1in \hangafter=1 +\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par +}} + +%% Define two-column mode, which is used in indexes. +%% Adapted from the TeXbook, page 416. +\catcode `\@=11 + +\newbox\partialpage + +\newdimen\doublecolumnhsize + +\def\begindoublecolumns{\begingroup + % Grab any single-column material above us. + \output = {\global\setbox\partialpage + =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}% + \eject + % + % Now switch to the double-column output routine. + \output={\doublecolumnout}% + % + % Change the page size parameters. We could do this once outside this + % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 + % format, but then we repeat the same computation. Repeating a couple + % of assignments once per index is clearly meaningless for the + % execution time, so we may as well do it once. + % + % First we halve the line length, less a little for the gutter between + % the columns. We compute the gutter based on the line length, so it + % changes automatically with the paper format. The magic constant + % below is chosen so that the gutter has the same value (well, +- < + % 1pt) as it did when we hard-coded it. + % + % We put the result in a separate register, \doublecolumhsize, so we + % can restore it in \pagesofar, after \hsize itself has (potentially) + % been clobbered. + % + \doublecolumnhsize = \hsize + \advance\doublecolumnhsize by -.04154\hsize + \divide\doublecolumnhsize by 2 + \hsize = \doublecolumnhsize + % + % Double the \vsize as well. (We don't need a separate register here, + % since nobody clobbers \vsize.) + \vsize = 2\vsize + \doublecolumnpagegoal +} + +\def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage} + +\def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth + \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage + \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1} + \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3} + \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi + \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi +} +\def\doublecolumnpagegoal{% + \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@ +} +\def\pagesofar{\unvbox\partialpage % + \hsize=\doublecolumnhsize % have to restore this since output routine + \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} +\def\doublecolumnout{% + \setbox5=\copy255 + {\vbadness=10000 \doublecolumnsplit} + \ifvbox255 + \setbox0=\vtop to\dimen@{\unvbox0} + \setbox2=\vtop to\dimen@{\unvbox2} + \onepageout\pagesofar \unvbox255 \penalty\outputpenalty + \else + \setbox0=\vbox{\unvbox5} + \ifvbox0 + \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip + \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth + {\vbadness=10000 + \loop \global\setbox5=\copy0 + \setbox1=\vsplit5 to\dimen@ + \setbox3=\vsplit5 to\dimen@ + \ifvbox5 \global\advance\dimen@ by1pt \repeat + \setbox0=\vbox to\dimen@{\unvbox1} + \setbox2=\vbox to\dimen@{\unvbox3} + \global\setbox\partialpage=\vbox{\pagesofar} + \doublecolumnpagegoal + } + \fi + \fi +} + +\catcode `\@=\other +\message{sectioning,} +% Define chapters, sections, etc. + +\newcount \chapno +\newcount \secno \secno=0 +\newcount \subsecno \subsecno=0 +\newcount \subsubsecno \subsubsecno=0 + +% This counter is funny since it counts through charcodes of letters A, B, ... +\newcount \appendixno \appendixno = `\@ +\def\appendixletter{\char\the\appendixno} + +\newwrite \contentsfile +% This is called from \setfilename. +\def\opencontents{\openout \contentsfile = \jobname.toc} + +% Each @chapter defines this as the name of the chapter. +% page headings and footings can use it. @section does likewise + +\def\thischapter{} \def\thissection{} +\def\seccheck#1{\if \pageno<0 % +\errmessage{@#1 not allowed after generating table of contents}\fi +% +} + +\def\chapternofonts{% +\let\rawbackslash=\relax% +\let\frenchspacing=\relax% +\def\result{\realbackslash result} +\def\equiv{\realbackslash equiv} +\def\expansion{\realbackslash expansion} +\def\print{\realbackslash print} +\def\TeX{\realbackslash TeX} +\def\dots{\realbackslash dots} +\def\copyright{\realbackslash copyright} +\def\tt{\realbackslash tt} +\def\bf{\realbackslash bf } +\def\w{\realbackslash w} +\def\less{\realbackslash less} +\def\gtr{\realbackslash gtr} +\def\hat{\realbackslash hat} +\def\char{\realbackslash char} +\def\tclose##1{\realbackslash tclose {##1}} +\def\code##1{\realbackslash code {##1}} +\def\samp##1{\realbackslash samp {##1}} +\def\r##1{\realbackslash r {##1}} +\def\b##1{\realbackslash b {##1}} +\def\key##1{\realbackslash key {##1}} +\def\file##1{\realbackslash file {##1}} +\def\kbd##1{\realbackslash kbd {##1}} +% These are redefined because @smartitalic wouldn't work inside xdef. +\def\i##1{\realbackslash i {##1}} +\def\cite##1{\realbackslash cite {##1}} +\def\var##1{\realbackslash var {##1}} +\def\emph##1{\realbackslash emph {##1}} +\def\dfn##1{\realbackslash dfn {##1}} +} + +\newcount\absseclevel % used to calculate proper heading level +\newcount\secbase\secbase=0 % @raise/lowersections modify this count + +% @raisesections: treat @section as chapter, @subsection as section, etc. +\def\raisesections{\global\advance\secbase by -1} +\let\up=\raisesections % original BFox name + +% @lowersections: treat @chapter as section, @section as subsection, etc. +\def\lowersections{\global\advance\secbase by 1} +\let\down=\lowersections % original BFox name + +% Choose a numbered-heading macro +% #1 is heading level if unmodified by @raisesections or @lowersections +% #2 is text for heading +\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \chapterzzz{#2} +\or + \seczzz{#2} +\or + \numberedsubseczzz{#2} +\or + \numberedsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \chapterzzz{#2} + \else + \numberedsubsubseczzz{#2} + \fi +\fi +} + +% like \numhead, but chooses appendix heading levels +\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \appendixzzz{#2} +\or + \appendixsectionzzz{#2} +\or + \appendixsubseczzz{#2} +\or + \appendixsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \appendixzzz{#2} + \else + \appendixsubsubseczzz{#2} + \fi +\fi +} + +% like \numhead, but chooses numberless heading levels +\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \unnumberedzzz{#2} +\or + \unnumberedseczzz{#2} +\or + \unnumberedsubseczzz{#2} +\or + \unnumberedsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \unnumberedzzz{#2} + \else + \unnumberedsubsubseczzz{#2} + \fi +\fi +} + + +\def\thischaptername{No Chapter Title} +\outer\def\chapter{\parsearg\chapteryyy} +\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz +\def\chapterzzz #1{\seccheck{chapter}% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \chapno by 1 \message{\putwordChapter \the\chapno}% +\chapmacro {#1}{\the\chapno}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +% We don't substitute the actual chapter name into \thischapter +% because we don't want its macros evaluated now. +\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% +{\chapternofonts% +\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec +}} + +\outer\def\appendix{\parsearg\appendixyyy} +\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz +\def\appendixzzz #1{\seccheck{appendix}% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \appendixno by 1 \message{Appendix \appendixletter}% +\chapmacro {#1}{\putwordAppendix{} \appendixletter}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% +{\chapternofonts% +\edef\temp{{\realbackslash chapentry + {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\global\let\section = \appendixsec +\global\let\subsection = \appendixsubsec +\global\let\subsubsection = \appendixsubsubsec +}} + +\outer\def\top{\parsearg\unnumberedyyy} +\outer\def\unnumbered{\parsearg\unnumberedyyy} +\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz +\def\unnumberedzzz #1{\seccheck{unnumbered}% +\secno=0 \subsecno=0 \subsubsecno=0 +% +% This used to be simply \message{#1}, but TeX fully expands the +% argument to \message. Therefore, if #1 contained @-commands, TeX +% expanded them. For example, in `@unnumbered The @cite{Book}', TeX +% expanded @cite (which turns out to cause errors because \cite is meant +% to be executed, not expanded). +% +% Anyway, we don't want the fully-expanded definition of @cite to appear +% as a result of the \message, we just want `@cite' itself. We use +% \the<toks register> to achieve this: TeX expands \the<toks> only once, +% simply yielding the contents of the <toks register>. +\toks0 = {#1}\message{(\the\toks0)}% +% +\unnumbchapmacro {#1}% +\gdef\thischapter{#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\global\let\section = \unnumberedsec +\global\let\subsection = \unnumberedsubsec +\global\let\subsubsection = \unnumberedsubsubsec +}} + +\outer\def\numberedsec{\parsearg\secyyy} +\def\secyyy #1{\numhead1{#1}} % normally calls seczzz +\def\seczzz #1{\seccheck{section}% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% +{\chapternofonts% +\edef\temp{{\realbackslash secentry % +{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appenixsection{\parsearg\appendixsecyyy} +\outer\def\appendixsec{\parsearg\appendixsecyyy} +\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz +\def\appendixsectionzzz #1{\seccheck{appendixsection}% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% +{\chapternofonts% +\edef\temp{{\realbackslash secentry % +{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} +\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz +\def\unnumberedseczzz #1{\seccheck{unnumberedsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} +\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz +\def\numberedsubseczzz #1{\seccheck{subsection}% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsecentry % +{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} +\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz +\def\appendixsubseczzz #1{\seccheck{appendixsubsec}% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsecentry % +{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} +\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz +\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} +\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz +\def\numberedsubsubseczzz #1{\seccheck{subsubsection}% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsubsecentry % + {#1} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} + {\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} +\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz +\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsubsecentry{#1}% + {\appendixletter} + {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} +\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz +\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +% These are variants which are not "outer", so they can appear in @ifinfo. +% Actually, they should now be obsolete; ordinary section commands should work. +\def\infotop{\parsearg\unnumberedzzz} +\def\infounnumbered{\parsearg\unnumberedzzz} +\def\infounnumberedsec{\parsearg\unnumberedseczzz} +\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} +\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} + +\def\infoappendix{\parsearg\appendixzzz} +\def\infoappendixsec{\parsearg\appendixseczzz} +\def\infoappendixsubsec{\parsearg\appendixsubseczzz} +\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} + +\def\infochapter{\parsearg\chapterzzz} +\def\infosection{\parsearg\sectionzzz} +\def\infosubsection{\parsearg\subsectionzzz} +\def\infosubsubsection{\parsearg\subsubsectionzzz} + +% These macros control what the section commands do, according +% to what kind of chapter we are in (ordinary, appendix, or unnumbered). +% Define them by default for a numbered chapter. +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec + +% Define @majorheading, @heading and @subheading + +% NOTE on use of \vbox for chapter headings, section headings, and +% such: +% 1) We use \vbox rather than the earlier \line to permit +% overlong headings to fold. +% 2) \hyphenpenalty is set to 10000 because hyphenation in a +% heading is obnoxious; this forbids it. +% 3) Likewise, headings look best if no \parindent is used, and +% if justification is not attempted. Hence \raggedright. + + +\def\majorheading{\parsearg\majorheadingzzz} +\def\majorheadingzzz #1{% +{\advance\chapheadingskip by 10pt \chapbreak }% +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +\def\chapheading{\parsearg\chapheadingzzz} +\def\chapheadingzzz #1{\chapbreak % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +\def\heading{\parsearg\secheadingi} + +\def\subheading{\parsearg\subsecheadingi} + +\def\subsubheading{\parsearg\subsubsecheadingi} + +% These macros generate a chapter, section, etc. heading only +% (including whitespace, linebreaking, etc. around it), +% given all the information in convenient, parsed form. + +%%% Args are the skip and penalty (usually negative) +\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} + +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} + +%%% Define plain chapter starts, and page on/off switching for it +% Parameter controlling skip before chapter headings (if needed) + +\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt + +\def\chapbreak{\dobreak \chapheadingskip {-4000}} +\def\chappager{\par\vfill\supereject} +\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} + +\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} + +\def\CHAPPAGoff{ +\global\let\pchapsepmacro=\chapbreak +\global\let\pagealignmacro=\chappager} + +\def\CHAPPAGon{ +\global\let\pchapsepmacro=\chappager +\global\let\pagealignmacro=\chappager +\global\def\HEADINGSon{\HEADINGSsingle}} + +\def\CHAPPAGodd{ +\global\let\pchapsepmacro=\chapoddpage +\global\let\pagealignmacro=\chapoddpage +\global\def\HEADINGSon{\HEADINGSdouble}} + +\CHAPPAGon + +\def\CHAPFplain{ +\global\let\chapmacro=\chfplain +\global\let\unnumbchapmacro=\unnchfplain} + +\def\chfplain #1#2{% + \pchapsepmacro + {% + \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #2\enspace #1}% + }% + \bigskip + \penalty5000 +} + +\def\unnchfplain #1{% +\pchapsepmacro % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 10000 % +} +\CHAPFplain % The default + +\def\unnchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 10000 % +} + +\def\chfopen #1#2{\chapoddpage {\chapfonts +\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% +\par\penalty 5000 % +} + +\def\CHAPFopen{ +\global\let\chapmacro=\chfopen +\global\let\unnumbchapmacro=\unnchfopen} + +% Parameter controlling skip before section headings. + +\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt +\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} + +\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt +\def\secheadingbreak{\dobreak \secheadingskip {-1000}} + +% @paragraphindent is defined for the Info formatting commands only. +\let\paragraphindent=\comment + +% Section fonts are the base font at magstep2, which produces +% a size a bit more than 14 points in the default situation. + +\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} +\def\plainsecheading #1{\secheadingi {#1}} +\def\secheadingi #1{{\advance \secheadingskip by \parskip % +\secheadingbreak}% +{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } + + +% Subsection fonts are the base font at magstep1, +% which produces a size of 12 points. + +\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} +\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % +\subsecheadingbreak}% +{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } + +\def\subsubsecfonts{\subsecfonts} % Maybe this should change: + % Perhaps make sssec fonts scaled + % magstep half +\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} +\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % +\subsecheadingbreak}% +{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} + + +\message{toc printing,} + +% Finish up the main text and prepare to read what we've written +% to \contentsfile. + +\newskip\contentsrightmargin \contentsrightmargin=1in +\def\startcontents#1{% + \pagealignmacro + \immediate\closeout \contentsfile + \ifnum \pageno>0 + \pageno = -1 % Request roman numbered pages. + \fi + % Don't need to put `Contents' or `Short Contents' in the headline. + % It is abundantly clear what they are. + \unnumbchapmacro{#1}\def\thischapter{}% + \begingroup % Set up to handle contents files properly. + \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 + \catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi + \raggedbottom % Worry more about breakpoints than the bottom. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. +} + + +% Normal (long) toc. +\outer\def\contents{% + \startcontents{\putwordTableofContents}% + \input \jobname.toc + \endgroup + \vfill \eject +} + +% And just the chapters. +\outer\def\summarycontents{% + \startcontents{\putwordShortContents}% + % + \let\chapentry = \shortchapentry + \let\unnumbchapentry = \shortunnumberedentry + % We want a true roman here for the page numbers. + \secfonts + \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl + \rm + \advance\baselineskip by 1pt % Open it up a little. + \def\secentry ##1##2##3##4{} + \def\unnumbsecentry ##1##2{} + \def\subsecentry ##1##2##3##4##5{} + \def\unnumbsubsecentry ##1##2{} + \def\subsubsecentry ##1##2##3##4##5##6{} + \def\unnumbsubsubsecentry ##1##2{} + \input \jobname.toc + \endgroup + \vfill \eject +} +\let\shortcontents = \summarycontents + +% These macros generate individual entries in the table of contents. +% The first argument is the chapter or section name. +% The last argument is the page number. +% The arguments in between are the chapter number, section number, ... + +% Chapter-level things, for both the long and short contents. +\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} + +% See comments in \dochapentry re vbox and related settings +\def\shortchapentry#1#2#3{% + \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% +} + +% Typeset the label for a chapter or appendix for the short contents. +% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. +% We could simplify the code here by writing out an \appendixentry +% command in the toc file for appendices, instead of using \chapentry +% for both, but it doesn't seem worth it. +\setbox0 = \hbox{\shortcontrm \putwordAppendix } +\newdimen\shortappendixwidth \shortappendixwidth = \wd0 + +\def\shortchaplabel#1{% + % We typeset #1 in a box of constant width, regardless of the text of + % #1, so the chapter titles will come out aligned. + \setbox0 = \hbox{#1}% + \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi + % + % This space should be plenty, since a single number is .5em, and the + % widest letter (M) is 1em, at least in the Computer Modern fonts. + % (This space doesn't include the extra space that gets added after + % the label; that gets put in in \shortchapentry above.) + \advance\dimen0 by 1.1em + \hbox to \dimen0{#1\hfil}% +} + +\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} +\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} + +% Sections. +\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} +\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} + +% Subsections. +\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} +\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} + +% And subsubsections. +\def\subsubsecentry#1#2#3#4#5#6{% + \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} +\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} + + +% This parameter controls the indentation of the various levels. +\newdimen\tocindent \tocindent = 3pc + +% Now for the actual typesetting. In all these, #1 is the text and #2 is the +% page number. +% +% If the toc has to be broken over pages, we would want to be at chapters +% if at all possible; hence the \penalty. +\def\dochapentry#1#2{% + \penalty-300 \vskip\baselineskip + \begingroup + \chapentryfonts + \tocentry{#1}{\dopageno{#2}}% + \endgroup + \nobreak\vskip .25\baselineskip +} + +\def\dosecentry#1#2{\begingroup + \secentryfonts \leftskip=\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +\def\dosubsecentry#1#2{\begingroup + \subsecentryfonts \leftskip=2\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +\def\dosubsubsecentry#1#2{\begingroup + \subsubsecentryfonts \leftskip=3\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +% Final typesetting of a toc entry; we use the same \entry macro as for +% the index entries, but we want to suppress hyphenation here. (We +% can't do that in the \entry macro, since index entries might consist +% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) +% +% \turnoffactive is for the sake of @" used for umlauts. +\def\tocentry#1#2{\begingroup + \hyphenpenalty = 10000 + \entry{\turnoffactive #1}{\turnoffactive #2}% +\endgroup} + +% Space between chapter (or whatever) number and the title. +\def\labelspace{\hskip1em \relax} + +\def\dopageno#1{{\rm #1}} +\def\doshortpageno#1{{\rm #1}} + +\def\chapentryfonts{\secfonts \rm} +\def\secentryfonts{\textfonts} +\let\subsecentryfonts = \textfonts +\let\subsubsecentryfonts = \textfonts + + +\message{environments,} + +% Since these characters are used in examples, it should be an even number of +% \tt widths. Each \tt character is 1en, so two makes it 1em. +% Furthermore, these definitions must come after we define our fonts. +\newbox\dblarrowbox \newbox\longdblarrowbox +\newbox\pushcharbox \newbox\bullbox +\newbox\equivbox \newbox\errorbox + +\let\ptexequiv = \equiv + +%{\tentt +%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} +%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} +%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} +%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} +% Adapted from the manmac format (p.420 of TeXbook) +%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex +% depth .1ex\hfil} +%} + +\def\point{$\star$} + +\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} +\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} +\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} + +\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} + +% Adapted from the TeXbook's \boxit. +{\tentt \global\dimen0 = 3em}% Width of the box. +\dimen2 = .55pt % Thickness of rules +% The text. (`r' is open on the right, `e' somewhat less so on the left.) +\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} + +\global\setbox\errorbox=\hbox to \dimen0{\hfil + \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. + \advance\hsize by -2\dimen2 % Rules. + \vbox{ + \hrule height\dimen2 + \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. + \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. + \kern3pt\vrule width\dimen2}% Space to right. + \hrule height\dimen2} + \hfil} + +% The @error{} command. +\def\error{\leavevmode\lower.7ex\copy\errorbox} + +% @tex ... @end tex escapes into raw Tex temporarily. +% One exception: @ is still an escape character, so that @end tex works. +% But \@ or @@ will get a plain tex @ character. + +\def\tex{\begingroup +\catcode `\\=0 \catcode `\{=1 \catcode `\}=2 +\catcode `\$=3 \catcode `\&=4 \catcode `\#=6 +\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie +\catcode `\%=14 +\catcode 43=12 +\catcode`\"=12 +\catcode`\==12 +\catcode`\|=12 +\catcode`\<=12 +\catcode`\>=12 +\escapechar=`\\ +% +\let\~=\ptextilde +\let\{=\ptexlbrace +\let\}=\ptexrbrace +\let\.=\ptexdot +\let\*=\ptexstar +\let\dots=\ptexdots +\def\@{@}% +\let\bullet=\ptexbullet +\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl +\let\L=\ptexL +% +\let\Etex=\endgroup} + +% Define @lisp ... @endlisp. +% @lisp does a \begingroup so it can rebind things, +% including the definition of @endlisp (which normally is erroneous). + +% Amount to narrow the margins by for @lisp. +\newskip\lispnarrowing \lispnarrowing=0.4in + +% This is the definition that ^^M gets inside @lisp, @example, and other +% such environments. \null is better than a space, since it doesn't +% have any width. +\def\lisppar{\null\endgraf} + +% Make each space character in the input produce a normal interword +% space in the output. Don't allow a line break at this space, as this +% is used only in environments like @example, where each line of input +% should produce a line of output anyway. +% +{\obeyspaces % +\gdef\sepspaces{\obeyspaces\let =\tie}} + +% Define \obeyedspace to be our active space, whatever it is. This is +% for use in \parsearg. +{\sepspaces% +\global\let\obeyedspace= } + +% This space is always present above and below environments. +\newskip\envskipamount \envskipamount = 0pt + +% Make spacing and below environment symmetrical. We use \parskip here +% to help in doing that, since in @example-like environments \parskip +% is reset to zero; thus the \afterenvbreak inserts no space -- but the +% start of the next paragraph will insert \parskip +% +\def\aboveenvbreak{{\advance\envskipamount by \parskip +\endgraf \ifdim\lastskip<\envskipamount +\removelastskip \penalty-50 \vskip\envskipamount \fi}} + +\let\afterenvbreak = \aboveenvbreak + +% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. +\let\nonarrowing=\relax + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \cartouche: draw rectangle w/rounded corners around argument +\font\circle=lcircle10 +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip +\circthick=\fontdimen8\circle +% +\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth +\def\ctr{{\hskip 6pt\circle\char'010}} +\def\cbl{{\circle\char'012\hskip -6pt}} +\def\cbr{{\hskip 6pt\circle\char'011}} +\def\carttop{\hbox to \cartouter{\hskip\lskip + \ctl\leaders\hrule height\circthick\hfil\ctr + \hskip\rskip}} +\def\cartbot{\hbox to \cartouter{\hskip\lskip + \cbl\leaders\hrule height\circthick\hfil\cbr + \hskip\rskip}} +% +\newskip\lskip\newskip\rskip + +\long\def\cartouche{% +\begingroup + \lskip=\leftskip \rskip=\rightskip + \leftskip=0pt\rightskip=0pt %we want these *outside*. + \cartinner=\hsize \advance\cartinner by-\lskip + \advance\cartinner by-\rskip + \cartouter=\hsize + \advance\cartouter by 18pt % allow for 3pt kerns on either +% side, and for 6pt waste from +% each corner char + \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing=\comment + \vbox\bgroup + \baselineskip=0pt\parskip=0pt\lineskip=0pt + \carttop + \hbox\bgroup + \hskip\lskip + \vrule\kern3pt + \vbox\bgroup + \hsize=\cartinner + \kern3pt + \begingroup + \baselineskip=\normbskip + \lineskip=\normlskip + \parskip=\normpskip + \vskip -\parskip +\def\Ecartouche{% + \endgroup + \kern3pt + \egroup + \kern3pt\vrule + \hskip\rskip + \egroup + \cartbot + \egroup +\endgroup +}} + + +% This macro is called at the beginning of all the @example variants, +% inside a group. +\def\nonfillstart{% + \aboveenvbreak + \inENV % This group ends at the end of the body + \hfuzz = 12pt % Don't be fussy + \sepspaces % Make spaces be word-separators rather than space tokens. + \singlespace + \let\par = \lisppar % don't ignore blank lines + \obeylines % each line of input is a line of output + \parskip = 0pt + \parindent = 0pt + \emergencystretch = 0pt % don't try to avoid overfull boxes + % @cartouche defines \nonarrowing to inhibit narrowing + % at next level down. + \ifx\nonarrowing\relax + \advance \leftskip by \lispnarrowing + \exdentamount=\lispnarrowing + \let\exdent=\nofillexdent + \let\nonarrowing=\relax + \fi +} + +% To ending an @example-like environment, we first end the paragraph +% (via \afterenvbreak's vertical glue), and then the group. That way we +% keep the zero \parskip that the environments set -- \parskip glue +% will be inserted at the beginning of the next paragraph in the +% document, after the environment. +% +\def\nonfillfinish{\afterenvbreak\endgroup}% + +% This macro is +\def\lisp{\begingroup + \nonfillstart + \let\Elisp = \nonfillfinish + \tt + \rawbackslash % have \ input char produce \ char from current font + \gobble +} + +% Define the \E... control sequence only if we are inside the +% environment, so the error checking in \end will work. +% +% We must call \lisp last in the definition, since it reads the +% return following the @example (or whatever) command. +% +\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} +\def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp} +\def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp} + +% @smallexample and @smalllisp. This is not used unless the @smallbook +% command is given. Originally contributed by Pavel@xerox. +% +\def\smalllispx{\begingroup + \nonfillstart + \let\Esmalllisp = \nonfillfinish + \let\Esmallexample = \nonfillfinish + % + % Smaller interline space and fonts for small examples. + \setleading{10pt}% + \indexfonts \tt + \rawbackslash % make \ output the \ character from the current font (tt) + \gobble +} + +% This is @display; same as @lisp except use roman font. +% +\def\display{\begingroup + \nonfillstart + \let\Edisplay = \nonfillfinish + \gobble +} + +% This is @format; same as @display except don't narrow margins. +% +\def\format{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eformat = \nonfillfinish + \gobble +} + +% @flushleft (same as @format) and @flushright. +% +\def\flushleft{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eflushleft = \nonfillfinish + \gobble +} +\def\flushright{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eflushright = \nonfillfinish + \advance\leftskip by 0pt plus 1fill + \gobble} + +% @quotation does normal linebreaking (hence we can't use \nonfillstart) +% and narrows the margins. +% +\def\quotation{% + \begingroup\inENV %This group ends at the end of the @quotation body + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \singlespace + \parindent=0pt + % We have retained a nonzero parskip for the environment, since we're + % doing normal filling. So to avoid extra space below the environment... + \def\Equotation{\parskip = 0pt \nonfillfinish}% + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing + \advance\rightskip by \lispnarrowing + \exdentamount = \lispnarrowing + \let\nonarrowing = \relax + \fi +} + +\message{defuns,} +% Define formatter for defuns +% First, allow user to change definition object font (\df) internally +\def\setdeffont #1 {\csname DEF#1\endcsname} + +\newskip\defbodyindent \defbodyindent=.4in +\newskip\defargsindent \defargsindent=50pt +\newskip\deftypemargin \deftypemargin=12pt +\newskip\deflastargmargin \deflastargmargin=18pt + +\newcount\parencount +% define \functionparens, which makes ( and ) and & do special things. +% \functionparens affects the group it is contained in. +\def\activeparens{% +\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active +\catcode`\[=\active \catcode`\]=\active} + +% Make control sequences which act like normal parenthesis chars. +\let\lparen = ( \let\rparen = ) + +{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) + +% Be sure that we always have a definition for `(', etc. For example, +% if the fn name has parens in it, \boldbrax will not be in effect yet, +% so TeX would otherwise complain about undefined control sequence. +\global\let(=\lparen \global\let)=\rparen +\global\let[=\lbrack \global\let]=\rbrack + +\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } +\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} +% This is used to turn on special parens +% but make & act ordinary (given that it's active). +\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} + +% Definitions of (, ) and & used in args for functions. +% This is the definition of ( outside of all parentheses. +\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % +\global\advance\parencount by 1 } +% +% This is the definition of ( when already inside a level of parens. +\gdef\opnested{\char`\(\global\advance\parencount by 1 } +% +\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. +% also in that case restore the outer-level definition of (. +\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi +\global\advance \parencount by -1 } +% If we encounter &foo, then turn on ()-hacking afterwards +\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } +% +\gdef\normalparens{\boldbrax\let&=\ampnr} +} % End of definition inside \activeparens +%% These parens (in \boldbrax) actually are a little bolder than the +%% contained text. This is especially needed for [ and ] +\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} +\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} + +% First, defname, which formats the header line itself. +% #1 should be the function name. +% #2 should be the type of definition, such as "Function". + +\def\defname #1#2{% +% Get the values of \leftskip and \rightskip as they were +% outside the @def... +\dimen2=\leftskip +\advance\dimen2 by -\defbodyindent +\dimen3=\rightskip +\advance\dimen3 by -\defbodyindent +\noindent % +\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% +\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line +\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations +\parshape 2 0in \dimen0 \defargsindent \dimen1 % +% Now output arg 2 ("Function" or some such) +% ending at \deftypemargin from the right margin, +% but stuck inside a box of width 0 so it does not interfere with linebreaking +{% Adjust \hsize to exclude the ambient margins, +% so that \rightline will obey them. +\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 +\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% +% Make all lines underfull and no complaints: +\tolerance=10000 \hbadness=10000 +\advance\leftskip by -\defbodyindent +\exdentamount=\defbodyindent +{\df #1}\enskip % Generate function name +} + +% Actually process the body of a definition +% #1 should be the terminating control sequence, such as \Edefun. +% #2 should be the "another name" control sequence, such as \defunx. +% #3 should be the control sequence that actually processes the header, +% such as \defunheader. + +\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % 61 is `=' +\obeylines\activeparens\spacesplit#3} + +\def\defmethparsebody #1#2#3#4 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} + +\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} + +% These parsing functions are similar to the preceding ones +% except that they do not make parens into active characters. +% These are used for "variables" since they have no arguments. + +\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % +\obeylines\spacesplit#3} + +% This is used for \def{tp,vr}parsebody. It could probably be used for +% some of the others, too, with some judicious conditionals. +% +\def\parsebodycommon#1#2#3{% + \begingroup\inENV % + \medbreak % + % Define the end token that this defining construct specifies + % so that it will exit this group. + \def#1{\endgraf\endgroup\medbreak}% + \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% + \parindent=0in + \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent + \exdentamount=\defbodyindent + \begingroup\obeylines +} + +\def\defvrparsebody#1#2#3#4 {% + \parsebodycommon{#1}{#2}{#3}% + \spacesplit{#3{#4}}% +} + +% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the +% type is just `struct', because we lose the braces in `{struct +% termios}' when \spacesplit reads its undelimited argument. Sigh. +% \let\deftpparsebody=\defvrparsebody +% +% So, to get around this, we put \empty in with the type name. That +% way, TeX won't find exactly `{...}' as an undelimited argument, and +% won't strip off the braces. +% +\def\deftpparsebody #1#2#3#4 {% + \parsebodycommon{#1}{#2}{#3}% + \spacesplit{\parsetpheaderline{#3{#4}}}\empty +} + +% Fine, but then we have to eventually remove the \empty *and* the +% braces (if any). That's what this does, putting the result in \tptemp. +% +\def\removeemptybraces\empty#1\relax{\def\tptemp{#1}}% + +% After \spacesplit has done its work, this is called -- #1 is the final +% thing to call, #2 the type name (which starts with \empty), and #3 +% (which might be empty) the arguments. +% +\def\parsetpheaderline#1#2#3{% + \removeemptybraces#2\relax + #1{\tptemp}{#3}% +}% + +\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\spacesplit{#3{#5}}} + +% Split up #2 at the first space token. +% call #1 with two arguments: +% the first is all of #2 before the space token, +% the second is all of #2 after that space token. +% If #2 contains no space token, all of it is passed as the first arg +% and the second is passed as empty. + +{\obeylines +\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% +\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% +\ifx\relax #3% +#1{#2}{}\else #1{#2}{#3#4}\fi}} + +% So much for the things common to all kinds of definitions. + +% Define @defun. + +% First, define the processing that is wanted for arguments of \defun +% Use this to expand the args and terminate the paragraph they make up + +\def\defunargs #1{\functionparens \sl +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +\hyphenchar\tensl=0 +#1% +\hyphenchar\tensl=45 +\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\penalty 10000\vskip -\parskip\penalty 10000% +} + +\def\deftypefunargs #1{% +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +% Use \boldbraxnoamp, not \functionparens, so that & is not special. +\boldbraxnoamp +\tclose{#1}% avoid \code because of side effects on active chars +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\penalty 10000\vskip -\parskip\penalty 10000% +} + +% Do complete processing of one @defun or @defunx line already parsed. + +% @deffn Command forward-char nchars + +\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} + +\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% +\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defun == @deffn Function + +\def\defun{\defparsebody\Edefun\defunx\defunheader} + +\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Function}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefun int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} + +% #1 is the data type. #2 is the name and args. +\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} +% #1 is the data type, #2 the name, #3 the args. +\def\deftypefunheaderx #1#2 #3\relax{% +\doind {fn}{\code{#2}}% Make entry in function index +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}% +\deftypefunargs {#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} + +% \defheaderxcond#1\relax$$$ +% puts #1 in @code, followed by a space, but does nothing if #1 is null. +\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} + +% #1 is the classification. #2 is the data type. #3 is the name and args. +\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} +% #1 is the classification, #2 the data type, #3 the name, #4 the args. +\def\deftypefnheaderx #1#2#3 #4\relax{% +\doind {fn}{\code{#3}}% Make entry in function index +\begingroup +\normalparens % notably, turn off `&' magic, which prevents +% at least some C++ text from working +\defname {\defheaderxcond#2\relax$$$#3}{#1}% +\deftypefunargs {#4}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defmac == @deffn Macro + +\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} + +\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Macro}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defspec == @deffn Special Form + +\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} + +\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Special Form}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% This definition is run if you use @defunx +% anywhere other than immediately after a @defun or @defunx. + +\def\deffnx #1 {\errmessage{@deffnx in invalid context}} +\def\defunx #1 {\errmessage{@defunx in invalid context}} +\def\defmacx #1 {\errmessage{@defmacx in invalid context}} +\def\defspecx #1 {\errmessage{@defspecx in invalid context}} +\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} +\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} + +% @defmethod, and so on + +% @defop {Funny Method} foo-class frobnicate argument + +\def\defop #1 {\def\defoptype{#1}% +\defopparsebody\Edefop\defopx\defopheader\defoptype} + +\def\defopheader #1#2#3{% +\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index +\begingroup\defname {#2}{\defoptype{} on #1}% +\defunargs {#3}\endgroup % +} + +% @defmethod == @defop Method + +\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} + +\def\defmethodheader #1#2#3{% +\dosubind {fn}{\code{#2}}{on #1}% entry in function index +\begingroup\defname {#2}{Method on #1}% +\defunargs {#3}\endgroup % +} + +% @defcv {Class Option} foo-class foo-flag + +\def\defcv #1 {\def\defcvtype{#1}% +\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} + +\def\defcvarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index +\begingroup\defname {#2}{\defcvtype{} of #1}% +\defvarargs {#3}\endgroup % +} + +% @defivar == @defcv {Instance Variable} + +\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} + +\def\defivarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index +\begingroup\defname {#2}{Instance Variable of #1}% +\defvarargs {#3}\endgroup % +} + +% These definitions are run if you use @defmethodx, etc., +% anywhere other than immediately after a @defmethod, etc. + +\def\defopx #1 {\errmessage{@defopx in invalid context}} +\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} +\def\defcvx #1 {\errmessage{@defcvx in invalid context}} +\def\defivarx #1 {\errmessage{@defivarx in invalid context}} + +% Now @defvar + +% First, define the processing that is wanted for arguments of @defvar. +% This is actually simple: just print them in roman. +% This must expand the args and terminate the paragraph they make up +\def\defvarargs #1{\normalparens #1% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000} + +% @defvr Counter foo-count + +\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} + +\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% +\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} + +% @defvar == @defvr Variable + +\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} + +\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{Variable}% +\defvarargs {#2}\endgroup % +} + +% @defopt == @defvr {User Option} + +\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} + +\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{User Option}% +\defvarargs {#2}\endgroup % +} + +% @deftypevar int foobar + +\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} + +% #1 is the data type. #2 is the name. +\def\deftypevarheader #1#2{% +\doind {vr}{\code{#2}}% Make entry in variables index +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} + +% @deftypevr {Global Flag} int enable + +\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} + +\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% +\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} + +% This definition is run if you use @defvarx +% anywhere other than immediately after a @defvar or @defvarx. + +\def\defvrx #1 {\errmessage{@defvrx in invalid context}} +\def\defvarx #1 {\errmessage{@defvarx in invalid context}} +\def\defoptx #1 {\errmessage{@defoptx in invalid context}} +\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} +\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} + +% Now define @deftp +% Args are printed in bold, a slight difference from @defvar. + +\def\deftpargs #1{\bf \defvarargs{#1}} + +% @deftp Class window height width ... + +\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} + +\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% +\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} + +% This definition is run if you use @deftpx, etc +% anywhere other than immediately after a @deftp, etc. + +\def\deftpx #1 {\errmessage{@deftpx in invalid context}} + +\message{cross reference,} +% Define cross-reference macros +\newwrite \auxfile + +\newif\ifhavexrefs % True if xref values are known. +\newif\ifwarnedxrefs % True if we warned once that they aren't known. + +% \setref{foo} defines a cross-reference point named foo. + +\def\setref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Ysectionnumberandtype}} + +\def\unnumbsetref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Ynothing}} + +\def\appendixsetref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Yappendixletterandtype}} + +% \xref, \pxref, and \ref generate cross-references to specified points. +% For \xrefX, #1 is the node name, #2 the name of the Info +% cross-reference, #3 the printed node name, #4 the name of the Info +% file, #5 the name of the printed manual. All but the node name can be +% omitted. +% +\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} +\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} +\def\ref#1{\xrefX[#1,,,,,,,]} +\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup + \def\printedmanual{\ignorespaces #5}% + \def\printednodename{\ignorespaces #3}% + \setbox1=\hbox{\printedmanual}% + \setbox0=\hbox{\printednodename}% + \ifdim \wd0 = 0pt + % No printed node name was explicitly given. + \ifx\SETxref-automatic-section-title\relax % + % Use the actual chapter/section title appear inside + % the square brackets. Use the real section title if we have it. + \ifdim \wd1>0pt% + % It is in another manual, so we don't have it. + \def\printednodename{\ignorespaces #1}% + \else + \ifhavexrefs + % We know the real title if we have the xref values. + \def\printednodename{\refx{#1-title}}% + \else + % Otherwise just copy the Info node name. + \def\printednodename{\ignorespaces #1}% + \fi% + \fi + \def\printednodename{#1-title}% + \else + % Use the node name inside the square brackets. + \def\printednodename{\ignorespaces #1}% + \fi + \fi + % + % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not + % insert empty discretionaries after hyphens, which means that it will + % not find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, this + % is a loss. Therefore, we give the text of the node name again, so it + % is as if TeX is seeing it for the first time. + \ifdim \wd1 > 0pt + \putwordsection{} ``\printednodename'' in \cite{\printedmanual}% + \else + % _ (for example) has to be the character _ for the purposes of the + % control sequence corresponding to the node, but it has to expand + % into the usual \leavevmode...\vrule stuff for purposes of + % printing. So we \turnoffactive for the \refx-snt, back on for the + % printing, back off for the \refx-pg. + {\turnoffactive \refx{#1-snt}{}}% + \space [\printednodename],\space + \turnoffactive \putwordpage\tie\refx{#1-pg}{}% + \fi +\endgroup} + +% \dosetq is the interface for calls from other macros + +% Use \turnoffactive so that punctuation chars such as underscore +% work in node names. +\def\dosetq #1#2{{\let\folio=0 \turnoffactive \auxhat% +\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% +\next}} + +% \internalsetq {foo}{page} expands into +% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} +% When the aux file is read, ' is the escape character + +\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} + +% Things to be expanded by \internalsetq + +\def\Ypagenumber{\folio} + +\def\Ytitle{\thissection} + +\def\Ynothing{} + +\def\Ysectionnumberandtype{% +\ifnum\secno=0 \putwordChapter\xreftie\the\chapno % +\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % +\else \ifnum \subsubsecno=0 % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % +\else % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\def\Yappendixletterandtype{% +\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% +\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % +\else \ifnum \subsubsecno=0 % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % +\else % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\gdef\xreftie{'tie} + +% Use TeX 3.0's \inputlineno to get the line number, for better error +% messages, but if we're using an old version of TeX, don't do anything. +% +\ifx\inputlineno\thisisundefined + \let\linenumber = \empty % Non-3.0. +\else + \def\linenumber{\the\inputlineno:\space} +\fi + +% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. +% If its value is nonempty, SUFFIX is output afterward. + +\def\refx#1#2{% + \expandafter\ifx\csname X#1\endcsname\relax + % If not defined, say something at least. + $\langle$un\-de\-fined$\rangle$% + \ifhavexrefs + \message{\linenumber Undefined cross reference `#1'.}% + \else + \ifwarnedxrefs\else + \global\warnedxrefstrue + \message{Cross reference values unknown; you must run TeX again.}% + \fi + \fi + \else + % It's defined, so just use it. + \csname X#1\endcsname + \fi + #2% Output the suffix in any case. +} + +% Read the last existing aux file, if any. No error if none exists. + +% This is the macro invoked by entries in the aux file. +\def\xrdef #1#2{ +{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} + +\def\readauxfile{% +\begingroup +\catcode `\^^@=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\^^C=\other +\catcode `\^^D=\other +\catcode `\^^E=\other +\catcode `\^^F=\other +\catcode `\^^G=\other +\catcode `\^^H=\other +\catcode `\=\other +\catcode `\^^L=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode 26=\other +\catcode `\^^[=\other +\catcode `\^^\=\other +\catcode `\^^]=\other +\catcode `\^^^=\other +\catcode `\^^_=\other +\catcode `\@=\other +\catcode `\^=\other +\catcode `\~=\other +\catcode `\[=\other +\catcode `\]=\other +\catcode`\"=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode `\$=\other +\catcode `\#=\other +\catcode `\&=\other +% `\+ does not work, so use 43. +\catcode 43=\other +% Make the characters 128-255 be printing characters +{% + \count 1=128 + \def\loop{% + \catcode\count 1=\other + \advance\count 1 by 1 + \ifnum \count 1<256 \loop \fi + }% +}% +% the aux file uses ' as the escape. +% Turn off \ as an escape so we do not lose on +% entries which were dumped with control sequences in their names. +% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ +% Reference to such entries still does not work the way one would wish, +% but at least they do not bomb out when the aux file is read in. +\catcode `\{=1 \catcode `\}=2 +\catcode `\%=\other +\catcode `\'=0 +\catcode`\^=7 % to make ^^e4 etc usable in xref tags +\catcode `\\=\other +\openin 1 \jobname.aux +\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue +\global\warnedobstrue +\fi +% Open the new aux file. Tex will close it automatically at exit. +\openout \auxfile=\jobname.aux +\endgroup} + + +% Footnotes. + +\newcount \footnoteno + +% The trailing space in the following definition for supereject is +% vital for proper filling; pages come out unaligned when you do a +% pagealignmacro call if that space before the closing brace is +% removed. +\def\supereject{\par\penalty -20000\footnoteno =0 } + +% @footnotestyle is meaningful for info output only.. +\let\footnotestyle=\comment + +\let\ptexfootnote=\footnote + +{\catcode `\@=11 +% +% Auto-number footnotes. Otherwise like plain. +\gdef\footnote{% + \global\advance\footnoteno by \@ne + \edef\thisfootno{$^{\the\footnoteno}$}% + % + % In case the footnote comes at the end of a sentence, preserve the + % extra spacing after we do the footnote number. + \let\@sf\empty + \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi + % + % Remove inadvertent blank space before typesetting the footnote number. + \unskip + \thisfootno\@sf + \footnotezzz +}% + +% Don't bother with the trickery in plain.tex to not require the +% footnote text as a parameter. Our footnotes don't need to be so general. +% +\long\gdef\footnotezzz#1{\insert\footins{% + % We want to typeset this text as a normal paragraph, even if the + % footnote reference occurs in (for example) a display environment. + % So reset some parameters. + \interlinepenalty\interfootnotelinepenalty + \splittopskip\ht\strutbox % top baseline for broken footnotes + \splitmaxdepth\dp\strutbox + \floatingpenalty\@MM + \leftskip\z@skip + \rightskip\z@skip + \spaceskip\z@skip + \xspaceskip\z@skip + \parindent\defaultparindent + % + % Hang the footnote text off the number. + \hang + \textindent{\thisfootno}% + % + % Don't crash into the line above the footnote text. Since this + % expands into a box, it must come within the paragraph, lest it + % provide a place where TeX can split the footnote. + \footstrut + #1\strut}% +} + +}%end \catcode `\@=11 + +% Set the baselineskip to #1, and the lineskip and strut size +% correspondingly. There is no deep meaning behind these magic numbers +% used as factors; they just match (closely enough) what Knuth defined. +% +\def\lineskipfactor{.08333} +\def\strutheightpercent{.70833} +\def\strutdepthpercent {.29167} +% +\def\setleading#1{% + \normalbaselineskip = #1\relax + \normallineskip = \lineskipfactor\normalbaselineskip + \normalbaselines + \setbox\strutbox =\hbox{% + \vrule width0pt height\strutheightpercent\baselineskip + depth \strutdepthpercent \baselineskip + }% +} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} + +% For a final copy, take out the rectangles +% that mark overfull boxes (in case you have decided +% that the text looks ok even though it passes the margin). +% +\def\finalout{\overfullrule=0pt} + + +% End of control word definitions. + +\message{and turning on texinfo input format.} + +\def\openindices{% + \newindex{cp}% + \newcodeindex{fn}% + \newcodeindex{vr}% + \newcodeindex{tp}% + \newcodeindex{ky}% + \newcodeindex{pg}% +} + +% Set some numeric style parameters, for 8.5 x 11 format. + +%\hsize = 6.5in +\newdimen\defaultparindent \defaultparindent = 15pt +\parindent = \defaultparindent +\parskip 18pt plus 1pt +\setleading{15pt} +\advance\topskip by 1.2cm + +% Prevent underfull vbox error messages. +\vbadness=10000 + +% Following George Bush, just get rid of widows and orphans. +\widowpenalty=10000 +\clubpenalty=10000 + +% Use TeX 3.0's \emergencystretch to help line breaking, but if we're +% using an old version of TeX, don't do anything. We want the amount of +% stretch added to depend on the line length, hence the dependence on +% \hsize. This makes it come to about 9pt for the 8.5x11 format. +% +\ifx\emergencystretch\thisisundefined + % Allow us to assign to \emergencystretch anyway. + \def\emergencystretch{\dimen0}% +\else + \emergencystretch = \hsize + \divide\emergencystretch by 45 +\fi + +% Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) +\def\smallbook{ + +% These values for secheadingskip and subsecheadingskip are +% experiments. RJC 7 Aug 1992 +\global\secheadingskip = 17pt plus 6pt minus 3pt +\global\subsecheadingskip = 14pt plus 6pt minus 3pt + +\global\lispnarrowing = 0.3in +\setleading{12pt} +\advance\topskip by -1cm +\global\parskip 3pt plus 1pt +\global\hsize = 5in +\global\vsize=7.5in +\global\tolerance=700 +\global\hfuzz=1pt +\global\contentsrightmargin=0pt +\global\deftypemargin=0pt +\global\defbodyindent=.5cm + +\global\pagewidth=\hsize +\global\pageheight=\vsize + +\global\let\smalllisp=\smalllispx +\global\let\smallexample=\smalllispx +\global\def\Esmallexample{\Esmalllisp} +} + +% Use @afourpaper to print on European A4 paper. +\def\afourpaper{ +\global\tolerance=700 +\global\hfuzz=1pt +\setleading{12pt} +\global\parskip 15pt plus 1pt + +\global\vsize= 53\baselineskip +\advance\vsize by \topskip +%\global\hsize= 5.85in % A4 wide 10pt +\global\hsize= 6.5in +\global\outerhsize=\hsize +\global\advance\outerhsize by 0.5in +\global\outervsize=\vsize +\global\advance\outervsize by 0.6in + +\global\pagewidth=\hsize +\global\pageheight=\vsize +} + +% Allow control of the text dimensions. Parameters in order: textheight; +% textwidth; \voffset; \hoffset (!); binding offset. All require a dimension; +% header is additional; added length extends the bottom of the page. + +\def\changepagesizes#1#2#3#4#5{ + \global\vsize= #1 + \advance\vsize by \topskip + \global\voffset= #3 + \global\hsize= #2 + \global\outerhsize=\hsize + \global\advance\outerhsize by 0.5in + \global\outervsize=\vsize + \global\advance\outervsize by 0.6in + \global\pagewidth=\hsize + \global\pageheight=\vsize + \global\normaloffset= #4 + \global\bindingoffset= #5} + +% This layout is compatible with Latex on A4 paper. + +\def\afourlatex{\changepagesizes{22cm}{15cm}{7mm}{4.6mm}{5mm}} + +% Use @afourwide to print on European A4 paper in wide format. +\def\afourwide{\afourpaper +\changepagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}} + +% Define macros to output various characters with catcode for normal text. +\catcode`\"=\other +\catcode`\~=\other +\catcode`\^=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode`\+=\other +\def\normaldoublequote{"} +\def\normaltilde{~} +\def\normalcaret{^} +\def\normalunderscore{_} +\def\normalverticalbar{|} +\def\normalless{<} +\def\normalgreater{>} +\def\normalplus{+} + +% This macro is used to make a character print one way in ttfont +% where it can probably just be output, and another way in other fonts, +% where something hairier probably needs to be done. +% +% #1 is what to print if we are indeed using \tt; #2 is what to print +% otherwise. Since all the Computer Modern typewriter fonts have zero +% interword stretch (and shrink), and it is reasonable to expect all +% typewriter fonts to have this, we can check that font parameter. +% +\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} + +% Turn off all special characters except @ +% (and those which the user can use as if they were ordinary). +% Most of these we simply print from the \tt font, but for some, we can +% use math or other variants that look better in normal text. + +\catcode`\"=\active +\def\activedoublequote{{\tt \char '042}} +\let"=\activedoublequote +\catcode`\~=\active +\def~{{\tt \char '176}} +\chardef\hat=`\^ +\catcode`\^=\active +\def\auxhat{\def^{'hat}} +\def^{{\tt \hat}} + +\catcode`\_=\active +\def_{\ifusingtt\normalunderscore\_} +% Subroutine for the previous macro. +\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} + +% \lvvmode is equivalent in function to \leavevmode. +% Using \leavevmode runs into trouble when written out to +% an index file due to the expansion of \leavevmode into ``\unhbox +% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our +% magic tricks with @. +\def\lvvmode{\vbox to 0pt{}} + +\catcode`\|=\active +\def|{{\tt \char '174}} +\chardef \less=`\< +\catcode`\<=\active +\def<{{\tt \less}} +\chardef \gtr=`\> +\catcode`\>=\active +\def>{{\tt \gtr}} +\catcode`\+=\active +\def+{{\tt \char 43}} +%\catcode 27=\active +%\def^^[{$\diamondsuit$} + +% Set up an active definition for =, but don't enable it most of the time. +{\catcode`\==\active +\global\def={{\tt \char 61}}} + +\catcode`+=\active +\catcode`\_=\active + +% If a .fmt file is being used, characters that might appear in a file +% name cannot be active until we have parsed the command line. +% So turn them off again, and have \everyjob (or @setfilename) turn them on. +% \otherifyactive is called near the end of this file. +\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} + +\catcode`\@=0 + +% \rawbackslashxx output one backslash character in current font +\global\chardef\rawbackslashxx=`\\ +%{\catcode`\\=\other +%@gdef@rawbackslashxx{\}} + +% \rawbackslash redefines \ as input to do \rawbackslashxx. +{\catcode`\\=\active +@gdef@rawbackslash{@let\=@rawbackslashxx }} + +% \normalbackslash outputs one backslash in fixed width font. +\def\normalbackslash{{\tt\rawbackslashxx}} + +% Say @foo, not \foo, in error messages. +\escapechar=`\@ + +% \catcode 17=0 % Define control-q +\catcode`\\=\active + +% Used sometimes to turn off (effectively) the active characters +% even after parsing them. +@def@turnoffactive{@let"=@normaldoublequote +@let\=@realbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus} + +@def@normalturnoffactive{@let"=@normaldoublequote +@let\=@normalbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus} + +% Make _ and + \other characters, temporarily. +% This is canceled by @fixbackslash. +@otherifyactive + +% If a .fmt file is being used, we don't want the `\input texinfo' to show up. +% That is what \eatinput is for; after that, the `\' should revert to printing +% a backslash. +% +@gdef@eatinput input texinfo{@fixbackslash} +@global@let\ = @eatinput + +% On the other hand, perhaps the file did not have a `\input texinfo'. Then +% the first `\{ in the file would cause an error. This macro tries to fix +% that, assuming it is called before the first `\' could plausibly occur. +% Also back turn on active characters that might appear in the input +% file name, in case not using a pre-dumped format. +% +@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi + @catcode`+=@active @catcode`@_=@active} + +%% These look ok in all fonts, so just make them not special. The @rm below +%% makes sure that the current font starts out as the newly loaded cmr10 +@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other + +@textfonts +@rm + +@c Local variables: +@c page-delimiter: "^\\\\message" +@c End: |