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