{
    "mode": "man",
    "parameter": "user_caps",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/user_caps/5/json",
    "generated": "2026-10-07T14:06:27Z",
    "synopsis": "",
    "sections": {
        "NAME": {
            "content": "usercaps - user-defined terminfo capability format\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "",
            "subsections": [
                {
                    "name": "infocmp -x",
                    "content": ""
                },
                {
                    "name": "tic -x",
                    "content": ""
                }
            ]
        },
        "DESCRIPTION": {
            "content": "",
            "subsections": [
                {
                    "name": "Background",
                    "content": "Before  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(1).  The box1 capability is used in tic to help with ter‐\nminal descriptions 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\neverything 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(1)  to  provide\nextended 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"
                },
                {
                    "name": "Recognized Capabilities",
                    "content": "The 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\nNQ Boolean,  used  to  suppress a consistency check in tic for the ncurses capabilities in\nuser6 through user9 (u6, u7, u8 and u9) which tell how to query the  terminal's  cursor\nposition and its device attributes.\n\nRGB\nBoolean,  number  or  string,  used to assert that the setaforeground and setaback‐\nground capabilities correspond to direct colors, using an RGB (red/green/blue)  conven‐\ntion.   This  capability allows the colorcontent function to return appropriate values\nwithout requiring 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(3NCURSES).\n\nSet this capability to a nonzero value to enable it.\n\nXM string, override ncurses's built-in string which enables/disables xterm(1) 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\nnonzero.  By default, ncurses handles the responses for the X11 xterm  mouse  protocol.\nIt  also 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 cus‐\ntomized 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 para‐\nmeters 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"
                },
                {
                    "name": "Extended Key Definitions",
                    "content": "Several 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(1) 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 capability codes describing the input generated by a\nterminal's key caps begin with “k”, and that shifted special keys use  uppercase  letters  in\ntheir  names,  ncurses's  terminal  database defines the following names and codes to which a\nsuffix is added.\n\nCode   Description\n─────────────────────────────────────────────────────────────────────────────────────────\nkDC    shifted kdch1 (delete character)\nkDN    shifted kcud1 (cursor down)\nkEND   shifted kend (end)\nkHOM   shifted khome (home)\nkLFT   shifted kcub1 (cursor back)\nkNXT   shifted knext (next)\nkPRV   shifted kprev (previous)\nkRIT   shifted kcuf1 (cursor forward)\nkUP    shifted kcuu1 (cursor up)\n\nKeycap nomenclature on the Unix systems for which curses was developed differs  from  today's\nubiquitous  descendants of the IBM PC/AT keyboard layout.  In the foregoing, interpret “back‐\nward” as “left”, “forward” as “right”, “next” as “page down”, and “prev(ious)” as “page 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\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(3NCURSES) for their values, and\n\n•   given  the  list of values, ask keydefined(3NCURSES) for the key-code which would be re‐\nturned for those keys by wgetch(3NCURSES).\n"
                }
            ]
        },
        "PORTABILITY": {
            "content": "The “-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",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Thomas E. Dickey\nbeginning with ncurses 5.0 (1999)\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "infocmp(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(1) features that  are  used\nin these extended capabilities.\n\nncurses 6.4                                  2024-01-13                                 usercaps(5)",
            "subsections": []
        }
    },
    "summary": "usercaps - user-defined terminfo capability format",
    "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"
        },
        {
            "name": "xterm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/xterm/1/json"
        }
    ]
}