source: vendor/bash/3.1/lib/termcap/grot/termcap.texi@ 3228

Last change on this file since 3228 was 3228, checked in by bird, 19 years ago

bash 3.1

File size: 138.4 KB
Line 
1\input texinfo @c -*-texinfo-*-
2@setfilename termcap.info
3@settitle The Termcap Library
4@smallbook
5
6@ifinfo
7This file documents the termcap library of the GNU system.
8
9Copyright (C) 1988 Free Software Foundation, Inc.
10
11Permission is granted to make and distribute verbatim copies of
12this manual provided the copyright notice and this permission notice
13are preserved on all copies.
14
15@ignore
16Permission is granted to process this file through TeX and print the
17results, provided the printed document carries copying permission
18notice identical to this one except for the removal of this paragraph
19(this paragraph not being relevant to the printed manual).
20
21@end ignore
22Permission is granted to copy and distribute modified versions of this
23manual under the conditions for verbatim copying, provided that the entire
24resulting derived work is distributed under the terms of a permission
25notice identical to this one.
26
27Permission is granted to copy and distribute translations of this manual
28into another language, under the above conditions for modified versions,
29except that this permission notice may be stated in a translation approved
30by the Foundation.
31@end ifinfo
32
33@setchapternewpage odd
34
35@c @shorttitlepage The Termcap Manual
36
37@titlepage
38@ignore
39@sp 6
40@center @titlefont{Termcap}
41@sp 1
42@center The Termcap Library and Data Base
43@sp 4
44@center Second Edition
45@sp 1
46@center December 1992
47@sp 5
48@center Richard M. Stallman
49@sp 1
50@center Free Software Foundation
51@end ignore
52
53@c Real title page
54@title The Termcap Manual
55@subtitle The Termcap Library and Data Base
56@subtitle Second Edition
57@subtitle December 1992
58@author Richard M. Stallman
59@page
60@vskip 0pt plus 1filll
61Copyright @copyright{} 1988 Free Software Foundation, Inc.
62
63Published by the Free Software Foundation
64(59 Temple Place, Suite 330, Boston, MA 02111 USA).
65Printed copies are available for $10 each.
66
67Permission is granted to make and distribute verbatim copies of
68this manual provided the copyright notice and this permission notice
69are preserved on all copies.
70
71Permission is granted to copy and distribute modified versions of this
72manual under the conditions for verbatim copying, provided that the entire
73resulting derived work is distributed under the terms of a permission
74notice identical to this one.
75
76Permission is granted to copy and distribute translations of this manual
77into another language, under the above conditions for modified versions,
78except that this permission notice may be stated in a translation approved
79by the Foundation.
80@sp 2
81Cover art by Etienne Suvasa.
82@end titlepage
83@page
84
85@synindex vr fn
86
87@node Top, Introduction, (dir), (dir)
88
89@menu
90* Introduction:: What is termcap? Why this manual?
91* Library:: The termcap library functions.
92* Data Base:: What terminal descriptions in @file{/etc/termcap} look like.
93* Capabilities:: Definitions of the individual terminal capabilities:
94 how to write them in descriptions, and how to use
95 their values to do display updating.
96* Summary:: Brief table of capability names and their meanings.
97* Var Index:: Index of C functions and variables.
98* Cap Index:: Index of termcap capabilities.
99* Index:: Concept index.
100
101 --- The Detailed Node Listing ---
102
103The Termcap Library
104
105* Preparation:: Preparing to use the termcap library.
106* Find:: Finding the description of the terminal being used.
107* Interrogate:: Interrogating the description for particular capabilities.
108* Initialize:: Initialization for output using termcap.
109* Padding:: Outputting padding.
110* Parameters:: Encoding parameters such as cursor positions.
111
112Padding
113
114* Why Pad:: Explanation of padding.
115* Not Enough:: When there is not enough padding.
116* Describe Padding:: The data base says how much padding a terminal needs.
117* Output Padding:: Using @code{tputs} to output the needed padding.
118
119Filling In Parameters
120
121* Encode Parameters:: The language for encoding parameters.
122* Using Parameters:: Outputting a string command with parameters.
123
124Sending Display Commands with Parameters
125
126* tparam:: The general case, for GNU termcap only.
127* tgoto:: The special case of cursor motion.
128
129The Format of the Data Base
130
131* Format:: Overall format of a terminal description.
132* Capability Format:: Format of capabilities within a description.
133* Naming:: Naming conventions for terminal types.
134* Inheriting:: Inheriting part of a description from
135a related terminal type.
136* Changing:: When changes in the data base take effect.
137
138Definitions of the Terminal Capabilities
139
140* Basic:: Basic characteristics.
141* Screen Size:: Screen size, and what happens when it changes.
142* Cursor Motion:: Various ways to move the cursor.
143* Wrapping:: What happens if you write a character in the last column.
144* Scrolling:: Pushing text up and down on the screen.
145* Windows:: Limiting the part of the window that output affects.
146* Clearing:: Erasing one or many lines.
147* Insdel Line:: Making new blank lines in mid-screen; deleting lines.
148* Insdel Char:: Inserting and deleting characters within a line.
149* Standout:: Highlighting some of the text.
150* Underlining:: Underlining some of the text.
151* Cursor Visibility:: Making the cursor more or less easy to spot.
152* Bell:: Attracts user's attention; not localized on the screen.
153* Keypad:: Recognizing when function keys or arrows are typed.
154* Meta Key:: @key{META} acts like an extra shift key.
155* Initialization:: Commands used to initialize or reset the terminal.
156* Pad Specs:: Info for the kernel on how much padding is needed.
157* Status Line:: A status line displays ``background'' information.
158* Half-Line:: Moving by half-lines, for superscripts and subscripts.
159* Printer:: Controlling auxiliary printers of display terminals.
160@end menu
161
162@node Introduction, Library, Top, Top
163@unnumbered Introduction
164
165@cindex termcap
166@dfn{Termcap} is a library and data base that enables programs to use
167display terminals in a terminal-independent manner. It originated in
168Berkeley Unix.
169
170The termcap data base describes the capabilities of hundreds of different
171display terminals in great detail. Some examples of the information
172recorded for a terminal could include how many columns wide it is, what
173string to send to move the cursor to an arbitrary position (including how
174to encode the row and column numbers), how to scroll the screen up one or
175several lines, and how much padding is needed for such a scrolling
176operation.
177
178The termcap library is provided for easy access this data base in programs
179that want to do terminal-independent character-based display output.
180
181This manual describes the GNU version of the termcap library, which has
182some extensions over the Unix version. All the extensions are identified
183as such, so this manual also tells you how to use the Unix termcap.
184
185The GNU version of the termcap library is available free as source code,
186for use in free programs, and runs on Unix and VMS systems (at least). You
187can find it in the GNU Emacs distribution in the files @file{termcap.c} and
188@file{tparam.c}.
189
190This manual was written for the GNU project, whose goal is to develop a
191complete free operating system upward-compatible with Unix for user
192programs. The project is approximately two thirds complete. For more
193information on the GNU project, including the GNU Emacs editor and the
194mostly-portable optimizing C compiler, send one dollar to
195
196@display
197Free Software Foundation
198675 Mass Ave
199Cambridge, MA 02139
200@end display
201
202@node Library, Data Base, Introduction, Top
203@chapter The Termcap Library
204
205The termcap library is the application programmer's interface to the
206termcap data base. It contains functions for the following purposes:
207
208@itemize @bullet
209@item
210Finding the description of the user's terminal type (@code{tgetent}).
211
212@item
213Interrogating the description for information on various topics
214(@code{tgetnum}, @code{tgetflag}, @code{tgetstr}).
215
216@item
217Computing and performing padding (@code{tputs}).
218
219@item
220Encoding numeric parameters such as cursor positions into the
221terminal-specific form required for display commands (@code{tparam},
222@code{tgoto}).
223@end itemize
224
225@menu
226* Preparation:: Preparing to use the termcap library.
227* Find:: Finding the description of the terminal being used.
228* Interrogate:: Interrogating the description for particular capabilities.
229* Initialize:: Initialization for output using termcap.
230* Padding:: Outputting padding.
231* Parameters:: Encoding parameters such as cursor positions.
232@end menu
233
234@node Preparation, Find, , Library
235@section Preparing to Use the Termcap Library
236
237To use the termcap library in a program, you need two kinds of preparation:
238
239@itemize @bullet
240@item
241The compiler needs declarations of the functions and variables in the
242library.
243
244On GNU systems, it suffices to include the header file
245@file{termcap.h} in each source file that uses these functions and
246variables.@refill
247
248On Unix systems, there is often no such header file. Then you must
249explictly declare the variables as external. You can do likewise for
250the functions, or let them be implicitly declared and cast their
251values from type @code{int} to the appropriate type.
252
253We illustrate the declarations of the individual termcap library
254functions with ANSI C prototypes because they show how to pass the
255arguments. If you are not using the GNU C compiler, you probably
256cannot use function prototypes, so omit the argument types and names
257from your declarations.
258
259@item
260The linker needs to search the library. Usually either
261@samp{-ltermcap} or @samp{-ltermlib} as an argument when linking will
262do this.@refill
263@end itemize
264
265@node Find, Interrogate, Preparation, Library
266@section Finding a Terminal Description: @code{tgetent}
267
268@findex tgetent
269An application program that is going to use termcap must first look up the
270description of the terminal type in use. This is done by calling
271@code{tgetent}, whose declaration in ANSI Standard C looks like:
272
273@example
274int tgetent (char *@var{buffer}, char *@var{termtype});
275@end example
276
277@noindent
278This function finds the description and remembers it internally so that
279you can interrogate it about specific terminal capabilities
280(@pxref{Interrogate}).
281
282The argument @var{termtype} is a string which is the name for the type of
283terminal to look up. Usually you would obtain this from the environment
284variable @code{TERM} using @code{getenv ("TERM")}.
285
286If you are using the GNU version of termcap, you can alternatively ask
287@code{tgetent} to allocate enough space. Pass a null pointer for
288@var{buffer}, and @code{tgetent} itself allocates the storage using
289@code{malloc}. There is no way to get the address that was allocated,
290and you shouldn't try to free the storage.@refill
291
292With the Unix version of termcap, you must allocate space for the
293description yourself and pass the address of the space as the argument
294@var{buffer}. There is no way you can tell how much space is needed, so
295the convention is to allocate a buffer 2048 characters long and assume that
296is enough. (Formerly the convention was to allocate 1024 characters and
297assume that was enough. But one day, for one kind of terminal, that was
298not enough.)
299
300No matter how the space to store the description has been obtained,
301termcap records its address internally for use when you later interrogate
302the description with @code{tgetnum}, @code{tgetstr} or @code{tgetflag}. If
303the buffer was allocated by termcap, it will be freed by termcap too if you
304call @code{tgetent} again. If the buffer was provided by you, you must
305make sure that its contents remain unchanged for as long as you still plan
306to interrogate the description.@refill
307
308The return value of @code{tgetent} is @minus{}1 if there is some difficulty
309accessing the data base of terminal types, 0 if the data base is accessible
310but the specified type is not defined in it, and some other value
311otherwise.
312
313Here is how you might use the function @code{tgetent}:
314
315@smallexample
316#ifdef unix
317static char term_buffer[2048];
318#else
319#define term_buffer 0
320#endif
321
322init_terminal_data ()
323@{
324 char *termtype = getenv ("TERM");
325 int success;
326
327 if (termtype == 0)
328 fatal ("Specify a terminal type with `setenv TERM <yourtype>'.\n");
329
330 success = tgetent (term_buffer, termtype);
331 if (success < 0)
332 fatal ("Could not access the termcap data base.\n");
333 if (success == 0)
334 fatal ("Terminal type `%s' is not defined.\n", termtype);
335@}
336@end smallexample
337
338@noindent
339Here we assume the function @code{fatal} prints an error message and exits.
340
341If the environment variable @code{TERMCAP} is defined, its value is used to
342override the terminal type data base. The function @code{tgetent} checks
343the value of @code{TERMCAP} automatically. If the value starts with
344@samp{/} then it is taken as a file name to use as the data base file,
345instead of @file{/etc/termcap} which is the standard data base. If the
346value does not start with @samp{/} then it is itself used as the terminal
347description, provided that the terminal type @var{termtype} is among the
348types it claims to apply to. @xref{Data Base}, for information on the
349format of a terminal description.@refill
350
351@node Interrogate, Initialize, Find, Library
352@section Interrogating the Terminal Description
353
354Each piece of information recorded in a terminal description is called a
355@dfn{capability}. Each defined terminal capability has a two-letter code
356name and a specific meaning. For example, the number of columns is named
357@samp{co}. @xref{Capabilities}, for definitions of all the standard
358capability names.
359
360Once you have found the proper terminal description with @code{tgetent}
361(@pxref{Find}), your application program must @dfn{interrogate} it for
362various terminal capabilities. You must specify the two-letter code of
363the capability whose value you seek.
364
365Capability values can be numeric, boolean (capability is either present or
366absent) or strings. Any particular capability always has the same value
367type; for example, @samp{co} always has a numeric value, while @samp{am}
368(automatic wrap at margin) is always a flag, and @samp{cm} (cursor motion
369command) always has a string value. The documentation of each capability
370says which type of value it has.@refill
371
372There are three functions to use to get the value of a capability,
373depending on the type of value the capability has. Here are their
374declarations in ANSI C:
375
376@findex tgetnum
377@findex tgetflag
378@findex tgetstr
379@example
380int tgetnum (char *@var{name});
381int tgetflag (char *@var{name});
382char *tgetstr (char *@var{name}, char **@var{area});
383@end example
384
385@table @code
386@item tgetnum
387Use @code{tgetnum} to get a capability value that is numeric. The
388argument @var{name} is the two-letter code name of the capability. If
389the capability is present, @code{tgetnum} returns the numeric value
390(which is nonnegative). If the capability is not mentioned in the
391terminal description, @code{tgetnum} returns @minus{}1.
392
393@item tgetflag
394Use @code{tgetflag} to get a boolean value. If the capability
395@var{name} is present in the terminal description, @code{tgetflag}
396returns 1; otherwise, it returns 0.
397
398@item tgetstr
399Use @code{tgetstr} to get a string value. It returns a pointer to a
400string which is the capability value, or a null pointer if the
401capability is not present in the terminal description.
402
403There are two ways @code{tgetstr} can find space to store the string value:
404
405@itemize @bullet
406@item
407You can ask @code{tgetstr} to allocate the space. Pass a null
408pointer for the argument @var{area}, and @code{tgetstr} will use
409@code{malloc} to allocate storage big enough for the value.
410Termcap will never free this storage or refer to it again; you
411should free it when you are finished with it.
412
413This method is more robust, since there is no need to guess how
414much space is needed. But it is supported only by the GNU
415termcap library.
416
417@item
418You can provide the space. Provide for the argument @var{area} the
419address of a pointer variable of type @code{char *}. Before calling
420@code{tgetstr}, initialize the variable to point at available space.
421Then @code{tgetstr} will store the string value in that space and will
422increment the pointer variable to point after the space that has been
423used. You can use the same pointer variable for many calls to
424@code{tgetstr}.
425
426There is no way to determine how much space is needed for a single
427string, and no way for you to prevent or handle overflow of the area
428you have provided. However, you can be sure that the total size of
429all the string values you will obtain from the terminal description is
430no greater than the size of the description (unless you get the same
431capability twice). You can determine that size with @code{strlen} on
432the buffer you provided to @code{tgetent}. See below for an example.
433
434Providing the space yourself is the only method supported by the Unix
435version of termcap.
436@end itemize
437@end table
438
439Note that you do not have to specify a terminal type or terminal
440description for the interrogation functions. They automatically use the
441description found by the most recent call to @code{tgetent}.
442
443Here is an example of interrogating a terminal description for various
444capabilities, with conditionals to select between the Unix and GNU methods
445of providing buffer space.
446
447@example
448char *tgetstr ();
449
450char *cl_string, *cm_string;
451int height;
452int width;
453int auto_wrap;
454
455char PC; /* For tputs. */
456char *BC; /* For tgoto. */
457char *UP;
458
459interrogate_terminal ()
460@{
461#ifdef UNIX
462 /* Here we assume that an explicit term_buffer
463 was provided to tgetent. */
464 char *buffer
465 = (char *) malloc (strlen (term_buffer));
466#define BUFFADDR &buffer
467#else
468#define BUFFADDR 0
469#endif
470
471 char *temp;
472
473 /* Extract information we will use. */
474 cl_string = tgetstr ("cl", BUFFADDR);
475 cm_string = tgetstr ("cm", BUFFADDR);
476 auto_wrap = tgetflag ("am");
477 height = tgetnum ("li");
478 width = tgetnum ("co");
479
480 /* Extract information that termcap functions use. */
481 temp = tgetstr ("pc", BUFFADDR);
482 PC = temp ? *temp : 0;
483 BC = tgetstr ("le", BUFFADDR);
484 UP = tgetstr ("up", BUFFADDR);
485@}
486@end example
487
488@noindent
489@xref{Padding}, for information on the variable @code{PC}. @xref{Using
490Parameters}, for information on @code{UP} and @code{BC}.
491
492@node Initialize, Padding, Interrogate, Library
493@section Initialization for Use of Termcap
494@cindex terminal flags (kernel)
495
496Before starting to output commands to a terminal using termcap,
497an application program should do two things:
498
499@itemize @bullet
500@item
501Initialize various global variables which termcap library output
502functions refer to. These include @code{PC} and @code{ospeed} for
503padding (@pxref{Output Padding}) and @code{UP} and @code{BC} for
504cursor motion (@pxref{tgoto}).@refill
505
506@item
507Tell the kernel to turn off alteration and padding of horizontal-tab
508characters sent to the terminal.
509@end itemize
510
511To turn off output processing in Berkeley Unix you would use @code{ioctl}
512with code @code{TIOCLSET} to set the bit named @code{LLITOUT}, and clear
513the bits @code{ANYDELAY} using @code{TIOCSETN}. In POSIX or System V, you
514must clear the bit named @code{OPOST}. Refer to the system documentation
515for details.@refill
516
517If you do not set the terminal flags properly, some older terminals will
518not work. This is because their commands may contain the characters that
519normally signify newline, carriage return and horizontal tab---characters
520which the kernel thinks it ought to modify before output.
521
522When you change the kernel's terminal flags, you must arrange to restore
523them to their normal state when your program exits. This implies that the
524program must catch fatal signals such as @code{SIGQUIT} and @code{SIGINT}
525and restore the old terminal flags before actually terminating.
526
527Modern terminals' commands do not use these special characters, so if you
528do not care about problems with old terminals, you can leave the kernel's
529terminal flags unaltered.
530
531@node Padding, Parameters, Initialize, Library
532@section Padding
533@cindex padding
534
535@dfn{Padding} means outputting null characters following a terminal display
536command that takes a long time to execute. The terminal description says
537which commands require padding and how much; the function @code{tputs},
538described below, outputs a terminal command while extracting from it the
539padding information, and then outputs the padding that is necessary.
540
541@menu
542* Why Pad:: Explanation of padding.
543* Not Enough:: When there is not enough padding.
544* Describe Padding:: The data base says how much padding a terminal needs.
545* Output Padding:: Using @code{tputs} to output the needed padding.
546@end menu
547
548@node Why Pad, Not Enough, , Padding
549@subsection Why Pad, and How
550
551Most types of terminal have commands that take longer to execute than they
552do to send over a high-speed line. For example, clearing the screen may
553take 20msec once the entire command is received. During that time, on a
5549600 bps line, the terminal could receive about 20 additional output
555characters while still busy clearing the screen. Every terminal has a
556certain amount of buffering capacity to remember output characters that
557cannot be processed yet, but too many slow commands in a row can cause the
558buffer to fill up. Then any additional output that cannot be processed
559immediately will be lost.
560
561To avoid this problem, we normally follow each display command with enough
562useless charaters (usually null characters) to fill up the time that the
563display command needs to execute. This does the job if the terminal throws
564away null characters without using up space in the buffer (which most
565terminals do). If enough padding is used, no output can ever be lost. The
566right amount of padding avoids loss of output without slowing down
567operation, since the time used to transmit padding is time that nothing
568else could be done.
569
570The number of padding characters needed for an operation depends on the
571line speed. In fact, it is proportional to the line speed. A 9600 baud
572line transmits about one character per msec, so the clear screen command in
573the example above would need about 20 characters of padding. At 1200 baud,
574however, only about 3 characters of padding are needed to fill up 20msec.
575
576@node Not Enough, Describe Padding, Why Pad, Padding
577@subsection When There Is Not Enough Padding
578
579There are several common manifestations of insufficient padding.
580
581@itemize @bullet
582@item
583Emacs displays @samp{I-search: ^Q-} at the bottom of the screen.
584
585This means that the terminal thought its buffer was getting full of
586display commands, so it tried to tell the computer to stop sending
587any.
588
589@item
590The screen is garbled intermittently, or the details of garbling vary
591when you repeat the action. (A garbled screen could be due to a
592command which is simply incorrect, or to user option in the terminal
593which doesn't match the assumptions of the terminal description, but
594this usually leads to reproducible failure.)
595
596This means that the buffer did get full, and some commands were lost.
597Many changeable factors can change which ones are lost.
598
599@item
600Screen is garbled at high output speeds but not at low speeds.
601Padding problems nearly always go away at low speeds, usually even at
6021200 baud.
603
604This means that a high enough speed permits commands to arrive faster
605than they can be executed.
606@end itemize
607
608Although any obscure command on an obscure terminal might lack padding,
609in practice problems arise most often from the clearing commands
610@samp{cl} and @samp{cd} (@pxref{Clearing}), the scrolling commands
611@samp{sf} and @samp{sr} (@pxref{Scrolling}), and the line insert/delete
612commands @samp{al} and @samp{dl} (@pxref{Insdel Line}).
613
614Occasionally the terminal description fails to define @samp{sf} and some
615programs will use @samp{do} instead, so you may get a problem with
616@samp{do}. If so, first define @samp{sf} just like @samp{do}, then
617add some padding to @samp{sf}.
618
619The best strategy is to add a lot of padding at first, perhaps 200 msec.
620This is much more than enough; in fact, it should cause a visible slowdown.
621(If you don't see a slowdown, the change has not taken effect;
622@pxref{Changing}.) If this makes the problem go away, you have found the
623right place to add padding; now reduce the amount until the problem comes
624back, then increase it again. If the problem remains, either it is in some
625other capability or it is not a matter of padding at all.
626
627Keep in mind that on many terminals the correct padding for insert/delete
628line or for scrolling is cursor-position dependent. If you get problems
629from scrolling a large region of the screen but not from scrolling a small
630part (just a few lines moving), it may mean that fixed padding should be
631replaced with position-dependent padding.
632
633@node Describe Padding, Output Padding, Not Enough, Padding
634@subsection Specifying Padding in a Terminal Description
635
636In the terminal description, the amount of padding required by each display
637command is recorded as a sequence of digits at the front of the command.
638These digits specify the padding time in milliseconds (msec). They can be
639followed optionally by a decimal point and one more digit, which is a
640number of tenths of msec.
641
642Sometimes the padding needed by a command depends on the cursor position.
643For example, the time taken by an ``insert line'' command is usually
644proportional to the number of lines that need to be moved down or cleared.
645An asterisk (@samp{*}) following the padding time says that the time
646should be multiplied by the number of screen lines affected by the command.
647
648@example
649:al=1.3*\E[L:
650@end example
651
652@noindent
653is used to describe the ``insert line'' command for a certain terminal.
654The padding required is 1.3 msec per line affected. The command itself is
655@samp{@key{ESC} [ L}.
656
657The padding time specified in this way tells @code{tputs} how many pad
658characters to output. @xref{Output Padding}.
659
660Two special capability values affect padding for all commands. These are
661the @samp{pc} and @samp{pb}. The variable @samp{pc} specifies the
662character to pad with, and @samp{pb} the speed below which no padding is
663needed. The defaults for these variables, a null character and 0,
664are correct for most terminals. @xref{Pad Specs}.
665
666@node Output Padding, , Describe Padding, Padding
667@subsection Performing Padding with @code{tputs}
668@cindex line speed
669
670@findex tputs
671Use the termcap function @code{tputs} to output a string containing an
672optional padding spec of the form described above (@pxref{Describe
673Padding}). The function @code{tputs} strips off and decodes the padding
674spec, outputs the rest of the string, and then outputs the appropriate
675padding. Here is its declaration in ANSI C:
676
677@example
678char PC;
679short ospeed;
680
681int tputs (char *@var{string}, int @var{nlines}, int (*@var{outfun}) ());
682@end example
683
684Here @var{string} is the string (including padding spec) to be output;
685@var{nlines} is the number of lines affected by the operation, which is
686used to multiply the amount of padding if the padding spec ends with a
687@samp{*}. Finally, @var{outfun} is a function (such as @code{fputchar})
688that is called to output each character. When actually called,
689@var{outfun} should expect one argument, a character.
690
691@vindex ospeed
692@vindex PC
693The operation of @code{tputs} is controlled by two global variables,
694@code{ospeed} and @code{PC}. The value of @code{ospeed} is supposed to be
695the terminal output speed, encoded as in the @code{ioctl} system call which
696gets the speed information. This is needed to compute the number of
697padding characters. The value of @code{PC} is the character used for
698padding.
699
700You are responsible for storing suitable values into these variables before
701using @code{tputs}. The value stored into the @code{PC} variable should be
702taken from the @samp{pc} capability in the terminal description (@pxref{Pad
703Specs}). Store zero in @code{PC} if there is no @samp{pc}
704capability.@refill
705
706The argument @var{nlines} requires some thought. Normally, it should be
707the number of lines whose contents will be cleared or moved by the command.
708For cursor motion commands, or commands that do editing within one line,
709use the value 1. For most commands that affect multiple lines, such as
710@samp{al} (insert a line) and @samp{cd} (clear from the cursor to the end
711of the screen), @var{nlines} should be the screen height minus the current
712vertical position (origin 0). For multiple insert and scroll commands such
713as @samp{AL} (insert multiple lines), that same value for @var{nlines} is
714correct; the number of lines being inserted is @i{not} correct.@refill
715
716If a ``scroll window'' feature is used to reduce the number of lines
717affected by a command, the value of @var{nlines} should take this into
718account. This is because the delay time required depends on how much work
719the terminal has to do, and the scroll window feature reduces the work.
720@xref{Scrolling}.
721
722Commands such as @samp{ic} and @samp{dc} (insert or delete characters) are
723problematical because the padding needed by these commands is proportional
724to the number of characters affected, which is the number of columns from
725the cursor to the end of the line. It would be nice to have a way to
726specify such a dependence, and there is no need for dependence on vertical
727position in these commands, so it is an obvious idea to say that for these
728commands @var{nlines} should really be the number of columns affected.
729However, the definition of termcap clearly says that @var{nlines} is always
730the number of lines affected, even in this case, where it is always 1. It
731is not easy to change this rule now, because too many programs and terminal
732descriptions have been written to follow it.
733
734Because @var{nlines} is always 1 for the @samp{ic} and @samp{dc} strings,
735there is no reason for them to use @samp{*}, but some of them do. These
736should be corrected by deleting the @samp{*}. If, some day, such entries
737have disappeared, it may be possible to change to a more useful convention
738for the @var{nlines} argument for these operations without breaking any
739programs.
740
741@node Parameters, , Padding, Library
742@section Filling In Parameters
743@cindex parameters
744
745Some terminal control strings require numeric @dfn{parameters}. For
746example, when you move the cursor, you need to say what horizontal and
747vertical positions to move it to. The value of the terminal's @samp{cm}
748capability, which says how to move the cursor, cannot simply be a string of
749characters; it must say how to express the cursor position numbers and
750where to put them within the command.
751
752The specifications of termcap include conventions as to which string-valued
753capabilities require parameters, how many parameters, and what the
754parameters mean; for example, it defines the @samp{cm} string to take
755two parameters, the vertical and horizontal positions, with 0,0 being the
756upper left corner. These conventions are described where the individual
757commands are documented.
758
759Termcap also defines a language used within the capability definition for
760specifying how and where to encode the parameters for output. This language
761uses character sequences starting with @samp{%}. (This is the same idea as
762@code{printf}, but the details are different.) The language for parameter
763encoding is described in this section.
764
765A program that is doing display output calls the functions @code{tparam} or
766@code{tgoto} to encode parameters according to the specifications. These
767functions produce a string containing the actual commands to be output (as
768well a padding spec which must be processed with @code{tputs};
769@pxref{Padding}).
770
771@menu
772* Encode Parameters:: The language for encoding parameters.
773* Using Parameters:: Outputting a string command with parameters.
774@end menu
775
776@node Encode Parameters, Using Parameters, , Parameters
777@subsection Describing the Encoding
778@cindex %
779
780A terminal command string that requires parameters contains special
781character sequences starting with @samp{%} to say how to encode the
782parameters. These sequences control the actions of @code{tparam} and
783@code{tgoto}.
784
785The parameters values passed to @code{tparam} or @code{tgoto} are
786considered to form a vector. A pointer into this vector determines
787the next parameter to be processed. Some of the @samp{%}-sequences
788encode one parameter and advance the pointer to the next parameter.
789Other @samp{%}-sequences alter the pointer or alter the parameter
790values without generating output.
791
792For example, the @samp{cm} string for a standard ANSI terminal is written
793as @samp{\E[%i%d;%dH}. (@samp{\E} stands for @key{ESC}.) @samp{cm} by
794convention always requires two parameters, the vertical and horizontal goal
795positions, so this string specifies the encoding of two parameters. Here
796@samp{%i} increments the two values supplied, and each @samp{%d} encodes
797one of the values in decimal. If the cursor position values 20,58 are
798encoded with this string, the result is @samp{\E[21;59H}.
799
800First, here are the @samp{%}-sequences that generate output. Except for
801@samp{%%}, each of them encodes one parameter and advances the pointer
802to the following parameter.
803
804@table @samp
805@item %%
806Output a single @samp{%}. This is the only way to represent a literal
807@samp{%} in a terminal command with parameters. @samp{%%} does not
808use up a parameter.
809
810@item %d
811As in @code{printf}, output the next parameter in decimal.
812
813@item %2
814Like @samp{%02d} in @code{printf}: output the next parameter in
815decimal, and always use at least two digits.
816
817@item %3
818Like @samp{%03d} in @code{printf}: output the next parameter in
819decimal, and always use at least three digits. Note that @samp{%4}
820and so on are @emph{not} defined.
821
822@item %.
823Output the next parameter as a single character whose ASCII code is
824the parameter value. Like @samp{%c} in @code{printf}.
825
826@item %+@var{char}
827Add the next parameter to the character @var{char}, and output the
828resulting character. For example, @samp{%+ } represents 0 as a space,
8291 as @samp{!}, etc.
830@end table
831
832The following @samp{%}-sequences specify alteration of the parameters
833(their values, or their order) rather than encoding a parameter for output.
834They generate no output; they are used only for their side effects
835on the parameters. Also, they do not advance the ``next parameter'' pointer
836except as explicitly stated. Only @samp{%i}, @samp{%r} and @samp{%>} are
837defined in standard Unix termcap. The others are GNU extensions.@refill
838
839@table @samp
840@item %i
841Increment the next two parameters. This is used for terminals that
842expect cursor positions in origin 1. For example, @samp{%i%d,%d} would
843output two parameters with @samp{1} for 0, @samp{2} for 1, etc.
844
845@item %r
846Interchange the next two parameters. This is used for terminals whose
847cursor positioning command expects the horizontal position first.
848
849@item %s
850Skip the next parameter. Do not output anything.
851
852@item %b
853Back up one parameter. The last parameter used will become once again
854the next parameter to be output, and the next output command will use
855it. Using @samp{%b} more than once, you can back up any number of
856parameters, and you can refer to each parameter any number of times.
857
858@item %>@var{c1}@var{c2}
859Conditionally increment the next parameter. Here @var{c1} and
860@var{c2} are characters which stand for their ASCII codes as numbers.
861If the next parameter is greater than the ASCII code of @var{c1}, the
862ASCII code of @var{c2} is added to it.@refill
863
864@item %a @var{op} @var{type} @var{pos}
865Perform arithmetic on the next parameter, do not use it up, and do not
866output anything. Here @var{op} specifies the arithmetic operation,
867while @var{type} and @var{pos} together specify the other operand.
868
869Spaces are used above to separate the operands for clarity; the spaces
870don't appear in the data base, where this sequence is exactly five
871characters long.
872
873The character @var{op} says what kind of arithmetic operation to
874perform. It can be any of these characters:
875
876@table @samp
877@item =
878assign a value to the next parameter, ignoring its old value.
879The new value comes from the other operand.
880
881@item +
882add the other operand to the next parameter.
883
884@item -
885subtract the other operand from the next parameter.
886
887@item *
888multiply the next parameter by the other operand.
889
890@item /
891divide the next parameter by the other operand.
892@end table
893
894The ``other operand'' may be another parameter's value or a constant;
895the character @var{type} says which. It can be:
896
897@table @samp
898@item p
899Use another parameter. The character @var{pos} says which
900parameter to use. Subtract 64 from its ASCII code to get the
901position of the desired parameter relative to this one. Thus,
902the character @samp{A} as @var{pos} means the parameter after the
903next one; the character @samp{?} means the parameter before the
904next one.
905
906@item c
907Use a constant value. The character @var{pos} specifies the
908value of the constant. The 0200 bit is cleared out, so that 0200
909can be used to represent zero.
910@end table
911@end table
912
913The following @samp{%}-sequences are special purpose hacks to compensate
914for the weird designs of obscure terminals. They modify the next parameter
915or the next two parameters but do not generate output and do not use up any
916parameters. @samp{%m} is a GNU extension; the others are defined in
917standard Unix termcap.
918
919@table @samp
920@item %n
921Exclusive-or the next parameter with 0140, and likewise the parameter
922after next.
923
924@item %m
925Complement all the bits of the next parameter and the parameter after next.
926
927@item %B
928Encode the next parameter in BCD. It alters the value of the
929parameter by adding six times the quotient of the parameter by ten.
930Here is a C statement that shows how the new value is computed:
931
932@example
933@var{parm} = (@var{parm} / 10) * 16 + @var{parm} % 10;
934@end example
935
936@item %D
937Transform the next parameter as needed by Delta Data terminals.
938This involves subtracting twice the remainder of the parameter by 16.
939
940@example
941@var{parm} -= 2 * (@var{parm} % 16);
942@end example
943@end table
944
945@node Using Parameters, , Encode Parameters, Parameters
946@subsection Sending Display Commands with Parameters
947
948The termcap library functions @code{tparam} and @code{tgoto} serve as the
949analog of @code{printf} for terminal string parameters. The newer function
950@code{tparam} is a GNU extension, more general but missing from Unix
951termcap. The original parameter-encoding function is @code{tgoto}, which
952is preferable for cursor motion.
953
954@menu
955* tparam:: The general case, for GNU termcap only.
956* tgoto:: The special case of cursor motion.
957@end menu
958
959@node tparam, tgoto, , Using Parameters
960@subsubsection @code{tparam}
961
962@findex tparam
963The function @code{tparam} can encode display commands with any number of
964parameters and allows you to specify the buffer space. It is the preferred
965function for encoding parameters for all but the @samp{cm} capability. Its
966ANSI C declaration is as follows:
967
968@smallexample
969char *tparam (char *@var{ctlstring}, char *@var{buffer}, int @var{size}, int @var{parm1},...)
970@end smallexample
971
972The arguments are a control string @var{ctlstring} (the value of a terminal
973capability, presumably), an output buffer @var{buffer} and @var{size}, and
974any number of integer parameters to be encoded. The effect of
975@code{tparam} is to copy the control string into the buffer, encoding
976parameters according to the @samp{%} sequences in the control string.
977
978You describe the output buffer by its address, @var{buffer}, and its size
979in bytes, @var{size}. If the buffer is not big enough for the data to be
980stored in it, @code{tparam} calls @code{malloc} to get a larger buffer. In
981either case, @code{tparam} returns the address of the buffer it ultimately
982uses. If the value equals @var{buffer}, your original buffer was used.
983Otherwise, a new buffer was allocated, and you must free it after you are
984done with printing the results. If you pass zero for @var{size} and
985@var{buffer}, @code{tparam} always allocates the space with @code{malloc}.
986
987All capabilities that require parameters also have the ability to specify
988padding, so you should use @code{tputs} to output the string produced by
989@code{tparam}. @xref{Padding}. Here is an example.
990
991@example
992@{
993char *buf;
994char buffer[40];
995
996buf = tparam (command, buffer, 40, parm);
997tputs (buf, 1, fputchar);
998if (buf != buffer)
999free (buf);
1000@}
1001@end example
1002
1003If a parameter whose value is zero is encoded with @samp{%.}-style
1004encoding, the result is a null character, which will confuse @code{tputs}.
1005This would be a serious problem, but luckily @samp{%.} encoding is used
1006only by a few old models of terminal, and only for the @samp{cm}
1007capability. To solve the problem, use @code{tgoto} rather than
1008@code{tparam} to encode the @samp{cm} capability.@refill
1009
1010@node tgoto, , tparam, Using Parameters
1011@subsubsection @code{tgoto}
1012
1013@findex tgoto
1014The special case of cursor motion is handled by @code{tgoto}. There
1015are two reasons why you might choose to use @code{tgoto}:
1016
1017@itemize @bullet
1018@item
1019For Unix compatibility, because Unix termcap does not have @code{tparam}.
1020
1021@item
1022For the @samp{cm} capability, since @code{tgoto} has a special feature
1023to avoid problems with null characters, tabs and newlines on certain old
1024terminal types that use @samp{%.} encoding for that capability.
1025@end itemize
1026
1027Here is how @code{tgoto} might be declared in ANSI C:
1028
1029@example
1030char *tgoto (char *@var{cstring}, int @var{hpos}, int @var{vpos})
1031@end example
1032
1033There are three arguments, the terminal description's @samp{cm} string and
1034the two cursor position numbers; @code{tgoto} computes the parametrized
1035string in an internal static buffer and returns the address of that buffer.
1036The next time you use @code{tgoto} the same buffer will be reused.
1037
1038@vindex UP
1039@vindex BC
1040Parameters encoded with @samp{%.} encoding can generate null characters,
1041tabs or newlines. These might cause trouble: the null character because
1042@code{tputs} would think that was the end of the string, the tab because
1043the kernel or other software might expand it into spaces, and the newline
1044becaue the kernel might add a carriage-return, or padding characters
1045normally used for a newline. To prevent such problems, @code{tgoto} is
1046careful to avoid these characters. Here is how this works: if the target
1047cursor position value is such as to cause a problem (that is to say, zero,
1048nine or ten), @code{tgoto} increments it by one, then compensates by
1049appending a string to move the cursor back or up one position.
1050
1051The compensation strings to use for moving back or up are found in global
1052variables named @code{BC} and @code{UP}. These are actual external C
1053variables with upper case names; they are declared @code{char *}. It is up
1054to you to store suitable values in them, normally obtained from the
1055@samp{le} and @samp{up} terminal capabilities in the terminal description
1056with @code{tgetstr}. Alternatively, if these two variables are both zero,
1057the feature of avoiding nulls, tabs and newlines is turned off.
1058
1059It is safe to use @code{tgoto} for commands other than @samp{cm} only if
1060you have stored zero in @code{BC} and @code{UP}.
1061
1062Note that @code{tgoto} reverses the order of its operands: the horizontal
1063position comes before the vertical position in the arguments to
1064@code{tgoto}, even though the vertical position comes before the horizontal
1065in the parameters of the @samp{cm} string. If you use @code{tgoto} with a
1066command such as @samp{AL} that takes one parameter, you must pass the
1067parameter to @code{tgoto} as the ``vertical position''.@refill
1068
1069@node Data Base, Capabilities, Library, Top
1070@chapter The Format of the Data Base
1071
1072The termcap data base of terminal descriptions is stored in the file
1073@file{/etc/termcap}. It contains terminal descriptions, blank lines, and
1074comments.
1075
1076A terminal description starts with one or more names for the terminal type.
1077The information in the description is a series of @dfn{capability names}
1078and values. The capability names have standard meanings
1079(@pxref{Capabilities}) and their values describe the terminal.
1080
1081@menu
1082* Format:: Overall format of a terminal description.
1083* Capability Format:: Format of capabilities within a description.
1084* Naming:: Naming conventions for terminal types.
1085* Inheriting:: Inheriting part of a description from
1086a related terminal type.
1087* Changing:: When changes in the data base take effect.
1088@end menu
1089
1090@node Format, Capability Format, , Data Base
1091@section Terminal Description Format
1092@cindex description format
1093
1094Aside from comments (lines starting with @samp{#}, which are ignored), each
1095nonblank line in the termcap data base is a terminal description.
1096A terminal description is nominally a single line, but it can be split
1097into multiple lines by inserting the two characters @samp{\ newline}.
1098This sequence is ignored wherever it appears in a description.
1099
1100The preferred way to split the description is between capabilities: insert
1101the four characters @samp{: \ newline tab} immediately before any colon.
1102This allows each sub-line to start with some indentation. This works
1103because, after the @samp{\ newline} are ignored, the result is @samp{: tab
1104:}; the first colon ends the preceding capability and the second colon
1105starts the next capability. If you split with @samp{\ newline} alone, you
1106may not add any indentation after them.
1107
1108Here is a real example of a terminal description:
1109
1110@example
1111dw|vt52|DEC vt52:\
1112 :cr=^M:do=^J:nl=^J:bl=^G:\
1113 :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\
1114 :cm=\EY%+ %+ :co#80:li#24:\
1115 :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\
1116 :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:
1117@end example
1118
1119Each terminal description begins with several names for the terminal type.
1120The names are separated by @samp{|} characters, and a colon ends the last
1121name. The first name should be two characters long; it exists only for the
1122sake of very old Unix systems and is never used in modern systems. The
1123last name should be a fully verbose name such as ``DEC vt52'' or ``Ann
1124Arbor Ambassador with 48 lines''. The other names should include whatever
1125the user ought to be able to specify to get this terminal type, such as
1126@samp{vt52} or @samp{aaa-48}. @xref{Naming}, for information on how to
1127choose terminal type names.
1128
1129After the terminal type names come the terminal capabilities, separated by
1130colons and with a colon after the last one. Each capability has a
1131two-letter name, such as @samp{cm} for ``cursor motion string'' or @samp{li}
1132for ``number of display lines''.
1133
1134@node Capability Format, Naming, Format, Data Base
1135@section Writing the Capabilities
1136
1137There are three kinds of capabilities: flags, numbers, and strings. Each
1138kind has its own way of being written in the description. Each defined
1139capability has by convention a particular kind of value; for example,
1140@samp{li} always has a numeric value and @samp{cm} always a string value.
1141
1142A flag capability is thought of as having a boolean value: the value is
1143true if the capability is present, false if not. When the capability is
1144present, just write its name between two colons.
1145
1146A numeric capability has a value which is a nonnegative number. Write the
1147capability name, a @samp{#}, and the number, between two colons. For
1148example, @samp{@dots{}:li#48:@dots{}} is how you specify the @samp{li}
1149capability for 48 lines.@refill
1150
1151A string-valued capability has a value which is a sequence of characters.
1152Usually these are the characters used to perform some display operation.
1153Write the capability name, a @samp{=}, and the characters of the value,
1154between two colons. For example, @samp{@dots{}:cm=\E[%i%d;%dH:@dots{}} is
1155how the cursor motion command for a standard ANSI terminal would be
1156specified.@refill
1157
1158Special characters in the string value can be expressed using
1159@samp{\}-escape sequences as in C; in addition, @samp{\E} stands for
1160@key{ESC}. @samp{^} is also a kind of escape character; @samp{^} followed
1161by @var{char} stands for the control-equivalent of @var{char}. Thus,
1162@samp{^a} stands for the character control-a, just like @samp{\001}.
1163@samp{\} and @samp{^} themselves can be represented as @samp{\\} and
1164@samp{\^}.@refill
1165
1166To include a colon in the string, you must write @samp{\072}. You might
1167ask, ``Why can't @samp{\:} be used to represent a colon?'' The reason is
1168that the interrogation functions do not count slashes while looking for a
1169capability. Even if @samp{:ce=ab\:cd:} were interpreted as giving the
1170@samp{ce} capability the value @samp{ab:cd}, it would also appear to define
1171@samp{cd} as a flag.
1172
1173The string value will often contain digits at the front to specify padding
1174(@pxref{Padding}) and/or @samp{%}-sequences within to specify how to encode
1175parameters (@pxref{Parameters}). Although these things are not to be
1176output literally to the terminal, they are considered part of the value of
1177the capability. They are special only when the string value is processed
1178by @code{tputs}, @code{tparam} or @code{tgoto}. By contrast, @samp{\} and
1179@samp{^} are considered part of the syntax for specifying the characters
1180in the string.
1181
1182Let's look at the VT52 example again:
1183
1184@example
1185dw|vt52|DEC vt52:\
1186 :cr=^M:do=^J:nl=^J:bl=^G:\
1187 :le=^H:bs:cd=\EJ:ce=\EK:cl=\EH\EJ:\
1188 :cm=\EY%+ %+ :co#80:li#24:\
1189 :nd=\EC:ta=^I:pt:sr=\EI:up=\EA:\
1190 :ku=\EA:kd=\EB:kr=\EC:kl=\ED:kb=^H:
1191@end example
1192
1193Here we see the numeric-valued capabilities @samp{co} and @samp{li}, the
1194flags @samp{bs} and @samp{pt}, and many string-valued capabilities. Most
1195of the strings start with @key{ESC} represented as @samp{\E}. The rest
1196contain control characters represented using @samp{^}. The meanings of the
1197individual capabilities are defined elsewhere (@pxref{Capabilities}).
1198
1199@node Naming, Inheriting, Capability Format, Data Base
1200@section Terminal Type Name Conventions
1201@cindex names of terminal types
1202
1203There are conventions for choosing names of terminal types. For one thing,
1204all letters should be in lower case. The terminal type for a terminal in
1205its most usual or most fundamental mode of operation should not have a
1206hyphen in it.
1207
1208If the same terminal has other modes of operation which require
1209different terminal descriptions, these variant descriptions are given
1210names made by adding suffixes with hyphens. Such alternate descriptions
1211are used for two reasons:
1212
1213@itemize @bullet
1214@item
1215When the terminal has a switch that changes its behavior. Since the
1216computer cannot tell how the switch is set, the user must tell the
1217computer by choosing the appropriate terminal type name.
1218
1219@cindex wrapping
1220For example, the VT-100 has a setup flag that controls whether the
1221cursor wraps at the right margin. If this flag is set to ``wrap'',
1222you must use the terminal type @samp{vt100-am}. Otherwise you must
1223use @samp{vt100-nam}. Plain @samp{vt100} is defined as a synonym for
1224either @samp{vt100-am} or @samp{vt100-nam} depending on the
1225preferences of the local site.@refill
1226
1227The standard suffix @samp{-am} stands for ``automatic margins''.
1228
1229@item
1230To give the user a choice in how to use the terminal. This is done
1231when the terminal has a switch that the computer normally controls.
1232
1233@cindex screen size
1234For example, the Ann Arbor Ambassador can be configured with many
1235screen sizes ranging from 20 to 60 lines. Fewer lines make bigger
1236characters but more lines let you see more of what you are editing.
1237As a result, users have different preferences. Therefore, termcap
1238provides terminal types for many screen sizes. If you choose type
1239@samp{aaa-30}, the terminal will be configured to use 30 lines; if you
1240choose @samp{aaa-48}, 48 lines will be used, and so on.
1241@end itemize
1242
1243Here is a list of standard suffixes and their conventional meanings:
1244
1245@table @samp
1246@item -w
1247Short for ``wide''. This is a mode that gives the terminal more
1248columns than usual. This is normally a user option.
1249
1250@item -am
1251``Automatic margins''. This is an alternate description for use when
1252the terminal's margin-wrap switch is on; it contains the @samp{am}
1253flag. The implication is that normally the switch is off and the
1254usual description for the terminal says that the switch is off.
1255
1256@item -nam
1257``No automatic margins''. The opposite of @samp{-am}, this names an
1258alternative description which lacks the @samp{am} flag. This implies
1259that the terminal is normally operated with the margin-wrap switch
1260turned on, and the normal description of the terminal says so.
1261
1262@item -na
1263``No arrows''. This terminal description initializes the terminal to
1264keep its arrow keys in local mode. This is a user option.
1265
1266@item -rv
1267``Reverse video''. This terminal description causes text output for
1268normal video to appear as reverse, and text output for reverse video
1269to come out as normal. Often this description differs from the usual
1270one by interchanging the two strings which turn reverse video on and
1271off.@refill
1272
1273This is a user option; you can choose either the ``reverse video''
1274variant terminal type or the normal terminal type, and termcap will
1275obey.
1276
1277@item -s
1278``Status''. Says to enable use of a status line which ordinary output
1279does not touch (@pxref{Status Line}).
1280
1281Some terminals have a special line that is used only as a status line.
1282For these terminals, there is no need for an @samp{-s} variant; the
1283status line commands should be defined by default. On other
1284terminals, enabling a status line means removing one screen line from
1285ordinary use and reducing the effective screen height. For these
1286terminals, the user can choose the @samp{-s} variant type to request
1287use of a status line.
1288
1289@item -@var{nlines}
1290Says to operate with @var{nlines} lines on the screen, for terminals
1291such as the Ambassador which provide this as an option. Normally this
1292is a user option; by choosing the terminal type, you control how many
1293lines termcap will use.
1294
1295@item -@var{npages}p
1296Says that the terminal has @var{npages} pages worth of screen memory,
1297for terminals where this is a hardware option.
1298
1299@item -unk
1300Says that description is not for direct use, but only for reference in
1301@samp{tc} capabilities. Such a description is a kind of subroutine,
1302because it describes the common characteristics of several variant
1303descriptions that would use other suffixes in place of @samp{-unk}.
1304@end table
1305
1306@node Inheriting, Changing, Naming, Data Base
1307@section Inheriting from Related Descriptions
1308
1309@cindex inheritance
1310When two terminal descriptions are similar, their identical parts do not
1311need to be given twice. Instead, one of the two can be defined in terms of
1312the other, using the @samp{tc} capability. We say that one description
1313@dfn{refers to} the other, or @dfn{inherits from} the other.
1314
1315The @samp{tc} capability must be the last one in the terminal description,
1316and its value is a string which is the name of another terminal type which
1317is referred to. For example,
1318
1319@example
1320N9|aaa|ambassador|aaa-30|ann arbor ambassador/30 lines:\
1321 :ti=\E[2J\E[30;0;0;30p:\
1322 :te=\E[60;0;0;30p\E[30;1H\E[J:\
1323 :li#30:tc=aaa-unk:
1324@end example
1325
1326@noindent
1327defines the terminal type @samp{aaa-30} (also known as plain @samp{aaa}) in
1328terms of @samp{aaa-unk}, which defines everything about the Ambassador that
1329is independent of screen height. The types @samp{aaa-36}, @samp{aaa-48}
1330and so on for other screen heights are likewise defined to inherit from
1331@samp{aaa-unk}.
1332
1333The capabilities overridden by @samp{aaa-30} include @samp{li}, which says
1334how many lines there are, and @samp{ti} and @samp{te}, which configure the
1335terminal to use that many lines.
1336
1337The effective terminal description for type @samp{aaa} consists of the text
1338shown above followed by the text of the description of @samp{aaa-unk}. The
1339@samp{tc} capability is handled automatically by @code{tgetent}, which
1340finds the description thus referenced and combines the two descriptions
1341(@pxref{Find}). Therefore, only the implementor of the terminal
1342descriptions needs to think about using @samp{tc}. Users and application
1343programmers do not need to be concerned with it.
1344
1345Since the reference terminal description is used last, capabilities
1346specified in the referring description override any specifications of the
1347same capabilities in the reference description.
1348
1349The referring description can cancel out a capability without specifying
1350any new value for it by means of a special trick. Write the capability in
1351the referring description, with the character @samp{@@} after the capability
1352name, as follows:
1353
1354@smallexample
1355NZ|aaa-30-nam|ann arbor ambassador/30 lines/no automatic-margins:\
1356 :am@@:tc=aaa-30:
1357@end smallexample
1358
1359@node Changing, , Inheriting, Data Base
1360@section When Changes in the Data Base Take Effect
1361
1362Each application program must read the terminal description from the
1363data base, so a change in the data base is effective for all jobs started
1364after the change is made.
1365
1366The change will usually have no effect on a job that have been in existence
1367since before the change. The program probably read the terminal description
1368once, when it was started, and is continuing to use what it read then.
1369If the program does not have a feature for reexamining the data base, then
1370you will need to run it again (probably killing the old job).
1371
1372If the description in use is coming from the @code{TERMCAP} environment
1373variable, then the data base file is effectively overridden, and changes in
1374it will have no effect until you change the @code{TERMCAP} variable as
1375well. For example, some users' @file{.login} files automatically copy the
1376terminal description into @code{TERMCAP} to speed startup of applications.
1377If you have done this, you will need to change the @code{TERMCAP} variable
1378to make the changed data base take effect.
1379
1380@node Capabilities, Summary, Data Base, Top
1381@chapter Definitions of the Terminal Capabilities
1382
1383This section is divided into many subsections, each for one aspect of
1384use of display terminals. For writing a display program, you usually need
1385only check the subsections for the operations you want to use. For writing
1386a terminal description, you must read each subsection and fill in the
1387capabilities described there.
1388
1389String capabilities that are display commands may require numeric
1390parameters (@pxref{Parameters}). Most such capabilities do not use
1391parameters. When a capability requires parameters, this is explicitly
1392stated at the beginning of its definition. In simple cases, the first or
1393second sentence of the definition mentions all the parameters, in the order
1394they should be given, using a name
1395@iftex
1396in italics
1397@end iftex
1398@ifinfo
1399in upper case
1400@end ifinfo
1401for each one. For example, the @samp{rp} capability is a command that
1402requires two parameters; its definition begins as follows:
1403
1404@quotation
1405String of commands to output a graphic character @var{c}, repeated @var{n}
1406times.
1407@end quotation
1408
1409In complex cases or when there are many parameters, they are described
1410explicitly.
1411
1412When a capability is described as obsolete, this means that programs should
1413not be written to look for it, but terminal descriptions should still be
1414written to provide it.
1415
1416When a capability is described as very obsolete, this means that it should
1417be omitted from terminal descriptions as well.
1418
1419@menu
1420* Basic:: Basic characteristics.
1421* Screen Size:: Screen size, and what happens when it changes.
1422* Cursor Motion:: Various ways to move the cursor.
1423* Wrapping:: What happens if you write a character in the last column.
1424* Scrolling:: Pushing text up and down on the screen.
1425* Windows:: Limiting the part of the window that output affects.
1426* Clearing:: Erasing one or many lines.
1427* Insdel Line:: Making new blank lines in mid-screen; deleting lines.
1428* Insdel Char:: Inserting and deleting characters within a line.
1429* Standout:: Highlighting some of the text.
1430* Underlining:: Underlining some of the text.
1431* Cursor Visibility:: Making the cursor more or less easy to spot.
1432* Bell:: Attracts user's attention; not localized on the screen.
1433* Keypad:: Recognizing when function keys or arrows are typed.
1434* Meta Key:: @key{META} acts like an extra shift key.
1435* Initialization:: Commands used to initialize or reset the terminal.
1436* Pad Specs:: Info for the kernel on how much padding is needed.
1437* Status Line:: A status line displays ``background'' information.
1438* Half-Line:: Moving by half-lines, for superscripts and subscripts.
1439* Printer:: Controlling auxiliary printers of display terminals.
1440@end menu
1441
1442@node Basic, Screen Size, , Capabilities
1443@section Basic Characteristics
1444
1445This section documents the capabilities that describe the basic and
1446nature of the terminal, and also those that are relevant to the output
1447of graphic characters.
1448
1449@table @samp
1450@item os
1451@kindex os
1452@cindex overstrike
1453Flag whose presence means that the terminal can overstrike. This
1454means that outputting a graphic character does not erase whatever was
1455present in the same character position before. The terminals that can
1456overstrike include printing terminals, storage tubes (all obsolete
1457nowadays), and many bit-map displays.
1458
1459@item eo
1460@kindex eo
1461Flag whose presence means that outputting a space erases a character
1462position even if the terminal supports overstriking. If this flag is
1463not present and overstriking is supported, output of a space has no
1464effect except to move the cursor.
1465
1466(On terminals that do not support overstriking, you can always assume
1467that outputting a space at a position erases whatever character was
1468previously displayed there.)
1469
1470@item gn
1471@kindex gn
1472@cindex generic terminal type
1473Flag whose presence means that this terminal type is a generic type
1474which does not really describe any particular terminal. Generic types
1475are intended for use as the default type assigned when the user
1476connects to the system, with the intention that the user should
1477specify what type he really has. One example of a generic type
1478is the type @samp{network}.
1479
1480Since the generic type cannot say how to do anything interesting with
1481the terminal, termcap-using programs will always find that the
1482terminal is too weak to be supported if the user has failed to specify
1483a real terminal type in place of the generic one. The @samp{gn} flag
1484directs these programs to use a different error message: ``You have
1485not specified your real terminal type'', rather than ``Your terminal
1486is not powerful enough to be used''.
1487
1488@item hc
1489@kindex hc
1490Flag whose presence means this is a hardcopy terminal.
1491
1492@item rp
1493@kindex rp
1494@cindex repeat output
1495String of commands to output a graphic character @var{c}, repeated @var{n}
1496times. The first parameter value is the ASCII code for the desired
1497character, and the second parameter is the number of times to repeat the
1498character. Often this command requires padding proportional to the
1499number of times the character is repeated. This effect can be had by
1500using parameter arithmetic with @samp{%}-sequences to compute the
1501amount of padding, then generating the result as a number at the front
1502of the string so that @code{tputs} will treat it as padding.
1503
1504@item hz
1505@kindex hz
1506Flag whose presence means that the ASCII character @samp{~} cannot be
1507output on this terminal because it is used for display commands.
1508
1509Programs handle this flag by checking all text to be output and
1510replacing each @samp{~} with some other character(s). If this is not
1511done, the screen will be thoroughly garbled.
1512
1513The old Hazeltine terminals that required such treatment are probably
1514very rare today, so you might as well not bother to support this flag.
1515
1516@item CC
1517@kindex CC
1518@cindex command character
1519String whose presence means the terminal has a settable command
1520character. The value of the string is the default command character
1521(which is usually @key{ESC}).
1522
1523All the strings of commands in the terminal description should be
1524written to use the default command character. If you are writing an
1525application program that changes the command character, use the
1526@samp{CC} capability to figure out how to translate all the display
1527commands to work with the new command character.
1528
1529Most programs have no reason to look at the @samp{CC} capability.
1530
1531@item xb
1532@kindex xb
1533@cindex Superbee
1534Flag whose presence identifies Superbee terminals which are unable to
1535transmit the characters @key{ESC} and @kbd{Control-C}. Programs which
1536support this flag are supposed to check the input for the code sequences
1537sent by the @key{F1} and @key{F2} keys, and pretend that @key{ESC}
1538or @kbd{Control-C} (respectively) had been read. But this flag is
1539obsolete, and not worth supporting.
1540@end table
1541
1542@node Screen Size, Cursor Motion, Basic, Capabilities
1543@section Screen Size
1544@cindex screen size
1545
1546A terminal description has two capabilities, @samp{co} and @samp{li},
1547that describe the screen size in columns and lines. But there is more
1548to the question of screen size than this.
1549
1550On some operating systems the ``screen'' is really a window and the
1551effective width can vary. On some of these systems, @code{tgetnum}
1552uses the actual width of the window to decide what value to return for
1553the @samp{co} capability, overriding what is actually written in the
1554terminal description. On other systems, it is up to the application
1555program to check the actual window width using a system call. For
1556example, on BSD 4.3 systems, the system call @code{ioctl} with code
1557@code{TIOCGWINSZ} will tell you the current screen size.
1558
1559On all window systems, termcap is powerless to advise the application
1560program if the user resizes the window. Application programs must
1561deal with this possibility in a system-dependent fashion. On some
1562systems the C shell handles part of the problem by detecting changes
1563in window size and setting the @code{TERMCAP} environment variable
1564appropriately. This takes care of application programs that are
1565started subsequently. It does not help application programs already
1566running.
1567
1568On some systems, including BSD 4.3, all programs using a terminal get
1569a signal named @code{SIGWINCH} whenever the screen size changes.
1570Programs that use termcap should handle this signal by using
1571@code{ioctl TIOCGWINSZ} to learn the new screen size.
1572
1573@table @samp
1574@item co
1575@kindex co
1576@cindex screen size
1577Numeric value, the width of the screen in character positions. Even
1578hardcopy terminals normally have a @samp{co} capability.
1579
1580@item li
1581@kindex li
1582Numeric value, the height of the screen in lines.
1583@end table
1584
1585@node Cursor Motion, Wrapping, Screen Size, Capabilities
1586@section Cursor Motion
1587@cindex cursor motion
1588
1589Termcap assumes that the terminal has a @dfn{cursor}, a spot on the screen
1590where a visible mark is displayed, and that most display commands take
1591effect at the position of the cursor. It follows that moving the cursor
1592to a specified location is very important.
1593
1594There are many terminal capabilities for different cursor motion
1595operations. A terminal description should define as many as possible, but
1596most programs do not need to use most of them. One capability, @samp{cm},
1597moves the cursor to an arbitrary place on the screen; this by itself is
1598sufficient for any application as long as there is no need to support
1599hardcopy terminals or certain old, weak displays that have only relative
1600motion commands. Use of other cursor motion capabilities is an
1601optimization, enabling the program to output fewer characters in some
1602common cases.
1603
1604If you plan to use the relative cursor motion commands in an application
1605program, you must know what the starting cursor position is. To do this,
1606you must keep track of the cursor position and update the records each
1607time anything is output to the terminal, including graphic characters.
1608In addition, it is necessary to know whether the terminal wraps after
1609writing in the rightmost column. @xref{Wrapping}.
1610
1611One other motion capability needs special mention: @samp{nw} moves the
1612cursor to the beginning of the following line, perhaps clearing all the
1613starting line after the cursor, or perhaps not clearing at all. This
1614capability is a least common denominator that is probably supported even by
1615terminals that cannot do most other things such as @samp{cm} or @samp{do}.
1616Even hardcopy terminals can support @samp{nw}.
1617
1618@table @asis
1619@item @samp{cm}
1620@kindex cm
1621String of commands to position the cursor at line @var{l}, column @var{c}.
1622Both parameters are origin-zero, and are defined relative to the
1623screen, not relative to display memory.
1624
1625All display terminals except a few very obsolete ones support @samp{cm},
1626so it is acceptable for an application program to refuse to operate on
1627terminals lacking @samp{cm}.
1628
1629@item @samp{ho}
1630@kindex ho
1631@cindex home position
1632String of commands to move the cursor to the upper left corner of the
1633screen (this position is called the @dfn{home position}). In
1634terminals where the upper left corner of the screen is not the same as
1635the beginning of display memory, this command must go to the upper
1636left corner of the screen, not the beginning of display memory.
1637
1638Every display terminal supports this capability, and many application
1639programs refuse to operate if the @samp{ho} capability is missing.
1640
1641@item @samp{ll}
1642@kindex ll
1643String of commands to move the cursor to the lower left corner of the
1644screen. On some terminals, moving up from home position does this,
1645but programs should never assume that will work. Just output the
1646@samp{ll} string (if it is provided); if moving to home position and
1647then moving up is the best way to get there, the @samp{ll} command
1648will do that.
1649
1650@item @samp{cr}
1651@kindex cr
1652String of commands to move the cursor to the beginning of the line it
1653is on. If this capability is not specified, many programs assume
1654they can use the ASCII carriage return character for this.
1655
1656@item @samp{le}
1657@kindex le
1658String of commands to move the cursor left one column. Unless the
1659@samp{bw} flag capability is specified, the effect is undefined if the
1660cursor is at the left margin; do not use this command there. If
1661@samp{bw} is present, this command may be used at the left margin, and
1662it wraps the cursor to the last column of the preceding line.
1663
1664@item @samp{nd}
1665@kindex nd
1666String of commands to move the cursor right one column. The effect is
1667undefined if the cursor is at the right margin; do not use this
1668command there, not even if @samp{am} is present.
1669
1670@item @samp{up}
1671@kindex up
1672String of commands to move the cursor vertically up one line. The
1673effect of sending this string when on the top line is undefined;
1674programs should never use it that way.
1675
1676@item @samp{do}
1677@kindex do
1678String of commands to move the cursor vertically down one line. The
1679effect of sending this string when on the bottom line is undefined;
1680programs should never use it that way.
1681
1682Some programs do use @samp{do} to scroll up one line if used at the
1683bottom line, if @samp{sf} is not defined but @samp{sr} is. This is
1684only to compensate for certain old, incorrect terminal descriptions.
1685(In principle this might actually lead to incorrect behavior on other
1686terminals, but that seems to happen rarely if ever.) But the proper
1687solution is that the terminal description should define @samp{sf} as
1688well as @samp{do} if the command is suitable for scrolling.
1689
1690The original idea was that this string would not contain a newline
1691character and therefore could be used without disabling the kernel's
1692usual habit of converting of newline into a carriage-return newline
1693sequence. But many terminal descriptions do use newline in the
1694@samp{do} string, so this is not possible; a program which sends the
1695@samp{do} string must disable output conversion in the kernel
1696(@pxref{Initialize}).
1697
1698@item @samp{bw}
1699@kindex bw
1700Flag whose presence says that @samp{le} may be used in column zero
1701to move to the last column of the preceding line. If this flag
1702is not present, @samp{le} should not be used in column zero.
1703
1704@item @samp{nw}
1705@kindex nw
1706String of commands to move the cursor to start of next line, possibly
1707clearing rest of line (following the cursor) before moving.
1708
1709@item @samp{DO}, @samp{UP}, @samp{LE}, @samp{RI}
1710@kindex DO
1711@kindex LE
1712@kindex RI
1713@kindex UP
1714Strings of commands to move the cursor @var{n} lines down vertically,
1715up vertically, or @var{n} columns left or right. Do not attempt to
1716move past any edge of the screen with these commands; the effect of
1717trying that is undefined. Only a few terminal descriptions provide
1718these commands, and most programs do not use them.
1719
1720@item @samp{CM}
1721@kindex CM
1722String of commands to position the cursor at line @var{l}, column
1723@var{c}, relative to display memory. Both parameters are origin-zero.
1724This capability is present only in terminals where there is a
1725difference between screen-relative and memory-relative addressing, and
1726not even in all such terminals.
1727
1728@item @samp{ch}
1729@kindex ch
1730String of commands to position the cursor at column @var{c} in the
1731same line it is on. This is a special case of @samp{cm} in which the
1732vertical position is not changed. The @samp{ch} capability is
1733provided only when it is faster to output than @samp{cm} would be in
1734this special case. Programs should not assume most display terminals
1735have @samp{ch}.
1736
1737@item @samp{cv}
1738@kindex cv
1739String of commands to position the cursor at line @var{l} in the same
1740column. This is a special case of @samp{cm} in which the horizontal
1741position is not changed. The @samp{cv} capability is provided only
1742when it is faster to output than @samp{cm} would be in this special
1743case. Programs should not assume most display terminals have
1744@samp{cv}.
1745
1746@item @samp{sc}
1747@kindex sc
1748String of commands to make the terminal save the current cursor
1749position. Only the last saved position can be used. If this
1750capability is present, @samp{rc} should be provided also. Most
1751terminals have neither.
1752
1753@item @samp{rc}
1754@kindex rc
1755String of commands to make the terminal restore the last saved cursor
1756position. If this capability is present, @samp{sc} should be provided
1757also. Most terminals have neither.
1758
1759@item @samp{ff}
1760@kindex ff
1761String of commands to advance to the next page, for a hardcopy
1762terminal.
1763
1764@item @samp{ta}
1765@kindex ta
1766String of commands to move the cursor right to the next hardware tab
1767stop column. Missing if the terminal does not have any kind of
1768hardware tabs. Do not send this command if the kernel's terminal
1769modes say that the kernel is expanding tabs into spaces.
1770
1771@item @samp{bt}
1772@kindex bt
1773String of commands to move the cursor left to the previous hardware
1774tab stop column. Missing if the terminal has no such ability; many
1775terminals do not. Do not send this command if the kernel's terminal
1776modes say that the kernel is expanding tabs into spaces.
1777@end table
1778
1779The following obsolete capabilities should be included in terminal
1780descriptions when appropriate, but should not be looked at by new programs.
1781
1782@table @samp
1783@item nc
1784@kindex nc
1785Flag whose presence means the terminal does not support the ASCII
1786carriage return character as @samp{cr}. This flag is needed because
1787old programs assume, when the @samp{cr} capability is missing, that
1788ASCII carriage return can be used for the purpose. We use @samp{nc}
1789to tell the old programs that carriage return may not be used.
1790
1791New programs should not assume any default for @samp{cr}, so they need
1792not look at @samp{nc}. However, descriptions should contain @samp{nc}
1793whenever they do not contain @samp{cr}.
1794
1795@item xt
1796@kindex xt
1797Flag whose presence means that the ASCII tab character may not be used
1798for cursor motion. This flag exists because old programs assume, when
1799the @samp{ta} capability is missing, that ASCII tab can be used for
1800the purpose. We use @samp{xt} to tell the old programs not to use tab.
1801
1802New programs should not assume any default for @samp{ta}, so they need
1803not look at @samp{xt} in connection with cursor motion. Note that
1804@samp{xt} also has implications for standout mode (@pxref{Standout}).
1805It is obsolete in regard to cursor motion but not in regard to
1806standout.
1807
1808In fact, @samp{xt} means that the terminal is a Teleray 1061.
1809
1810@item bc
1811@kindex bc
1812Very obsolete alternative name for the @samp{le} capability.
1813
1814@item bs
1815@kindex bs
1816Flag whose presence means that the ASCII character backspace may be
1817used to move the cursor left. Obsolete; look at @samp{le} instead.
1818
1819@item nl
1820@kindex nl
1821Obsolete capability which is a string that can either be used to move
1822the cursor down or to scroll. The same string must scroll when used
1823on the bottom line and move the cursor when used on any other line.
1824New programs should use @samp{do} or @samp{sf}, and ignore @samp{nl}.
1825
1826If there is no @samp{nl} capability, some old programs assume they can
1827use the newline character for this purpose. These programs follow a
1828bad practice, but because they exist, it is still desirable to define
1829the @samp{nl} capability in a terminal description if the best way to
1830move down is @emph{not} a newline.
1831@end table
1832
1833@node Wrapping, Scrolling, Cursor Motion, Capabilities
1834@section Wrapping
1835@cindex wrapping
1836
1837@dfn{Wrapping} means moving the cursor from the right margin to the left
1838margin of the following line. Some terminals wrap automatically when a
1839graphic character is output in the last column, while others do not. Most
1840application programs that use termcap need to know whether the terminal
1841wraps. There are two special flag capabilities to describe what the
1842terminal does when a graphic character is output in the last column.
1843
1844@table @samp
1845@item am
1846@kindex am
1847Flag whose presence means that writing a character in the last column
1848causes the cursor to wrap to the beginning of the next line.
1849
1850If @samp{am} is not present, writing in the last column leaves the
1851cursor at the place where the character was written.
1852
1853Writing in the last column of the last line should be avoided on
1854terminals with @samp{am}, as it may or may not cause scrolling to
1855occur (@pxref{Scrolling}). Scrolling is surely not what you would
1856intend.
1857
1858If your program needs to check the @samp{am} flag, then it also needs
1859to check the @samp{xn} flag which indicates that wrapping happens in a
1860strange way. Many common terminals have the @samp{xn} flag.
1861
1862@item xn
1863@kindex xn
1864Flag whose presence means that the cursor wraps in a strange way. At
1865least two distinct kinds of strange behavior are known; the termcap
1866data base does not contain anything to distinguish the two.
1867
1868On Concept-100 terminals, output in the last column wraps the cursor
1869almost like an ordinary @samp{am} terminal. But if the next thing
1870output is a newline, it is ignored.
1871
1872DEC VT-100 terminals (when the wrap switch is on) do a different
1873strange thing: the cursor wraps only if the next thing output is
1874another graphic character. In fact, the wrap occurs when the
1875following graphic character is received by the terminal, before the
1876character is placed on the screen.
1877
1878On both of these terminals, after writing in the last column a
1879following graphic character will be displayed in the first column of
1880the following line. But the effect of relative cursor motion
1881characters such as newline or backspace at such a time depends on the
1882terminal. The effect of erase or scrolling commands also depends on
1883the terminal. You can't assume anything about what they will do on a
1884terminal that has @samp{xn}. So, to be safe, you should never do
1885these things at such a time on such a terminal.
1886
1887To be sure of reliable results on a terminal which has the @samp{xn}
1888flag, output a @samp{cm} absolute positioning command after writing in
1889the last column. Another safe thing to do is to output carriage-return
1890newline, which will leave the cursor at the beginning of the following
1891line.
1892
1893@item LP
1894@kindex LP
1895Flag whose presence means that it is safe to write in the last column of
1896the last line without worrying about undesired scrolling. @samp{LP}
1897indicates the DEC flavor of @samp{xn} strangeness.
1898@end table
1899
1900@node Scrolling, Windows, Wrapping, Capabilities
1901@section Scrolling
1902@cindex scrolling
1903
1904@dfn{Scrolling} means moving the contents of the screen up or down one or
1905more lines. Moving the contents up is @dfn{forward scrolling}; moving them
1906down is @dfn{reverse scrolling}.
1907
1908Scrolling happens after each line of output during ordinary output on most
1909display terminals. But in an application program that uses termcap for
1910random-access output, scrolling happens only when explicitly requested with
1911the commands in this section.
1912
1913Some terminals have a @dfn{scroll region} feature. This lets you limit
1914the effect of scrolling to a specified range of lines. Lines outside the
1915range are unaffected when scrolling happens. The scroll region feature
1916is available if either @samp{cs} or @samp{cS} is present.
1917
1918@table @samp
1919@item sf
1920@kindex sf
1921String of commands to scroll the screen one line up, assuming it is
1922output with the cursor at the beginning of the bottom line.
1923
1924@item sr
1925@kindex sr
1926String of commands to scroll the screen one line down, assuming it is
1927output with the cursor at the beginning of the top line.
1928
1929@item do
1930A few programs will try to use @samp{do} to do the work of @samp{sf}.
1931This is not really correct---it is an attempt to compensate for the
1932absence of a @samp{sf} command in some old terminal descriptions.
1933
1934Since these terminal descriptions do define @samp{sr}, perhaps at one
1935time the definition of @samp{do} was different and it could be used
1936for scrolling as well. But it isn't desirable to combine these two
1937functions in one capability, since scrolling often requires more
1938padding than simply moving the cursor down. Defining @samp{sf} and
1939@samp{do} separately allows you to specify the padding properly.
1940Also, all sources agree that @samp{do} should not be relied on to do
1941scrolling.
1942
1943So the best approach is to add @samp{sf} capabilities to the
1944descriptions of these terminals, copying the definition of @samp{do}
1945if that does scroll.
1946
1947@item SF
1948@kindex SF
1949String of commands to scroll the screen @var{n} lines up, assuming it
1950is output with the cursor at the beginning of the bottom line.
1951
1952@item SR
1953@kindex SR
1954String of commands to scroll the screen @var{n} lines down, assuming it
1955is output with the cursor at the beginning of the top line.
1956
1957@item cs
1958@kindex cs
1959String of commands to set the scroll region. This command takes two
1960parameters, @var{start} and @var{end}, which are the line numbers
1961(origin-zero) of the first line to include in the scroll region and of
1962the last line to include in it. When a scroll region is set,
1963scrolling is limited to the specified range of lines; lines outside
1964the range are not affected by scroll commands.
1965
1966Do not try to move the cursor outside the scroll region. The region
1967remains set until explicitly removed. To remove the scroll region,
1968use another @samp{cs} command specifying the full height of the
1969screen.
1970
1971The cursor position is undefined after the @samp{cs} command is set,
1972so position the cursor with @samp{cm} immediately afterward.
1973
1974@item cS
1975@kindex cS
1976String of commands to set the scroll region using parameters in
1977different form. The effect is the same as if @samp{cs} were used.
1978Four parameters are required:
1979
1980@enumerate
1981@item
1982Total number of lines on the screen.
1983@item
1984Number of lines above desired scroll region.
1985@item
1986Number of lines below (outside of) desired scroll region.
1987@item
1988Total number of lines on the screen, the same as the first parameter.
1989@end enumerate
1990
1991This capability is a GNU extension that was invented to allow the Ann
1992Arbor Ambassador's scroll-region command to be described; it could
1993also be done by putting non-Unix @samp{%}-sequences into a @samp{cs}
1994string, but that would have confused Unix programs that used the
1995@samp{cs} capability with the Unix termcap. Currently only GNU Emacs
1996uses the @samp{cS} capability.
1997
1998@item ns
1999@kindex ns
2000Flag which means that the terminal does not normally scroll for
2001ordinary sequential output. For modern terminals, this means that
2002outputting a newline in ordinary sequential output with the cursor on
2003the bottom line wraps to the top line. For some obsolete terminals,
2004other things may happen.
2005
2006The terminal may be able to scroll even if it does not normally do so.
2007If the @samp{sf} capability is provided, it can be used for scrolling
2008regardless of @samp{ns}.
2009
2010@item da
2011@kindex da
2012Flag whose presence means that lines scrolled up off the top of the
2013screen may come back if scrolling down is done subsequently.
2014
2015The @samp{da} and @samp{db} flags do not, strictly speaking, affect
2016how to scroll. But programs that scroll usually need to clear the
2017lines scrolled onto the screen, if these flags are present.
2018
2019@item db
2020@kindex db
2021Flag whose presence means that lines scrolled down off the bottom of
2022the screen may come back if scrolling up is done subsequently.
2023
2024@item lm
2025@kindex lm
2026Numeric value, the number of lines of display memory that the terminal
2027has. A value of zero means that the terminal has more display memory
2028than can fit on the screen, but no fixed number of lines. (The number
2029of lines may depend on the amount of text in each line.)
2030@end table
2031
2032Any terminal description that defines @samp{SF} should also define @samp{sf};
2033likewise for @samp{SR} and @samp{sr}. However, many terminals can only
2034scroll by one line at a time, so it is common to find @samp{sf} and not
2035@samp{SF}, or @samp{sr} without @samp{SR}.@refill
2036
2037Therefore, all programs that use the scrolling facilities should be
2038prepared to work with @samp{sf} in the case that @samp{SF} is absent, and
2039likewise with @samp{sr}. On the other hand, an application program that
2040uses only @samp{sf} and not @samp{SF} is acceptable, though slow on some
2041terminals.@refill
2042
2043When outputting a scroll command with @code{tputs}, the @var{nlines}
2044argument should be the total number of lines in the portion of the screen
2045being scrolled. Very often these commands require padding proportional to
2046this number of lines. @xref{Padding}.
2047
2048@node Windows, Clearing, Scrolling, Capabilities
2049@section Windows
2050@cindex window
2051
2052A @dfn{window}, in termcap, is a rectangular portion of the screen to which
2053all display operations are restricted. Wrapping, clearing, scrolling,
2054insertion and deletion all operate as if the specified window were all the
2055screen there was.
2056
2057@table @samp
2058@item wi
2059@kindex wi
2060String of commands to set the terminal output screen window.
2061This string requires four parameters, all origin-zero:
2062@enumerate
2063@item
2064The first line to include in the window.
2065@item
2066The last line to include in the window.
2067@item
2068The first column to include in the window.
2069@item
2070The last column to include in the window.
2071@end enumerate
2072@end table
2073
2074Most terminals do not support windows.
2075
2076@node Clearing, Insdel Line, Windows, Capabilities
2077@section Clearing Parts of the Screen
2078@cindex erasing
2079@cindex clearing the screen
2080
2081There are several terminal capabilities for clearing parts of the screen
2082to blank. All display terminals support the @samp{cl} string, and most
2083display terminals support all of these capabilities.
2084
2085@table @samp
2086@item cl
2087@kindex cl
2088String of commands to clear the entire screen and position the cursor
2089at the upper left corner.
2090
2091@item cd
2092@kindex cd
2093String of commands to clear the line the cursor is on, and all the
2094lines below it, down to the bottom of the screen. This command string
2095should be used only with the cursor in column zero; their effect is
2096undefined if the cursor is elsewhere.
2097
2098@item ce
2099@kindex ce
2100String of commands to clear from the cursor to the end of the current
2101line.
2102
2103@item ec
2104@kindex ec
2105String of commands to clear @var{n} characters, starting with the
2106character that the cursor is on. This command string is expected to
2107leave the cursor position unchanged. The parameter @var{n} should never
2108be large enough to reach past the right margin; the effect of such a
2109large parameter would be undefined.
2110@end table
2111
2112Clear to end of line (@samp{ce}) is extremely important in programs that
2113maintain an updating display. Nearly all display terminals support this
2114operation, so it is acceptable for a an application program to refuse to
2115work if @samp{ce} is not present. However, if you do not want this
2116limitation, you can accomplish clearing to end of line by outputting spaces
2117until you reach the right margin. In order to do this, you must know the
2118current horizontal position. Also, this technique assumes that writing a
2119space will erase. But this happens to be true on all the display terminals
2120that fail to support @samp{ce}.
2121
2122@node Insdel Line, Insdel Char, Clearing, Capabilities
2123@section Insert/Delete Line
2124
2125@cindex insert line
2126@cindex delete line
2127@dfn{Inserting a line} means creating a blank line in the middle
2128of the screen, and pushing the existing lines of text apart. In fact,
2129the lines above the insertion point do not change, while the lines below
2130move down, and one is normally lost at the bottom of the screen.
2131
2132@dfn{Deleting a line} means causing the line to disappear from the screen,
2133closing up the gap by moving the lines below it upward. A new line
2134appears at the bottom of the screen. Usually this line is blank, but
2135on terminals with the @samp{db} flag it may be a line previously moved
2136off the screen bottom by scrolling or line insertion.
2137
2138Insertion and deletion of lines is useful in programs that maintain an
2139updating display some parts of which may get longer or shorter. They are
2140also useful in editors for scrolling parts of the screen, and for
2141redisplaying after lines of text are killed or inserted.
2142
2143Many terminals provide commands to insert or delete a single line at the
2144cursor position. Some provide the ability to insert or delete several
2145lines with one command, using the number of lines to insert or delete as a
2146parameter. Always move the cursor to column zero before using any of
2147these commands.
2148
2149@table @samp
2150@item al
2151@kindex al
2152String of commands to insert a blank line before the line the cursor
2153is on. The existing line, and all lines below it, are moved down.
2154The last line in the screen (or in the scroll region, if one is set)
2155disappears and in most circumstances is discarded. It may not be
2156discarded if the @samp{db} is present (@pxref{Scrolling}).
2157
2158The cursor must be at the left margin before this command is used.
2159This command does not move the cursor.
2160
2161@item dl
2162@kindex dl
2163String of commands to delete the line the cursor is on. The following
2164lines move up, and a blank line appears at the bottom of the screen
2165(or bottom of the scroll region). If the terminal has the @samp{db}
2166flag, a nonblank line previously pushed off the screen bottom may
2167reappear at the bottom.
2168
2169The cursor must be at the left margin before this command is used.
2170This command does not move the cursor.
2171
2172@item AL
2173@kindex AL
2174String of commands to insert @var{n} blank lines before the line that
2175the cursor is on. It is like @samp{al} repeated @var{n} times, except
2176that it is as fast as one @samp{al}.
2177
2178@item DL
2179@kindex DL
2180String of commands to delete @var{n} lines starting with the line that
2181the cursor is on. It is like @samp{dl} repeated @var{n} times, except
2182that it is as fast as one @samp{dl}.
2183@end table
2184
2185Any terminal description that defines @samp{AL} should also define
2186@samp{al}; likewise for @samp{DL} and @samp{dl}. However, many terminals
2187can only insert or delete one line at a time, so it is common to find
2188@samp{al} and not @samp{AL}, or @samp{dl} without @samp{DL}.@refill
2189
2190Therefore, all programs that use the insert and delete facilities should be
2191prepared to work with @samp{al} in the case that @samp{AL} is absent, and
2192likewise with @samp{dl}. On the other hand, it is acceptable to write
2193an application that uses only @samp{al} and @samp{dl} and does not look
2194for @samp{AL} or @samp{DL} at all.@refill
2195
2196If a terminal does not support line insertion and deletion directly,
2197but does support a scroll region, the effect of insertion and deletion
2198can be obtained with scrolling. However, it is up to the individual
2199user program to check for this possibility and use the scrolling
2200commands to get the desired result. It is fairly important to implement
2201this alternate strategy, since it is the only way to get the effect of
2202line insertion and deletion on the popular VT100 terminal.
2203
2204Insertion and deletion of lines is affected by the scroll region on
2205terminals that have a settable scroll region. This is useful when it is
2206desirable to move any few consecutive lines up or down by a few lines.
2207@xref{Scrolling}.
2208
2209The line pushed off the bottom of the screen is not lost if the terminal
2210has the @samp{db} flag capability; instead, it is pushed into display
2211memory that does not appear on the screen. This is the same thing that
2212happens when scrolling pushes a line off the bottom of the screen.
2213Either reverse scrolling or deletion of a line can bring the apparently
2214lost line back onto the bottom of the screen. If the terminal has the
2215scroll region feature as well as @samp{db}, the pushed-out line really
2216is lost if a scroll region is in effect.
2217
2218When outputting an insert or delete command with @code{tputs}, the
2219@var{nlines} argument should be the total number of lines from the cursor
2220to the bottom of the screen (or scroll region). Very often these commands
2221require padding proportional to this number of lines. @xref{Padding}.
2222
2223For @samp{AL} and @samp{DL} the @var{nlines} argument should @emph{not}
2224depend on the number of lines inserted or deleted; only the total number of
2225lines affected. This is because it is just as fast to insert two or
2226@var{n} lines with @samp{AL} as to insert one line with @samp{al}.
2227
2228@node Insdel Char, Standout, Insdel Line, Capabilities
2229@section Insert/Delete Character
2230@cindex insert character
2231@cindex delete character
2232
2233@dfn{Inserting a character} means creating a blank space in the middle of a
2234line, and pushing the rest of the line rightward. The character in the
2235rightmost column is lost.
2236
2237@dfn{Deleting a character} means causing the character to disappear from
2238the screen, closing up the gap by moving the rest of the line leftward. A
2239blank space appears in the rightmost column.
2240
2241Insertion and deletion of characters is useful in programs that maintain an
2242updating display some parts of which may get longer or shorter. It is also
2243useful in editors for redisplaying the results of editing within a line.
2244
2245Many terminals provide commands to insert or delete a single character at
2246the cursor position. Some provide the ability to insert or delete several
2247characters with one command, using the number of characters to insert or
2248delete as a parameter.
2249
2250@cindex insert mode
2251Many terminals provide an insert mode in which outputting a graphic
2252character has the added effect of inserting a position for that character.
2253A special command string is used to enter insert mode and another is used
2254to exit it. The reason for designing a terminal with an insert mode rather
2255than an insert command is that inserting character positions is usually
2256followed by writing characters into them. With insert mode, this is as
2257fast as simply writing the characters, except for the fixed overhead of
2258entering and leaving insert mode. However, when the line speed is great
2259enough, padding may be required for the graphic characters output in insert
2260mode.
2261
2262Some terminals require you to enter insert mode and then output a special
2263command for each position to be inserted. Or they may require special
2264commands to be output before or after each graphic character to be
2265inserted.
2266
2267@cindex delete mode
2268Deletion of characters is usually accomplished by a straightforward command
2269to delete one or several positions; but on some terminals, it is necessary
2270to enter a special delete mode before using the delete command, and leave
2271delete mode afterward. Sometimes delete mode and insert mode are the same
2272mode.
2273
2274Some terminals make a distinction between character positions in which a
2275space character has been output and positions which have been cleared. On
2276these terminals, the effect of insert or delete character runs to the first
2277cleared position rather than to the end of the line. In fact, the effect
2278may run to more than one line if there is no cleared position to stop the
2279shift on the first line. These terminals are identified by the @samp{in}
2280flag capability.
2281
2282On terminals with the @samp{in} flag, the technique of skipping over
2283characters that you know were cleared, and then outputting text later on in
2284the same line, causes later insert and delete character operations on that
2285line to do nonstandard things. A program that has any chance of doing this
2286must check for the @samp{in} flag and must be careful to write explicit
2287space characters into the intermediate columns when @samp{in} is present.
2288
2289A plethora of terminal capabilities are needed to describe all of this
2290complexity. Here is a list of them all. Following the list, we present
2291an algorithm for programs to use to take proper account of all of these
2292capabilities.
2293
2294@table @samp
2295@item im
2296@kindex im
2297String of commands to enter insert mode.
2298
2299If the terminal has no special insert mode, but it can insert
2300characters with a special command, @samp{im} should be defined with a
2301null value, because the @samp{vi} editor assumes that insertion of a
2302character is impossible if @samp{im} is not provided.
2303
2304New programs should not act like @samp{vi}. They should pay attention
2305to @samp{im} only if it is defined.
2306
2307@item ei
2308@kindex ei
2309String of commands to leave insert mode. This capability must be
2310present if @samp{im} is.
2311
2312On a few old terminals the same string is used to enter and exit
2313insert mode. This string turns insert mode on if it was off, and off
2314it it was on. You can tell these terminals because the @samp{ei}
2315string equals the @samp{im} string. If you want to support these
2316terminals, you must always remember accurately whether insert mode is
2317in effect. However, these terminals are obsolete, and it is
2318reasonable to refuse to support them. On all modern terminals, you
2319can safely output @samp{ei} at any time to ensure that insert mode is
2320turned off.
2321
2322@item ic
2323@kindex ic
2324String of commands to insert one character position at the cursor.
2325The cursor does not move.
2326
2327If outputting a graphic character while in insert mode is sufficient
2328to insert the character, then the @samp{ic} capability should be
2329defined with a null value.
2330
2331If your terminal offers a choice of ways to insert---either use insert
2332mode or use a special command---then define @samp{im} and do not define
2333@samp{ic}, since this gives the most efficient operation when several
2334characters are to be inserted. @emph{Do not} define both strings, for
2335that means that @emph{both} must be used each time insertion is done.
2336
2337@item ip
2338@kindex ip
2339String of commands to output following an inserted graphic character
2340in insert mode. Often it is used just for a padding spec, when padding
2341is needed after an inserted character (@pxref{Padding}).
2342
2343@item IC
2344@kindex IC
2345String of commands to insert @var{n} character positions at and after
2346the cursor. It has the same effect as repeating the @samp{ic} string
2347and a space, @var{n} times.
2348
2349If @samp{IC} is provided, application programs may use it without first
2350entering insert mode.
2351
2352@item mi
2353@kindex mi
2354Flag whose presence means it is safe to move the cursor while in insert
2355mode and assume the terminal remains in insert mode.
2356
2357@item in
2358@kindex in
2359Flag whose presence means that the terminal distinguishes between
2360character positions in which space characters have been output and
2361positions which have been cleared.
2362@end table
2363
2364An application program can assume that the terminal can do character
2365insertion if @emph{any one of} the capabilities @samp{IC}, @samp{im},
2366@samp{ic} or @samp{ip} is provided.
2367
2368To insert @var{n} blank character positions, move the cursor to the place
2369to insert them and follow this algorithm:
2370
2371@enumerate
2372@item
2373If an @samp{IC} string is provided, output it with parameter @var{n}
2374and you are finished. Otherwise (or if you don't want to bother to
2375look for an @samp{IC} string) follow the remaining steps.
2376
2377@item
2378Output the @samp{im} string, if there is one, unless the terminal is
2379already in insert mode.
2380
2381@item
2382Repeat steps 4 through 6, @var{n} times.
2383
2384@item
2385Output the @samp{ic} string if any.
2386
2387@item
2388Output a space.
2389
2390@item
2391Output the @samp{ip} string if any.
2392
2393@item
2394Output the @samp{ei} string, eventually, to exit insert mode. There
2395is no need to do this right away. If the @samp{mi} flag is present,
2396you can move the cursor and the cursor will remain in insert mode;
2397then you can do more insertion elsewhere without reentering insert
2398mode.
2399@end enumerate
2400
2401To insert @var{n} graphic characters, position the cursor and follow this
2402algorithm:
2403
2404@enumerate
2405@item
2406If an @samp{IC} string is provided, output it with parameter @var{n},
2407then output the graphic characters, and you are finished. Otherwise
2408(or if you don't want to bother to look for an @samp{IC} string)
2409follow the remaining steps.
2410
2411@item
2412Output the @samp{im} string, if there is one, unless the terminal is
2413already in insert mode.
2414
2415@item
2416For each character to be output, repeat steps 4 through 6.
2417
2418@item
2419Output the @samp{ic} string if any.
2420
2421@item
2422Output the next graphic character.
2423
2424@item
2425Output the @samp{ip} string if any.
2426
2427@item
2428Output the @samp{ei} string, eventually, to exit insert mode. There
2429is no need to do this right away. If the @samp{mi} flag is present,
2430you can move the cursor and the cursor will remain in insert mode;
2431then you can do more insertion elsewhere without reentering insert
2432mode.
2433@end enumerate
2434
2435Note that this is not the same as the original Unix termcap specifications
2436in one respect: it assumes that the @samp{IC} string can be used without
2437entering insert mode. This is true as far as I know, and it allows you be
2438able to avoid entering and leaving insert mode, and also to be able to
2439avoid the inserted-character padding after the characters that go into the
2440inserted positions.
2441
2442Deletion of characters is less complicated; deleting one column is done by
2443outputting the @samp{dc} string. However, there may be a delete mode that
2444must be entered with @samp{dm} in order to make @samp{dc} work.
2445
2446@table @samp
2447@item dc
2448@kindex dc
2449String of commands to delete one character position at the cursor. If
2450@samp{dc} is not present, the terminal cannot delete characters.
2451
2452@item DC
2453@kindex DC
2454String of commands to delete @var{n} characters starting at the cursor.
2455It has the same effect as repeating the @samp{dc} string @var{n} times.
2456Any terminal description that has @samp{DC} also has @samp{dc}.
2457
2458@item dm
2459@kindex dm
2460String of commands to enter delete mode. If not present, there is no
2461delete mode, and @samp{dc} can be used at any time (assuming there is
2462a @samp{dc}).
2463
2464@item ed
2465@kindex ed
2466String of commands to exit delete mode. This must be present if
2467@samp{dm} is.
2468@end table
2469
2470To delete @var{n} character positions, position the cursor and follow these
2471steps:
2472
2473@enumerate
2474@item
2475If the @samp{DC} string is present, output it with parameter @var{n}
2476and you are finished. Otherwise, follow the remaining steps.
2477
2478@item
2479Output the @samp{dm} string, unless you know the terminal is already
2480in delete mode.
2481
2482@item
2483Output the @samp{dc} string @var{n} times.
2484
2485@item
2486Output the @samp{ed} string eventually. If the flag capability
2487@samp{mi} is present, you can move the cursor and do more deletion
2488without leaving and reentering delete mode.
2489@end enumerate
2490
2491As with the @samp{IC} string, we have departed from the original termcap
2492specifications by assuming that @samp{DC} works without entering delete
2493mode even though @samp{dc} would not.
2494
2495If the @samp{dm} and @samp{im} capabilities are both present and have the
2496same value, it means that the terminal has one mode for both insertion and
2497deletion. It is useful for a program to know this, because then it can do
2498insertions after deletions, or vice versa, without leaving insert/delete
2499mode and reentering it.
2500
2501@node Standout, Underlining, Insdel Char, Capabilities
2502@section Standout and Appearance Modes
2503@cindex appearance modes
2504@cindex standout
2505@cindex magic cookie
2506
2507@dfn{Appearance modes} are modifications to the ways characters are
2508displayed. Typical appearance modes include reverse video, dim, bright,
2509blinking, underlined, invisible, and alternate character set. Each kind of
2510terminal supports various among these, or perhaps none.
2511
2512For each type of terminal, one appearance mode or combination of them that
2513looks good for highlighted text is chosen as the @dfn{standout mode}. The
2514capabilities @samp{so} and @samp{se} say how to enter and leave standout
2515mode. Programs that use appearance modes only to highlight some text
2516generally use the standout mode so that they can work on as many terminals
2517as possible. Use of specific appearance modes other than ``underlined''
2518and ``alternate character set'' is rare.
2519
2520Terminals that implement appearance modes fall into two general classes as
2521to how they do it.
2522
2523In some terminals, the presence or absence of any appearance mode is
2524recorded separately for each character position. In these terminals, each
2525graphic character written is given the appearance modes current at the time
2526it is written, and keeps those modes until it is erased or overwritten.
2527There are special commands to turn the appearance modes on or off for
2528characters to be written in the future.
2529
2530In other terminals, the change of appearance modes is represented by a
2531marker that belongs to a certain screen position but affects all following
2532screen positions until the next marker. These markers are traditionally
2533called @dfn{magic cookies}.
2534
2535The same capabilities (@samp{so}, @samp{se}, @samp{mb} and so on) for
2536turning appearance modes on and off are used for both magic-cookie
2537terminals and per-character terminals. On magic cookie terminals, these
2538give the commands to write the magic cookies. On per-character terminals,
2539they change the current modes that affect future output and erasure. Some
2540simple applications can use these commands without knowing whether or not
2541they work by means of cookies.
2542
2543However, a program that maintains and updates a display needs to know
2544whether the terminal uses magic cookies, and exactly what their effect is.
2545This information comes from the @samp{sg} capability.
2546
2547The @samp{sg} capability is a numeric capability whose presence indicates
2548that the terminal uses magic cookies for appearance modes. Its value is
2549the number of character positions that a magic cookie occupies. Usually
2550the cookie occupies one or more character positions on the screen, and these
2551character positions are displayed as blank, but in some terminals the
2552cookie has zero width.
2553
2554The @samp{sg} capability describes both the magic cookie to turn standout
2555on and the cookie to turn it off. This makes the assumption that both
2556kinds of cookie have the same width on the screen. If that is not true,
2557the narrower cookie must be ``widened'' with spaces until it has the same
2558width as the other.
2559
2560On some magic cookie terminals, each line always starts with normal
2561display; in other words, the scope of a magic cookie never extends over
2562more than one line. But on other terminals, one magic cookie affects all
2563the lines below it unless explicitly canceled. Termcap does not define any
2564way to distinguish these two ways magic cookies can work. To be safe, it
2565is best to put a cookie at the beginning of each line.
2566
2567On some per-character terminals, standout mode or other appearance modes
2568may be canceled by moving the cursor. On others, moving the cursor has no
2569effect on the state of the appearance modes. The latter class of terminals
2570are given the flag capability @samp{ms} (``can move in standout''). All
2571programs that might have occasion to move the cursor while appearance modes
2572are turned on must check for this flag; if it is not present, they should
2573reset appearance modes to normal before doing cursor motion.
2574
2575A program that has turned on only standout mode should use @samp{se} to
2576reset the standout mode to normal. A program that has turned on only
2577alternate character set mode should use @samp{ae} to return it to normal.
2578If it is possible that any other appearance modes are turned on, use the
2579@samp{me} capability to return them to normal.
2580
2581Note that the commands to turn on one appearance mode, including @samp{so}
2582and @samp{mb} @dots{} @samp{mr}, if used while some other appearance modes
2583are turned on, may combine the two modes on some terminals but may turn off
2584the mode previously enabled on other terminals. This is because some
2585terminals do not have a command to set or clear one appearance mode without
2586changing the others. Programs should not attempt to use appearance modes
2587in combination except with @samp{sa}, and when switching from one single
2588mode to another should always turn off the previously enabled mode and then
2589turn on the new desired mode.
2590
2591On some old terminals, the @samp{so} and @samp{se} commands may be the same
2592command, which has the effect of turning standout on if it is off, or off
2593it is on. It is therefore risky for a program to output extra @samp{se}
2594commands for good measure. Fortunately, all these terminals are obsolete.
2595
2596Programs that update displays in which standout-text may be replaced with
2597non-standout text must check for the @samp{xs} flag. In a per-character
2598terminal, this flag says that the only way to remove standout once written is
2599to clear that portion of the line with the @samp{ce} string or something
2600even more powerful (@pxref{Clearing}); just writing new characters at those
2601screen positions will not change the modes in effect there. In a magic
2602cookie terminal, @samp{xs} says that the only way to remove a cookie is to
2603clear a portion of the line that includes the cookie; writing a different
2604cookie at the same position does not work.
2605
2606Such programs must also check for the @samp{xt} flag, which means that the
2607terminal is a Teleray 1061. On this terminal it is impossible to position
2608the cursor at the front of a magic cookie, so the only two ways to remove a
2609cookie are (1) to delete the line it is on or (2) to position the cursor at
2610least one character before it (possibly on a previous line) and output the
2611@samp{se} string, which on these terminals finds and removes the next
2612@samp{so} magic cookie on the screen. (It may also be possible to remove a
2613cookie which is not at the beginning of a line by clearing that line.) The
2614@samp{xt} capability also has implications for the use of tab characters,
2615but in that regard it is obsolete (@xref{Cursor Motion}).
2616
2617@table @samp
2618@item so
2619@kindex so
2620String of commands to enter standout mode.
2621
2622@item se
2623@kindex se
2624String of commands to leave standout mode.
2625
2626@item sg
2627@kindex sg
2628Numeric capability, the width on the screen of the magic cookie. This
2629capability is absent in terminals that record appearance modes
2630character by character.
2631
2632@item ms
2633@kindex ms
2634Flag whose presence means that it is safe to move the cursor while the
2635appearance modes are not in the normal state. If this flag is absent,
2636programs should always reset the appearance modes to normal before
2637moving the cursor.
2638
2639@item xs
2640@kindex xs
2641Flag whose presence means that the only way to reset appearance modes
2642already on the screen is to clear to end of line. On a per-character
2643terminal, you must clear the area where the modes are set. On a magic
2644cookie terminal, you must clear an area containing the cookie.
2645See the discussion above.
2646
2647@item xt
2648@kindex xt
2649Flag whose presence means that the cursor cannot be positioned right
2650in front of a magic cookie, and that @samp{se} is a command to delete
2651the next magic cookie following the cursor. See discussion above.
2652
2653@item mb
2654@kindex mb
2655String of commands to enter blinking mode.
2656
2657@item md
2658@kindex md
2659String of commands to enter double-bright mode.
2660
2661@item mh
2662@kindex mh
2663String of commands to enter half-bright mode.
2664
2665@item mk
2666@kindex mk
2667String of commands to enter invisible mode.
2668
2669@item mp
2670@kindex mp
2671String of commands to enter protected mode.
2672
2673@item mr
2674@kindex mr
2675String of commands to enter reverse-video mode.
2676
2677@item me
2678@kindex me
2679String of commands to turn off all appearance modes, including
2680standout mode and underline mode. On some terminals it also turns off
2681alternate character set mode; on others, it may not. This capability
2682must be present if any of @samp{mb} @dots{} @samp{mr} is present.
2683
2684@item as
2685@kindex as
2686String of commands to turn on alternate character set mode. This mode
2687assigns some or all graphic characters an alternate picture on the
2688screen. There is no standard as to what the alternate pictures look
2689like.
2690
2691@item ae
2692@kindex ae
2693String of commands to turn off alternate character set mode.
2694
2695@item sa
2696@kindex sa
2697String of commands to turn on an arbitrary combination of appearance
2698modes. It accepts 9 parameters, each of which controls a particular
2699kind of appearance mode. A parameter should be 1 to turn its appearance
2700mode on, or zero to turn that mode off. Most terminals do not support
2701the @samp{sa} capability, even among those that do have various
2702appearance modes.
2703
2704The nine parameters are, in order, @var{standout}, @var{underline},
2705@var{reverse}, @var{blink}, @var{half-bright}, @var{double-bright},
2706@var{blank}, @var{protect}, @var{alt char set}.
2707@end table
2708
2709@node Underlining, Cursor Visibility, Standout, Capabilities
2710@section Underlining
2711@cindex underlining
2712
2713Underlining on most terminals is a kind of appearance mode, much like
2714standout mode. Therefore, it may be implemented using magic cookies or as
2715a flag in the terminal whose current state affects each character that is
2716output. @xref{Standout}, for a full explanation.
2717
2718The @samp{ug} capability is a numeric capability whose presence indicates
2719that the terminal uses magic cookies for underlining. Its value is the
2720number of character positions that a magic cookie for underlining occupies;
2721it is used for underlining just as @samp{sg} is used for standout. Aside
2722from the simplest applications, it is impossible to use underlining
2723correctly without paying attention to the value of @samp{ug}.
2724
2725@table @samp
2726@item us
2727@kindex us
2728String of commands to turn on underline mode or to output a magic cookie
2729to start underlining.
2730
2731@item ue
2732@kindex ue
2733String of commands to turn off underline mode or to output a magic
2734cookie to stop underlining.
2735
2736@item ug
2737@kindex ug
2738Width of magic cookie that represents a change of underline mode;
2739or missing, if the terminal does not use a magic cookie for this.
2740
2741@item ms
2742@kindex ms
2743Flag whose presence means that it is safe to move the cursor while the
2744appearance modes are not in the normal state. Underlining is an
2745appearance mode. If this flag is absent, programs should always turn
2746off underlining before moving the cursor.
2747@end table
2748
2749There are two other, older ways of doing underlining: there can be a
2750command to underline a single character, or the output of @samp{_}, the
2751ASCII underscore character, as an overstrike could cause a character to be
2752underlined. New programs need not bother to handle these capabilities
2753unless the author cares strongly about the obscure terminals which support
2754them. However, terminal descriptions should provide these capabilities
2755when appropriate.
2756
2757@table @samp
2758@item uc
2759@kindex uc
2760String of commands to underline the character under the cursor, and
2761move the cursor right.
2762
2763@item ul
2764@kindex ul
2765Flag whose presence means that the terminal can underline by
2766overstriking an underscore character (@samp{_}); some terminals can do
2767this even though they do not support overstriking in general. An
2768implication of this flag is that when outputting new text to overwrite
2769old text, underscore characters must be treated specially lest they
2770underline the old text instead.
2771@end table
2772
2773@node Cursor Visibility, Bell, Underlining, Capabilities
2774@section Cursor Visibility
2775@cindex visibility
2776
2777Some terminals have the ability to make the cursor invisible, or to enhance
2778it. Enhancing the cursor is often done by programs that plan to use the
2779cursor to indicate to the user a position of interest that may be anywhere
2780on the screen---for example, the Emacs editor enhances the cursor on entry.
2781Such programs should always restore the cursor to normal on exit.
2782
2783@table @samp
2784@item vs
2785@kindex vs
2786String of commands to enhance the cursor.
2787
2788@item vi
2789@kindex vi
2790String of commands to make the cursor invisible.
2791
2792@item ve
2793@kindex ve
2794String of commands to return the cursor to normal.
2795@end table
2796
2797If you define either @samp{vs} or @samp{vi}, you must also define @samp{ve}.
2798
2799@node Bell, Keypad, Cursor Visibility, Capabilities
2800@section Bell
2801@cindex bell
2802@cindex visible bell
2803
2804Here we describe commands to make the terminal ask for the user to pay
2805attention to it.
2806
2807@table @samp
2808@item bl
2809@kindex bl
2810String of commands to cause the terminal to make an audible sound. If
2811this capability is absent, the terminal has no way to make a suitable
2812sound.
2813
2814@item vb
2815@kindex vb
2816String of commands to cause the screen to flash to attract attention
2817(``visible bell''). If this capability is absent, the terminal has no
2818way to do such a thing.
2819@end table
2820
2821@node Keypad, Meta Key, Bell, Capabilities
2822@section Keypad and Function Keys
2823
2824Many terminals have arrow and function keys that transmit specific
2825character sequences to the computer. Since the precise sequences used
2826depend on the terminal, termcap defines capabilities used to say what the
2827sequences are. Unlike most termcap string-valued capabilities, these are
2828not strings of commands to be sent to the terminal, rather strings that
2829are received from the terminal.
2830
2831Programs that expect to use keypad keys should check, initially, for a
2832@samp{ks} capability and send it, to make the keypad actually transmit.
2833Such programs should also send the @samp{ke} string when exiting.
2834
2835@table @asis
2836@item @samp{ks}
2837@kindex ka@dots{}ku
2838String of commands to make the keypad keys transmit. If this
2839capability is not provided, but the others in this section are,
2840programs may assume that the keypad keys always transmit.
2841
2842@item @samp{ke}
2843String of commands to make the keypad keys work locally. This
2844capability is provided only if @samp{ks} is.
2845
2846@item @samp{kl}
2847String of input characters sent by typing the left-arrow key. If this
2848capability is missing, you cannot expect the terminal to have a
2849left-arrow key that transmits anything to the computer.
2850
2851@item @samp{kr}
2852String of input characters sent by typing the right-arrow key.
2853
2854@item @samp{ku}
2855String of input characters sent by typing the up-arrow key.
2856
2857@item @samp{kd}
2858String of input characters sent by typing the down-arrow key.
2859
2860@item @samp{kh}
2861String of input characters sent by typing the ``home-position'' key.
2862
2863@item @samp{K1} @dots{} @samp{K5}
2864@kindex K1@dots{}K5
2865Strings of input characters sent by the five other keys in a 3-by-3
2866array that includes the arrow keys, if the keyboard has such a 3-by-3
2867array. Note that one of these keys may be the ``home-position'' key,
2868in which case one of these capabilities will have the same value as
2869the @samp{kh} key.
2870
2871@item @samp{k0}
2872String of input characters sent by function key 10 (or 0, if the terminal
2873has one labeled 0).
2874
2875@item @samp{k1} @dots{} @samp{k9}
2876@kindex k1@dots{}k9
2877Strings of input characters sent by function keys 1 through 9,
2878provided for those function keys that exist.
2879
2880@item @samp{kn}
2881Number: the number of numbered function keys, if there are more than
288210.
2883
2884@item @samp{l0} @dots{} @samp{l9}
2885@kindex l0@dots{}l9
2886Strings which are the labels appearing on the keyboard on the keys
2887described by the capabilities @samp{k0} @dots{} @samp{l9}. These
2888capabilities should be left undefined if the labels are @samp{f0} or
2889@samp{f10} and @samp{f1} @dots{} @samp{f9}.@refill
2890
2891@item @samp{kH}
2892@kindex kA@dots{}kT
2893String of input characters sent by the ``home down'' key, if there is
2894one.
2895
2896@item @samp{kb}
2897String of input characters sent by the ``backspace'' key, if there is
2898one.
2899
2900@item @samp{ka}
2901String of input characters sent by the ``clear all tabs'' key, if there
2902is one.
2903
2904@item @samp{kt}
2905String of input characters sent by the ``clear tab stop this column''
2906key, if there is one.
2907
2908@item @samp{kC}
2909String of input characters sent by the ``clear screen'' key, if there is
2910one.
2911
2912@item @samp{kD}
2913String of input characters sent by the ``delete character'' key, if
2914there is one.
2915
2916@item @samp{kL}
2917String of input characters sent by the ``delete line'' key, if there is
2918one.
2919
2920@item @samp{kM}
2921String of input characters sent by the ``exit insert mode'' key, if
2922there is one.
2923
2924@item @samp{kE}
2925String of input characters sent by the ``clear to end of line'' key, if
2926there is one.
2927
2928@item @samp{kS}
2929String of input characters sent by the ``clear to end of screen'' key,
2930if there is one.
2931
2932@item @samp{kI}
2933String of input characters sent by the ``insert character'' or ``enter
2934insert mode'' key, if there is one.
2935
2936@item @samp{kA}
2937String of input characters sent by the ``insert line'' key, if there is
2938one.
2939
2940@item @samp{kN}
2941String of input characters sent by the ``next page'' key, if there is
2942one.
2943
2944@item @samp{kP}
2945String of input characters sent by the ``previous page'' key, if there is
2946one.
2947
2948@item @samp{kF}
2949String of input characters sent by the ``scroll forward'' key, if there
2950is one.
2951
2952@item @samp{kR}
2953String of input characters sent by the ``scroll reverse'' key, if there
2954is one.
2955
2956@item @samp{kT}
2957String of input characters sent by the ``set tab stop in this column''
2958key, if there is one.
2959
2960@item @samp{ko}
2961String listing the other function keys the terminal has. This is a
2962very obsolete way of describing the same information found in the
2963@samp{kH} @dots{} @samp{kT} keys. The string contains a list of
2964two-character termcap capability names, separated by commas. The
2965meaning is that for each capability name listed, the terminal has a
2966key which sends the string which is the value of that capability. For
2967example, the value @samp{:ko=cl,ll,sf,sr:} says that the terminal has
2968four function keys which mean ``clear screen'', ``home down'',
2969``scroll forward'' and ``scroll reverse''.@refill
2970@end table
2971
2972@node Meta Key, Initialization, Keypad, Capabilities
2973@section Meta Key
2974
2975@cindex meta key
2976A Meta key is a key on the keyboard that modifies each character you type
2977by controlling the 0200 bit. This bit is on if and only if the Meta key is
2978held down when the character is typed. Characters typed using the Meta key
2979are called Meta characters. Emacs uses Meta characters as editing
2980commands.
2981
2982@table @samp
2983@item km
2984@kindex km
2985Flag whose presence means that the terminal has a Meta key.
2986
2987@item mm
2988@kindex mm
2989String of commands to enable the functioning of the Meta key.
2990
2991@item mo
2992@kindex mo
2993String of commands to disable the functioning of the Meta key.
2994@end table
2995
2996If the terminal has @samp{km} but does not have @samp{mm} and @samp{mo}, it
2997means that the Meta key always functions. If it has @samp{mm} and
2998@samp{mo}, it means that the Meta key can be turned on or off. Send the
2999@samp{mm} string to turn it on, and the @samp{mo} string to turn it off.
3000I do not know why one would ever not want it to be on.
3001
3002@node Initialization, Pad Specs, Meta Key, Capabilities
3003@section Initialization
3004@cindex reset
3005@cindex initialization
3006@cindex tab stops
3007
3008@table @samp
3009@item ti
3010@kindex ti
3011String of commands to put the terminal into whatever special modes are
3012needed or appropriate for programs that move the cursor
3013nonsequentially around the screen. Programs that use termcap to do
3014full-screen display should output this string when they start up.
3015
3016@item te
3017@kindex te
3018String of commands to undo what is done by the @samp{ti} string.
3019Programs that output the @samp{ti} string on entry should output this
3020string when they exit.
3021
3022@item is
3023@kindex is
3024String of commands to initialize the terminal for each login session.
3025
3026@item if
3027@kindex if
3028String which is the name of a file containing the string of commands
3029to initialize the terminal for each session of use. Normally @samp{is}
3030and @samp{if} are not both used.
3031
3032@item i1
3033@itemx i3
3034@kindex i1
3035@kindex i3
3036Two more strings of commands to initialize the terminal for each login
3037session. The @samp{i1} string (if defined) is output before @samp{is}
3038or @samp{if}, and the @samp{i3} string (if defined) is output after.
3039
3040The reason for having three separate initialization strings is to make
3041it easier to define a group of related terminal types with slightly
3042different initializations. Define two or three of the strings in the
3043basic type; then the other types can override one or two of the
3044strings.
3045
3046@item rs
3047@kindex rs
3048String of commands to reset the terminal from any strange mode it may
3049be in. Normally this includes the @samp{is} string (or other commands
3050with the same effects) and more. What would go in the @samp{rs}
3051string but not in the @samp{is} string are annoying or slow commands
3052to bring the terminal back from strange modes that nobody would
3053normally use.
3054
3055@item it
3056@kindex it
3057Numeric value, the initial spacing between hardware tab stop columns
3058when the terminal is powered up. Programs to initialize the terminal
3059can use this to decide whether there is a need to set the tab stops.
3060If the initial width is 8, well and good; if it is not 8, then the
3061tab stops should be set; if they cannot be set, the kernel is told
3062to convert tabs to spaces, and other programs will observe this and do
3063likewise.
3064
3065@item ct
3066@kindex ct
3067String of commands to clear all tab stops.
3068
3069@item st
3070@kindex st
3071String of commands to set tab stop at current cursor column on all
3072lines.
3073
3074@item NF
3075@kindex NF
3076Flag whose presence means that the terminal does not support XON/XOFF
3077flow control. Programs should not send XON (@kbd{C-q}) or XOFF
3078(@kbd{C-s}) characters to the terminal.
3079@end table
3080
3081@node Pad Specs, Status Line, Initialization, Capabilities
3082@section Padding Capabilities
3083@cindex padding
3084
3085There are two terminal capabilities that exist just to explain the proper
3086way to obey the padding specifications in all the command string
3087capabilities. One, @samp{pc}, must be obeyed by all termcap-using
3088programs.
3089
3090@table @samp
3091@item pb
3092@kindex pb
3093Numeric value, the lowest baud rate at which padding is actually
3094needed. Programs may check this and refrain from doing any padding at
3095lower speeds.
3096
3097@item pc
3098@kindex pc
3099String of commands for padding. The first character of this string is
3100to be used as the pad character, instead of using null characters for
3101padding. If @samp{pc} is not provided, use null characters. Every
3102program that uses termcap must look up this capability and use it to
3103set the variable @code{PC} that is used by @code{tputs}.
3104@xref{Padding}.
3105@end table
3106
3107Some termcap capabilities exist just to specify the amount of padding that
3108the kernel should give to cursor motion commands used in ordinary
3109sequential output.
3110
3111@table @samp
3112@item dC
3113@kindex dC
3114Numeric value, the number of msec of padding needed for the
3115carriage-return character.
3116
3117@item dN
3118@kindex dN
3119Numeric value, the number of msec of padding needed for the newline
3120(linefeed) character.
3121
3122@item dB
3123@kindex dB
3124Numeric value, the number of msec of padding needed for the backspace
3125character.
3126
3127@item dF
3128@kindex dF
3129Numeric value, the number of msec of padding needed for the formfeed
3130character.
3131
3132@item dT
3133@kindex dT
3134Numeric value, the number of msec of padding needed for the tab
3135character.
3136@end table
3137
3138In some systems, the kernel uses the above capabilities; in other systems,
3139the kernel uses the paddings specified in the string capabilities
3140@samp{cr}, @samp{sf}, @samp{le}, @samp{ff} and @samp{ta}. Descriptions of
3141terminals which require such padding should contain the @samp{dC} @dots{}
3142@samp{dT} capabilities and also specify the appropriate padding in the
3143corresponding string capabilities. Since no modern terminals require
3144padding for ordinary sequential output, you probably won't need to do
3145either of these things.
3146
3147@node Status Line, Half-Line, Pad Specs, Capabilities
3148@section Status Line
3149
3150@cindex status line
3151A @dfn{status line} is a line on the terminal that is not used for ordinary
3152display output but instead used for a special message. The intended use is
3153for a continuously updated description of what the user's program is doing,
3154and that is where the name ``status line'' comes from, but in fact it could
3155be used for anything. The distinguishing characteristic of a status line
3156is that ordinary output to the terminal does not affect it; it changes only
3157if the special status line commands of this section are used.
3158
3159@table @samp
3160@item hs
3161@kindex hs
3162Flag whose presence means that the terminal has a status line. If a
3163terminal description specifies that there is a status line, it must
3164provide the @samp{ts} and @samp{fs} capabilities.
3165
3166@item ts
3167@kindex ts
3168String of commands to move the terminal cursor into the status line.
3169Usually these commands must specifically record the old cursor
3170position for the sake of the @samp{fs} string.
3171
3172@item fs
3173@kindex fs
3174String of commands to move the cursor back from the status line to its
3175previous position (outside the status line).
3176
3177@item es
3178@kindex es
3179Flag whose presence means that other display commands work while
3180writing the status line. In other words, one can clear parts of it,
3181insert or delete characters, move the cursor within it using @samp{ch}
3182if there is a @samp{ch} capability, enter and leave standout mode, and
3183so on.
3184
3185@item ds
3186@kindex ds
3187String of commands to disable the display of the status line. This
3188may be absent, if there is no way to disable the status line display.
3189
3190@item ws
3191@kindex ws
3192Numeric value, the width of the status line. If this capability is
3193absent in a terminal that has a status line, it means the status line
3194is the same width as the other lines.
3195
3196Note that the value of @samp{ws} is sometimes as small as 8.
3197@end table
3198
3199@node Half-Line, Printer, Status Line, Capabilities
3200@section Half-Line Motion
3201
3202Some terminals have commands for moving the cursor vertically by half-lines,
3203useful for outputting subscripts and superscripts. Mostly it is hardcopy
3204terminals that have such features.
3205
3206@table @samp
3207@item hu
3208@kindex hu
3209String of commands to move the cursor up half a line. If the terminal
3210is a display, it is your responsibility to avoid moving up past the
3211top line; however, most likely the terminal that supports this is a
3212hardcopy terminal and there is nothing to be concerned about.
3213
3214@item hd
3215@kindex hd
3216String of commands to move the cursor down half a line. If the
3217terminal is a display, it is your responsibility to avoid moving down
3218past the bottom line, etc.
3219@end table
3220
3221@node Printer, , Half-Line, Capabilities
3222@section Controlling Printers Attached to Terminals
3223@cindex printer
3224
3225Some terminals have attached hardcopy printer ports. They may be able to
3226copy the screen contents to the printer; they may also be able to redirect
3227output to the printer. Termcap does not have anything to tell the program
3228whether the redirected output appears also on the screen; it does on some
3229terminals but not all.
3230
3231@table @samp
3232@item ps
3233@kindex ps
3234String of commands to cause the contents of the screen to be printed.
3235If it is absent, the screen contents cannot be printed.
3236
3237@item po
3238@kindex po
3239String of commands to redirect further output to the printer.
3240
3241@item pf
3242@kindex pf
3243String of commands to terminate redirection of output to the printer.
3244This capability must be present in the description if @samp{po} is.
3245
3246@item pO
3247@kindex pO
3248String of commands to redirect output to the printer for next @var{n}
3249characters of output, regardless of what they are. Redirection will
3250end automatically after @var{n} characters of further output. Until
3251then, nothing that is output can end redirection, not even the
3252@samp{pf} string if there is one. The number @var{n} should not be
3253more than 255.
3254
3255One use of this capability is to send non-text byte sequences (such as
3256bit-maps) to the printer.
3257@end table
3258
3259Most terminals with printers do not support all of @samp{ps}, @samp{po} and
3260@samp{pO}; any one or two of them may be supported. To make a program that
3261can send output to all kinds of printers, it is necessary to check for all
3262three of these capabilities, choose the most convenient of the ones that
3263are provided, and use it in its own appropriate fashion.
3264
3265@node Summary, Var Index, Capabilities, Top
3266@chapter Summary of Capability Names
3267
3268Here are all the terminal capability names in alphabetical order
3269with a brief description of each. For cross references to their definitions,
3270see the index of capability names (@pxref{Cap Index}).
3271
3272@table @samp
3273@item ae
3274String to turn off alternate character set mode.
3275@item al
3276String to insert a blank line before the cursor.
3277@item AL
3278String to insert @var{n} blank lines before the cursor.
3279@item am
3280Flag: output to last column wraps cursor to next line.
3281@item as
3282String to turn on alternate character set mode.like.
3283@item bc
3284Very obsolete alternative name for the @samp{le} capability.
3285@item bl
3286String to sound the bell.
3287@item bs
3288Obsolete flag: ASCII backspace may be used for leftward motion.
3289@item bt
3290String to move the cursor left to the previous hardware tab stop column.
3291@item bw
3292Flag: @samp{le} at left margin wraps to end of previous line.
3293@item CC
3294String to change terminal's command character.
3295@item cd
3296String to clear the line the cursor is on, and following lines.
3297@item ce
3298String to clear from the cursor to the end of the line.
3299@item ch
3300String to position the cursor at column @var{c} in the same line.
3301@item cl
3302String to clear the entire screen and put cursor at upper left corner.
3303@item cm
3304String to position the cursor at line @var{l}, column @var{c}.
3305@item CM
3306String to position the cursor at line @var{l}, column
3307@var{c}, relative to display memory.
3308@item co
3309Number: width of the screen.
3310@item cr
3311String to move cursor sideways to left margin.
3312@item cs
3313String to set the scroll region.
3314@item cS
3315Alternate form of string to set the scroll region.
3316@item ct
3317String to clear all tab stops.
3318@item cv
3319String to position the cursor at line @var{l} in the same column.
3320@item da
3321Flag: data scrolled off top of screen may be scrolled back.
3322@item db
3323Flag: data scrolled off bottom of screen may be scrolled back.
3324@item dB
3325Obsolete number: msec of padding needed for the backspace character.
3326@item dc
3327String to delete one character position at the cursor.
3328@item dC
3329Obsolete number: msec of padding needed for the carriage-return character.
3330@item DC
3331String to delete @var{n} characters starting at the cursor.
3332@item dF
3333Obsolete number: msec of padding needed for the formfeed character.
3334@item dl
3335String to delete the line the cursor is on.
3336@item DL
3337String to delete @var{n} lines starting with the cursor's line.
3338@item dm
3339String to enter delete mode.
3340@item dN
3341Obsolete number: msec of padding needed for the newline character.
3342@item do
3343String to move the cursor vertically down one line.
3344@item DO
3345String to move cursor vertically down @var{n} lines.
3346@item ds
3347String to disable the display of the status line.
3348@item dT
3349Obsolete number: msec of padding needed for the tab character.
3350@item ec
3351String of commands to clear @var{n} characters at cursor.
3352@item ed
3353String to exit delete mode.
3354@item ei
3355String to leave insert mode.
3356@item eo
3357Flag: output of a space can erase an overstrike.
3358@item es
3359Flag: other display commands work while writing the status line.
3360@item ff
3361String to advance to the next page, for a hardcopy terminal.
3362@item fs
3363String to move the cursor back from the status line to its
3364previous position (outside the status line).
3365@item gn
3366Flag: this terminal type is generic, not real.
3367@item hc
3368Flag: hardcopy terminal.
3369@item hd
3370String to move the cursor down half a line.
3371@item ho
3372String to position cursor at upper left corner.
3373@item hs
3374Flag: the terminal has a status line.
3375@item hu
3376String to move the cursor up half a line.
3377@item hz
3378Flag: terminal cannot accept @samp{~} as output.
3379@item i1
3380String to initialize the terminal for each login session.
3381@item i3
3382String to initialize the terminal for each login session.
3383@item ic
3384String to insert one character position at the cursor.
3385@item IC
3386String to insert @var{n} character positions at the cursor.
3387@item if
3388String naming a file of commands to initialize the terminal.
3389@item im
3390String to enter insert mode.
3391@item in
3392Flag: outputting a space is different from moving over empty positions.
3393@item ip
3394String to output following an inserted character in insert mode.
3395@item is
3396String to initialize the terminal for each login session.
3397@item it
3398Number: initial spacing between hardware tab stop columns.
3399@item k0
3400String of input sent by function key 0 or 10.
3401@item k1 @dots{} k9
3402Strings of input sent by function keys 1 through 9.
3403@item K1 @dots{} K5
3404Strings sent by the five other keys in 3-by-3 array with arrows.
3405@item ka
3406String of input sent by the ``clear all tabs'' key.
3407@item kA
3408String of input sent by the ``insert line'' key.
3409@item kb
3410String of input sent by the ``backspace'' key.
3411@item kC
3412String of input sent by the ``clear screen'' key.
3413@item kd
3414String of input sent by typing the down-arrow key.
3415@item kD
3416String of input sent by the ``delete character'' key.
3417@item ke
3418String to make the function keys work locally.
3419@item kE
3420String of input sent by the ``clear to end of line'' key.
3421@item kF
3422String of input sent by the ``scroll forward'' key.
3423@item kh
3424String of input sent by typing the ``home-position'' key.
3425@item kH
3426String of input sent by the ``home down'' key.
3427@item kI
3428String of input sent by the ``insert character'' or ``enter
3429insert mode'' key.
3430@item kl
3431String of input sent by typing the left-arrow key.
3432@item kL
3433String of input sent by the ``delete line'' key.
3434@item km
3435Flag: the terminal has a Meta key.
3436@item kM
3437String of input sent by the ``exit insert mode'' key.
3438@item kn
3439Numeric value, the number of numbered function keys.
3440@item kN
3441String of input sent by the ``next page'' key.
3442@item ko
3443Very obsolete string listing the terminal's named function keys.
3444@item kP
3445String of input sent by the ``previous page'' key.
3446@item kr
3447String of input sent by typing the right-arrow key.
3448@item kR
3449String of input sent by the ``scroll reverse'' key.
3450@item ks
3451String to make the function keys transmit.
3452@item kS
3453String of input sent by the ``clear to end of screen'' key.
3454@item kt
3455String of input sent by the ``clear tab stop this column'' key.
3456@item kT
3457String of input sent by the ``set tab stop in this column'' key.
3458@item ku
3459String of input sent by typing the up-arrow key.
3460@item l0
3461String on keyboard labelling function key 0 or 10.
3462@item l1 @dots{} l9
3463Strings on keyboard labelling function keys 1 through 9.
3464@item le
3465String to move the cursor left one column.
3466@item LE
3467String to move cursor left @var{n} columns.
3468@item li
3469Number: height of the screen.
3470@item ll
3471String to position cursor at lower left corner.
3472@item lm
3473Number: lines of display memory.
3474@item LP
3475Flag: writing to last column of last line will not scroll.
3476@item mb
3477String to enter blinking mode.
3478@item md
3479String to enter double-bright mode.
3480@item me
3481String to turn off all appearance modes
3482@item mh
3483String to enter half-bright mode.
3484@item mi
3485Flag: cursor motion in insert mode is safe.
3486@item mk
3487String to enter invisible mode.
3488@item mm
3489String to enable the functioning of the Meta key.
3490@item mo
3491String to disable the functioning of the Meta key.
3492@item mp
3493String to enter protected mode.
3494@item mr
3495String to enter reverse-video mode.
3496@item ms
3497Flag: cursor motion in standout mode is safe.
3498@item nc
3499Obsolete flag: do not use ASCII carriage-return on this terminal.
3500@item nd
3501String to move the cursor right one column.
3502@item NF
3503Flag: do not use XON/XOFF flow control.
3504@item nl
3505Obsolete alternative name for the @samp{do} and @samp{sf} capabilities.
3506@item ns
3507Flag: the terminal does not normally scroll for sequential output.
3508@item nw
3509String to move to start of next line, possibly clearing rest of old line.
3510@item os
3511Flag: terminal can overstrike.
3512@item pb
3513Number: the lowest baud rate at which padding is actually needed.
3514@item pc
3515String containing character for padding.
3516@item pf
3517String to terminate redirection of output to the printer.
3518@item po
3519String to redirect further output to the printer.
3520@item pO
3521String to redirect @var{n} characters ofoutput to the printer.
3522@item ps
3523String to print the screen on the attached printer.
3524@item rc
3525String to move to last saved cursor position.
3526@item RI
3527String to move cursor right @var{n} columns.
3528@item rp
3529String to output character @var{c} repeated @var{n} times.
3530@item rs
3531String to reset the terminal from any strange modes.
3532@item sa
3533String to turn on an arbitrary combination of appearance modes.
3534@item sc
3535String to save the current cursor position.
3536@item se
3537String to leave standout mode.
3538@item sf
3539String to scroll the screen one line up.
3540@item SF
3541String to scroll the screen @var{n} lines up.
3542@item sg
3543Number: width of magic standout cookie. Absent if magic cookies are
3544not used.
3545@item so
3546String to enter standout mode.
3547@item sr
3548String to scroll the screen one line down.
3549@item SR
3550String to scroll the screen @var{n} line down.
3551@item st
3552String to set tab stop at current cursor column on all lines.
3553programs.
3554@item ta
3555String to move the cursor right to the next hardware tab stop column.
3556@item te
3557String to return terminal to settings for sequential output.
3558@item ti
3559String to initialize terminal for random cursor motion.
3560@item ts
3561String to move the terminal cursor into the status line.
3562@item uc
3563String to underline one character and move cursor right.
3564@item ue
3565String to turn off underline mode
3566@item ug
3567Number: width of underlining magic cookie. Absent if underlining
3568doesn't use magic cookies.
3569@item ul
3570Flag: underline by overstriking with an underscore.
3571@item up
3572String to move the cursor vertically up one line.
3573@item UP
3574String to move cursor vertically up @var{n} lines.
3575@item us
3576String to turn on underline mode
3577@item vb
3578String to make the screen flash.
3579@item ve
3580String to return the cursor to normal.
3581@item vi
3582String to make the cursor invisible.
3583@item vs
3584String to enhance the cursor.
3585@item wi
3586String to set the terminal output screen window.
3587@item ws
3588Number: the width of the status line.
3589@item xb
3590Flag: superbee terminal.
3591@item xn
3592Flag: cursor wraps in a strange way.
3593@item xs
3594Flag: clearing a line is the only way to clear the appearance modes of
3595positions in that line (or, only way to remove magic cookies on that
3596line).
3597@item xt
3598Flag: Teleray 1061; several strange characteristics.
3599@end table
3600
3601@node Var Index, Cap Index, Summary, Top
3602@unnumbered Variable and Function Index
3603
3604@printindex fn
3605
3606@node Cap Index, Index, Var Index, Top
3607@unnumbered Capability Index
3608
3609@printindex ky
3610
3611@node Index, , Cap Index, Top
3612@unnumbered Concept Index
3613
3614@printindex cp
3615
3616@contents
3617@bye
Note: See TracBrowser for help on using the repository browser.