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