{
    "content": [
        {
            "type": "text",
            "text": "# user_caps(5) (man)\n\n**Summary:** usercaps - user-defined terminfo capabilities\n\n## See Also\n\n- infocmp(1)\n- tic(1)\n- screen(1)\n- tmux(1)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (1 lines) — 1 subsections\n  - tic -x, infocmp -x (1 lines)\n- **DESCRIPTION** (1 lines) — 3 subsections\n  - Background (100 lines)\n  - Recognized capabilities (111 lines)\n  - Extended key-definitions (54 lines)\n- **PORTABILITY** (3 lines)\n- **SEE ALSO** (9 lines)\n- **AUTHORS** (6 lines)\n\n## Full Content\n\n### NAME\n\nusercaps - user-defined terminfo capabilities\n\n### SYNOPSIS\n\n#### tic -x, infocmp -x\n\n### DESCRIPTION\n\n#### Background\n\nBefore  ncurses  5.0, terminfo databases used a fixed repertoire of terminal capabilities de‐\nsigned for the SVr2 terminal database in 1984, and extended in stages  through  SVr4  (1989),\nand standardized in the Single Unix Specification beginning in 1995.\n\nMost  of the extensions in this fixed repertoire were additions to the tables of boolean, nu‐\nmeric and string capabilities.  Rather than change the meaning of an existing  capability,  a\nnew name was added.  The terminfo database uses a binary format; binary compatibility was en‐\nsured by using a header which gave the number of items in the tables for each type  of  capa‐\nbility.  The standardization was incomplete:\n\n•   The  binary  format itself is not described in the X/Open Curses documentation.  Only the\nsource format is described.\n\nLibrary developers rely upon the SVr4 documentation, and reverse-engineering the compiled\nterminfo files to match the binary format.\n\n•   Lacking  a standard for the binary format, most implementations copy the SVr2 binary for‐\nmat, which uses 16-bit signed integers, and is limited to 4096-byte entries.\n\nThe format cannot represent very large numeric capabilities, nor can it  represent  large\nnumbers of special keyboard definitions.\n\n•   The tables of capability names differ between implementations.\n\nAlthough  they  may provide all of the standard capability names, the position in the ta‐\nbles differs because some features were added as needed, while others were added (out  of\norder) to comply with X/Open Curses.\n\nWhile  ncurses'  repertoire  of  predefined capabilities is closest to Solaris, Solaris's\nterminfo database has a few differences from the list published by  X/Open  Curses.   For\nexample,  ncurses  can  be  configured with tables which match the terminal databases for\nAIX, HP-UX or OSF/1, rather than the default Solaris-like configuration.\n\n•   In SVr4 curses and ncurses, the terminal database is defined at compile-time using a text\nfile which lists the different terminal capabilities.\n\nIn  principle, the text-file can be extended, but doing this requires recompiling and re‐\ninstalling the library.  The text-file used in ncurses for terminal capabilities includes\ndetails  for  various  systems  past the documented X/Open Curses features.  For example,\nncurses supports these capabilities in each configuration:\n\nmemorylock\n(meml) lock memory above cursor\n\nmemoryunlock\n(memu) unlock memory\n\nboxchars1\n(box1) box characters primary set\n\nThe memory lock/unlock capabilities were included because they were  used  in  the  X11R6\nterminal description for xterm.  The box1 capability is used in tic to help with terminal\ndescriptions written for AIX.\n\nDuring the 1990s, some users were reluctant to use terminfo in spite of its  performance  ad‐\nvantages over termcap:\n\n•   The  fixed repertoire prevented users from adding features for unanticipated terminal im‐\nprovements (or required them to reuse existing capabilities as a workaround).\n\n•   The limitation to 16-bit signed integers was also mentioned.  Because termcap stores  ev‐\nerything as a string, it could represent larger numbers.\n\nAlthough  termcap's  extensibility was rarely used (it was never the speaker who had actually\nused the feature), the criticism had a point.  ncurses 5.0 provided a way to detect  nonstan‐\ndard capabilities, determine their type and optionally store and retrieve them in a way which\ndid not interfere with other applications.  These are referred to as  user-defined  capabili‐\nties because no modifications to the toolset's predefined capability names are needed.\n\nThe  ncurses utilities tic and infocmp have a command-line option “-x” to control whether the\nnonstandard capabilities are stored or retrieved.  A library function  useextendednames  is\nprovided for the same purpose.\n\nWhen  compiling a terminal database, if “-x” is set, tic will store a user-defined capability\nif the capability name is not one of the predefined names.\n\nBecause ncurses provides a termcap library interface, these user-defined capabilities may  be\nvisible to termcap applications:\n\n•   The  termcap interface (like all implementations of termcap) requires that the capability\nnames are 2-characters.\n\nWhen the capability is simple enough for use in a termcap application, it is provided  as\na 2-character name.\n\n•   There  are other user-defined capabilities which refer to features not usable in termcap,\ne.g., parameterized strings that use more than two parameters or use more than the  triv‐\nial expression support provided by termcap.  For these, the terminfo database should have\nonly capability names with 3 or more characters.\n\n•   Some terminals can send distinct strings for special keys (cursor-, keypad- or  function-\nkeys) depending on modifier keys (shift, control, etc.).  While terminfo and termcap have\na set of 60 predefined function-key names, to which a series of  keys  can  be  assigned,\nthat is insufficient for more than a dozen keys multiplied by more than a couple of modi‐\nfier combinations.  The ncurses database uses a convention based on xterm to provide  ex‐\ntended special-key names.\n\nFitting  that  into  termcap's limitation of 2-character names would be pointless.  These\nextended keys are available only with terminfo.\n\n#### Recognized capabilities\n\nThe ncurses library uses the user-definable capabilities.  While the  terminfo  database  may\nhave other extensions, ncurses makes explicit checks for these:\n\nAX boolean,  asserts that the terminal interprets SGR 39 and SGR 49 by resetting the fore‐\nground and background color, respectively, to the default.\n\nThis is a feature recognized by the screen program as well.\n\nE3 string, tells how to  clear  the  terminal's  scrollback  buffer.   When  present,  the\nclear(1) program sends this before clearing the terminal.\n\nThe command “tput clear” does the same thing.\n\nRGB\nboolean, number or string, to assert that the setaforeground and setabackground ca‐\npabilities correspond to direct colors, using an RGB (red/green/blue) convention.  This\ncapability  allows  the colorcontent function to return appropriate values without re‐\nquiring the application to initialize colors using initcolor.\n\nThe capability type determines the values which ncurses sees:\n\nboolean\nimplies that the number of bits for red, green and blue are  the  same.   Using  the\nmaximum  number  of colors, ncurses adds two, divides that sum by three, and assigns\nthe result to red, green and blue in that order.\n\nIf the number of bits needed for the number of colors is not a  multiple  of  three,\nthe blue (and green) components lose in comparison to red.\n\nnumber\ntells  ncurses  what  result  to add to red, green and blue.  If ncurses runs out of\nbits, blue (and green) lose just as in the boolean case.\n\nstring\nexplicitly list the number of bits used for red, green  and  blue  components  as  a\nslash-separated list of decimal integers.\n\nBecause  there  are  several  RGB encodings in use, applications which make assumptions\nabout the number of bits per color are unlikely to work reliably.  As a  trivial  case,\nfor  example, one could define RGB#1 to represent the standard eight ANSI colors, i.e.,\none bit per color.\n\nU8 number, asserts that ncurses must use Unicode values for line-drawing  characters,  and\nthat  it  should  ignore  the alternate character set capabilities when the locale uses\nUTF-8 encoding.  For more information, see the  discussion  of  NCURSESNOUTF8ACS  in\nncurses(3X).\n\nSet this capability to a nonzero value to enable it.\n\nXM string, override ncurses's built-in string which enables/disables xterm mouse mode.\n\nncurses  sends  a character sequence to the terminal to initialize mouse mode, and when\nthe user clicks the mouse buttons or (in certain modes) moves the  mouse,  handles  the\ncharacters sent back by the terminal to tell it what was done with the mouse.\n\nThe  mouse  protocol  is enabled when the mask passed in the mousemask function is non‐\nzero.  By default, ncurses handles the responses for the X11 xterm mouse protocol.   It\nalso  knows  about  the  SGR 1006 xterm mouse protocol, but must to be told to look for\nthis specifically.  It will not be able to guess which mode is used,  because  the  re‐\nsponses are enough alike that only confusion would result.\n\nThe XM capability has a single parameter.  If nonzero, the mouse protocol should be en‐\nabled.  If zero, the mouse protocol should be disabled.  ncurses inspects this capabil‐\nity  if it is present, to see whether the 1006 protocol is used.  If so, it expects the\nresponses to use the SGR 1006 xterm mouse protocol.\n\nThe xterm mouse protocol is used by other terminal emulators.   The  terminal  database\nuses building-blocks for the various xterm mouse protocols which can be used in custom‐\nized terminal descriptions.\n\nThe terminal database building blocks for this mouse feature also have an  experimental\ncapability  xm.   The “xm” capability describes the mouse response.  Currently there is\nno interpreter which would use this information to make the  mouse  support  completely\ndata-driven.\n\nxm  shows  the format of the mouse responses.  In this experimental capability, the pa‐\nrameters are\n\np1   y-ordinate\n\np2   x-ordinate\n\np3   button\n\np4   state, e.g., pressed or released\n\np5   y-ordinate starting region\n\np6   x-ordinate starting region\n\np7   y-ordinate ending region\n\np8   x-ordinate ending region\n\nHere are examples from the terminal database for the most  commonly  used  xterm  mouse\nprotocols:\n\nxterm+x11mouse|X11 xterm mouse protocol,\nkmous=\\E[M, XM=\\E[?1000%?%p1%{1}%=%th%el%;,\nxm=\\E[M\n%?%p4%t%p3%e%{3}%;%' '%+%c\n%p2%'!'%+%c\n%p1%'!'%+%c,\n\nxterm+sm+1006|xterm SGR-mouse,\nkmous=\\E[<, XM=\\E[?1006;1000%?%p1%{1}%=%th%el%;,\nxm=\\E[<%i%p3%d;\n%p1%d;\n%p2%d;\n%?%p4%tM%em%;,\n\n#### Extended key-definitions\n\nSeveral  terminals  provide the ability to send distinct strings for combinations of modified\nspecial keys.  There is no standard for what those keys can send.\n\nSince 1999, xterm has supported shift, control, alt, and meta modifiers  which  produce  dis‐\ntinct  special-key  strings.   In a terminal description, ncurses has no special knowledge of\nthe modifiers used.  Applications can use the naming convention established for xterm to find\nthese special keys in the terminal description.\n\nStarting  with  the  curses convention that key names begin with “k” and that shifted special\nkeys are an uppercase name, ncurses' terminal database defines these names to which a  suffix\nis added:\n\nName   Description\n───────────────────────────────────────────────────────────────\nkDC    special form of kdch1 (delete character)\nkDN    special form of kcud1 (cursor down)\nkEND   special form of kend (End)\nkHOM   special form of khome (Home)\nkLFT   special form of kcub1 (cursor-left or cursor-back)\nkNXT   special form of knext (Next, or Page-Down)\nkPRV   special form of kprev (Prev, or Page-Up)\nkRIT   special form of kcuf1 (cursor-right, or cursor-forward)\nkUP    special form of kcuu1 (cursor-up)\n\nThese are the suffixes used to denote the modifiers:\n\nValue   Description\n──────────────────────────────────\n2       Shift\n3       Alt\n4       Shift + Alt\n5       Control\n6       Shift + Control\n7       Alt + Control\n8       Shift + Alt + Control\n9       Meta\n10      Meta + Shift\n11      Meta + Alt\n12      Meta + Alt + Shift\n13      Meta + Ctrl\n\n14      Meta + Ctrl + Shift\n15      Meta + Ctrl + Alt\n16      Meta + Ctrl + Alt + Shift\n\nNone of these are predefined; terminal descriptions can refer to names which ncurses will al‐\nlocate at runtime to key-codes.  To use these keys in  an  ncurses  program,  an  application\ncould do this:\n\n•   using a list of extended key names, ask tigetstr(3X) for their values, and\n\n•   given  the  list  of values, ask keydefined(3X) for the key-code which would be returned\nfor those keys by wgetch(3X).\n\n### PORTABILITY\n\nThe “-x” extension feature of tic and infocmp has been adopted in NetBSD curses.  That imple‐\nmentation stores user-defined capabilities, but makes no use of these capabilities itself.\n\n### SEE ALSO\n\ninfocmp(1), tic(1).\n\nThe  terminal  database  section NCURSES USER-DEFINABLE CAPABILITIES summarizes commonly-used\nuser-defined capabilities which are used in the terminal descriptions.  Some  of  those  fea‐\ntures are mentioned in screen(1) or tmux(1).\n\nXTerm  Control Sequences provides further information on the xterm features which are used in\nthese extended capabilities.\n\n### AUTHORS\n\nThomas E. Dickey\nbeginning with ncurses 5.0 (1999)\n\n\n\nusercaps(5)\n\n"
        }
    ],
    "structuredContent": {
        "command": "user_caps",
        "section": "5",
        "mode": "man",
        "summary": "usercaps - user-defined terminfo capabilities",
        "synopsis": "",
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "infocmp",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/infocmp/1/json"
            },
            {
                "name": "tic",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/tic/1/json"
            },
            {
                "name": "screen",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/screen/1/json"
            },
            {
                "name": "tmux",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/tmux/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "tic -x, infocmp -x",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "DESCRIPTION",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Background",
                        "lines": 100
                    },
                    {
                        "name": "Recognized capabilities",
                        "lines": 111
                    },
                    {
                        "name": "Extended key-definitions",
                        "lines": 54
                    }
                ]
            },
            {
                "name": "PORTABILITY",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 6,
                "subsections": []
            }
        ]
    }
}