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