]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/user_caps.5.html
061b203e8bb95f9f55d2fbe8cd6e20ccbfdf11ca
[ncurses.git] / doc / html / man / user_caps.5.html
1 <!--
2   * t
3   ****************************************************************************
4   * Copyright 2018-2022,2023 Thomas E. Dickey                                *
5   * Copyright 2017 Free Software Foundation, Inc.                            *
6   *                                                                          *
7   * Permission is hereby granted, free of charge, to any person obtaining a  *
8   * copy of this software and associated documentation files (the            *
9   * "Software"), to deal in the Software without restriction, including      *
10   * without limitation the rights to use, copy, modify, merge, publish,      *
11   * distribute, distribute with modifications, sublicense, and/or sell       *
12   * copies of the Software, and to permit persons to whom the Software is    *
13   * furnished to do so, subject to the following conditions:                 *
14   *                                                                          *
15   * The above copyright notice and this permission notice shall be included  *
16   * in all copies or substantial portions of the Software.                   *
17   *                                                                          *
18   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
19   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
20   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
21   * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
22   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
23   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
24   * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
25   *                                                                          *
26   * Except as contained in this notice, the name(s) of the above copyright   *
27   * holders shall not be used in advertising or otherwise to promote the     *
28   * sale, use or other dealings in this Software without prior written       *
29   * authorization.                                                           *
30   ****************************************************************************
31   * @Id: user_caps.5,v 1.36 2023/09/16 23:38:39 tom Exp @
32 -->
33 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
34 <HTML>
35 <HEAD>
36 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
37 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
38 <TITLE>user_caps 5 2023-09-16 ncurses 6.4 File formats</TITLE>
39 <link rel="author" href="mailto:bug-ncurses@gnu.org">
40
41 </HEAD>
42 <BODY>
43 <H1 class="no-header">user_caps 5 2023-09-16 ncurses 6.4 File formats</H1>
44 <PRE>
45 <STRONG><A HREF="user_caps.5.html">user_caps(5)</A></STRONG>                     File formats                     <STRONG><A HREF="user_caps.5.html">user_caps(5)</A></STRONG>
46
47
48
49
50 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
51        user_caps - user-defined <EM>terminfo</EM> capability format
52
53
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55        <STRONG>tic</STRONG> <STRONG>-x,</STRONG> <STRONG>infocmp</STRONG> <STRONG>-x</STRONG>
56
57
58 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
59
60 </PRE><H3><a name="h3-Background">Background</a></H3><PRE>
61        Before  ncurses  5.0,  terminfo  databases  used  a <EM>fixed</EM> <EM>repertoire</EM> of
62        terminal capabilities designed for the SVr2 terminal database in  1984,
63        and  extended  in  stages  through SVr4 (1989), and standardized in the
64        Single Unix Specification beginning in 1995.
65
66        Most of the <EM>extensions</EM> in this fixed repertoire were additions  to  the
67        tables of boolean, numeric and string capabilities.  Rather than change
68        the meaning of an existing capability,  a  new  name  was  added.   The
69        terminfo  database  uses  a  binary  format;  binary  compatibility was
70        ensured by using a header which gave the number of items in the  tables
71        for each type of capability.  The standardization was incomplete:
72
73        <STRONG>o</STRONG>   The  <EM>binary</EM>  <EM>format</EM>  itself  is  not described in the X/Open Curses
74            documentation.  Only the <EM>source</EM> <EM>format</EM> is described.
75
76            Library developers rely upon the SVr4 documentation,  and  reverse-
77            engineering the compiled terminfo files to match the binary format.
78
79        <STRONG>o</STRONG>   Lacking a standard for the binary format, most implementations copy
80            the SVr2 binary format, which uses 16-bit signed integers,  and  is
81            limited to 4096-byte entries.
82
83            The  format  cannot  represent very large numeric capabilities, nor
84            can it represent large numbers of special keyboard definitions.
85
86        <STRONG>o</STRONG>   The tables of capability names differ between implementations.
87
88            Although they <EM>may</EM> provide all of the standard capability names, the
89            position  in the tables differs because some features were added as
90            needed, while others were added  (out  of  order)  to  comply  with
91            X/Open Curses.
92
93            While  ncurses' repertoire of predefined capabilities is closest to
94            Solaris, Solaris's terminfo database has a few differences from the
95            list  published  by  X/Open  Curses.   For  example, ncurses can be
96            configured with tables which match the terminal databases for  AIX,
97            HP-UX or OSF/1, rather than the default Solaris-like configuration.
98
99        <STRONG>o</STRONG>   In  SVr4  curses  and  ncurses, the terminal database is defined at
100            compile-time using a text file which lists the  different  terminal
101            capabilities.
102
103            In  principle,  the  text-file  can  be  extended,  but  doing this
104            requires recompiling and reinstalling the library.   The  text-file
105            used  in  ncurses  for  terminal  capabilities includes details for
106            various systems past the documented X/Open  Curses  features.   For
107            example, ncurses supports these capabilities in each configuration:
108
109                memory_lock
110                     (meml) lock memory above cursor
111
112                memory_unlock
113                     (memu) unlock memory
114
115                box_chars_1
116                     (box1) box characters primary set
117
118            The memory lock/unlock capabilities were included because they were
119            used in the X11R6 terminal  description  for  <STRONG>xterm(1)</STRONG>.   The  <EM>box1</EM>
120            capability  is  used  in  tic  to  help  with terminal descriptions
121            written for AIX.
122
123        During the 1990s, some users were reluctant to use terminfo in spite of
124        its performance advantages over termcap:
125
126        <STRONG>o</STRONG>   The  fixed  repertoire  prevented  users  from  adding features for
127            unanticipated terminal improvements  (or  required  them  to  reuse
128            existing capabilities as a workaround).
129
130        <STRONG>o</STRONG>   The  limitation  to  16-bit  signed  integers  was  also mentioned.
131            Because termcap stores everything as a string, it  could  represent
132            larger numbers.
133
134        Although  termcap's  extensibility  was  rarely  used (it was never the
135        <EM>speaker</EM> who had actually used the feature), the criticism had a  point.
136        ncurses   5.0  provided  a  way  to  detect  nonstandard  capabilities,
137        determine their type and optionally store and retrieve them  in  a  way
138        which did not interfere with other applications.  These are referred to
139        as <EM>user-defined</EM> <EM>capabilities</EM> because no modifications to the  toolset's
140        predefined capability names are needed.
141
142        The  ncurses  utilities <STRONG>tic</STRONG> and <STRONG>infocmp</STRONG> have a command-line option "-x"
143        to  control  whether  the  nonstandard  capabilities  are   stored   or
144        retrieved.   A  library function <STRONG>use_extended_names</STRONG> is provided for the
145        same purpose.
146
147        When compiling a terminal database, if "-x" is set, <STRONG>tic</STRONG>  will  store  a
148        user-defined  capability  if  the  capability  name  is  not one of the
149        predefined names.
150
151        Because ncurses provides  a  termcap  library  interface,  these  user-
152        defined capabilities may be visible to termcap applications:
153
154        <STRONG>o</STRONG>   The   termcap  interface  (like  all  implementations  of  termcap)
155            requires that the capability names are 2-characters.
156
157            When  the  capability  is  simple  enough  for  use  in  a  termcap
158            application, it is provided as a 2-character name.
159
160        <STRONG>o</STRONG>   There  are  other user-defined capabilities which refer to features
161            not usable in termcap, e.g., parameterized strings  that  use  more
162            than two parameters or use more than the trivial expression support
163            provided by termcap.  For these, the terminfo database should  have
164            only capability names with 3 or more characters.
165
166        <STRONG>o</STRONG>   Some terminals can send distinct strings for special keys (cursor-,
167            keypad-  or  function-keys)  depending  on  modifier  keys  (shift,
168            control,  etc.).   While  terminfo  and  termcap  have  a set of 60
169            predefined function-key names, to which a series  of  keys  can  be
170            assigned,   that  is  insufficient  for  more  than  a  dozen  keys
171            multiplied by more than a couple  of  modifier  combinations.   The
172            ncurses  database  uses  a  convention based on <STRONG>xterm(1)</STRONG> to provide
173            extended special-key names.
174
175            Fitting that into termcap's limitation of 2-character  names  would
176            be   pointless.   These  extended  keys  are  available  only  with
177            terminfo.
178
179
180 </PRE><H3><a name="h3-Recognized-capabilities">Recognized capabilities</a></H3><PRE>
181        The ncurses library uses the user-definable  capabilities.   While  the
182        terminfo  database  may  have  other extensions, ncurses makes explicit
183        checks for these:
184
185           AX <EM>boolean</EM>, asserts that the terminal interprets SGR 39 and  SGR  49
186              by  resetting  the foreground and background color, respectively,
187              to the default.
188
189              This is a feature recognized by the <STRONG>screen</STRONG> program as well.
190
191           E3 <EM>string</EM>, tells how to  clear  the  terminal's  scrollback  buffer.
192              When present, the <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG> program sends this before clearing the
193              terminal.
194
195              The command "<STRONG>tput</STRONG> <STRONG>clear</STRONG>" does the same thing.
196
197           NQ used to suppress a consistency  check  in  tic  for  the  ncurses
198              capabilities  in  user6  through  user9 (u6, u7, u8 and u9) which
199              tell how to query the terminal's cursor position and  its  device
200              attributes.
201
202           RGB
203              <EM>boolean</EM>,   <EM>number</EM>   <STRONG>or</STRONG>   <EM>string</EM>,   used   to   assert   that  the
204              <STRONG>set_a_foreground</STRONG> and <STRONG>set_a_background</STRONG> capabilities correspond  to
205              <EM>direct</EM>  <EM>colors</EM>,  using  an RGB (red/green/blue) convention.  This
206              capability  allows   the   <STRONG>color_content</STRONG>   function   to   return
207              appropriate   values   without   requiring   the  application  to
208              initialize colors using <STRONG>init_color</STRONG>.
209
210              The capability type determines the values which ncurses sees:
211
212              <EM>boolean</EM>
213                 implies that the number of bits for red, green  and  blue  are
214                 the  same.   Using  the maximum number of colors, ncurses adds
215                 two, divides that sum by three, and assigns the result to red,
216                 green and blue in that order.
217
218                 If the number of bits needed for the number of colors is not a
219                 multiple of three, the blue (and  green)  components  lose  in
220                 comparison to red.
221
222              <EM>number</EM>
223                 tells  ncurses  what result to add to red, green and blue.  If
224                 ncurses runs out of bits, blue (and green) lose just as in the
225                 <EM>boolean</EM> case.
226
227              <EM>string</EM>
228                 explicitly  list  the  number  of bits used for red, green and
229                 blue components as a slash-separated list of decimal integers.
230
231              Because there are several  RGB  encodings  in  use,  applications
232              which  make  assumptions  about  the number of bits per color are
233              unlikely to work reliably.  As a trivial case, for  example,  one
234              could  define  <STRONG>RGB#1</STRONG> to represent the standard eight ANSI colors,
235              i.e., one bit per color.
236
237           U8 <EM>number</EM>, asserts that ncurses must use Unicode  values  for  line-
238              drawing  characters,  and  that  it  should  ignore the alternate
239              character set capabilities when the locale uses  UTF-8  encoding.
240              For  more  information, see the discussion of <STRONG>NCURSES_NO_UTF8_ACS</STRONG>
241              in <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>.
242
243              Set this capability to a nonzero value to enable it.
244
245           XM <EM>string</EM>, override ncurses's built-in string which enables/disables
246              <STRONG>xterm(1)</STRONG> mouse mode.
247
248              ncurses  sends a character sequence to the terminal to initialize
249              mouse mode, and when the user clicks the  mouse  buttons  or  (in
250              certain  modes) moves the mouse, handles the characters sent back
251              by the terminal to tell it what was done with the mouse.
252
253              The mouse protocol  is  enabled  when  the  <EM>mask</EM>  passed  in  the
254              <STRONG>mousemask</STRONG>  function  is nonzero.  By default, ncurses handles the
255              responses for the X11 xterm mouse protocol.  It also knows  about
256              the  <EM>SGR</EM>  <EM>1006</EM>  xterm mouse protocol, but must to be told to look
257              for this specifically.  It will not be able to guess  which  mode
258              is  used,  because  the  responses  are  enough  alike  that only
259              confusion would result.
260
261              The <STRONG>XM</STRONG> capability has a single parameter.  If nonzero, the  mouse
262              protocol  should  be enabled.  If zero, the mouse protocol should
263              be disabled.  ncurses inspects this capability if it is  present,
264              to  see whether the 1006 protocol is used.  If so, it expects the
265              responses to use the <EM>SGR</EM> <EM>1006</EM> xterm mouse protocol.
266
267              The xterm mouse protocol is used  by  other  terminal  emulators.
268              The  terminal database uses building-blocks for the various xterm
269              mouse  protocols  which  can  be  used  in  customized   terminal
270              descriptions.
271
272              The terminal database building blocks for this mouse feature also
273              have  an  experimental  capability  <EM>xm</EM>.   The   "xm"   capability
274              describes  the mouse response.  Currently there is no interpreter
275              which would use  this  information  to  make  the  mouse  support
276              completely data-driven.
277
278              <EM>xm</EM> shows the format of the mouse responses.  In this experimental
279              capability, the parameters are
280
281                <EM>p1</EM>   y-ordinate
282
283                <EM>p2</EM>   x-ordinate
284
285                <EM>p3</EM>   button
286
287                <EM>p4</EM>   state, e.g., pressed or released
288
289                <EM>p5</EM>   y-ordinate starting region
290
291                <EM>p6</EM>   x-ordinate starting region
292
293                <EM>p7</EM>   y-ordinate ending region
294
295                <EM>p8</EM>   x-ordinate ending region
296
297              Here are  examples  from  the  terminal  database  for  the  most
298              commonly used xterm mouse protocols:
299
300                xterm+x11mouse|X11 xterm mouse protocol,
301                        kmous=\E[M, XM=\E[?1000%?%p1%{1}%=%th%el%;,
302                        xm=\E[M
303                           %?%p4%t%p3%e%{3}%;%' '%+%c
304                           %p2%'!'%+%c
305                           %p1%'!'%+%c,
306
307                xterm+sm+1006|xterm SGR-mouse,
308                        kmous=\E[&lt;, XM=\E[?1006;1000%?%p1%{1}%=%th%el%;,
309                        xm=\E[&lt;%i%p3%d;
310                           %p1%d;
311                           %p2%d;
312                           %?%p4%tM%em%;,
313
314
315 </PRE><H3><a name="h3-Extended-key-definitions">Extended key-definitions</a></H3><PRE>
316        Several  terminals  provide  the  ability  to send distinct strings for
317        combinations of modified special keys.  There is no standard  for  what
318        those keys can send.
319
320        Since  1999,  <STRONG>xterm(1)</STRONG>  has  supported  <EM>shift</EM>,  <EM>control</EM>,  <EM>alt</EM>, and <EM>meta</EM>
321        modifiers which produce distinct special-key strings.   In  a  terminal
322        description,  ncurses  has  no special knowledge of the modifiers used.
323        Applications can use the <EM>naming</EM> <EM>convention</EM>  established  for  <STRONG>xterm</STRONG>  to
324        find these special keys in the terminal description.
325
326        Starting  with  the curses convention that <EM>key</EM> <EM>names</EM> begin with "k" and
327        that shifted special keys are  an  uppercase  name,  ncurses'  terminal
328        database defines these names to which a suffix is added:
329
330             <STRONG>Name</STRONG>   <STRONG>Description</STRONG>
331             ---------------------------------------------------------------
332             kDC    special form of kdch1 (delete character)
333             kDN    special form of kcud1 (cursor down)
334             kEND   special form of kend (End)
335             kHOM   special form of khome (Home)
336             kLFT   special form of kcub1 (cursor-left or cursor-back)
337             kNXT   special form of knext (Next, or Page-Down)
338             kPRV   special form of kprev (Prev, or Page-Up)
339             kRIT   special form of kcuf1 (cursor-right, or cursor-forward)
340             kUP    special form of kcuu1 (cursor-up)
341
342        These are the suffixes used to denote the modifiers:
343
344             <STRONG>Value</STRONG>   <STRONG>Description</STRONG>
345             ----------------------------------
346             2       Shift
347             3       Alt
348             4       Shift + Alt
349             5       Control
350             6       Shift + Control
351             7       Alt + Control
352             8       Shift + Alt + Control
353             9       Meta
354             10      Meta + Shift
355             11      Meta + Alt
356             12      Meta + Alt + Shift
357             13      Meta + Ctrl
358             14      Meta + Ctrl + Shift
359             15      Meta + Ctrl + Alt
360             16      Meta + Ctrl + Alt + Shift
361
362        None  of these are predefined; terminal descriptions can refer to <EM>names</EM>
363        which ncurses will allocate at runtime to <EM>key-codes</EM>.  To use these keys
364        in an ncurses program, an application could do this:
365
366        <STRONG>o</STRONG>   using  a  list  of  extended  key <EM>names</EM>, ask <STRONG><A HREF="curs_terminfo.3x.html">tigetstr(3x)</A></STRONG> for their
367            values, and
368
369        <STRONG>o</STRONG>   given the list of values,  ask  <STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>  for  the  <EM>key-code</EM>
370            which would be returned for those keys by <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG>.
371
372
373 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
374        The  "-x"  extension  feature  of  <STRONG>tic</STRONG>  and <STRONG>infocmp</STRONG> has been adopted in
375        NetBSD curses.  That implementation stores  user-defined  capabilities,
376        but makes no use of these capabilities itself.
377
378
379 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
380        <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>.
381
382        The  terminal  database  section  <EM>NCURSES</EM>  <EM>USER-DEFINABLE</EM>  <EM>CAPABILITIES</EM>
383        summarizes commonly-used user-defined capabilities which  are  used  in
384        the  terminal  descriptions.   Some  of those features are mentioned in
385        <STRONG>screen(1)</STRONG> or <STRONG>tmux(1)</STRONG>.
386
387        <EM>XTerm</EM> <EM>Control</EM> <EM>Sequences</EM> provides further information  on  the  <STRONG>xterm(1)</STRONG>
388        features which are used in these extended capabilities.
389
390
391 </PRE><H2><a name="h2-AUTHORS">AUTHORS</a></H2><PRE>
392        Thomas E. Dickey
393        beginning with ncurses 5.0 (1999)
394
395
396
397 ncurses 6.4                       2023-09-16                      <STRONG><A HREF="user_caps.5.html">user_caps(5)</A></STRONG>
398 </PRE>
399 <div class="nav">
400 <ul>
401 <li><a href="#h2-NAME">NAME</a></li>
402 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
403 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
404 <ul>
405 <li><a href="#h3-Background">Background</a></li>
406 <li><a href="#h3-Recognized-capabilities">Recognized capabilities</a></li>
407 <li><a href="#h3-Extended-key-definitions">Extended key-definitions</a></li>
408 </ul>
409 </li>
410 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
411 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
412 <li><a href="#h2-AUTHORS">AUTHORS</a></li>
413 </ul>
414 </div>
415 </BODY>
416 </HTML>