]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/terminfo.tail
ncurses 6.4 - patch 20230715
[ncurses.git] / man / terminfo.tail
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: terminfo.tail,v 1.120 2023/07/15 19:46:56 tom Exp $
31 .ps +1
32 .SS User-Defined Capabilities
33 .
34 The preceding section listed the \fIpredefined\fP capabilities.
35 They deal with some special features for terminals no longer
36 (or possibly never) produced.
37 Occasionally there are special features of newer terminals which
38 are awkward or impossible to represent by reusing the predefined
39 capabilities.
40 .PP
41 \fBncurses\fP addresses this limitation by allowing user-defined capabilities.
42 The \fB@TIC@\fP and \fB@INFOCMP@\fP programs provide
43 the \fB\-x\fP option for this purpose.
44 When \fB\-x\fP is set,
45 \fB@TIC@\fP treats unknown capabilities as user-defined.
46 That is, if \fB@TIC@\fP encounters a capability name
47 which it does not recognize,
48 it infers its type (boolean, number or string) from the syntax
49 and makes an extended table entry for that capability.
50 The \fBuse_extended_names\fP(3X) function makes this information
51 conditionally available to applications.
52 The ncurses library provides the data leaving most of the behavior
53 to applications:
54 .bP
55 User-defined capability strings whose name begins
56 with \*(``k\*('' are treated as function keys.
57 .bP
58 The types (boolean, number, string) determined by \fB@TIC@\fP
59 can be inferred by successful calls on \fBtigetflag\fP, etc.
60 .bP
61 If the capability name happens to be two characters,
62 the capability is also available through the termcap interface.
63 .PP
64 While termcap is said to be extensible because it does not use a predefined set
65 of capabilities,
66 in practice it has been limited to the capabilities defined by
67 terminfo implementations.
68 As a rule,
69 user-defined capabilities intended for use by termcap applications should
70 be limited to booleans and numbers to avoid running past the 1023 byte
71 limit assumed by termcap implementations and their applications.
72 In particular, providing extended sets of function keys (past the 60
73 numbered keys and the handful of special named keys) is best done using
74 the longer names available using terminfo.
75 .PP
76 The ncurses library uses a few of these user-defined capabilities,
77 as described in \fBuser_caps\fR(5).
78 Other user-defined capabilities (including function keys) are
79 described in the terminal database, in the section on
80 .I "NCURSES USER-DEFINABLE CAPABILITIES"
81 .
82 .SS A Sample Entry
83 .
84 The following entry, describing an ANSI-standard terminal, is representative
85 of what a \fBterminfo\fP entry for a modern terminal typically looks like.
86 .PP
87 .nf
88 .ft CW
89 \s-2ansi|ansi/pc-term compatible with color,
90         am, mc5i, mir, msgr,
91         colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,
92         acsc=+\\020\\,\\021-\\030.^Y0\\333`\\004a\\261f\\370g\\361h\\260
93              j\\331k\\277l\\332m\\300n\\305o~p\\304q\\304r\\304s_t\\303
94              u\\264v\\301w\\302x\\263y\\363z\\362{\\343|\\330}\\234~\\376,
95         bel=^G, blink=\\E[5m, bold=\\E[1m, cbt=\\E[Z, clear=\\E[H\\E[J,
96         cr=^M, cub=\\E[%p1%dD, cub1=\\E[D, cud=\\E[%p1%dB, cud1=\\E[B,
97         cuf=\\E[%p1%dC, cuf1=\\E[C, cup=\\E[%i%p1%d;%p2%dH,
98         cuu=\\E[%p1%dA, cuu1=\\E[A, dch=\\E[%p1%dP, dch1=\\E[P,
99         dl=\\E[%p1%dM, dl1=\\E[M, ech=\\E[%p1%dX, ed=\\E[J, el=\\E[K,
100         el1=\\E[1K, home=\\E[H, hpa=\\E[%i%p1%dG, ht=\\E[I, hts=\\EH,
101         ich=\\E[%p1%d@, il=\\E[%p1%dL, il1=\\E[L, ind=^J,
102         indn=\\E[%p1%dS, invis=\\E[8m, kbs=^H, kcbt=\\E[Z, kcub1=\\E[D,
103         kcud1=\\E[B, kcuf1=\\E[C, kcuu1=\\E[A, khome=\\E[H, kich1=\\E[L,
104         mc4=\\E[4i, mc5=\\E[5i, nel=\\r\\E[S, op=\\E[39;49m,
105         rep=%p1%c\\E[%p2%{1}%-%db, rev=\\E[7m, rin=\\E[%p1%dT,
106         rmacs=\\E[10m, rmpch=\\E[10m, rmso=\\E[m, rmul=\\E[m,
107         s0ds=\\E(B, s1ds=\\E)B, s2ds=\\E*B, s3ds=\\E+B,
108         setab=\\E[4%p1%dm, setaf=\\E[3%p1%dm,
109         sgr=\\E[0;10%?%p1%t;7%;
110                    %?%p2%t;4%;
111                    %?%p3%t;7%;
112                    %?%p4%t;5%;
113                    %?%p6%t;1%;
114                    %?%p7%t;8%;
115                    %?%p9%t;11%;m,
116         sgr0=\\E[0;10m, smacs=\\E[11m, smpch=\\E[11m, smso=\\E[7m,
117         smul=\\E[4m, tbc=\\E[3g, u6=\\E[%i%d;%dR, u7=\\E[6n,
118         u8=\\E[?%[;0123456789]c, u9=\\E[c, vpa=\\E[%i%p1%dd,
119 .fi
120 .ft R
121 .PP
122 Entries may continue onto multiple lines by placing white space at
123 the beginning of each line except the first.
124 Comments may be included on lines beginning with \*(``#\*(''.
125 Capabilities in
126 .I terminfo
127 are of three types:
128 .bP
129 Boolean capabilities which indicate that the terminal has
130 some particular feature,
131 .bP
132 numeric capabilities giving the size of the terminal
133 or the size of particular delays, and
134 .bP
135 string
136 capabilities, which give a sequence which can be used to perform particular
137 terminal operations.
138 .SS Types of Capabilities
139 All capabilities have names.
140 For instance, the fact that
141 ANSI-standard terminals have
142 .I "automatic margins"
143 (i.e., an automatic return and line-feed
144 when the end of a line is reached) is indicated by the capability \fBam\fP.
145 Hence the description of ansi includes \fBam\fP.
146 Numeric capabilities are followed by the character \*(``#\*('' and then a positive value.
147 Thus \fBcols\fP, which indicates the number of columns the terminal has,
148 gives the value \*(``80\*('' for ansi.
149 Values for numeric capabilities may be specified in decimal, octal or hexadecimal,
150 using the C programming language conventions (e.g., 255, 0377 and 0xff or 0xFF).
151 .PP
152 Finally, string valued capabilities, such as \fBel\fP (clear to end of line
153 sequence) are given by the two-character code, an \*(``=\*('', and then a string
154 ending at the next following \*(``,\*(''.
155 .PP
156 A number of escape sequences are provided in the string valued capabilities
157 for easy encoding of characters there:
158 .bP
159 Both \fB\eE\fP and \fB\ee\fP
160 map to an \s-1ESCAPE\s0 character,
161 .bP
162 \fB^x\fP maps to a control-x for any appropriate \fIx\fP, and
163 .bP
164 the sequences
165 .RS 6
166 .PP
167 \fB\en\fP, \fB\el\fP, \fB\er\fP, \fB\et\fP, \fB\eb\fP, \fB\ef\fP, and \fB\es\fP
168 .RE
169 .IP
170 produce
171 .RS 6
172 .PP
173 \fInewline\fP, \fIline-feed\fP, \fIreturn\fP, \fItab\fP, \fIbackspace\fP, \fIform-feed\fP, and \fIspace\fP,
174 .RE
175 .IP
176 respectively.
177 .PP
178 X/Open Curses does not say what \*(``appropriate \fIx\fP\*('' might be.
179 In practice, that is a printable ASCII graphic character.
180 The special case \*(``^?\*('' is interpreted as DEL (127).
181 In all other cases, the character value is AND'd with 0x1f,
182 mapping to ASCII control codes in the range 0 through 31.
183 .PP
184 Other escapes include
185 .bP
186 \fB\e^\fP for \fB^\fP,
187 .bP
188 \fB\e\e\fP for \fB\e\fP,
189 .bP
190 \fB\e\fP, for comma,
191 .bP
192 \fB\e:\fP for \fB:\fP,
193 .bP
194 and \fB\e0\fP for null.
195 .IP
196 \fB\e0\fP will produce \e200, which does not terminate a string but behaves
197 as a null character on most terminals, providing CS7 is specified.
198 See \fBstty\fP(1).
199 .IP
200 The reason for this quirk is to maintain binary compatibility of the
201 compiled terminfo files with other implementations,
202 e.g., the SVr4 systems, which document this.
203 Compiled terminfo files use null-terminated strings, with no lengths.
204 Modifying this would require a new binary format,
205 which would not work with other implementations.
206 .PP
207 Finally, characters may be given as three octal digits after a \fB\e\fP.
208 .PP
209 A delay in milliseconds may appear anywhere in a string capability, enclosed in
210 $<..> brackets, as in \fBel\fP=\eEK$<5>,
211 and padding characters are supplied by \fBtputs\fP(3X)
212 to provide this delay.
213 .bP
214 The delay must be a number with at most one decimal
215 place of precision; it may be followed by suffixes \*(``*\*('' or \*(``/\*('' or both.
216 .bP
217 A \*(``*\*(''
218 indicates that the padding required is proportional to the number of lines
219 affected by the operation, and the amount given is the per-affected-unit
220 padding required.
221 (In the case of insert character, the factor is still the
222 number of \fIlines\fP affected.)
223 .IP
224 Normally, padding is advisory if the device has the \fBxon\fP
225 capability; it is used for cost computation but does not trigger delays.
226 .bP
227 A \*(``/\*(''
228 suffix indicates that the padding is mandatory and forces a delay of the given
229 number of milliseconds even on devices for which \fBxon\fP is present to
230 indicate flow control.
231 .PP
232 Sometimes individual capabilities must be commented out.
233 To do this, put a period before the capability name.
234 For example, see the second
235 .B ind
236 in the example above.
237 .br
238 .ne 5
239 .SS Fetching Compiled Descriptions
240 The \fBncurses\fP library searches for terminal descriptions in several places.
241 It uses only the first description found.
242 The library has a compiled-in list of places to search
243 which can be overridden by environment variables.
244 Before starting to search,
245 \fBncurses\fP eliminates duplicates in its search list.
246 .bP
247 If the environment variable TERMINFO is set, it is interpreted as the pathname
248 of a directory containing the compiled description you are working on.
249 Only that directory is searched.
250 .bP
251 If TERMINFO is not set,
252 \fBncurses\fP will instead look in the directory \fB$HOME/.terminfo\fP
253 for a compiled description.
254 .bP
255 Next, if the environment variable TERMINFO_DIRS is set,
256 \fBncurses\fP will interpret the contents of that variable
257 as a list of colon-separated directories (or database files) to be searched.
258 .IP
259 An empty directory name (i.e., if the variable begins or ends
260 with a colon, or contains adjacent colons)
261 is interpreted as the system location \fI\*d\fP.
262 .bP
263 Finally, \fBncurses\fP searches these compiled-in locations:
264 .RS
265 .bP
266 a list of directories (@TERMINFO_DIRS@), and
267 .bP
268 the system terminfo directory, \fI\*d\fP (the compiled-in default).
269 .RE
270 .SS Preparing Descriptions
271 We now outline how to prepare descriptions of terminals.
272 The most effective way to prepare a terminal description is by imitating
273 the description of a similar terminal in
274 .I terminfo
275 and to build up a description gradually, using partial descriptions
276 with
277 .I vi
278 or some other screen-oriented program to check that they are correct.
279 Be aware that a very unusual terminal may expose deficiencies in
280 the ability of the
281 .I terminfo
282 file to describe it
283 or bugs in the screen-handling code of the test program.
284 .PP
285 To get the padding for insert line right (if the terminal manufacturer
286 did not document it) a severe test is to edit a large file at 9600 baud,
287 delete 16 or so lines from the middle of the screen, then hit the \*(``u\*(''
288 key several times quickly.
289 If the terminal messes up, more padding is usually needed.
290 A similar test can be used for insert character.
291 .SS Basic Capabilities
292 The number of columns on each line for the terminal is given by the
293 \fBcols\fP numeric capability.
294 If the terminal is a \s-1CRT\s0, then the
295 number of lines on the screen is given by the \fBlines\fP capability.
296 If the terminal wraps around to the beginning of the next line when
297 it reaches the right margin, then it should have the \fBam\fP capability.
298 If the terminal can clear its screen, leaving the cursor in the home
299 position, then this is given by the \fBclear\fP string capability.
300 If the terminal overstrikes
301 (rather than clearing a position when a character is struck over)
302 then it should have the \fBos\fP capability.
303 If the terminal is a printing terminal, with no soft copy unit,
304 give it both
305 .B hc
306 and
307 .BR os .
308 .RB ( os
309 applies to storage scope terminals, such as \s-1TEKTRONIX\s+1 4010
310 series, as well as hard copy and APL terminals.)
311 If there is a code to move the cursor to the left edge of the current
312 row, give this as
313 .BR cr .
314 (Normally this will be carriage return, control/M.)
315 If there is a code to produce an audible signal (bell, beep, etc)
316 give this as
317 .BR bel .
318 .PP
319 If there is a code to move the cursor one position to the left
320 (such as backspace) that capability should be given as
321 .BR cub1 .
322 Similarly, codes to move to the right, up, and down should be
323 given as
324 .BR cuf1 ,
325 .BR cuu1 ,
326 and
327 .BR cud1 .
328 These local cursor motions should not alter the text they pass over,
329 for example, you would not normally use \*(``\fBcuf1\fP=\ \*('' because the
330 space would erase the character moved over.
331 .PP
332 A very important point here is that the local cursor motions encoded
333 in
334 .I terminfo
335 are undefined at the left and top edges of a \s-1CRT\s0 terminal.
336 Programs should never attempt to backspace around the left edge,
337 unless
338 .B bw
339 is given,
340 and never attempt to go up locally off the top.
341 In order to scroll text up, a program will go to the bottom left corner
342 of the screen and send the
343 .B ind
344 (index) string.
345 .PP
346 To scroll text down, a program goes to the top left corner
347 of the screen and sends the
348 .B ri
349 (reverse index) string.
350 The strings
351 .B ind
352 and
353 .B ri
354 are undefined when not on their respective corners of the screen.
355 .PP
356 Parameterized versions of the scrolling sequences are
357 .B indn
358 and
359 .B rin
360 which have the same semantics as
361 .B ind
362 and
363 .B ri
364 except that they take one parameter, and scroll that many lines.
365 They are also undefined except at the appropriate edge of the screen.
366 .PP
367 The \fBam\fP capability tells whether the cursor sticks at the right
368 edge of the screen when text is output, but this does not necessarily
369 apply to a
370 .B cuf1
371 from the last column.
372 The only local motion which is defined from the left edge is if
373 .B bw
374 is given, then a
375 .B cub1
376 from the left edge will move to the right edge of the previous row.
377 If
378 .B bw
379 is not given, the effect is undefined.
380 This is useful for drawing a box around the edge of the screen, for example.
381 If the terminal has switch selectable automatic margins,
382 the
383 .I terminfo
384 file usually assumes that this is on; i.e., \fBam\fP.
385 If the terminal has a command which moves to the first column of the next
386 line, that command can be given as
387 .B nel
388 (newline).
389 It does not matter if the command clears the remainder of the current line,
390 so if the terminal has no
391 .B cr
392 and
393 .B lf
394 it may still be possible to craft a working
395 .B nel
396 out of one or both of them.
397 .PP
398 These capabilities suffice to describe hard-copy and \*(``glass-tty\*('' terminals.
399 Thus the model 33 teletype is described as
400 .PP
401 .DT
402 .nf
403 .ft CW
404 .\".in -2
405 \s-133\||\|tty33\||\|tty\||\|model 33 teletype,
406         bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,\s+1
407 .\".in +2
408 .ft R
409 .fi
410 .PP
411 while the Lear Siegler \s-1ADM-3\s0 is described as
412 .PP
413 .DT
414 .nf
415 .ft CW
416 .\".in -2
417 \s-1adm3\||\|3\||\|lsi adm3,
418         am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
419         ind=^J, lines#24,\s+1
420 .\".in +2
421 .ft R
422 .fi
423 .SS Parameterized Strings
424 Cursor addressing and other strings requiring parameters
425 in the terminal are described by a
426 parameterized string capability,
427 with \fIprintf\fP-like escapes such as \fI%x\fP in it.
428 For example, to address the cursor, the
429 .B cup
430 capability is given, using two parameters:
431 the row and column to address to.
432 (Rows and columns are numbered from zero and refer to the
433 physical screen visible to the user, not to any unseen memory.)
434 If the terminal has memory relative cursor addressing,
435 that can be indicated by
436 .BR mrcup .
437 .PP
438 The parameter mechanism uses a stack and special \fB%\fP codes
439 to manipulate it.
440 Typically a sequence will push one of the
441 parameters onto the stack and then print it in some format.
442 Print (e.g., \*(``%d\*('') is a special case.
443 Other operations, including \*(``%t\*('' pop their operand from the stack.
444 It is noted that more complex operations are often necessary,
445 e.g., in the \fBsgr\fP string.
446 .PP
447 The \fB%\fP encodings have the following meanings:
448 .TP 5
449 \fB%%\fP
450 outputs \*(``%\*(''
451 .TP
452 \fB%\fP\fI[[\fP:\fI]flags][width[.precision]][\fP\fBdoxXs\fP\fI]\fP
453 as in \fBprintf\fP(3), flags are \fI[\-+#]\fP and \fIspace\fP.
454 Use a \*(``:\*('' to allow the next character to be a \*(``\-\*('' flag,
455 avoiding interpreting \*(``%\-\*('' as an operator.
456 .TP
457 \f(CW%c\fP
458 print \fIpop()\fP like %c in \fBprintf\fP
459 .TP
460 \fB%s\fP
461 print \fIpop()\fP like %s in \fBprintf\fP
462 .TP
463 \fB%p\fP\fI[1\-9]\fP
464 push \fIi\fP'th parameter
465 .TP
466 \fB%P\fP\fI[a\-z]\fP
467 set dynamic variable \fI[a\-z]\fP to \fIpop()\fP
468 .TP
469 \fB%g\fP\fI[a\-z]\fP
470 get dynamic variable \fI[a\-z]\fP and push it
471 .TP
472 \fB%P\fP\fI[A\-Z]\fP
473 set static variable \fI[a\-z]\fP to \fIpop()\fP
474 .TP
475 \fB%g\fP\fI[A\-Z]\fP
476 get static variable \fI[a\-z]\fP and push it
477 .IP
478 The terms \*(``static\*('' and \*(``dynamic\*('' are misleading.
479 Historically, these are simply two different sets of variables,
480 whose values are not reset between calls to \fBtparm\fP(3X).
481 However, that fact is not documented in other implementations.
482 Relying on it will adversely impact portability to other implementations:
483 .RS
484 .bP
485 SVr2 curses supported \fIdynamic\fP variables.
486 Those are set only by a \fB%P\fP operator.
487 A \fB%g\fP for a given variable without first setting it with \fB%P\fP
488 will give unpredictable results, because dynamic variables are
489 an uninitialized local array on the stack in the \fBtparm\fP function.
490 .bP
491 SVr3.2 curses supported \fIstatic\fP variables.
492 Those are an array in the \fBTERMINAL\fP
493 structure (declared in \fBterm.h\fP),
494 and are zeroed automatically when the \fBsetupterm\fP function
495 allocates the data.
496 .bP
497 SVr4 curses made no further improvements
498 to the \fIdynamic/static\fP variable feature.
499 .bP
500 Solaris XPG4 curses does not distinguish between \fIdynamic\fP and
501 \fIstatic\fP variables.
502 They are the same.
503 Like SVr4 curses, XPG4 curses does not initialize these explicitly.
504 .bP
505 Before version 6.3, ncurses stores both \fIdynamic\fP and \fIstatic\fP
506 variables in persistent storage, initialized to zeros.
507 .bP
508 Beginning with version 6.3, ncurses stores \fIstatic\fP and \fIdynamic\fP
509 variables in the same manner as SVr4.
510 .RS
511 .bP
512 Unlike other implementations, ncurses zeros dynamic variables
513 before the first \fB%g\fP or \fB%P\fP operator.
514 .bP
515 Like SVr2,
516 the scope of dynamic variables in ncurses
517 is within the current call to
518 \fBtparm\fP.
519 Use static variables if persistent storage is needed.
520 .RE
521 .RE
522 .TP
523 \fB%\(aq\fP\fIc\fP\fB\(aq\fP
524 char constant \fIc\fP
525 .TP
526 \fB%{\fP\fInn\fP\fB}\fP
527 integer constant \fInn\fP
528 .TP
529 \fB%l\fP
530 push strlen(pop)
531 .TP
532 \fB%+\fP, \fB%\-\fP, \fB%*\fP, \fB%/\fP, \fB%m\fP
533 arithmetic (%m is \fImod\fP): \fIpush(pop() op pop())\fP
534 .TP
535 \fB%&\fP, \fB%|\fP, \fB%^\fP
536 bit operations (AND, OR and exclusive-OR): \fIpush(pop() op pop())\fP
537 .TP
538 \fB%=\fP, \fB%>\fP, \fB%<\fP
539 logical operations: \fIpush(pop() op pop())\fP
540 .TP
541 \fB%A\fP, \fB%O\fP
542 logical AND and OR operations (for conditionals)
543 .TP
544 \fB%!\fP, \fB%~\fP
545 unary operations (logical and bit complement): \fIpush(op pop())\fP
546 .TP
547 \fB%i\fP
548 add 1 to first two parameters (for ANSI terminals)
549 .TP
550 \fB%?\fP \fIexpr\fP \fB%t\fP \fIthenpart\fP \fB%e\fP \fIelsepart\fP \fB%;\fP
551 This forms an if-then-else.
552 The \fB%e\fP \fIelsepart\fP is optional.
553 Usually the \fB%?\fP \fIexpr\fP part pushes a value onto the stack,
554 and \fB%t\fP pops it from the stack, testing if it is nonzero (true).
555 If it is zero (false), control passes to the \fB%e\fP (else) part.
556 .IP
557 It is possible to form else-if's a la Algol 68:
558 .RS
559 \fB%?\fP c\d1\u \fB%t\fP b\d1\u \fB%e\fP c\d2\u \fB%t\fP b\d2\u \fB%e\fP c\d3\u \fB%t\fP b\d3\u \fB%e\fP c\d4\u \fB%t\fP b\d4\u \fB%e\fP \fB%;\fP
560 .RE
561 .IP
562 where c\di\u are conditions, b\di\u are bodies.
563 .IP
564 Use the \fB\-f\fP option of \fB@TIC@\fP or \fB@INFOCMP@\fP to see
565 the structure of if-then-else's.
566 Some strings, e.g., \fBsgr\fP can be very complicated when written
567 on one line.
568 The \fB\-f\fP option splits the string into lines with the parts indented.
569 .PP
570 Binary operations are in postfix form with the operands in the usual order.
571 That is, to get x\-5 one would use \*(``%gx%{5}%\-\*(''.
572 \fB%P\fP and \fB%g\fP variables are
573 persistent across escape-string evaluations.
574 .PP
575 Consider the HP2645, which, to get to row 3 and column 12, needs
576 to be sent \eE&a12c03Y padded for 6 milliseconds.
577 Note that the order
578 of the rows and columns is inverted here, and that the row and column
579 are printed as two digits.
580 Thus its \fBcup\fP capability is \*(``cup=6\eE&%p2%2dc%p1%2dY\*(''.
581 .PP
582 The Microterm \s-1ACT-IV\s0 needs the current row and column sent
583 preceded by a \fB^T\fP, with the row and column simply encoded in binary,
584 \*(``cup=^T%p1%c%p2%c\*(''.
585 Terminals which use \*(``%c\*('' need to be able to
586 backspace the cursor (\fBcub1\fP),
587 and to move the cursor up one line on the screen (\fBcuu1\fP).
588 This is necessary because it is not always safe to transmit \fB\en\fP
589 \fB^D\fP and \fB\er\fP, as the system may change or discard them.
590 (The library routines dealing with terminfo set tty modes so that
591 tabs are never expanded, so \et is safe to send.
592 This turns out to be essential for the Ann Arbor 4080.)
593 .PP
594 A final example is the \s-1LSI ADM\s0-3a, which uses row and column
595 offset by a blank character, thus \*(``cup=\eE=%p1%\(aq \(aq%+%c%p2%\(aq \(aq%+%c\*(''.
596 After sending \*(``\eE=\*('', this pushes the first parameter, pushes the
597 ASCII value for a space (32), adds them (pushing the sum on the stack
598 in place of the two previous values) and outputs that value as a character.
599 Then the same is done for the second parameter.
600 More complex arithmetic is possible using the stack.
601 .SS Cursor Motions
602 If the terminal has a fast way to home the cursor
603 (to very upper left corner of screen) then this can be given as
604 \fBhome\fP; similarly a fast way of getting to the lower left-hand corner
605 can be given as \fBll\fP; this may involve going up with \fBcuu1\fP
606 from the home position,
607 but a program should never do this itself (unless \fBll\fP does) because it
608 can make no assumption about the effect of moving up from the home position.
609 Note that the home position is the same as addressing to (0,0):
610 to the top left corner of the screen, not of memory.
611 (Thus, the \eEH sequence on HP terminals cannot be used for
612 .BR home .)
613 .PP
614 If the terminal has row or column absolute cursor addressing,
615 these can be given as single parameter capabilities
616 .B hpa
617 (horizontal position absolute)
618 and
619 .B vpa
620 (vertical position absolute).
621 Sometimes these are shorter than the more general two parameter
622 sequence (as with the hp2645) and can be used in preference to
623 .BR cup .
624 If there are parameterized local motions (e.g., move
625 .I n
626 spaces to the right) these can be given as
627 .BR cud ,
628 .BR cub ,
629 .BR cuf ,
630 and
631 .B cuu
632 with a single parameter indicating how many spaces to move.
633 These are primarily useful if the terminal does not have
634 .BR cup ,
635 such as the \s-1TEKTRONIX\s+1 4025.
636 .PP
637 If the terminal needs to be in a special mode when running
638 a program that uses these capabilities,
639 the codes to enter and exit this mode can be given as \fBsmcup\fP and \fBrmcup\fP.
640 This arises, for example, from terminals like the Concept with more than
641 one page of memory.
642 If the terminal has only memory relative cursor addressing and not screen
643 relative cursor addressing, a one screen-sized window must be fixed into
644 the terminal for cursor addressing to work properly.
645 This is also used for the \s-1TEKTRONIX\s+1 4025,
646 where
647 .B smcup
648 sets the command character to be the one used by terminfo.
649 If the \fBsmcup\fP sequence will not restore the screen after an
650 \fBrmcup\fP sequence is output (to the state prior to outputting
651 \fBrmcup\fP), specify \fBnrrmc\fP.
652 .SS Margins
653 SVr4 (and X/Open Curses)
654 list several string capabilities for setting margins.
655 Two were intended for use with terminals,
656 and another six were intended for use with printers.
657 .bP
658 The two terminal capabilities assume that the terminal may have
659 the capability of setting the left and/or right margin at the current
660 cursor column position.
661 .bP
662 The printer capabilities assume that the printer may have
663 two types of capability:
664 .RS
665 .bP
666 the ability to set a top and/or bottom margin using the current
667 line position, and
668 .bP
669 parameterized capabilities for setting the top, bottom, left, right margins
670 given the number of rows or columns.
671 .RE
672 .PP
673 In practice, the categorization into \*(``terminal\*('' and \*(``printer\*(''
674 is not suitable:
675 .bP
676 The AT&T SVr4 terminal database uses \fBsmgl\fP four times,
677 for AT&T hardware.
678 .IP
679 Three of the four are printers.
680 They lack the ability to set left/right margins by specifying the column.
681 .bP
682 Other (non-AT&T) terminals may support margins
683 but using different assumptions from AT&T.
684 .IP
685 For instance, the DEC VT420 supports left/right margins,
686 but only using a column parameter.
687 As an added complication, the VT420 uses two settings to fully enable
688 left/right margins (left/right margin mode, and origin mode).
689 The former enables the margins, which causes printed text
690 to wrap within margins, but the latter is needed to prevent
691 cursor-addressing outside those margins.
692 .bP
693 Both DEC VT420 left/right margins are set with a single control sequence.
694 If either is omitted, the corresponding margin is set to the left or
695 right edge of the display (rather than leaving the margin unmodified).
696 .PP
697 These are the margin-related capabilities:
698 .TS
699 center;
700 l l
701 _ _
702 lw8 lw18.
703 \fBName Description\fP
704 smgl    Set left margin at current column
705 smgr    Set right margin at current column
706 smgb    Set bottom margin at current line
707 smgt    Set top margin at current line
708 smgbp   Set bottom margin at line \fIN\fP
709 smglp   Set left margin at column \fIN\fP
710 smgrp   Set right margin at column \fIN\fP
711 smgtp   Set top margin at line \fIN\fP
712 smglr   Set both left and right margins to \fIL\fP and \fIR\fP
713 smgtb   Set both top and bottom margins to \fIT\fP and \fIB\fP
714 .TE
715 .PP
716 When writing an application that
717 uses these string capabilities,
718 the pairs should be first checked to see
719 if each capability in the pair is set or only one is set:
720 .bP
721 If both \fBsmglp\fP and \fBsmgrp\fP are set,
722 each is used with a single argument, \fIN\fP,
723 that gives the column number of the left and right margin, respectively.
724 .bP
725 If both \fBsmgtp\fP and \fBsmgbp\fP are set,
726 each is used to set the top and bottom margin,
727 respectively:
728 .RS 4
729 .bP
730 \fBsmgtp\fP is used with a single argument, \fIN\fP,
731 the line number of the top margin.
732 .bP
733 \fBsmgbp\fP is used with two arguments, \fIN\fP and \fIM\fP,
734 that give the line number of the bottom margin,
735 the first counting from the top of the
736 page and the second counting from the bottom.
737 This accommodates the two styles of specifying
738 the bottom margin in different manufacturers' printers.
739 .RE
740 .IP
741 When designing a terminfo entry for a
742 printer that has a settable bottom margin,
743 only the first or second argument should be used, depending on the printer.
744 When developing an application that uses \fBsmgbp\fP to set the bottom margin,
745 both arguments must be given.
746 .PP
747 Conversely, when only one capability in the pair is set:
748 .bP
749 If only one of \fBsmglp\fP and \fBsmgrp\fP is set,
750 then it is used with two arguments,
751 the column number of the left and right margins, in that order.
752 .bP
753 Likewise, if only one of \fBsmgtp\fP and \fBsmgbp\fP is set, then it
754 is used with two arguments that give the top and bottom margins,
755 in that order, counting from the top of the page.
756 .IP
757 When designing a terminfo entry for a printer that requires setting both
758 left and right or top and bottom margins simultaneously,
759 only one capability in the pairs
760 \fBsmglp\fP and \fBsmgrp\fP or
761 \fBsmgtp\fP and \fBsmgbp\fP should be defined,
762 leaving the other unset.
763 .PP
764 Except for very old terminal descriptions, e.g., those developed for SVr4,
765 the scheme just described should be considered obsolete.
766 An improved set of capabilities was added late in the SVr4 releases
767 (\fBsmglr\fP and \fBsmgtb\fP),
768 which explicitly use two parameters for setting the left/right or top/bottom
769 margins.
770 .PP
771 When setting margins, the line- and column-values are zero-based.
772 .PP
773 The \fBmgc\fP string capability should be defined.
774 Applications such as \fBtabs\fP(1) rely upon this to reset all margins.
775 .\"
776 .SS Area Clears
777 If the terminal can clear from the current position to the end of the
778 line, leaving the cursor where it is, this should be given as \fBel\fP.
779 If the terminal can clear from the beginning of the line to the current
780 position inclusive, leaving
781 the cursor where it is, this should be given as \fBel1\fP.
782 If the terminal can clear from the current position to the end of the
783 display, then this should be given as \fBed\fP.
784 \fBEd\fP is only defined from the first column of a line.
785 (Thus, it can be simulated by a request to delete a large number of lines,
786 if a true
787 .B ed
788 is not available.)
789 .\"
790 .SS Insert/delete line and vertical motions
791 If the terminal can open a new blank line before the line where the cursor
792 is, this should be given as \fBil1\fP; this is done only from the first
793 position of a line.
794 The cursor must then appear on the newly blank line.
795 If the terminal can delete the line which the cursor is on, then this
796 should be given as \fBdl1\fP; this is done only from the first position on
797 the line to be deleted.
798 Versions of
799 .B il1
800 and
801 .B dl1
802 which take a single parameter and insert or delete that many lines can
803 be given as
804 .B il
805 and
806 .BR dl .
807 .PP
808 If the terminal has a settable scrolling region (like the vt100)
809 the command to set this can be described with the
810 .B csr
811 capability, which takes two parameters:
812 the top and bottom lines of the scrolling region.
813 The cursor position is, alas, undefined after using this command.
814 .PP
815 It is possible to get the effect of insert or delete line using
816 .B csr
817 on a properly chosen region; the
818 .B sc
819 and
820 .B rc
821 (save and restore cursor) commands may be useful for ensuring that
822 your synthesized insert/delete string does not move the cursor.
823 (Note that the \fBncurses\fP(3X) library does this synthesis
824 automatically, so you need not compose insert/delete strings for
825 an entry with \fBcsr\fP).
826 .PP
827 Yet another way to construct insert and delete might be to use a combination of
828 index with the memory-lock feature found on some terminals (like the HP\-700/90
829 series, which however also has insert/delete).
830 .PP
831 Inserting lines at the top or bottom of the screen can also be
832 done using
833 .B ri
834 or
835 .B ind
836 on many terminals without a true insert/delete line,
837 and is often faster even on terminals with those features.
838 .PP
839 The boolean \fBnon_dest_scroll_region\fP should be set if each scrolling
840 window is effectively a view port on a screen-sized canvas.
841 To test for
842 this capability, create a scrolling region in the middle of the screen,
843 write something to the bottom line, move the cursor to the top of the region,
844 and do \fBri\fP followed by \fBdl1\fP or \fBind\fP.
845 If the data scrolled
846 off the bottom of the region by the \fBri\fP re-appears, then scrolling
847 is non-destructive.
848 System V and XSI Curses expect that \fBind\fP, \fBri\fP,
849 \fBindn\fP, and \fBrin\fP will simulate destructive scrolling; their
850 documentation cautions you not to define \fBcsr\fP unless this is true.
851 This \fBcurses\fP implementation is more liberal and will do explicit erases
852 after scrolling if \fBndsrc\fP is defined.
853 .PP
854 If the terminal has the ability to define a window as part of
855 memory, which all commands affect,
856 it should be given as the parameterized string
857 .BR wind .
858 The four parameters are the starting and ending lines in memory
859 and the starting and ending columns in memory, in that order.
860 .PP
861 If the terminal can retain display memory above, then the
862 \fBda\fP capability should be given; if display memory can be retained
863 below, then \fBdb\fP should be given.
864 These indicate
865 that deleting a line or scrolling may bring non-blank lines up from below
866 or that scrolling back with \fBri\fP may bring down non-blank lines.
867 .SS Insert/Delete Character
868 There are two basic kinds of intelligent terminals with respect to
869 insert/delete character which can be described using
870 .I terminfo.
871 The most common insert/delete character operations affect only the characters
872 on the current line and shift characters off the end of the line rigidly.
873 Other terminals, such as the Concept 100 and the Perkin Elmer Owl, make
874 a distinction between typed and untyped blanks on the screen, shifting
875 upon an insert or delete only to an untyped blank on the screen which is
876 either eliminated, or expanded to two untyped blanks.
877 .PP
878 You can determine the
879 kind of terminal you have by clearing the screen and then typing
880 text separated by cursor motions.
881 Type \*(``abc\ \ \ \ def\*('' using local
882 cursor motions (not spaces) between the \*(``abc\*('' and the \*(``def\*(''.
883 Then position the cursor before the \*(``abc\*('' and put the terminal in insert
884 mode.
885 If typing characters causes the rest of the line to shift
886 rigidly and characters to fall off the end, then your terminal does
887 not distinguish between blanks and untyped positions.
888 If the \*(``abc\*(''
889 shifts over to the \*(``def\*('' which then move together around the end of the
890 current line and onto the next as you insert, you have the second type of
891 terminal, and should give the capability \fBin\fP, which stands for
892 \*(``insert null\*(''.
893 .PP
894 While these are two logically separate attributes (one line versus multi-line
895 insert mode, and special treatment of untyped spaces) we have seen no
896 terminals whose insert mode cannot be described with the single attribute.
897 .PP
898 Terminfo can describe both terminals which have an insert mode, and terminals
899 which send a simple sequence to open a blank position on the current line.
900 Give as \fBsmir\fP the sequence to get into insert mode.
901 Give as \fBrmir\fP the sequence to leave insert mode.
902 Now give as \fBich1\fP any sequence needed to be sent just before sending
903 the character to be inserted.
904 Most terminals with a true insert mode
905 will not give \fBich1\fP; terminals which send a sequence to open a screen
906 position should give it here.
907 .PP
908 If your terminal has both, insert mode is usually preferable to \fBich1\fP.
909 Technically, you should not give both unless the terminal actually requires
910 both to be used in combination.
911 Accordingly, some non-curses applications get
912 confused if both are present; the symptom is doubled characters in an update
913 using insert.
914 This requirement is now rare; most \fBich\fP sequences do not
915 require previous smir, and most smir insert modes do not require \fBich1\fP
916 before each character.
917 Therefore, the new \fBcurses\fP actually assumes this
918 is the case and uses either \fBrmir\fP/\fBsmir\fP or \fBich\fP/\fBich1\fP as
919 appropriate (but not both).
920 If you have to write an entry to be used under
921 new curses for a terminal old enough to need both, include the
922 \fBrmir\fP/\fBsmir\fP sequences in \fBich1\fP.
923 .PP
924 If post insert padding is needed, give this as a number of milliseconds
925 in \fBip\fP (a string option).
926 Any other sequence which may need to be
927 sent after an insert of a single character may also be given in \fBip\fP.
928 If your terminal needs both to be placed into an \*(``insert mode\*('' and
929 a special code to precede each inserted character, then both
930 .BR smir / rmir
931 and
932 .B ich1
933 can be given, and both will be used.
934 The
935 .B ich
936 capability, with one parameter,
937 .IR n ,
938 will repeat the effects of
939 .B ich1
940 .I n
941 times.
942 .PP
943 If padding is necessary between characters typed while not
944 in insert mode, give this as a number of milliseconds padding in \fBrmp\fP.
945 .PP
946 It is occasionally necessary to move around while in insert mode
947 to delete characters on the same line (e.g., if there is a tab after
948 the insertion position).
949 If your terminal allows motion while in
950 insert mode you can give the capability \fBmir\fP to speed up inserting
951 in this case.
952 Omitting \fBmir\fP will affect only speed.
953 Some terminals
954 (notably Datamedia's) must not have \fBmir\fP because of the way their
955 insert mode works.
956 .PP
957 Finally, you can specify
958 .B dch1
959 to delete a single character,
960 .B dch
961 with one parameter,
962 .IR n ,
963 to delete
964 .I n characters,
965 and delete mode by giving \fBsmdc\fP and \fBrmdc\fP
966 to enter and exit delete mode (any mode the terminal needs to be placed
967 in for
968 .B dch1
969 to work).
970 .PP
971 A command to erase
972 .I n
973 characters (equivalent to outputting
974 .I n
975 blanks without moving the cursor)
976 can be given as
977 .B ech
978 with one parameter.
979 .SS "Highlighting, Underlining, and Visible Bells"
980 If your terminal has one or more kinds of display attributes,
981 these can be represented in a number of different ways.
982 You should choose one display form as
983 \f2standout mode\fP,
984 representing a good, high contrast, easy-on-the-eyes,
985 format for highlighting error messages and other attention getters.
986 (If you have a choice, reverse video plus half-bright is good,
987 or reverse video alone.)
988 The sequences to enter and exit standout mode
989 are given as \fBsmso\fP and \fBrmso\fP, respectively.
990 If the code to change into or out of standout
991 mode leaves one or even two blank spaces on the screen,
992 as the TVI 912 and Teleray 1061 do,
993 then \fBxmc\fP should be given to tell how many spaces are left.
994 .PP
995 Codes to begin underlining and end underlining can be given as \fBsmul\fP
996 and \fBrmul\fP respectively.
997 If the terminal has a code to underline the current character and move
998 the cursor one space to the right,
999 such as the Microterm Mime,
1000 this can be given as \fBuc\fP.
1001 .PP
1002 Other capabilities to enter various highlighting modes include
1003 .B blink
1004 (blinking)
1005 .B bold
1006 (bold or extra bright)
1007 .B dim
1008 (dim or half-bright)
1009 .B invis
1010 (blanking or invisible text)
1011 .B prot
1012 (protected)
1013 .B rev
1014 (reverse video)
1015 .B sgr0
1016 (turn off
1017 .I all
1018 attribute modes)
1019 .B smacs
1020 (enter alternate character set mode)
1021 and
1022 .B rmacs
1023 (exit alternate character set mode).
1024 Turning on any of these modes singly may or may not turn off other modes.
1025 .PP
1026 If there is a sequence to set arbitrary combinations of modes,
1027 this should be given as
1028 .B sgr
1029 (set attributes),
1030 taking 9 parameters.
1031 Each parameter is either 0 or nonzero, as the corresponding attribute is on or off.
1032 The 9 parameters are, in order:
1033 standout, underline, reverse, blink, dim, bold, blank, protect, alternate
1034 character set.
1035 Not all modes need be supported by
1036 .BR sgr ,
1037 only those for which corresponding separate attribute commands exist.
1038 .PP
1039 For example, the DEC vt220 supports most of the modes:
1040 .PP
1041 .TS
1042 center;
1043 l l l
1044 l l l
1045 lw18 lw14 lw18.
1046 \fBtparm parameter      attribute       escape sequence\fP
1047
1048 none    none    \\E[0m
1049 p1      standout        \\E[0;1;7m
1050 p2      underline       \\E[0;4m
1051 p3      reverse \\E[0;7m
1052 p4      blink   \\E[0;5m
1053 p5      dim     not available
1054 p6      bold    \\E[0;1m
1055 p7      invis   \\E[0;8m
1056 p8      protect not used
1057 p9      altcharset      ^O (off) ^N (on)
1058 .TE
1059 .PP
1060 We begin each escape sequence by turning off any existing modes, since
1061 there is no quick way to determine whether they are active.
1062 Standout is set up to be the combination of reverse and bold.
1063 The vt220 terminal has a protect mode,
1064 though it is not commonly used in sgr
1065 because it protects characters on the screen from the host's erasures.
1066 The altcharset mode also is different in that it is either ^O or ^N,
1067 depending on whether it is off or on.
1068 If all modes are turned on, the resulting sequence is \\E[0;1;4;5;7;8m^N.
1069 .PP
1070 Some sequences are common to different modes.
1071 For example, ;7 is output when either p1 or p3 is true, that is, if
1072 either standout or reverse modes are turned on.
1073 .PP
1074 Writing out the above sequences, along with their dependencies yields
1075 .PP
1076 .ne 11
1077 .TS
1078 center;
1079 l l l
1080 l l l
1081 lw18 lw14 lw18.
1082 \fBsequence     when to output  terminfo translation\fP
1083
1084 .ft CW
1085 \\E[0   always  \\E[0
1086 ;1      if p1 or p6     %?%p1%p6%|%t;1%;
1087 ;4      if p2   %?%p2%|%t;4%;
1088 ;5      if p4   %?%p4%|%t;5%;
1089 ;7      if p1 or p3     %?%p1%p3%|%t;7%;
1090 ;8      if p7   %?%p7%|%t;8%;
1091 m       always  m
1092 ^N or ^O        if p9 ^N, else ^O       %?%p9%t^N%e^O%;
1093 .ft R
1094 .TE
1095 .PP
1096 Putting this all together into the sgr sequence gives:
1097 .PP
1098 .ft CW
1099 .nf
1100     sgr=\\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p4%t;5%;
1101         %?%p1%p3%|%t;7%;%?%p7%t;8%;m%?%p9%t\\016%e\\017%;,
1102 .fi
1103 .ft R
1104 .PP
1105 Remember that if you specify sgr, you must also specify sgr0.
1106 Also, some implementations rely on sgr being given if sgr0 is,
1107 Not all terminfo entries necessarily have an sgr string, however.
1108 Many terminfo entries are derived from termcap entries
1109 which have no sgr string.
1110 The only drawback to adding an sgr string is that termcap also
1111 assumes that sgr0 does not exit alternate character set mode.
1112 .PP
1113 Terminals with the \*(``magic cookie\*('' glitch
1114 .RB ( xmc )
1115 deposit special \*(``cookies\*('' when they receive mode-setting sequences,
1116 which affect the display algorithm rather than having extra bits for
1117 each character.
1118 Some terminals, such as the HP 2621, automatically leave standout
1119 mode when they move to a new line or the cursor is addressed.
1120 Programs using standout mode should exit standout mode before
1121 moving the cursor or sending a newline,
1122 unless the
1123 .B msgr
1124 capability, asserting that it is safe to move in standout mode, is present.
1125 .PP
1126 If the terminal has
1127 a way of flashing the screen to indicate an error quietly (a bell replacement)
1128 then this can be given as \fBflash\fP; it must not move the cursor.
1129 .PP
1130 If the cursor needs to be made more visible than normal when it is
1131 not on the bottom line (to make, for example, a non-blinking underline into an
1132 easier to find block or blinking underline)
1133 give this sequence as
1134 .BR cvvis .
1135 If there is a way to make the cursor completely invisible, give that as
1136 .BR civis .
1137 The capability
1138 .B cnorm
1139 should be given which undoes the effects of both of these modes.
1140 .PP
1141 If your terminal correctly generates underlined characters
1142 (with no special codes needed)
1143 even though it does not overstrike,
1144 then you should give the capability \fBul\fP.
1145 If a character overstriking another leaves both characters on the screen,
1146 specify the capability \fBos\fP.
1147 If overstrikes are erasable with a blank,
1148 then this should be indicated by giving \fBeo\fP.
1149 .SS Keypad and Function Keys
1150 If the terminal has a keypad that transmits codes when the keys are pressed,
1151 this information can be given.
1152 Note that it is not possible to handle
1153 terminals where the keypad only works in local (this applies, for example,
1154 to the unshifted HP 2621 keys).
1155 If the keypad can be set to transmit or not transmit,
1156 give these codes as \fBsmkx\fP and \fBrmkx\fP.
1157 Otherwise the keypad is assumed to always transmit.
1158 .PP
1159 The codes sent by the left arrow, right arrow, up arrow, down arrow,
1160 and home keys can be given as
1161 \fBkcub1, kcuf1, kcuu1, kcud1, \fRand\fB khome\fP respectively.
1162 If there are function keys such as f0, f1, ..., f10, the codes they send
1163 can be given as \fBkf0, kf1, ..., kf10\fP.
1164 If these keys have labels other than the default f0 through f10, the labels
1165 can be given as \fBlf0, lf1, ..., lf10\fP.
1166 .PP
1167 The codes transmitted by certain other special keys can be given:
1168 .bP
1169 .B kll
1170 (home down),
1171 .bP
1172 .B kbs
1173 (backspace),
1174 .bP
1175 .B ktbc
1176 (clear all tabs),
1177 .bP
1178 .B kctab
1179 (clear the tab stop in this column),
1180 .bP
1181 .B kclr
1182 (clear screen or erase key),
1183 .bP
1184 .B kdch1
1185 (delete character),
1186 .bP
1187 .B kdl1
1188 (delete line),
1189 .bP
1190 .B krmir
1191 (exit insert mode),
1192 .bP
1193 .B kel
1194 (clear to end of line),
1195 .bP
1196 .B ked
1197 (clear to end of screen),
1198 .bP
1199 .B kich1
1200 (insert character or enter insert mode),
1201 .bP
1202 .B kil1
1203 (insert line),
1204 .bP
1205 .B knp
1206 (next page),
1207 .bP
1208 .B kpp
1209 (previous page),
1210 .bP
1211 .B kind
1212 (scroll forward/down),
1213 .bP
1214 .B kri
1215 (scroll backward/up),
1216 .bP
1217 .B khts
1218 (set a tab stop in this column).
1219 .PP
1220 In addition, if the keypad has a 3 by 3 array of keys including the four
1221 arrow keys, the other five keys can be given as
1222 .BR ka1 ,
1223 .BR ka3 ,
1224 .BR kb2 ,
1225 .BR kc1 ,
1226 and
1227 .BR kc3 .
1228 These keys are useful when the effects of a 3 by 3 directional pad are needed.
1229 .PP
1230 Strings to program function keys can be given as
1231 .BR pfkey ,
1232 .BR pfloc ,
1233 and
1234 .BR pfx .
1235 A string to program screen labels should be specified as \fBpln\fP.
1236 Each of these strings takes two parameters: the function key number to
1237 program (from 0 to 10) and the string to program it with.
1238 Function key numbers out of this range may program undefined keys in
1239 a terminal dependent manner.
1240 The difference between the capabilities is that
1241 .B pfkey
1242 causes pressing the given key to be the same as the user typing the
1243 given string;
1244 .B pfloc
1245 causes the string to be executed by the terminal in local; and
1246 .B pfx
1247 causes the string to be transmitted to the computer.
1248 .PP
1249 The capabilities \fBnlab\fP, \fBlw\fP and \fBlh\fP
1250 define the number of programmable
1251 screen labels and their width and height.
1252 If there are commands to turn the labels on and off,
1253 give them in \fBsmln\fP and \fBrmln\fP.
1254 \fBsmln\fP is normally output after one or more pln
1255 sequences to make sure that the change becomes visible.
1256 .SS Tabs and Initialization
1257 A few capabilities are used only for tabs:
1258 .bP
1259 If the terminal has hardware tabs, the command to advance to the next
1260 tab stop can be given as
1261 .B ht
1262 (usually control/I).
1263 .bP
1264 A \*(``back-tab\*('' command which moves leftward to the preceding tab stop can
1265 be given as
1266 .BR cbt .
1267 .IP
1268 By convention, if the teletype modes indicate that tabs are being
1269 expanded by the computer rather than being sent to the terminal,
1270 programs should not use
1271 .B ht
1272 or
1273 .B cbt
1274 even if they are present, since the user may not have the tab stops
1275 properly set.
1276 .bP
1277 If the terminal has hardware tabs which are initially set every
1278 .I n
1279 spaces when the terminal is powered up,
1280 the numeric parameter
1281 .B it
1282 is given, showing the number of spaces the tabs are set to.
1283 .IP
1284 The \fBit\fP capability is normally used by the \fB@TSET@\fP
1285 command to determine whether to set the mode for hardware tab expansion,
1286 and whether to set the tab stops.
1287 If the terminal has tab stops that can be saved in non-volatile memory,
1288 the terminfo description can assume that they are properly set.
1289 .PP
1290 Other capabilities
1291 include
1292 .bP
1293 .BR is1 ,
1294 .BR is2 ,
1295 and
1296 .BR is3 ,
1297 initialization strings for the terminal,
1298 .bP
1299 .BR iprog ,
1300 the path name of a program to be run to initialize the terminal,
1301 .bP
1302 and \fBif\fP, the name of a file containing long initialization strings.
1303 .PP
1304 These strings are expected to set the terminal into modes consistent
1305 with the rest of the terminfo description.
1306 They are normally sent to the terminal, by the
1307 .I init
1308 option of the \fB@TPUT@\fP program, each time the user logs in.
1309 They will be printed in the following order:
1310 .RS
1311 .TP
1312 run the program
1313 .B iprog
1314 .TP
1315 output
1316 .br
1317 \fBis1\fP and
1318 .br
1319 \fBis2\fP
1320 .TP
1321 set the margins using
1322 \fBmgc\fP or
1323 .br
1324 \fBsmglp\fP and \fBsmgrp\fP or
1325 .br
1326 \fBsmgl\fP and \fBsmgr\fP
1327 .TP
1328 set tabs using
1329 .B tbc
1330 and
1331 .B hts
1332 .TP
1333 print the file
1334 \fBif\fP
1335 .TP
1336 and finally output
1337 \fBis3\fP.
1338 .RE
1339 .PP
1340 Most initialization is done with
1341 .BR is2 .
1342 Special terminal modes can be set up without duplicating strings
1343 by putting the common sequences in
1344 .B is2
1345 and special cases in
1346 .B is1
1347 and
1348 .BR is3 .
1349 .PP
1350 A set of sequences that does a harder reset from a totally unknown state
1351 can be given as
1352 .BR rs1 ,
1353 .BR rs2 ,
1354 .B rf
1355 and
1356 .BR rs3 ,
1357 analogous to
1358 .B is1 ,
1359 .B is2 ,
1360 .B if
1361 and
1362 .B is3
1363 respectively.
1364 These strings are output
1365 by \fIreset\fP option of \fB@TPUT@\fP,
1366 or by the \fB@RESET@\fP program
1367 (an alias of \fB@TSET@\fP),
1368 which is used when the terminal gets into a wedged state.
1369 Commands are normally placed in
1370 .BR rs1 ,
1371 .B rs2
1372 .B rs3
1373 and
1374 .B rf
1375 only if they produce annoying effects on the screen and are not
1376 necessary when logging in.
1377 For example, the command to set the vt100 into 80-column mode would
1378 normally be part of
1379 .BR is2 ,
1380 but it causes an annoying glitch of the screen and is not normally
1381 needed since the terminal is usually already in 80-column mode.
1382 .PP
1383 The \fB@RESET@\fP program writes strings including
1384 .BR iprog ,
1385 etc., in the same order as the
1386 .I init
1387 program, using
1388 .BR rs1 ,
1389 etc., instead of
1390 .BR is1 ,
1391 etc.
1392 If any of
1393 .BR rs1 ,
1394 .BR rs2 ,
1395 .BR rs3 ,
1396 or
1397 .B rf
1398 reset capability strings are missing,
1399 the \fB@RESET@\fP program
1400 falls back upon the corresponding initialization capability string.
1401 .PP
1402 If there are commands to set and clear tab stops, they can be given as
1403 .B tbc
1404 (clear all tab stops)
1405 and
1406 .B hts
1407 (set a tab stop in the current column of every row).
1408 If a more complex sequence is needed to set the tabs than can be
1409 described by this, the sequence can be placed in
1410 .B is2
1411 or
1412 .BR if .
1413 .PP
1414 The \fB@TPUT@ reset\fP command uses the same capability strings
1415 as the \fB@RESET@\fP command,
1416 although the two programs (\fB@TPUT@\fP and \fB@RESET@\fP)
1417 provide different command-line options.
1418 .PP
1419 In practice, these terminfo capabilities are not often used in
1420 initialization of tabs
1421 (though they are required for the \fB@TABS@\fP program):
1422 .bP
1423 Almost all hardware terminals (at least those which supported tabs)
1424 initialized those to every \fIeight\fP columns:
1425 .IP
1426 The only exception was the AT&T 2300 series,
1427 which set tabs to every \fIfive\fP columns.
1428 .bP
1429 In particular, developers of the hardware terminals which are commonly used
1430 as models for modern terminal emulators provided documentation demonstrating
1431 that \fIeight\fP columns were the standard.
1432 .bP
1433 Because of this, the terminal initialization programs
1434 \fB@TPUT@\fP and \fB@TSET@\fP
1435 use the
1436 \fBtbc\fP (\fBclear_all_tabs\fP) and
1437 \fBhts\fP (\fBset_tab\fP) capabilities directly
1438 only when the \fBit\fP (\fBinit_tabs\fP) capability
1439 is set to a value other than \fIeight\fP.
1440 .SS Delays and Padding
1441 Many older and slower terminals do not support either XON/XOFF or DTR
1442 handshaking, including hard copy terminals and some very archaic CRTs
1443 (including, for example, DEC VT100s).
1444 These may require padding characters
1445 after certain cursor motions and screen changes.
1446 .PP
1447 If the terminal uses xon/xoff handshaking for flow control (that is,
1448 it automatically emits ^S back to the host when its input buffers are
1449 close to full), set
1450 .BR xon .
1451 This capability suppresses the emission of padding.
1452 You can also set it
1453 for memory-mapped console devices effectively that do not have a speed limit.
1454 Padding information should still be included so that routines can
1455 make better decisions about relative costs, but actual pad characters will
1456 not be transmitted.
1457 .PP
1458 If \fBpb\fP (padding baud rate) is given, padding is suppressed at baud rates
1459 below the value of \fBpb\fP.
1460 If the entry has no padding baud rate, then
1461 whether padding is emitted or not is completely controlled by \fBxon\fP.
1462 .PP
1463 If the terminal requires other than a null (zero) character as a pad,
1464 then this can be given as \fBpad\fP.
1465 Only the first character of the
1466 .B pad
1467 string is used.
1468 .SS Status Lines
1469 Some terminals have an extra \*(``status line\*('' which is not normally used by
1470 software (and thus not counted in the terminal's \fBlines\fP capability).
1471 .PP
1472 The simplest case is a status line which is cursor-addressable but not
1473 part of the main scrolling region on the screen; the Heathkit H19 has
1474 a status line of this kind, as would a 24-line VT100 with a 23-line
1475 scrolling region set up on initialization.
1476 This situation is indicated
1477 by the \fBhs\fP capability.
1478 .PP
1479 Some terminals with status lines need special sequences to access the
1480 status line.
1481 These may be expressed as a string with single parameter
1482 \fBtsl\fP which takes the cursor to a given zero-origin column on the
1483 status line.
1484 The capability \fBfsl\fP must return to the main-screen
1485 cursor positions before the last \fBtsl\fP.
1486 You may need to embed the
1487 string values of \fBsc\fP (save cursor) and \fBrc\fP (restore cursor)
1488 in \fBtsl\fP and \fBfsl\fP to accomplish this.
1489 .PP
1490 The status line is normally assumed to be the same width as the width
1491 of the terminal.
1492 If this is untrue, you can specify it with the numeric
1493 capability \fBwsl\fP.
1494 .PP
1495 A command to erase or blank the status line may be specified as \fBdsl\fP.
1496 .PP
1497 The boolean capability \fBeslok\fP specifies that escape sequences, tabs,
1498 etc., work ordinarily in the status line.
1499 .PP
1500 The \fBncurses\fP implementation does not yet use any of these capabilities.
1501 They are documented here in case they ever become important.
1502 .SS Line Graphics
1503 Many terminals have alternate character sets useful for forms-drawing.
1504 Terminfo and \fBcurses\fP have built-in support
1505 for most of the drawing characters
1506 supported by the VT100, with some characters from the AT&T 4410v1 added.
1507 This alternate character set may be specified by the \fBacsc\fP capability.
1508 .PP
1509 .TS H
1510 center expand;
1511 l l l l l
1512 l l l l l
1513 _ _ _ _ _
1514 lw25 lw10 lw6 lw6 lw6.
1515 .\".TH
1516 \fBGlyph        ACS     Ascii   acsc    acsc\fP
1517 \fBName Name    Default Char    Value\fP
1518 arrow pointing right    ACS_RARROW      >       +       0x2b
1519 arrow pointing left     ACS_LARROW      <       ,       0x2c
1520 arrow pointing up       ACS_UARROW      ^       \-      0x2d
1521 arrow pointing down     ACS_DARROW      v       .       0x2e
1522 solid square block      ACS_BLOCK       #       0       0x30
1523 diamond                 ACS_DIAMOND     +       `       0x60
1524 checker board (stipple) ACS_CKBOARD     :       a       0x61
1525 degree symbol           ACS_DEGREE      \e      f       0x66
1526 plus/minus              ACS_PLMINUS     #       g       0x67
1527 board of squares        ACS_BOARD       #       h       0x68
1528 lantern symbol          ACS_LANTERN     #       i       0x69
1529 lower right corner      ACS_LRCORNER    +       j       0x6a
1530 upper right corner      ACS_URCORNER    +       k       0x6b
1531 upper left corner       ACS_ULCORNER    +       l       0x6c
1532 lower left corner       ACS_LLCORNER    +       m       0x6d
1533 large plus or crossover ACS_PLUS        +       n       0x6e
1534 scan line 1             ACS_S1          ~       o       0x6f
1535 scan line 3             ACS_S3          \-      p       0x70
1536 horizontal line         ACS_HLINE       \-      q       0x71
1537 scan line 7             ACS_S7          \-      r       0x72
1538 scan line 9             ACS_S9          \&_     s       0x73
1539 tee pointing right      ACS_LTEE        +       t       0x74
1540 tee pointing left       ACS_RTEE        +       u       0x75
1541 tee pointing up         ACS_BTEE        +       v       0x76
1542 tee pointing down       ACS_TTEE        +       w       0x77
1543 vertical line           ACS_VLINE       |       x       0x78
1544 less-than-or-equal-to   ACS_LEQUAL      <       y       0x79
1545 greater-than-or-equal-to        ACS_GEQUAL      >       z       0x7a
1546 greek pi                ACS_PI  *       {       0x7b
1547 not-equal               ACS_NEQUAL      !       |       0x7c
1548 UK pound sign           ACS_STERLING    f       }       0x7d
1549 bullet                  ACS_BULLET      o       ~       0x7e
1550 .TE
1551 .PP
1552 A few notes apply to the table itself:
1553 .bP
1554 X/Open Curses incorrectly states that the mapping for \fIlantern\fP is
1555 uppercase \*(``I\*('' although Unix implementations use the
1556 lowercase \*(``i\*('' mapping.
1557 .bP
1558 The DEC VT100 implemented graphics using the alternate character set
1559 feature, temporarily switching \fImodes\fP and sending characters
1560 in the range 0x60 (96) to 0x7e (126)
1561 (the \fBacsc Value\fP column in the table).
1562 .bP
1563 The AT&T terminal added graphics characters outside that range.
1564 .IP
1565 Some of the characters within the range do not match the VT100;
1566 presumably they were used in the AT&T terminal:
1567 \fIboard of squares\fP replaces the VT100 \fInewline\fP symbol, while
1568 \fIlantern symbol\fP replaces the VT100 \fIvertical tab\fP symbol.
1569 The other VT100 symbols for control characters (\fIhorizontal tab\fP,
1570 \fIcarriage return\fP and \fIline-feed\fP) are not (re)used in curses.
1571 .PP
1572 The best way to define a new device's graphics set is to add a column
1573 to a copy of this table for your terminal, giving the character which
1574 (when emitted between \fBsmacs\fP/\fBrmacs\fP switches) will be rendered
1575 as the corresponding graphic.
1576 Then read off the VT100/your terminal
1577 character pairs right to left in sequence; these become the ACSC string.
1578 .SS Color Handling
1579 The curses library functions \fBinit_pair\fP and \fBinit_color\fP
1580 manipulate the \fIcolor pairs\fP and \fIcolor values\fP discussed in this
1581 section
1582 (see \fBcurs_color\fP(3X) for details on these and related functions).
1583 .PP
1584 Most color terminals are either \*(``Tektronix-like\*('' or \*(``HP-like\*('':
1585 .bP
1586 Tektronix-like
1587 terminals have a predefined set of \fIN\fP colors
1588 (where \fIN\fP is usually 8),
1589 and can set
1590 character-cell foreground and background characters independently, mixing them
1591 into \fIN\fP\ *\ \fIN\fP color-pairs.
1592 .bP
1593 On HP-like terminals, the user must set each color
1594 pair up separately (foreground and background are not independently settable).
1595 Up to \fIM\fP color-pairs may be set up from 2*\fIM\fP different colors.
1596 ANSI-compatible terminals are Tektronix-like.
1597 .PP
1598 Some basic color capabilities are independent of the color method.
1599 The numeric
1600 capabilities \fBcolors\fP and \fBpairs\fP specify the maximum numbers of colors
1601 and color-pairs that can be displayed simultaneously.
1602 The \fBop\fP (original
1603 pair) string resets foreground and background colors to their default values
1604 for the terminal.
1605 The \fBoc\fP string resets all colors or color-pairs to
1606 their default values for the terminal.
1607 Some terminals (including many PC
1608 terminal emulators) erase screen areas with the current background color rather
1609 than the power-up default background; these should have the boolean capability
1610 \fBbce\fP.
1611 .PP
1612 While the curses library works with \fIcolor pairs\fP
1613 (reflecting the inability of some devices to set foreground
1614 and background colors independently),
1615 there are separate capabilities for setting these features:
1616 .bP
1617 To change the current foreground or background color on a Tektronix-type
1618 terminal, use \fBsetaf\fP (set ANSI foreground) and \fBsetab\fP (set ANSI
1619 background) or \fBsetf\fP (set foreground) and \fBsetb\fP (set background).
1620 These take one parameter, the color number.
1621 The SVr4 documentation describes
1622 only \fBsetaf\fP/\fBsetab\fP; the XPG4 draft says that "If the terminal
1623 supports ANSI escape sequences to set background and foreground, they should
1624 be coded as \fBsetaf\fP and \fBsetab\fP, respectively.
1625 .bP
1626 If the terminal
1627 supports other escape sequences to set background and foreground, they should
1628 be coded as \fBsetf\fP and \fBsetb\fP, respectively.
1629 The \fBvidputs\fP and the \fBrefresh\fP(3X) functions
1630 use the \fBsetaf\fP and \fBsetab\fP capabilities if they are defined.
1631 .PP
1632 The \fBsetaf\fP/\fBsetab\fP and \fBsetf\fP/\fBsetb\fP capabilities take a
1633 single numeric argument each.
1634 Argument values 0-7 of \fBsetaf\fP/\fBsetab\fP are portably defined as
1635 follows (the middle column is the symbolic #define available in the header for
1636 the \fBcurses\fP or \fBncurses\fP libraries).
1637 The terminal hardware is free to
1638 map these as it likes, but the RGB values indicate normal locations in color
1639 space.
1640 .PP
1641 .TS H
1642 center;
1643 l c c c
1644 l l n l.
1645 \fBColor        #define         Value   RGB\fP
1646 black   \fBCOLOR_BLACK\fP       0       0, 0, 0
1647 red     \fBCOLOR_RED\ \fP       1       max,0,0
1648 green   \fBCOLOR_GREEN\fP       2       0,max,0
1649 yellow  \fBCOLOR_YELLOW\fP      3       max,max,0
1650 blue    \fBCOLOR_BLUE\fP        4       0,0,max
1651 magenta \fBCOLOR_MAGENTA\fP     5       max,0,max
1652 cyan    \fBCOLOR_CYAN\fP        6       0,max,max
1653 white   \fBCOLOR_WHITE\fP       7       max,max,max
1654 .TE
1655 .PP
1656 The argument values of \fBsetf\fP/\fBsetb\fP historically correspond to
1657 a different mapping, i.e.,
1658 .TS H
1659 center;
1660 l c c c
1661 l l n l.
1662 \fBColor        #define         Value   RGB\fP
1663 black   \fBCOLOR_BLACK\fP       0       0, 0, 0
1664 blue    \fBCOLOR_BLUE\fP        1       0,0,max
1665 green   \fBCOLOR_GREEN\fP       2       0,max,0
1666 cyan    \fBCOLOR_CYAN\fP        3       0,max,max
1667 red     \fBCOLOR_RED\ \fP       4       max,0,0
1668 magenta \fBCOLOR_MAGENTA\fP     5       max,0,max
1669 yellow  \fBCOLOR_YELLOW\fP      6       max,max,0
1670 white   \fBCOLOR_WHITE\fP       7       max,max,max
1671 .TE
1672 .PP
1673 It is important to not confuse the two sets of color capabilities;
1674 otherwise red/blue will be interchanged on the display.
1675 .PP
1676 On an HP-like terminal, use \fBscp\fP with a color-pair number parameter to set
1677 which color pair is current.
1678 .PP
1679 Some terminals allow the \fIcolor values\fP to be modified:
1680 .bP
1681 On a Tektronix-like terminal, the capability \fBccc\fP may be present to
1682 indicate that colors can be modified.
1683 If so, the \fBinitc\fP capability will
1684 take a color number (0 to \fBcolors\fP \- 1)and three more parameters which
1685 describe the color.
1686 These three parameters default to being interpreted as RGB
1687 (Red, Green, Blue) values.
1688 If the boolean capability \fBhls\fP is present,
1689 they are instead as HLS (Hue, Lightness, Saturation) indices.
1690 The ranges are
1691 terminal-dependent.
1692 .bP
1693 On an HP-like terminal, \fBinitp\fP may give a capability for changing a
1694 color-pair value.
1695 It will take seven parameters; a color-pair number (0 to
1696 \fBmax_pairs\fP \- 1), and two triples describing first background and then
1697 foreground colors.
1698 These parameters must be (Red, Green, Blue) or
1699 (Hue, Lightness, Saturation) depending on \fBhls\fP.
1700 .PP
1701 On some color terminals, colors collide with highlights.
1702 You can register
1703 these collisions with the \fBncv\fP capability.
1704 This is a bit-mask of
1705 attributes not to be used when colors are enabled.
1706 The correspondence with the
1707 attributes understood by \fBcurses\fP is as follows:
1708 .PP
1709 .TS
1710 center;
1711 l l l l
1712 lw20 lw2 lw10 lw10.
1713 \fBAttribute    Bit     Decimal Set by\fP
1714 A_STANDOUT      0       1       sgr
1715 A_UNDERLINE     1       2       sgr
1716 A_REVERSE       2       4       sgr
1717 A_BLINK         3       8       sgr
1718 A_DIM           4       16      sgr
1719 A_BOLD          5       32      sgr
1720 A_INVIS         6       64      sgr
1721 A_PROTECT       7       128     sgr
1722 A_ALTCHARSET    8       256     sgr
1723 A_HORIZONTAL    9       512     sgr1
1724 A_LEFT  10      1024    sgr1
1725 A_LOW   11      2048    sgr1
1726 A_RIGHT 12      4096    sgr1
1727 A_TOP   13      8192    sgr1
1728 A_VERTICAL      14      16384   sgr1
1729 A_ITALIC        15      32768   sitm
1730 .TE
1731 .PP
1732 For example, on many IBM PC consoles, the underline attribute collides with the
1733 foreground color blue and is not available in color mode.
1734 These should have
1735 an \fBncv\fP capability of 2.
1736 .PP
1737 SVr4 curses does nothing with \fBncv\fP, ncurses recognizes it and optimizes
1738 the output in favor of colors.
1739 .SS Miscellaneous
1740 If the terminal requires other than a null (zero) character as a pad, then this
1741 can be given as pad.
1742 Only the first character of the pad string is used.
1743 If the terminal does not have a pad character, specify npc.
1744 Note that ncurses implements the termcap-compatible \fBPC\fP variable;
1745 though the application may set this value to something other than
1746 a null, ncurses will test \fBnpc\fP first and use napms if the terminal
1747 has no pad character.
1748 .PP
1749 If the terminal can move up or down half a line,
1750 this can be indicated with
1751 .B hu
1752 (half-line up)
1753 and
1754 .B hd
1755 (half-line down).
1756 This is primarily useful for superscripts and subscripts on hard-copy terminals.
1757 If a hard-copy terminal can eject to the next page (form feed), give this as
1758 .B ff
1759 (usually control/L).
1760 .PP
1761 If there is a command to repeat a given character a given number of
1762 times (to save time transmitting a large number of identical characters)
1763 this can be indicated with the parameterized string
1764 .BR rep .
1765 The first parameter is the character to be repeated and the second
1766 is the number of times to repeat it.
1767 Thus, tparm(repeat_char, \(aqx\(aq, 10) is the same as \*(``xxxxxxxxxx\*(''.
1768 .PP
1769 If the terminal has a settable command character, such as the \s-1TEKTRONIX\s+1 4025,
1770 this can be indicated with
1771 .BR cmdch .
1772 A prototype command character is chosen which is used in all capabilities.
1773 This character is given in the
1774 .B cmdch
1775 capability to identify it.
1776 The following convention is supported on some UNIX systems:
1777 The environment is to be searched for a
1778 .B CC
1779 variable, and if found, all
1780 occurrences of the prototype character are replaced with the character
1781 in the environment variable.
1782 .PP
1783 Terminal descriptions that do not represent a specific kind of known
1784 terminal, such as
1785 .IR switch ,
1786 .IR dialup ,
1787 .IR patch ,
1788 and
1789 .IR network ,
1790 should include the
1791 .B gn
1792 (generic) capability so that programs can complain that they do not know
1793 how to talk to the terminal.
1794 (This capability does not apply to
1795 .I virtual
1796 terminal descriptions for which the escape sequences are known.)
1797 .PP
1798 If the terminal has a \*(``meta key\*('' which acts as a shift key,
1799 setting the 8th bit of any character transmitted, this fact can
1800 be indicated with
1801 .BR km .
1802 Otherwise, software will assume that the 8th bit is parity and it
1803 will usually be cleared.
1804 If strings exist to turn this \*(``meta mode\*('' on and off, they
1805 can be given as
1806 .B smm
1807 and
1808 .BR rmm .
1809 .PP
1810 If the terminal has more lines of memory than will fit on the screen
1811 at once, the number of lines of memory can be indicated with
1812 .BR lm .
1813 A value of
1814 .BR lm #0
1815 indicates that the number of lines is not fixed,
1816 but that there is still more memory than fits on the screen.
1817 .PP
1818 If the terminal is one of those supported by the \s-1UNIX\s+1 virtual
1819 terminal protocol, the terminal number can be given as
1820 .BR vt .
1821 .PP
1822 Media copy
1823 strings which control an auxiliary printer connected to the terminal
1824 can be given as
1825 .BR mc0 :
1826 print the contents of the screen,
1827 .BR mc4 :
1828 turn off the printer, and
1829 .BR mc5 :
1830 turn on the printer.
1831 When the printer is on, all text sent to the terminal will be sent
1832 to the printer.
1833 It is undefined whether the text is also displayed on the terminal screen
1834 when the printer is on.
1835 A variation
1836 .B mc5p
1837 takes one parameter, and leaves the printer on for as many characters
1838 as the value of the parameter, then turns the printer off.
1839 The parameter should not exceed 255.
1840 All text, including
1841 .BR mc4 ,
1842 is transparently passed to the printer while an
1843 .B mc5p
1844 is in effect.
1845 .SS Glitches and Braindamage
1846 Hazeltine terminals, which do not allow \*(``~\*('' characters to be displayed should
1847 indicate \fBhz\fP.
1848 .PP
1849 Terminals which ignore a line-feed immediately after an \fBam\fP wrap,
1850 such as the Concept and vt100,
1851 should indicate \fBxenl\fP.
1852 .PP
1853 If
1854 .B el
1855 is required to get rid of standout
1856 (instead of merely writing normal text on top of it),
1857 \fBxhp\fP should be given.
1858 .PP
1859 Teleray terminals, where tabs turn all characters moved over to blanks,
1860 should indicate \fBxt\fP (destructive tabs).
1861 Note: the variable indicating this is now \*(``dest_tabs_magic_smso\*(''; in
1862 older versions, it was teleray_glitch.
1863 This glitch is also taken to mean that it is not possible to position
1864 the cursor on top of a \*(``magic cookie\*('',
1865 that to erase standout mode it is instead necessary to use
1866 delete and insert line.
1867 The ncurses implementation ignores this glitch.
1868 .PP
1869 The Beehive Superbee, which is unable to correctly transmit the escape
1870 or control/C characters, has
1871 .BR xsb ,
1872 indicating that the f1 key is used for escape and f2 for control/C.
1873 (Only certain Superbees have this problem, depending on the ROM.)
1874 Note that in older terminfo versions, this capability was called
1875 \*(``beehive_glitch\*(''; it is now \*(``no_esc_ctl_c\*(''.
1876 .PP
1877 Other specific terminal problems may be corrected by adding more
1878 capabilities of the form \fBx\fP\fIx\fP.
1879 .SS Pitfalls of Long Entries
1880 Long terminfo entries are unlikely to be a problem; to date, no entry has even
1881 approached terminfo's 4096-byte string-table maximum.
1882 Unfortunately, the termcap
1883 translations are much more strictly limited (to 1023 bytes), thus termcap translations
1884 of long terminfo entries can cause problems.
1885 .PP
1886 The man pages for 4.3BSD and older versions of \fBtgetent\fP instruct the user to
1887 allocate a 1024-byte buffer for the termcap entry.
1888 The entry gets null-terminated by
1889 the termcap library, so that makes the maximum safe length for a termcap entry
1890 1k\-1 (1023) bytes.
1891 Depending on what the application and the termcap library
1892 being used does, and where in the termcap file the terminal type that \fBtgetent\fP
1893 is searching for is, several bad things can happen.
1894 .PP
1895 Some termcap libraries print a warning message or exit if they find an
1896 entry that's longer than 1023 bytes; others do not; others truncate the
1897 entries to 1023 bytes.
1898 Some application programs allocate more than
1899 the recommended 1K for the termcap entry; others do not.
1900 .PP
1901 Each termcap entry has two important sizes associated with it: before
1902 \*(``tc\*('' expansion, and after \*(``tc\*('' expansion.
1903 \*(``tc\*('' is the capability that
1904 tacks on another termcap entry to the end of the current one, to add
1905 on its capabilities.
1906 If a termcap entry does not use the \*(``tc\*(''
1907 capability, then of course the two lengths are the same.
1908 .PP
1909 The \*(``before tc expansion\*('' length is the most important one, because it
1910 affects more than just users of that particular terminal.
1911 This is the
1912 length of the entry as it exists in /etc/termcap, minus the
1913 backslash-newline pairs, which \fBtgetent\fP strips out while reading it.
1914 Some termcap libraries strip off the final newline, too (GNU termcap does not).
1915 Now suppose:
1916 .bP
1917 a termcap entry before expansion is more than 1023 bytes long,
1918 .bP
1919 and the application has only allocated a 1k buffer,
1920 .bP
1921 and the termcap library (like the one in BSD/OS 1.1 and GNU) reads
1922 the whole entry into the buffer, no matter what its length, to see
1923 if it is the entry it wants,
1924 .bP
1925 and \fBtgetent\fP is searching for a terminal type that either is the
1926 long entry, appears in the termcap file after the long entry, or
1927 does not appear in the file at all (so that \fBtgetent\fP has to search
1928 the whole termcap file).
1929 .PP
1930 Then \fBtgetent\fP will overwrite memory, perhaps its stack, and probably core dump
1931 the program.
1932 Programs like telnet are particularly vulnerable; modern telnets
1933 pass along values like the terminal type automatically.
1934 The results are almost
1935 as undesirable with a termcap library, like SunOS 4.1.3 and Ultrix 4.4, that
1936 prints warning messages when it reads an overly long termcap entry.
1937 If a
1938 termcap library truncates long entries, like OSF/1 3.0, it is immune to dying
1939 here but will return incorrect data for the terminal.
1940 .PP
1941 The \*(``after tc expansion\*('' length will have a similar effect to the
1942 above, but only for people who actually set TERM to that terminal
1943 type, since \fBtgetent\fP only does \*(``tc\*('' expansion once it is found the
1944 terminal type it was looking for, not while searching.
1945 .PP
1946 In summary, a termcap entry that is longer than 1023 bytes can cause,
1947 on various combinations of termcap libraries and applications, a core
1948 dump, warnings, or incorrect operation.
1949 If it is too long even before
1950 \*(``tc\*('' expansion, it will have this effect even for users of some other
1951 terminal types and users whose TERM variable does not have a termcap
1952 entry.
1953 .PP
1954 When in \-C (translate to termcap) mode, the \fBncurses\fP implementation of
1955 \fB@TIC@\fP(1M) issues warning messages when the pre-tc length of a termcap
1956 translation is too long.
1957 The \-c (check) option also checks resolved (after tc
1958 expansion) lengths.
1959 .SS Binary Compatibility
1960 It is not wise to count on portability of binary terminfo entries between
1961 commercial UNIX versions.
1962 The problem is that there are at least two versions
1963 of terminfo (under HP\-UX and AIX) which diverged from System V terminfo after
1964 SVr1, and have added extension capabilities to the string table that (in the
1965 binary format) collide with System V and XSI Curses extensions.
1966 .SH EXTENSIONS
1967 Searching for terminal descriptions in
1968 \fB$HOME/.terminfo\fP and TERMINFO_DIRS
1969 is not supported by older implementations.
1970 .PP
1971 Some SVr4 \fBcurses\fP implementations, and all previous to SVr4, do not
1972 interpret the %A and %O operators in parameter strings.
1973 .PP
1974 SVr4/XPG4 do not specify whether \fBmsgr\fP licenses movement while in
1975 an alternate-character-set mode (such modes may, among other things, map
1976 CR and NL to characters that do not trigger local motions).
1977 The \fBncurses\fP implementation ignores \fBmsgr\fP in \fBALTCHARSET\fP
1978 mode.
1979 This raises the possibility that an XPG4
1980 implementation making the opposite interpretation may need terminfo
1981 entries made for \fBncurses\fP to have \fBmsgr\fP turned off.
1982 .PP
1983 The \fBncurses\fP library handles insert-character and insert-character modes
1984 in a slightly non-standard way to get better update efficiency.
1985 See
1986 the \fBInsert/Delete Character\fP subsection above.
1987 .PP
1988 The parameter substitutions for \fBset_clock\fP and \fBdisplay_clock\fP are
1989 not documented in SVr4 or the XSI Curses standard.
1990 They are deduced from the
1991 documentation for the AT&T 505 terminal.
1992 .PP
1993 Be careful assigning the \fBkmous\fP capability.
1994 The \fBncurses\fP library wants to interpret it as \fBKEY_MOUSE\fP,
1995 for use by terminals and emulators like xterm
1996 that can return mouse-tracking information in the keyboard-input stream.
1997 .PP
1998 X/Open Curses does not mention italics.
1999 Portable applications must assume that numeric capabilities are
2000 signed 16-bit values.
2001 This includes the \fIno_color_video\fP (\fBncv\fP) capability.
2002 The 32768 mask value used for italics with \fBncv\fP can be confused with
2003 an absent or cancelled \fBncv\fP.
2004 If italics should work with colors,
2005 then the \fBncv\fP value must be specified, even if it is zero.
2006 .PP
2007 Different commercial ports of terminfo and curses support different subsets of
2008 the XSI Curses standard and (in some cases) different extension sets.
2009 Here
2010 is a summary, accurate as of October 1995:
2011 .bP
2012 \fBSVR4, Solaris, ncurses\fP \-\-
2013 These support all SVr4 capabilities.
2014 .bP
2015 \fBSGI\fP \-\-
2016 Supports the SVr4 set, adds one undocumented extended string
2017 capability (\fBset_pglen\fP).
2018 .bP
2019 \fBSVr1, Ultrix\fP \-\-
2020 These support a restricted subset of terminfo capabilities.
2021 The booleans end with \fBxon_xoff\fP;
2022 the numerics with \fBwidth_status_line\fP;
2023 and the strings with \fBprtr_non\fP.
2024 .bP
2025 \fBHP/UX\fP \-\-
2026 Supports the SVr1 subset, plus the SVr[234] numerics \fBnum_labels\fP,
2027 \fBlabel_height\fP, \fBlabel_width\fP, plus function keys 11 through 63, plus
2028 \fBplab_norm\fP, \fBlabel_on\fP, and \fBlabel_off\fP, plus some incompatible
2029 extensions in the string table.
2030 .bP
2031 \fBAIX\fP \-\-
2032 Supports the SVr1 subset, plus function keys 11 through 63, plus a number
2033 of incompatible string table extensions.
2034 .bP
2035 \fBOSF\fP \-\-
2036 Supports both the SVr4 set and the AIX extensions.
2037 .SH FILES
2038 .TP 25
2039 \*d/?/*
2040 files containing terminal descriptions
2041 .SH SEE ALSO
2042 .na
2043 .hy 0
2044 \fB@INFOCMP@\fP(1M),
2045 \fB@TABS@\fP(1),
2046 \fB@TIC@\fP(1M),
2047 \fBcurses\fP(3X),
2048 \fBcurs_color\fP(3X),
2049 \fBcurs_variables\fP(3X),
2050 \fBprintf\fP(3),
2051 \fBterm_variables\fP(3X).
2052 \fBterm\fP(\*n).
2053 \fBuser_caps\fP(5).
2054 .SH AUTHORS
2055 Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
2056 Based on \fIpcurses\fP by Pavel Curtis.