Terminal Control under QNX Dan Hildebrand Last revision: Nov 14, 1991, 12:40 pm Table of Contents 0. Introduction 1. The Terminfo Database 2. Terminfo source file format 3. Table of Terminfo and Termcap capability names 4. Description of Basic Capabilities 4.1 Miscellaneous Notes 4.2 Parameterized Strings 4.3 Cursor Motions 4.4 Area Clears 4.5 Insert / Delete Line 4.6 Insert / Delete Character 4.7 Highlighting, Underlining and Visible Bells 4.8 Terminal Keypad Control 4.9 Terminal Initialization 4.10 Line Graphics 4.11 Color Manipulation 4.12 Terminfo library routines 4.13 Environment Variables 4.14 Debugging terminfo applications 0. Introduction Fundamental to any terminal are a number of basic capabilities, such as line feed and carriage return. These basic capabilities are needed by just about any application which wishes to control a terminal. As terminals become more complex and full featured, the capabilities of the terminal also increase. Capabilities such as clearing the screen, positioning text to a particular screen location, changing colors or making the text blink are further examples. Application programmers would like to be able to write applications that make use of these various terminal capabilities. Unfortunately, in a computing environment containing terminals and consoles of varying capabilities, no single standard exists which all terminals adhere to. Instead, each manufacturer has defined a set of standards, with various products implementing sub-sets or super-sets of those standards. Programmers need to be able to utilize these capabilities without making their programs intimately aware of the capabilities of each different manufacturer's terminal or without requiring that the program be explicitly written for a particular terminal. Over the years, UNIX systems have evolved various program libraries and collections of data files to enable programs to achieve terminal independence. QNX provides many of these standard facilities while also providing some which are unique. With a database of terminal capabilities available for an application to query, applications can be designed to extract the capabilities they need for a given terminal. Applications can also check for the existance of more advanced capabilities and use them as well. For example, if the terminal has a "clear to end of line" capability, it would be much quicker for the application to use this rather than to try accomplish the same effect by outputting spaces to the end of each line. 1. The terminfo database At the root of terminal independence is the terminfo database. This is a collection of files that describe the capabilities of various terminals and how to invoke those capabilities. Information such as the number of rows and columns on the screen, whether or not an insert line capability exists and how it is invoked, etc are described in these files. With this database available, a collection of program libraries are available that allow application programs to request various effects on the terminal screen and those library routines will use the capabilities to implement the requested effect. For example, a program might request that a "clear to end of line" be performed and the routine charged with this function would have the duty of either outputting a sequence of spaces to accomplish this, or using a capability built into the terminal to accomplish this. From the perspective of the application, the operation is performed without needing to be concerned with the mechanics of exactly how the operation is performed on the terminal. The terminfo database consists of a collection of directories and files stored within the /usr/lib/terminfo directory. The contents of this directory is similar to the following: / | usr | lib | terminfo | | ----------------------------- | | |...| | a b c z terminfo.src <-- File containing full-text description of terminal ^ capabilities. | \------ Directories containing compiled terminfo files. Within /usr/lib/terminfo is a file called "terminfo.src" that contains the full text description of the terminal definitions in the system. This file is compiled with the "tic" utility ( see the utility reference for details on this process ) to produce the binary versions of the terminal definitions. The compiled, binary definitions are stored in subdirectories that start with the first letter of the terminal name. For example, the qnx terminal definition, when compiled, creates a file stored as /usr/lib/terminfo/q/qnx. In a similar manner, the vt100 definition is stored in /usr/lib/terminfo/v/vt100. Synonyms described in the textual description or a terminal are stored as links to the primary definition. This two level directory structure allows applications to be able to quickly locate a terminal definition. The compiled nature of these definitions also allows them to be quickly loaded and processed. At startup, an application usually calls setupterm() ( or another routine such as term_load(), which then calls setupterm() ) to load the terminfo capability data for the terminal named in the TERM environment variable. The format of the data in these binary files is system-indepedant. As a result, binary terminfo files can be moved between QNX and UNIX systems without recompilation and will work as is. If necessary, the "infocmp" utility can be used to convert a binary terminal definition back into a textual form that can be edited and recompiled with "tic" into a new binary definition. An older approach to describing terminal capabilities is called 'termcap'. Systems using termcap definitions store them within a '/etc/termcap' file in a form somewhat similar to the text in the /usr/lib/terminfo/terminfo.src file. If it is necessary to convert from terminfo to termcap, the "infocmp" utility has a '-C' option which will cause it to generate a termcap entry from an existing terminfo definition. Use of this option allows the system to maintain a master "terminfo" database from which termcap definitions can be generated as required by older applications. Capabilities within a termcap definition are defined with a two character name, and those names are presented within the tables in this technical note as a reference to readers familiar with termcap. 2. Terminfo source file format To prepare a terminfo terminal description, it is usually best to start with the definition of a similar terminal and modify it as necessary. The "tic" and "infocmp" utilities are the tools used to manipulate terminal definition files and the compiled, binary versions ( see the utility reference for details on the "tic" and "infocmp" utilities ). The "tic" utility is used to compile the file into the binary format used by the terminfo library routines and the "infocmp" utility is used to reverse this process to regenerate the textual description in a form suitable for editing. For example, the command "infocmp qnx" would generate the text which follows from the binary, compiled description of the qnx terminal stored in /usr/lib/terminfo/q/qnx. # qnx qnx|qnxt|qnx4|qnxt4|qnx console, km, mir, msgr, xt, cols#80, it#4, lines#25, colors#8, pairs#8, ncv#3, bel=^g, cr=\r, clear=\EH\EJ, el=\EK, ed=\EJ, cup=\EY%p1%' '%+%c%p2%' '%+%c, cud1=\l, home=\EH, civis=\Ey0, cub1=\b, cnorm=\Ey1, cuf1=\EC, cuu1=\EA, cvvis=\Ey2, dch1=\Ef, dl1=\EF, blink=\E{, bold=\E<, smcup=\Ei, rev=\E(, smso=\E<, smul=\E[, sgr0=\E}\E]\E>\E), rmcup=\Eh\ER, rmso=\E>, rmul=\E], ich1=\Ee, il1=\EE, ktbc=\377\344, kclr=\377\341, kctab=\377\237, kdch1=\377\254, kdl1=\377\274, kcud1=\377\251, krmir=\377\313, kel=\377\310, ked=\377\314, kf1=\377\201, kf10=\377\212, kf2=\377\202, kf3=\377\203, kf4=\377\204, kf5=\377\205, kf6=\377\206, kf7=\377\207, kf8=\377\210, kf9=\377\211, khome=\377\240, kich1=\377\253, kil1=\377\273, kcub1=\377\244, knp=\377\252, kpp=\377\242, kcuf1=\377\246, kind=\377\261, kri=\377\271, khts=\377\342, kcuu1=\377\241, rep=\Eg%p2%' '%+%c%p1%c, rs1=\ER, ind=\l, ri=\EI, sgr=%?%p1%t\E<%;%p2%t\E[%;%p3%t\E(%;%p4%t\E{%;%p6%t\E<%;, ht=\t, acsc=l\332m\300k\277j\331q\304x\263u\264t\303n\305v\301w\302O\333a\262o\337s\334, kcbt=\377\200, kbeg=\377\300, kcan=\377\243, kclo=\377\343, kcmd=\377\245, kcpy=\377\265, kcrt=\377\305, kend=\377\250, kent=\377\320, kext=\377\270, kfnd=\377\346, khlp=\377\350, kmrk=\377\355, kmsg=\377\345, kmov=\377\351, knxt=\377\312, kopn=\377\357, kopt=\377\353, kprv=\377\302, kprt=\377\255, krdo=\377\336, kref=\377\354, krfr=\377\347, krpl=\377\362, krst=\377\352, kres=\377\360, ksav=\377\361, kund=\377\365, kBEG=\377\356, kCAN=\377\263, kCMD=\377\267, kCPY=\377\363, kCRT=\377\364, kDL=\377\366, kslt=\377\247, kEND=\377\301, kEOL=\377\311, kEXT=\377\367, kFND=\377\370, kHLP=\377\371, kHOM=\377\260, kIC=\377\340, kLFT=\377\264, kMSG=\377\304, kMOV=\377\306, kNXT=\377\272, kOPT=\377\372, kPRV=\377\262, kPRT=\377\275, kRDO=\377\315, kRIT=\377\266, kSAV=\377\307, kSPD=\377\303, kf11=\377\256, kf12=\377\257, kf13=\377\213, kf14=\377\214, kf15=\377\215, kf16=\377\216, kf17=\377\217, kf18=\377\220, kf19=\377\221, kf20=\377\222, kf21=\377\223, kf22=\377\224, kf23=\377\333, kf24=\377\334, kf25=\377\225, kf26=\377\226, kf27=\377\227, kf28=\377\230, kf29=\377\231, kf30=\377\232, kf31=\377\233, kf32=\377\234, kf33=\377\235, kf34=\377\236, kf35=\377\276, kf36=\377\277, kf37=\377\321, kf38=\377\322, kf39=\377\323, kf40=\377\324, kf41=\377\325, kf42=\377\326, kf43=\377\327, kf44=\377\330, kf45=\377\331, kf46=\377\332, kf47=\377\316, kf48=\377\317, op=\ER, scp=\E@%p1%02d, The format of this text consists of a sequence of lines, with each entry ending in a comma. Lines starting with '#' are treated as comment lines and the first line not beginning with a '#' contains the names of the terminals defined by this definition. The first name should be the most common name for the terminal, and the following names should be commonly understood synonyms for the terminal. Each name is ended with a '|' character and the last name on the line should be the full text of the terminal name. When "tic" is compiling the terminfo definition, the compiled output will be placed in a file named by the first terminal name and the following terminal names ( other than the last ) will be linked ( see the ln utility ) to the first output file. Only the final, full text name may exceed 14 characters in length and may contain spaces. All the other names must be unique in the first 14 characters and not contain spaces. The 14 character name length limitation is for historical reasons. There are various conventions used for choosing terminal names. When defining a terminal type which is a simple variation of another terminal, it should be named with the same terminal type, followed by a hypen, and some text indicating what is different about it. For example, a monochrome QNX terminal could be named qnx-mono. The lines following the declaration of the terminal name have either a tab of a space as the first character on the line and consist of a three types of information. These types are: boolean - A variable either true or false indicating that the terminal does or does not exhibit that capability. For example, the presence of the capability name 'am' indicates that the terminal performs an "auto margin", meaning that the terminal will automatically position the cursor to the next line's left margin when written to with the cursor already positioned to the right-most column. The absence of the boolean capability name in the description indicates that the terminal does not have that capability. integer - A numeric quantity specifying details like the number of rows or columns. For example, an 80 column the terminal would be expressed as cols#80. Values for these numeric quantities can be expressed, using conventional C syntax, in decimal, octal or hexadecimal. string - A character sequence describing the characters that must be sent by the application to the terminal to invoke the capability. These sequences can be quite complex, as the syntax implements an RPN interpreter. Definition of string capabilities takes the form of a two to five character capability name followed by an '=' character and a string representing the definition of that capability. The string is terminated by a comma. All the strings defined in these tables may have padding specified, except for those strings which define keyboard input sequences. Input key sequences are part of the string section of the definition and all begin with the letter 'k'. See section (3) of this document for the list of capability names available to define a terminfo terminal description file. Within the definition of a string capability, various characters have special meanings. 1) Padding for processing delays imposed by the terminal may be expressed anywhere in the definition string in the form $<..> where the ".." within the brackets is replaced with a number representing the required delay in milliseconds. For example, the declaration "clear=\EH\EJ$<5>" would indicate that a delay of 5 milliseconds was required after issuing the escape sequence to allow the terminal to execute the requested clear screen operation. Typically, padding is generated by inserting null's into the data stream, since computationally generated delays would not have the desired effect if the data stream was passed through communication devices with their own buffereing characteristics. Padding characters are generated by the tputs() routine when it processes the capability on its way to the terminal, so this routine should always be used for output to the terminal. The numeric expression of the delay can be any of the following: a simple integer, an integer followed by an '*' character, an integer followed by a '/' character, or an integer followed by both a '*' and a '/'. The '*' indicates that the delay required is proportional to the number of lines effected by the operation. When 'xon' is defined padding will not be expanded by the tputs() routine. Padding defined with a '/' character is taken to be mandatory, and honored even if xon is defined. 2) The '\' character is used as an 'escape' character to indicate that the next character in the string has special meaning. Some of the special meanings for the character pairs formed with the '\' are: \b = backspace ( 0x08 ) \e = escape ( 0x1b ) \E = escape ( 0x1b ) \f = formfeed ( 0x0c ) \l = line feed ( 0x0a ) \n = newline ( 0x0a ) \r = carriage return ( 0x0d ) \s = space ( 0x20 ) \t = tab ( 0x09 ) \; = semi-colon ( ';' ) \, = comma ( ',' ) \: = colon ( ':' ) \^ = caret ( '^' ) \\ = backslash ( '\' ) \0 = null ( 0x00 ) \xxx = Where 'xxx' is an octal number defines that value 3) A trailing '@' on a capability name means that capability does not exist. 4) A leading period ( '.') on a capability name acts as if that capability name was "commented out". When creating a new terminal definition, much effort can be saved by describing the new terminal in terms of how it differs from an existing terminal. The "tic" utility supports a "use=terminal_name" syntax that allows the description of a terminal to be expressed in terms of how it differs from an existing definition. Any declarations expressed before the "use=terminal_name" take precedence over those extracted from the specified "terminal_name". Multiple "use=" declarations can be used within a single terminal definition. For example, the vt102 terminal differs only slightly from the vt100, so the definition of a vt102 can be expressed as: # # vt102 - adds insert/delete line, delete character # vt102|vt102-am|dec vt102 (with advanced video), dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, il=\E[%p1%dL, il1=\E[L, use=vt100, Another feature is that the '@' character can be appended to a declared capability name to indicate that the capability should be removed from the definition. For example, a QNX terminal that did not have "clear to end of line" could be defined as: qnx-noeol|qnx w/o clear to end of line, el@, use=qnx, The combination of the "use=terminal_name" facility and the ability to disable portions of a definition enables the easy creation of terminal types 3. Table of Terminfo and Termcap capability names In the tables which follow, a Variable name is the name by which a C programmer accesses a capability directly within a C program. A Capname is the name used for the capability within a terminfo description ( as generated by "infocmp" ). A Termcap code is the capability name that would be used to refer to the capability using the older "termcap" facility for terminal control. The tables are sorted first by Variable name, as they would appear in a C program, and secondly by terminfo capability name, as the names would be used in a terminfo definition file. Appended to each description may appear the following abbreviations: (G) indicates that the capability string should be passed through the tparm() library routine to have parameter instantiated within the string. (*) indicates that padding may be based on the number of lines effected on the output device by the capability. (#i) where i is a numeric value indicates the i'th parameter. Boolean Capabilities ( Sorted by Variable Name ) Cap- Term- Variable name name cap Description auto_left_margin bw bw Backspace wraps from column 0 to last column auto_right_margin am am Terminal has automatic margins back_color_erase bce be Screen erased with background color can_change ccc cc Terminal can re-define existing color ceol_standout_glitch xhp xs Standout not erased by overwriting (hp) col_addr_glitch xhpa YA Only positive motion for hpa/mhpa caps cpi_changes_res cpix YF Changing character pitch changes resolution cr_cancels_micro_mode crxm YB Using cr turns off micro mode dest_tabs_magic_smso xt xt Destructive tabs, magic smso char (t1061) eat_newline_glitch xenl xn Newline ignored after 80 columns (Concept) erase_overstrike eo eo Can erase overstrikes with a blank generic_type gn gn Generic line type (e.g., dialup, switch) hard_copy hc hc Hardcopy terminal hard_cursor chts HC Cursor is hard to see has_meta_key km km Has a meta key (shift, sets parity bit) has_print_wheel daisy YC Printer needs operator to change character set has_status_line hs hs Has extra "status line" hue_lightness_saturation hls hl Terminal uses only HLS color notation (Tektronic) insert_null_glitch in in Insert mode distinguishes nulls lpi_changes_res lpix YG Changing line pitch changes resolution memory_above da da Display may be retained above the screen memory_below db db Display may be retained below the screen move_insert_mode mir mi Safe to move while in insert mode move_standout_mode msgr ms Safe to move in standout modes needs_xon_xoff nxon nx Padding won't work,xon/woff required no_esc_ctlc xsb xb Beehive (f1=escape, f2=ctrl C) no_pad_char npc NP Pad character doesn't exist non_dest_scroll_region ndscr ND Scrolling region is non-destructive non_rev_rmcup nrrmc NR smcup does not reverse rmcup over_strike os os Terminal overstrikes on hard-copy terminal prtr_silent mc5i 5i Printer won't echo on screen row_addr_glitch xvpa YD Only positive motion for vpa/mvpa caps semi_auto_right_margin sam YE Printing in last column causes cr, not lf status_line_esc_ok eslok es Escape can be used on the status line tilde_glitch hz hz Hazeltine; can't print tilde (~) transparent_underline ul ul Underline character overstrikes xon_xoff xon xo Terminal uses xon/xoff handshaking Numeric Capabilities ( Sorted by Variable Name ) Cap- Term- Variable name name cap buffer_capacity bufsz Ya Number of bytes buffered before printing columns cols co Number of columns in a line dot_horz_spacing spinh Yc Spacing of dots horizontally in dots per inch dot_vert_spacing spinv Yb Spacing of pins vertically in pins per inch init_tabs it it Tabs initially every # spaces label_height lh lh Number of rows in each label label_width lw lw Number of columns in each label lines lines li Number of lines on a screen or a page lines_of_memory lm lm Lines of memory if > lines; 0 means varies magic_cookie_glitch xmc sg Number of blank characters left by smso or rmso max_attributes ma ma Maximum combined video attributes terminal can display max_colors colors Co Maximum number of colors on the screen max_micro_address maddr Yd Maximum value in micro_..._address max_micro_jump mjump Ye Maximum value in parm_..._address max_pairs pairs pa Maximum number of color-pairs on the screen maximum_windows wnum MW Maximum number of definable windows micro_char_size mcs Yf Character step size when in micro mode micro_line_size mls Yg Line step size when in micro mode no_color_video ncv NC Video attributes that can't be used with colors num_labels nlab Nl Number of labels on screen (start at 1) number_of_pins npins Yh Number of pins in print- head output_res_char orc Yi Horizontal resolution in units per character output_res_horz_inch orhi Yk Horizontal resolution in units per inch output_res_line orl Yj Vertical resolution in units per line output_res_vert_inch orvi Yl Vertical resolution in units per inch padding_baud_rate pb pb Lowest baud rate where padding needed print_rate cps Ym Print rate in characters per second virtual_terminal vt vt Virtual terminal number (UNIX system) wide_char_size widcs Yn Character step size when in double wide mode width_status_line wsl ws Number of columns in status line String Capabilities ( Sorted by Variable Name ) Cap- Term- Variable name name cap acs_chars acsc ac Graphic charset pairs aAbBcC - def=vt100 back_tab cbt bt Back tab bell bel bl Audible signal (bell) carriage_return cr cr Carriage return (*) change_char_pitch cpi ZA Change number of characters per inch (dg change_line_pitch lpi ZB Change number of lines per inch (dg change_res_horz chr ZC Change horizontal resolution (dg change_res_vert cvr ZD Change vertical resolution (dg change_scroll_region csr cs Change to lines #1 through #2 (vt100)(G) char_padding rmp rP Like ip but when in replace mode char_set_names csnm Zy List of character set names clear_all_tabs tbc ct Clear all tab stops clear_margins mgc MC Clear all margins (top, bottom, and sides) clear_screen clear cl Clear screen and home cursor (*) clr_bol el1 cb Clear to beginning of line, inclusive clr_eol el ce Clear to end of line clr_eos ed cd Clear to end of display (*) column_address hpa ch Horizontal position absolute (G) command_character cmdch CC Terminal settable cmd character in prototype create_window cwin CW Define win #1 to go from #2,#3 to #4,#5 cursor_address cup cm Move to row #1 col #2 (G) cursor_down cud1 do Down one line cursor_home home ho Home cursor (if no cup) cursor_invisible civis vi Make cursor invisible cursor_left cub1 le Move left one space cursor_mem_address mrcup CM Memory relative cursor addressing (G) cursor_normal cnorm ve Make cursor appear normal (undo vs/vi) cursor_right cuf1 nd Non-destructive space (cursor or carriage right) cursor_to_ll ll ll Last line, first column (if no cup) cursor_up cuu1 up Upline (cursor up) cursor_visible cvvis vs Make cursor very visible define_char defc ZE Define a character in a character set [dagger +] delete_character dch1 dc Delete a character (*) delete_line dl1 dl Delete line (*) dial_phone dial DI Dial phone number #1 dis_status_line dsl ds Disable status line display_clock dclk DK Display time-of-day clock down_half_line hd hd Half-line down (forward 1/2 linefeed) ena_acs enacs eA Enable alternate character set enter_alt_charset_mode smacs as Start alternate character set enter_am_mode smam SA Turn on automatic margins enter_blink_mode blink mb Turn on blinking enter_bold_mode bold md Turn on bold (extra bright) mode enter_ca_mode smcup ti String to begin programs that use cup enter_delete_mode smdc dm Delete mode (enter) enter_dim_mode dim mh Turn on half-bright mode enter_doublewide_mode swidm ZF Enable double wide printing enter_draft_quality sdrfq ZG Set draft quality print enter_insert_mode smir im Insert mode (enter) enter_italics_mode sitm ZH Enable italics enter_leftward_mode slm ZI Enable leftward carriage motion enter_micro_mode smicm ZJ Enable micro motion capabilities enter_near_letter_quality snlq ZK Set near-letter quality print enter_normal_quality snrmq ZL Set normal quality print enter_protected_mode prot mp Turn on protected mode enter_reverse_mode rev mr Turn on reverse video mode enter_secure_mode invis mk Turn on blank mode (character invisible) enter_shadow_mode sshm ZM Enable shadow printing enter_standout_mode smso so Begin standout mode enter_subscript_mode ssubm ZN Enable subscript printing enter_superscript_mode ssupm ZO Enable superscript printing enter_underline_mode smul us Start underscore mode enter_upward_mode sum ZP Enable upward carriage motion enter_xon_mode smxon SX Turn on xon/xoff handshaking erase_chars ech ec Erase #1 characters (G) exit_alt_charset_mode rmacs ae End alternate character set exit_am_mode rmam RA Turn off automatic margins exit_attribute_mode sgr0 me Turn off all attributes exit_ca_mode rmcup te String to end programs that use cup exit_delete_mode rmdc ed End delete mode exit_doublewide_mode rwidm ZQ Disable double wide printing exit_insert_mode rmir ei End insert mode exit_italics_mode ritm ZR Disable italics exit_leftward_mode rlm ZS Enable rightward (normal) carriage motion exit_micro_mode rmicm ZT Disable micro motion capabilities exit_shadow_mode rshm ZU Disable shadow printing exit_standout_mode rmso se End standout mode exit_subscript_mode rsubm ZV Disable subscript printing exit_superscript_mode rsupm ZW Disable superscript printing exit_underline_mode rmul ue End underscore mode exit_upward_mode rum ZX Enable downward (normal) carriage motion exit_xon_mode rmxon RX Turn off xon/xoff handshaking fixed_pause pause PA Pause for 2-3 seconds flash_hook hook fh Flash the switch hook flash_screen flash vb Visible bell (may not move cursor) form_feed ff ff Hardcopy terminal page eject (*) from_status_line fsl fs Return from status line goto_window wingo WG Go to window #1 hangup hup HU Hang-up phone init_1string is1 i1 Terminal or printer initialization string init_2string is2 is Terminal or printer initialization string init_3string is3 i3 Terminal or printer initialization string init_file if if Name of initialization file init_prog iprog iP Path name of program for initialization initialize_color initc Ic Initialize the definition of color initialize_pair initp Ip Initialize color-pair insert_character ich1 ic Insert character insert_line il1 al Add new blank line (*) insert_padding ip ip Insert pad after character inserted (*) keypad_local rmkx ke Out of "keypad-transmit" mode keypad_xmit smkx ks Put terminal in "keypad-transmit" mode lab_f0 lf0 l0 Labels on function key f0 if not f0 lab_f1 lf1 l1 Labels on function key f1 if not f1 lab_f2 lf2 l2 Labels on function key f2 if not f2 lab_f3 lf3 l3 Labels on function key f3 if not f3 lab_f4 lf4 l4 Labels on function key f4 if not f4 lab_f5 lf5 l5 Labels on function key f5 if not f5 lab_f6 lf6 l6 Labels on function key f6 if not f6 lab_f7 lf7 l7 Labels on function key f7 if not f7 lab_f8 lf8 l8 Labels on function key f8 if not f8 lab_f9 lf9 l9 Labels on function key f9 if not f9 lab_f10 lf10 la Labels on function key f10 if not f10 label_format fln Lf Label format label_off rmln LF Turn off soft labels label_on smln LO Turn of soft labels meta_off rmm mo Turn off "meta mode" meta_on smm mm Turn on "meta mode" (8th bit) micro_column_address mhpa ZY Like column_address for micro adjustment (+dagger) micro_down mcud1 ZZ Like cursor_down for micro adjustment micro_left mcub1 Za Like cursor_left for micro adjustment micro_right mcuf1 Zb Like cursor_right for micro adjustment micro_row_address mvpa Zc Like row_address for micro adjustment micro_up mcuu1 Zd Like cursor_up for micro adjustment newline nel nw Newline (behaves like cr followed by lf) order_of_pins porder Ze Matches software bits to print-head pins orig_colors oc oc Set all color (-pair)s to the original ones orig_pair op op Set default color-pair to the original one pad_char pad pc Pad character (rather than null) parm_dch dch DC Delete #1 chars (G*) parm_delete_line dl DL Delete #1 lines (G*) parm_down_cursor cud DO Move down #1 lines (G*) parm_down_micro mcud Zf Like parm_down_cursor for micro adjust (G*)_ parm_ich ich IC Insert #1 blank chars (G*) parm_index indn SF Scroll forward #1 lines (G*) parm_insert_line il AL Add #1 new blank lines (G*) parm_left_cursor cub LE Move cursor left #1 spaces (G) parm_left_micro mcub Zg Like parm_left_cursor for micro adjust (+dagger) parm_right_cursor cuf RI Move right #1 spaces (G*) parm_right_micro mcuf Zh Like parm_right_cursor for micro adjust (+dagger) parm_rindex rin SR Scroll backward #1 lines (G) parm_up_cursor cuu UP Move cursor up #1 lines (G*) parm_up_micro mcuu Zi Like parm_up_cursor for micro adjust (+dagger) pkey_key pfkey pk Prog funct key #1 to type string #2 pkey_local pfloc pl Prog funct key #1 to execute string #2 pkey_xmit pfx px Prog funct key #1 to xmit string #2 plab_norm pln pn Prog label #1 to show string #2 print_screen mc0 ps Print contents of the screen prtr_non mc5p pO Turn on the printer for #1 bytes prtr_off mc4 pf Turn off the printer prtr_on mc5 po Turn on the printer pulse pulse PU Select pulse dialing quick_dial qdial QD Dial phone number #1, without progress detection remove_clock rmclk RC Remove time-of-day clock repeat_char rep rp Repeat char #1 #2 times (G*) req_for_input rfi RF Send next input char (for ptys) reset_1string rs1 r1 Reset terminal completely to sane modes reset_2string rs2 r2 Reset terminal completely to sane modes reset_3string rs3 r3 Reset terminal completely to sane modes reset_file rf rf Name of file containing reset string restore_cursor rc rc Restore cursor to position of the last sc row_address vpa cv Vertical position absolute (G) save_cursor sc sc Save cursor position scroll_forward ind sf Scroll text up scroll_reverse ri sr Scroll text down select_char_set scs Zj Select character set (+dagger) set_attributes sgr sa Define the video attributes (G) #1-#9 set_background setb Sb Set current background color set_bottom_margin smgb Zk Set bottom margin at current line set_bottom_margin_parm smgbp Zl Set bottom margin at line #1 (+dagger) set_clock sclk SC Set time-of-day clock set_color_pair scp sp Set current color-pair set_foreground setf Sf Set current foreground color1 set_left_margin smgl ML Set left margin at current line set_left_margin_parm smglp Zm Set left margin at column #1 (+dagger) set_right_margin smgr MR Set right margin at current column set_right_margin_parm smgrp Zn Set right margin at column #1 (+dagger) set_tab hts st Set a tab in all rows, current column set_top_margin smgt Zo Set top margin at current line set_top_margin_parm smgtp Zp Set top margin at line #1 (+dagger) set_window wind wi Current window is lines #1-#2 cols #3-#4 (G) start_bit_image sbim Zq Start printing bit image graphics (+dagger) start_char_set_def scsd Zr Start definition of a character set (+dagger) stop_bit_image rbim Zs End printing bit image graphics stop_char_set_def rcsd Zt End definition of a character set subscript_characters subcs Zu List of "subscript-able" characters superscript_characters supcs Zv List of "superscript-able" characters tab ht ta Tab to next 8-space hardware tab stop these_cause_cr docr Zw Printing any of these cahr causes cr to_status_line tsl ts Go to status line, col #1 (G) tone tone TO Select touch tone dialing underline_char uc uc Underscore one char and move past it up_half_line hu hu Half-line up (reverse 1/2 linefeed) user0 u0 u0 User string 0 user1 u1 u1 User string 1 user2 u2 u2 User string 4 user3 u3 u3 User string 3 user4 u4 u4 User string 4 user5 u5 u5 User string 5 user6 u6 u6 User string 6 user7 u7 u7 User string 7 user8 u8 u8 User string 8 user9 u9 u9 User string 9 wait_tone wait WA Wait for dial tone xoff_character xoffc XF X-off character xon_character xonc XN X-on character zero_motion zerom Zx No motion for the subsequent character Key Definitions ( Sorted by Variable Name ) Cap- Term- Variable name name cap key_a1 ka1 K1 KEY_A1, 0534, upper left of keypad key_a3 ka3 K3 KEY_A3, 0535, upper right of keypad key_b2 kb2 K2 KEY_B2, 0536, center of keypad key_backspace kbs kb KEY_BACKSPACE, 0407, sent by backspace key key_beg kbeg @1 KEY_BEG, 05042, sent by beg(inning) key key_btab kcbt kB KEY_BTAB. 0541, sent by back-tab key key_c1 kc1 K4 KEY_C1, 0537, lower left of keypad key_c3 kc3 K5 KEY_C3, 0540, lower right of keypad key_cancel kcan @2 KEY_CANCEL, 0543, sent by cancel key key_catab ktbc ka KEY_CATAB, 0526, sent by clear-all tabs key key_clear kclr kC KEY_CLEAR, 0515, sent by clear-screen or erase key key_close kclo @3 KEY_CLOSE, 0544, sent by close key key_command kcmd @4 KEY_COMMAND, 0545, sent by cmd (command) key key_copy kcpy @5 KEY_COPY, 0546, sent by copy key key_create kcrt @6 KEY_CREATE, 0547, sent by create key key_ctab kctab kt KEY_CTAB, 0525, sent by clear-tab key key_dc kdch1 kD KEY_DC, 0512, sent by delete-character key key_dl kdl1 kL KEY_DL, 0510, sent by delete-line key key_down kcud1 kd KEY_DOWN, 0402, sent by terminal down-arrow key key_eic krmir kM KEY_EIC, 0514, sent by rmir or smir in insert mode key_end kend @7 KEY_END, 0550, sent by end key key_enter kent @8 KEY_ENTER, 0527, sent by enter/send key key_eol kel kE KEY_EOL, 0517, sent by clear-to-end-of-line key key_eos ked kS KEY_EOS, 0516, sent by clear-to-end-of-screen key key_exit kext @9 KEY_EXIT, 0551, sent by exist key key_f0 kf0 k0 KEY_F(0), 0410, sent by function key f0 key_f1 kf1 k1 KEY_F(1), 0411, sent by function key f1 key_f2 kf2 k2 KEY_F(2), 0412, sent by function key f2 key_f3 kf3 k3 KEY_F(3), 0413, sent by function key f3 key_f4 kf4 k4 KEY_F(4), 0414, sent by function key f4 key_f5 kf5 k5 KEY_F(5), 0415, sent by function key f5 key_f6 kf6 k6 KEY_F(6), 0416, sent by function key f6 key_f7 kf7 k7 KEY_F(7), 0417, sent by function key f7 key_f8 kf8 k8 KEY_F(8), 0420, sent by function key f8 key_f9 kf9 k9 KEY_F(9), 0421, sent by function key f9 key_f10 kf10 k; KEY_F(10), 0422, sent by function key f10 key_f11 kf11 F1 KEY_F(11), 0423, sent by function key f11 key_f12 kf12 F2 KEY_F(12), 0424, sent by function key f12 key_f13 kf13 F3 KEY_F(13), 0425, sent by function key f13 key_f14 kf14 F4 KEY_F(14), 0426, sent by function key f14 key_f15 kf15 F5 KEY_F(15), 0427, sent by function key f15 key_f16 kf16 F6 KEY_F(16), 0430, sent by function key f16 key_f17 kf17 F7 KEY_F(17), 0431, sent by function key f17 key_f18 kf18 F8 KEY_F(18), 0432, sent by function key f18 key_f19 kf19 F9 KEY_F(19), 0433, sent by function key f19 key_f20 kf20 FA KEY_F(20), 0434, sent by function key f20 key_f21 kf21 FB KEY_F(21), 0435, sent by function key f21 key_f22 kf22 FC KEY_F(22), 0436, sent by function key f22 key_f23 kf23 FD KEY_F(23), 0437, sent by function key f23 key_f24 kf24 FE KEY_F(24), 0440, sent by function key f24 key_f25 kf25 FF KEY_F(25), 0441, sent by function key f25 key_f26 kf26 FG KEY_F(26), 0442, sent by function key f26 key_f27 kf27 FH KEY_F(27), 0443, sent by function key f27 key_f28 kf28 FI KEY_F(28), 0444, sent by function key f28 key_f29 kf29 FJ KEY_F(29), 0445, sent by function key f29 key_f30 kf30 FK KEY_F(30), 0446, sent by function key f30 key_f31 kf31 FL KEY_F(31), 0447, sent by function key f31 key_f32 kf32 FM KEY_F(32), 0450, sent by function key f32 key_f33 kf33 FN KEY_F(13), 0451, sent by function key f13 key_f34 kf34 FO KEY_F(34), 0452, sent by function key f34 key_f35 kf35 FP KEY_F(35), 0453, sent by function key f35 key_f36 kf36 FQ KEY_F(36), 0454, sent by function key f36 key_f37 kf37 FR KEY_F(37), 0455, sent by function key f37 key_f38 kf38 FS KEY_F(38), 0456, sent by function key f38 key_f39 kf39 FT KEY_F(39), 0457, sent by function key f39 key_f40 kf40 FU KEY_F(40), 0460, sent by function key f40 key_f41 kf41 FV KEY_F(41), 0461, sent by function key f41 key_f42 kf42 FW KEY_F(42), 0462, sent by function key f42 key_f43 kf43 FX KEY_F(43), 0463, sent by function key f43 key_f44 kf44 FY KEY_F(44), 0464, sent by function key f44 key_f45 kf45 FZ KEY_F(45), 0465, sent by function key f45 key_f46 kf46 Fa KEY_F(46), 0466, sent by function key f46 key_f47 kf47 Fb KEY_F(47), 0467, sent by function key f47 key_f48 kf48 Fc KEY_F(48), 0470, sent by function key f48 key_f49 kf49 Fd KEY_F(49), 0471, sent by function key f49 key_f50 kf50 Fe KEY_F(50), 0472, sent by function key f50 key_f51 kf51 Ff KEY_F(51), 0473, sent by function key f51 key_f52 kf52 Fg KEY_F(52), 0474, sent by function key f52 key_f53 kf53 Fh KEY_F(53), 0475, sent by function key f53 key_f54 kf54 Fi KEY_F(54), 0476, sent by function key f54 key_f55 kf55 Fj KEY_F(55), 0477, sent by function key f55 key_f56 kf56 Fk KEY_F(56), 0500, sent by function key f56 key_f57 kf57 Fl KEY_F(57), 0501, sent by function key f57 key_f58 kf58 Fm KEY_F(58), 0502, sent by function key f58 key_f59 kf59 Fn KEY_F(59), 0503, sent by function key f59 key_f60 kf60 Fo KEY_F(60), 0504, sent by function key f60 key_f61 kf61 Fp KEY_F(61), 0505, sent by function key f61 key_f62 kf62 Fq KEY_F(62), 0506, sent by function key f62 key_f63 kf63 Fr KEY_F(63), 0507, sent by function key f63 key_find kfnd @0 KEY_FIND, 0552, sent by find key key_help khlp %1 KEY_HELP, 0553, sent by help key key_home khome kh KEY_HOME, 0406, sent by home key key_ic kich1 kI KEY_IC, 0513, sent by ins-char/enter ins-mode key key_il kil1 kA KEY_IL, 0511, sent by insert-line key key_left kcub1 kl KEY_LEFT, 0404, sent by terminal left-arrow key key_ll kll kH KEY_LL, 0533, sent by home-down key key_mark kmrk %2 KEY_MARK, 0554, sent by mark key key_message kmsg %3 KEY_MESSAGE, 0555, sent by message key key_move kmov %4 KEY_MOVE,0556, sent by move key key_next knxt %5 KEY_NEXT, 0557, sent by next-object key key_npage knp kN KEY_NPAGE, 0522, sent by next-page key key_open kopn %6 KEY_OPEN, 0560, sent by open key key_options kopt %7 KEY_OPTIONS, 0561, sent by options key key_ppage kpp kP KEY_PPAGE, 0523, sent by previous-page key key_previous kprv %8 KEY_PREVIOUS, 0562, sent by previous-object key key_print kprt %9 KEY_PRINT, 0532, sent by print or copy key key_redo krdo %0 KEY_REDO, 0563, sent by redo key key_reference kref &1 KEY_REFERENCE, 0564, sent by ref(erence) key key_refresh krfr &2 KEY_REFRESH, 0565, sent by refresh key key_replace krpl &3 KEY_REPLACE, 0566, sent by replace key key_restart krst &4 KEY_RESTART, 0567, sent by restart key key_resume kres &5 KEY_RESUME, 0570, sent by resume key key_right kcuf1 kr KEY_RIGHT, 0405, sent by terminal right-arrow key key_save ksav &6 KEY_SAVE, 0571, sent by save key key_sbeg kBEG &9 KEY_SBEG, 0572, sent by shifted beginning key key_scancel kCAN &0 KEY_SCANCEL. 0573, sent by shifted cancel key key_scommand kCMD *1 KEY_SCOMMAND, 0574, sent by shifted command key key_scopy kCPY *2 KEY_SCOPY, 0575, sent by shifted copy key key_screate kCRT *3 KEY_SCREATE, 0576, sent by shifted create key Key_sdc kDC *4 KEY_SDC, 0577, sent by shifted delete-char key key_sdl kDL *5 KEY_SDL, 0600, sent by delete-line key key_select kslt *6 KEY_SELECT, 0601, sent by select key key_send kEND *7 KEY_SEND, 0602, sent by shifted end key key_seol kEOL *8 KEY_SEOL, 0603, sent by shifted clear-line key key_sexit kEXT *9 KEY_SEXIT, 0604, sent by shifted exit key key_sf kind kF KEY_SF, 0520, sent by scroll-forward/down key key_sfind kFND *0 KEY_SFIND, 0605, sent by shifted find key key_shelp kHLP #1 KEY_SHELP, 0606, sent by shifted help key key_shome kHOM #2 KEY_SHOME, 0607, sent by shifted home key key_sic kIC #3 KEY_SIC, 0610, sent by shifted input key key_sleft kLFT #4 KEY_SLEFT, 0611, sent by shifted left-arrow key key_smessage kMSG %a KEY_SMESSAGE, 0612, sent by shifted message key key_smove kMOV %b KEY_SMOVE, 0613, sent by shifted move key key_snext kNXT %c KEY_SNEXT, 0614, sent by shifted next key key_soptions kOPT %d KEY_SOPTIONS, 0615, sent by shifted options key key_sprevious kPRV %e KEY_SPREVIOUS, 0616, sent by shifted prev key key_sprint kPRT %f KEY_SPRINT, 0617, sent by shifted print key key_sr kri kR KEY_SR, 0521, sent by scroll-backward/up key key_sredo kRDO %g KEY_SREDO, 0620, sent by shifted redo key key_sreplace kRPL %h KEY_SREPLACE, 0621, sent by shifted replace key key_sright kRIT %i KEY_SRIGHT, 0622, sent by shifted right-arrow key key_srsume kRES %j KEY_SRSUME, 0623, sent by shifted resume key key_ssave kSAV !1 KEY_SSAVE, 0624, sent by shifted save key key_ssuspend kSPD !2 KEY_SSUSPEND, 0625, sent by shifted suspend key key_stab khts kT KEY_STAB, 0524, sent by set-tab key key_sundo kUND !3 KEY_SUNDO, 0626, sent by shifted undo key key_suspend kspd &7 KEY_SUSPEND, 0627, sent by suspend key key_undo kund &8 KEY_UNDO, 0630, sent by undo key key_up kcuu1 ku KEY_UP, 0403, sent by terminal up-arrow key Boolean Capabilities ( Sorted by Terminfo Capname ) Cap- Term- name Variable name cap Description am auto_right_margin am Terminal has automatic margins bce back_color_erase be Screen erased with background color bw auto_left_margin bw cub1 wraps from column 0 to last column ccc can_change cc Terminal can re-define existing color chts hard_cursor HC Cursor is hard to see cpix cpi_changes_res YF Changing character pitch changes resolution crxm cr_cancels_micro_mode YB Using cr turns off micro mode da memory_above da Display may be retained above the screen daisy has_print_wheel YC Printer needs operator to change character set db memory_below db Display may be retained below the screen eo erase_overstrike eo Can erase overstrikes with a blank eslok status_line_esc_ok es Escape can be used on the status line gn generic_type gn Generic line type (e.g., dialup, switch) hc hard_copy hc Hardcopy terminal hls hue_lightness_saturation hl Terminal uses only HLS color notation (Tektronic) hs has_status_line hs Has extra "status line" hz tilde_glitch hz Hazeltine; can't print tilde (~) in insert_null_glitch in Insert mode distinguishes nulls km has_meta_key km Has a meta key (shift, sets parity bit) lpix lpi_changes_res YG Changing line pitch changes resolution mc5i prtr_silent 5i Printer won't echo on screen mir move_insert_mode mi Safe to move while in insert mode msgr move_standout_mode ms Safe to move in standout modes ndscr non_dest_scroll_region ND Scrolling region is non-destructive npc no_pad_char NP Pad character doesn't exist nrrmc non_rev_rmcup NR smcup does not reverse rmcup nxon needs_xon_xoff nx Padding won't work,xon/woff required os over_strike os Terminal overstrikes on hard-copy terminal sam semi_auto_right_margin YE Printing in last column causes cr ul transparent_underline ul Underline character overstrikes xenl eat_newline_glitch xn Newline ignored after 80 columns (Concept) xhp ceol_standout_glitch xs Standout not erased by overwriting (hp) xhpa col_addr_glitch YA Only positive motion for hpa/mhpa caps xon xon_xoff xo Terminal uses xon/xoff handshaking xsb no_esc_ctlc xb Beehive (f1=escape, f2=ctrl C) xt dest_tabs_magic_smso xt Destructive tabs, magic smso char (t1061) xvpa row_addr_glitch YD Only positive motion for vpa/mvpa caps Numeric Capabilities ( Sorted by Terminfo Capname ) Cap- Term- name Variable name cap Description bufsz buffer_capacity Ya Number of bytes buffered before printing colors max_colors Co Maximum number of colors on the screen cols columns co Number of columns in a line cps print_rate Ym Print rate in characters per second it init_tabs it Tabs initially every # spaces lh label_height lh Number of rows in each label lines lines li Number of lines on a screen or a page lm lines_of_memory lm Lines of memory if > lines; 0 means varies lw label_width lw Number of columns in each label ma max_attributes ma Maximum combined video attributes terminal can display maddr max_micro_address Yd Maximum value in micro_..._address mcs micro_char_size Yf Character step size when in micro mode mjump max_micro_jump Ye Maximum value in parm_..._address mls micro_line_size Yg Line step size when in micro mode ncv no_color_video NC Video attributes that can't be used with colors nlab num_labels Nl Number of labels on screen (start at 1) npins number_of_pins Yh Number of pins in print- head orc output_res_char Yi Horizontal resolution in units per character orhi output_res_horz_inch Yk Horizontal resolution in units per inch orl output_res_line Yj Vertical resolution in units per line orvi output_res_vert_inch Yl Vertical resolution in units per inch pairs max_pairs pa Maximum number of color-pairs on the screen pb padding_baud_rate pb Lowest baud rate where padding needed spinh dot_horz_spacing Yc Spacing of dots horizontally in dots per inch spinv dot_vert_spacing Yb Spacing of pins vertically in pins per inch vt virtual_terminal vt Virtual terminal number (UNIX system) widcs wide_char_size Yn Character step size when in double wide mode wnum maximum_windows MW Maximum number of definable windows wsl width_status_line ws Number of columns in status line xmc magic_cookie_glitch sg Number of blank characters left by smso or rmso String Capabilities ( Sorted by Terminfo Capname ) Cap- Term- name Variable name cap Description acsc acs_chars ac Graphic charset pairs aAbBcC - def=vt100 bel bell bl Audible signal (bell) blink enter_blink_mode mb Turn on blinking bold enter_bold_mode md Turn on bold (extra bright) mode cbt back_tab bt Back tab chr change_res_horz ZC Change horizontal resolution (dg civis cursor_invisible vi Make cursor invisible clear clear_screen cl Clear screen and home cursor (*) cmdch command_character CC Terminal settable cmd character in prototype cnorm cursor_normal ve Make cursor appear normal (undo vs/vi) cpi change_char_pitch ZA Change number of characters per inch (dg cr carriage_return cr Carriage return (*) csnm char_set_names Zy List of character set names csr change_scroll_region cs Change to lines #1 through #2 (vt100)(G) cub parm_left_cursor LE Move cursor left #1 spaces (G) cub1 cursor_left le Move left one space cud parm_down_cursor DO Move down #1 lines (G*) cud1 cursor_down do Down one line cuf parm_right_cursor RI Move right #1 spaces (G*) cuf1 cursor_right nd Non-destructive space (cursor or carriage right) cup cursor_address cm Move to row #1 col #2 (G) cuu parm_up_cursor UP Move cursor up #1 lines (G*) cuu1 cursor_up up Upline (cursor up) cvr change_res_vert ZD Change vertical resolution (dg cvvis cursor_visible vs Make cursor very visible cwin create_window CW Define win #1 to go from #2,#3 to #4,#5 dch parm_dch DC Delete #1 chars (G*) dch1 delete_character dc Delete a character (*) dclk display_clock DK Display time-of-day clock defc define_char ZE Define a character in a character set [dagger +] dial dial_phone DI Dial phone number #1 dim enter_dim_mode mh Turn on half-bright mode dl parm_delete_line DL Delete #1 lines (G*) dl1 delete_line dl Delete line (*) docr these_cause_cr Zw Printing any of these cahr causes cr dsl dis_status_line ds Disable status line ech erase_chars ec Erase #1 characters (G) ed clr_eos cd Clear to end of display (*) el clr_eol ce Clear to end of line el1 clr_bol cb Clear to beginning of line, inclusive enacs ena_acs eA Enable alternate character set ff form_feed ff Hardcopy terminal page eject (*) flash flash_screen vb Visible bell (may not move cursor) fln label_format Lf Label format fsl from_status_line fs Return from status line hd down_half_line hd Half-line down (forward 1/2 linefeed) home cursor_home ho Home cursor (if no cup) hook flash_hook fh Flash the switch hook hpa column_address ch Horizontal position absolute (G) ht tab ta Tab to next 8-space hardware tab stop hts set_tab st Set a tab in all rows, current column hu up_half_line hu Half-line up (reverse 1/2 linefeed) hup hangup HU Hang-up phone ich parm_ich IC Insert #1 blank chars (G*) ich1 insert_character ic Insert character if init_file if Name of initialization file il parm_insert_line AL Add #1 new blank lines (G*) il1 insert_line al Add new blank line (*) ind scroll_forward sf Scroll text up indn parm_index SF Scroll forward #1 lines (G*) initc initialize_color Ic Initialize the definition of color initp initialize_pair Ip Initialize color-pair invis enter_secure_mode mk Turn on blank mode (character invisible) ip insert_padding ip Insert pad after character inserted (*) iprog init_prog iP Path name of program for initialization is1 init_1string i1 Terminal or printer initialization string is2 init_2string is Terminal or printer initialization string is3 init_3string i3 Terminal or printer initialization string lf0 lab_f0 l0 Labels on function key f0 if not f0 lf1 lab_f1 l1 Labels on function key f1 if not f1 lf10 lab_f10 la Labels on function key f10 if not f10 lf2 lab_f2 l2 Labels on function key f2 if not f2 lf3 lab_f3 l3 Labels on function key f3 if not f3 lf4 lab_f4 l4 Labels on function key f4 if not f4 lf5 lab_f5 l5 Labels on function key f5 if not f5 lf6 lab_f6 l6 Labels on function key f6 if not f6 lf7 lab_f7 l7 Labels on function key f7 if not f7 lf8 lab_f8 l8 Labels on function key f8 if not f8 lf9 lab_f9 l9 Labels on function key f9 if not f9 ll cursor_to_ll ll Last line, first column (if no cup) lpi change_line_pitch ZB Change number of lines per inch (dg mc0 print_screen ps Print contents of the screen mc4 prtr_off pf Turn off the printer mc5 prtr_on po Turn on the printer mc5p prtr_non pO Turn on the printer for #1 bytes mcub parm_left_micro Zg Like parm_left_cursor for micro adjust (+dagger) mcub1 micro_left Za Like cursor_left for micro adjustment mcud parm_down_micro Zf Like parm_down_cursor for micro adjust (G*)_ mcud1 micro_down ZZ Like cursor_down for micro adjustment mcuf parm_right_micro Zh Like parm_right_cursor for micro adjust (+dagger) mcuf1 micro_right Zb Like cursor_right for micro adjustment mcuu parm_up_micro Zi Like parm_up_cursor for micro adjust (+dagger) mcuu1 micro_up Zd Like cursor_up for micro adjustment mgc clear_margins MC Clear all margins (top, bottom, and sides) mhpa micro_column_address ZY Like column_address for micro adjustment (+dagger) mrcup cursor_mem_address CM Memory relative cursor addressing (G) mvpa micro_row_address Zc Like row_address for micro adjustment nel newline nw Newline (behaves like cr followed by lf) oc orig_colors oc Set all color (-pair)s to the original ones op orig_pair op Set default color-pair to the original one pad pad_char pc Pad character (rather than null) pause fixed_pause PA Pause for 2-3 seconds pfkey pkey_key pk Prog funct key #1 to type string #2 pfloc pkey_local pl Prog funct key #1 to execute string #2 pfx pkey_xmit px Prog funct key #1 to xmit string #2 pln plab_norm pn Prog label #1 to show string #2 porder order_of_pins Ze Matches software bits to print-head pins prot enter_protected_mode mp Turn on protected mode pulse pulse PU Select pulse dialing qdial quick_dial QD Dial phone number #1, without progress detection rbim stop_bit_image Zs End printing bit image graphics rc restore_cursor rc Restore cursor to position of the last sc rcsd stop_char_set_def Zt End definition of a character set rep repeat_char rp Repeat char #1 #2 times (G*) rev enter_reverse_mode mr Turn on reverse video mode rf reset_file rf Name of file containing reset string rfi req_for_input RF Send next input char (for ptys) ri scroll_reverse sr Scroll text down rin parm_rindex SR Scroll backward #1 lines (G) ritm exit_italics_mode ZR Disable italics rlm exit_leftward_mode ZS Enable rightward (normal) carriage motion rmacs exit_alt_charset_mode ae End alternate character set rmam exit_am_mode RA Turn off automatic margins rmclk remove_clock RC Remove time-of-day clock rmcup exit_ca_mode te String to end programs that use cup rmdc exit_delete_mode ed End delete mode rmicm exit_micro_mode ZT Disable micro motion capabilities rmir exit_insert_mode ei End insert mode rmkx keypad_local ke Out of "keypad-transmit" mode rmln label_off LF Turn off soft labels rmm meta_off mo Turn off "meta mode" rmp char_padding rP Like ip but when in replace mode rmso exit_standout_mode se End standout mode rmul exit_underline_mode ue End underscore mode rmxon exit_xon_mode RX Turn off xon/xoff handshaking rs1 reset_1string r1 Reset terminal completely to sane modes rs2 reset_2string r2 Reset terminal completely to sane modes rs3 reset_3string r3 Reset terminal completely to sane modes rshm exit_shadow_mode ZU Disable shadow printing rsubm exit_subscript_mode ZV Disable subscript printing rsupm exit_superscript_mode ZW Disable superscript printing rum exit_upward_mode ZX Enable downward (normal) carriage motion rwidm exit_doublewide_mode ZQ Disable double wide printing sbim start_bit_image Zq Start printing bit image graphics (+dagger) sc save_cursor sc Save cursor position sclk set_clock SC Set time-of-day clock scp set_color_pair sp Set current color-pair scs select_char_set Zj Select character set (+dagger) scsd start_char_set_def Zr Start definition of a character set (+dagger) sdrfq enter_draft_quality ZG Set draft quality print setb set_background Sb Set current background color setf set_foreground Sf Set current foreground color1 sgr set_attributes sa Define the video attributes (G) #1-#9 sgr0 exit_attribute_mode me Turn off all attributes sitm enter_italics_mode ZH Enable italics slm enter_leftward_mode ZI Enable leftward carriage motion smacs enter_alt_charset_mode as Start alternate character set smam enter_am_mode SA Turn on automatic margins smcup enter_ca_mode ti String to begin programs that use cup smdc enter_delete_mode dm Delete mode (enter) smgb set_bottom_margin Zk Set bottom margin at current line smgbp set_bottom_margin_parm Zl Set bottom margin at line #1 (+dagger) smgl set_left_margin ML Set left margin at current line smglp set_left_margin_parm Zm Set left margin at column #1 (+dagger) smgr set_right_margin MR Set right margin at current column smgrp set_right_margin_parm Zn Set right margin at column #1 (+dagger) smgt set_top_margin Zo Set top margin at current line smgtp set_top_margin_parm Zp Set top margin at line #1 (+dagger) smicm enter_micro_mode ZJ Enable micro motion capabilities smir enter_insert_mode im Insert mode (enter) smkx keypad_xmit ks Put terminal in "keypad-transmit" mode smln label_on LO Turn of soft labels smm meta_on mm Turn on "meta mode" (8th bit) smso enter_standout_mode so Begin standout mode smul enter_underline_mode us Start underscore mode smxon enter_xon_mode SX Turn on xon/xoff handshaking snlq enter_near_letter_quality ZK Set near-letter quality print snrmq enter_normal_quality ZL Set normal quality print sshm enter_shadow_mode ZM Enable shadow printing ssubm enter_subscript_mode ZN Enable subscript printing ssupm enter_superscript_mode ZO Enable superscript printing subcs subscript_characters Zu List of "subscript-able" characters sum enter_upward_mode ZP Enable upward carriage motion supcs superscript_characters Zv List of "superscript-able" characters swidm enter_doublewide_mode ZF Enable double wide printing tbc clear_all_tabs ct Clear all tab stops tone tone TO Select touch tone dialing tsl to_status_line ts Go to status line, col #1 (G) u0 user0 u0 User string 0 u1 user1 u1 User string 1 u2 user2 u2 User string 4 u3 user3 u3 User string 3 u4 user4 u4 User string 4 u5 user5 u5 User string 5 u6 user6 u6 User string 6 u7 user7 u7 User string 7 u8 user8 u8 User string 8 u9 user9 u9 User string 9 uc underline_char uc Underscore one char and move past it vpa row_address cv Vertical position absolute (G) wait wait_tone WA Wait for dial tone wind set_window wi Current window is lines #1-#2 cols #3-#4 (G) wingo goto_window WG Go to window #1 xoffc xoff_character XF X-off character xonc xon_character XN X-on character zerom zero_motion Zx No motion for the subsequent character Key Definitions ( Sorted by Terminfo Capname ) Cap- Term- name Variable name cap Description kBEG key_sbeg &9 KEY_SBEG, 0572, sent by shifted beginning key kCAN key_scancel &0 KEY_SCANCEL. 0573, sent by shifted cancel key kCMD key_scommand *1 KEY_SCOMMAND, 0574, sent by shifted command key kCPY key_scopy *2 KEY_SCOPY, 0575, sent by shifted copy key kCRT key_screate *3 KEY_SCREATE, 0576, sent by shifted create key kDC Key_sdc *4 KEY_SDC, 0577, sent by shifted delete-char key kDL key_sdl *5 KEY_SDL, 0600, sent by delete-line key kEND key_send *7 KEY_SEND, 0602, sent by shifted end key kEOL key_seol *8 KEY_SEOL, 0603, sent by shifted clear-line key kEXT key_sexit *9 KEY_SEXIT, 0604, sent by shifted exit key kFND key_sfind *0 KEY_SFIND, 0605, sent by shifted find key kHLP key_shelp #1 KEY_SHELP, 0606, sent by shifted help key kHOM key_shome #2 KEY_SHOME, 0607, sent by shifted home key kIC key_sic #3 KEY_SIC, 0610, sent by shifted input key kLFT key_sleft #4 KEY_SLEFT, 0611, sent by shifted left-arrow key kMOV key_smove %b KEY_SMOVE, 0613, sent by shifted move key kMSG key_smessage %a KEY_SMESSAGE, 0612, sent by shifted message key kNXT key_snext %c KEY_SNEXT, 0614, sent by shifted next key kOPT key_soptions %d KEY_SOPTIONS, 0615, sent by shifted options key kPRT key_sprint %f KEY_SPRINT, 0617, sent by shifted print key kPRV key_sprevious %e KEY_SPREVIOUS, 0616, sent by shifted prev key kRDO key_sredo %g KEY_SREDO, 0620, sent by shifted redo key kRES key_srsume %j KEY_SRSUME, 0623, sent by shifted resume key kRIT key_sright %i KEY_SRIGHT, 0622, sent by shifted right-arrow key kRPL key_sreplace %h KEY_SREPLACE, 0621, sent by shifted replace key kSAV key_ssave !1 KEY_SSAVE, 0624, sent by shifted save key kSPD key_ssuspend !2 KEY_SSUSPEND, 0625, sent by shifted suspend key kUND key_sundo !3 KEY_SUNDO, 0626, sent by shifted undo key ka1 key_a1 K1 KEY_A1, 0534, upper left of keypad ka3 key_a3 K3 KEY_A3, 0535, upper right of keypad kb2 key_b2 K2 KEY_B2, 0536, center of keypad kbeg key_beg @1 KEY_BEG, 05042, sent by beg(inning) key kbs key_backspace kb KEY_BACKSPACE, 0407, sent by backspace key kc1 key_c1 K4 KEY_C1, 0537, lower left of keypad kc3 key_c3 K5 KEY_C3, 0540, lower right of keypad kcan key_cancel @2 KEY_CANCEL, 0543, sent by cancel key kcbt key_btab kB KEY_BTAB. 0541, sent by back-tab key kclo key_close @3 KEY_CLOSE, 0544, sent by close key kclr key_clear kC KEY_CLEAR, 0515, sent by clear-screen or erase key kcmd key_command @4 KEY_COMMAND, 0545, sent by cmd (command) key kcpy key_copy @5 KEY_COPY, 0546, sent by copy key kcrt key_create @6 KEY_CREATE, 0547, sent by create key kctab key_ctab kt KEY_CTAB, 0525, sent by clear-tab key kcub1 key_left kl KEY_LEFT, 0404, sent by terminal left-arrow key kcud1 key_down kd KEY_DOWN, 0402, sent by terminal down-arrow key kcuf1 key_right kr KEY_RIGHT, 0405, sent by terminal right-arrow key kcuu1 key_up ku KEY_UP, 0403, sent by terminal up-arrow key kdch1 key_dc kD KEY_DC, 0512, sent by delete-character key kdl1 key_dl kL KEY_DL, 0510, sent by delete-line key ked key_eos kS KEY_EOS, 0516, sent by clear-to-end-of-screen key kel key_eol kE KEY_EOL, 0517, sent by clear-to-end-of-line key kend key_end @7 KEY_END, 0550, sent by end key kent key_enter @8 KEY_ENTER, 0527, sent by enter/send key kext key_exit @9 KEY_EXIT, 0551, sent by exist key kf0 key_f0 k0 KEY_F(0), 0410, sent by function key f0 kf1 key_f1 k1 KEY_F(1), 0411, sent by function key f1 kf2 key_f2 k2 KEY_F(2), 0412, sent by function key f2 kf3 key_f3 k3 KEY_F(3), 0413, sent by function key f3 kf4 key_f4 k4 KEY_F(4), 0414, sent by function key f4 kf5 key_f5 k5 KEY_F(5), 0415, sent by function key f5 kf6 key_f6 k6 KEY_F(6), 0416, sent by function key f6 kf7 key_f7 k7 KEY_F(7), 0417, sent by function key f7 kf8 key_f8 k8 KEY_F(8), 0420, sent by function key f8 kf9 key_f9 k9 KEY_F(9), 0421, sent by function key f9 kf10 key_f10 k; KEY_F(10), 0422, sent by function key f10 kf11 key_f11 F1 KEY_F(11), 0423, sent by function key f11 kf12 key_f12 F2 KEY_F(12), 0424, sent by function key f12 kf13 key_f13 F3 KEY_F(13), 0425, sent by function key f13 kf14 key_f14 F4 KEY_F(14), 0426, sent by function key f14 kf15 key_f15 F5 KEY_F(15), 0427, sent by function key f15 kf16 key_f16 F6 KEY_F(16), 0430, sent by function key f16 kf17 key_f17 F7 KEY_F(17), 0431, sent by function key f17 kf18 key_f18 F8 KEY_F(18), 0432, sent by function key f18 kf19 key_f19 F9 KEY_F(19), 0433, sent by function key f19 kf20 key_f20 FA KEY_F(20), 0434, sent by function key f20 kf21 key_f21 FB KEY_F(21), 0435, sent by function key f21 kf22 key_f22 FC KEY_F(22), 0436, sent by function key f22 kf23 key_f23 FD KEY_F(23), 0437, sent by function key f23 kf24 key_f24 FE KEY_F(24), 0440, sent by function key f24 kf25 key_f25 FF KEY_F(25), 0441, sent by function key f25 kf26 key_f26 FG KEY_F(26), 0442, sent by function key f26 kf27 key_f27 FH KEY_F(27), 0443, sent by function key f27 kf28 key_f28 FI KEY_F(28), 0444, sent by function key f28 kf29 key_f29 FJ KEY_F(29), 0445, sent by function key f29 kf30 key_f30 FK KEY_F(30), 0446, sent by function key f30 kf31 key_f31 FL KEY_F(31), 0447, sent by function key f31 kf32 key_f32 FM KEY_F(32), 0450, sent by function key f32 kf33 key_f33 FN KEY_F(13), 0451, sent by function key f13 kf34 key_f34 FO KEY_F(34), 0452, sent by function key f34 kf35 key_f35 FP KEY_F(35), 0453, sent by function key f35 kf36 key_f36 FQ KEY_F(36), 0454, sent by function key f36 kf37 key_f37 FR KEY_F(37), 0455, sent by function key f37 kf38 key_f38 FS KEY_F(38), 0456, sent by function key f38 kf39 key_f39 FT KEY_F(39), 0457, sent by function key f39 kf40 key_f40 FU KEY_F(40), 0460, sent by function key f40 kf41 key_f41 FV KEY_F(41), 0461, sent by function key f41 kf42 key_f42 FW KEY_F(42), 0462, sent by function key f42 kf43 key_f43 FX KEY_F(43), 0463, sent by function key f43 kf44 key_f44 FY KEY_F(44), 0464, sent by function key f44 kf45 key_f45 FZ KEY_F(45), 0465, sent by function key f45 kf46 key_f46 Fa KEY_F(46), 0466, sent by function key f46 kf47 key_f47 Fb KEY_F(47), 0467, sent by function key f47 kf48 key_f48 Fc KEY_F(48), 0470, sent by function key f48 kf49 key_f49 Fd KEY_F(49), 0471, sent by function key f49 kf50 key_f50 Fe KEY_F(50), 0472, sent by function key f50 kf51 key_f51 Ff KEY_F(51), 0473, sent by function key f51 kf52 key_f52 Fg KEY_F(52), 0474, sent by function key f52 kf53 key_f53 Fh KEY_F(53), 0475, sent by function key f53 kf54 key_f54 Fi KEY_F(54), 0476, sent by function key f54 kf55 key_f55 Fj KEY_F(55), 0477, sent by function key f55 kf56 key_f56 Fk KEY_F(56), 0500, sent by function key f56 kf57 key_f57 Fl KEY_F(57), 0501, sent by function key f57 kf58 key_f58 Fm KEY_F(58), 0502, sent by function key f58 kf59 key_f59 Fn KEY_F(59), 0503, sent by function key f59 kf60 key_f60 Fo KEY_F(60), 0504, sent by function key f60 kf61 key_f61 Fp KEY_F(61), 0505, sent by function key f61 kf62 key_f62 Fq KEY_F(62), 0506, sent by function key f62 kf63 key_f63 Fr KEY_F(63), 0507, sent by function key f63 kfnd key_find @0 KEY_FIND, 0552, sent by find key khlp key_help %1 KEY_HELP, 0553, sent by help key khome key_home kh KEY_HOME, 0406, sent by home key khts key_stab kT KEY_STAB, 0524, sent by set-tab key kich1 key_ic kI KEY_IC, 0513, sent by ins-char/enter ins-mode key kil1 key_il kA KEY_IL, 0511, sent by insert-line key kind key_sf kF KEY_SF, 0520, sent by scroll-forward/down key kll key_ll kH KEY_LL, 0533, sent by home-down key kmov key_move %4 KEY_MOVE,0556, sent by move key kmrk key_mark %2 KEY_MARK, 0554, sent by mark key kmsg key_message %3 KEY_MESSAGE, 0555, sent by message key knp key_npage kN KEY_NPAGE, 0522, sent by next-page key knxt key_next %5 KEY_NEXT, 0557, sent by next-object key kopn key_open %6 KEY_OPEN, 0560, sent by open key kopt key_options %7 KEY_OPTIONS, 0561, sent by options key kpp key_ppage kP KEY_PPAGE, 0523, sent by previous-page key kprt key_print %9 KEY_PRINT, 0532, sent by print or copy key kprv key_previous %8 KEY_PREVIOUS, 0562, sent by previous-object key krdo key_redo %0 KEY_REDO, 0563, sent by redo key kref key_reference &1 KEY_REFERENCE, 0564, sent by ref(erence) key kres key_resume &5 KEY_RESUME, 0570, sent by resume key krfr key_refresh &2 KEY_REFRESH, 0565, sent by refresh key kri key_sr kR KEY_SR, 0521, sent by scroll-backward/up key krmir key_eic kM KEY_EIC, 0514, sent by rmir or smir in insert mode krpl key_replace &3 KEY_REPLACE, 0566, sent by replace key krst key_restart &4 KEY_RESTART, 0567, sent by restart key ksav key_save &6 KEY_SAVE, 0571, sent by save key kslt key_select *6 KEY_SELECT, 0601, sent by select key kspd key_suspend &7 KEY_SUSPEND, 0627, sent by suspend key ktbc key_catab ka KEY_CATAB, 0526, sent by clear-all tabs key kund key_undo &8 KEY_UNDO, 0630, sent by undo key 4. Description of Basic Capabilities 4.1 Miscellaneous Notes Cursor motions defined for a terminfo definition should be non-destructive, that is, they should not modify the text the cursor passes over. For example, the space ( 0x20 ) character would not make a good choice as a cuf1 ( cursor forward ) definition because it would overwrite the character behind the cursor with a space. Relative cursor motion at the screen edges should be treated as undefined, ie: don't assume that the terminal will wrap from one edge to the other, either horizontally or vertically, when the edges of the screen are encountered. The only exception to this is for terminals which define a 'bw' capability, implying that backspace will wrap back to the right margin on the line above. Similarly, the 'ind' and 'ri' capabilities ( index and reverse index ) are only defined to be valid when the cursor is in the bottom left or top right corners, respectively. Their action is undefined if the cursor is anywhere else on the screen. The QNX getch() library routine by default uses 300 milliseconds as the hold off within function key processing to determine if the key being processed was typed by the user, or part of a multi-character sequence being mapped to a single function key value. If this default is not suitable for a given terminal or serial line interface, the 'cps' or print_rate numeric capability can be used to express some other interval, in tenths of a second. Terminals needing a pad character other than null ( 0x00 ) should encode this required character in the 'pad' string variable, from which only the first character will be used. The 'rep' capability is useful to encode repeated runs of characters into a shorter sequence. Although the QNX console is quick enough that this does not make a measurable difference at the console, this capability can greatly reduce the time to transmit repeating characters to a terminal over a slower serial link. For example, to express a repeated run of '-' characters to draw a line, the call tput( tparm( repeat_char, '-', 70 ) ); will generate a sequence only 4 characters long ( for a QNX 4.x terminal ), much better than the 70 characters required without the 'rep' capability. Terminfo definitions which exist for special purposes, and not to encode terminals ( storing special control data for modems, printers, etc ), should have the 'gn' ( generic ) capability defined so that applications can emit an appropriate error when attempting to make use of this terminal type. If the terminal uses xon/xoff, the capability 'xon' should be defined. This will cause the terminfo routines to not send padding characters to the terminal ( assuming that the terminal will assert flow control as necessary ). The 'smxon' and 'rmxon' capabilities can be used to turn flow control on and off. A common problem seen by vt100 terminals is that a character received that should move the cursor to the next line, left margin, will not until the next character is received. The 'xenl' capability should be defined to indicate this. 4.2 Parameterized Strings Many of the capability strings require parameters to be inserted to fully specify the indicated function. For example, the 'cup' capability ( cursor position ) requires both a row and a column. To implement this requirement, the strings parsed by the terminfo output routines recognize a printf()-like syntax with various extensions to realize the level of control required. The syntax implemented within the capability strings provides a stack-oriented Reverse Polish Notation (RPN) engine to process the parameters much like an RPN calculator would. Examining a 'cup' string for a VT52 terminal will make the operation of this syntax clear. As it would appear within a VT52 terminfo definition, the 'cup' string is: cup=\EY%p1%' '%+%c%p2%' '%+%c, The manner by which this string would be used within a program to have the parameters processed to produce an output string would be: tparm( cursor_address, row, col ) ); This 'tparm' function would return a pointer to a string containing the data to be sent to the terminal to position the cursor at the requested row and column. Looking again at the cup string definition, the sequence of operations applied by tparm to generate the output string is: 1) \EY Place escape ( 0x1b ) and 'Y' in the output string 2) %p1 Push p1 ( first parameter ) on the stack 3) %' ' Push a space ( 0x20 ) character on the stack 4) %+ Pop the top two values, add them, and push the result 5) %c Pop from the stack and place, as a character value, the value in the output string 6) %p2 Push p2 ( second parameter ) on the stack 7) %' ' Push a space ( 0x20 ) character on the stack 8) %+ Pop the top two values, add them, and push the result 9) %c Pop from the stack and place, as a character value, the value in the output string These are the % operators available for use within the terminfo capability strings: %% Output '%' %c Pop from stack and output as a character %'c' Push specified constant character 'c' %{nn} Push decimal constant nn, or by using C syntax, an octal or hexadecimal number. %p[1-9] Push specified parameter ( 1 through 9 ) %P[a-z] Pop from stack and assign to specified variable a through z %g[a-z] Get specified variable ( a through z ) and push it %l Push the length of the string ( pop() ) in bytes %+ Apply indicated arithmetic operator ( %m is mod ). Sequence of %- operators is push( pop() operation pop() ). %* %/ %m %^ xor Apply indicated bit operation: push( pop() operation pop() ) %& and %| or %> Apply indicated logical operation: push( pop() operation pop() ) %= %< %O Logical operators AND and OR %A %~ Unary operators: push( operator pop() ) %! %i Add 1 to first parameter, if only one parameter present Add 1 to first two parameters, if more than one parameter present %[[:]flags][width[.precision]][diouxXs] This syntax is borrowed from printf. The flags are -, +, # and space. If a '+' or '-' character immediately follows the '%' for the printf format, a ':' should be inserted to differentiate it from the %+ or %- operator. Conditional evaluation: if-then-else is coded as: %? expression %t then-part %e else-part %; if-then is coded as: %? expression %t then-part %; 4.3 Cursor Motions In general, it is worthwhile to specify all of the cursor addressing methods a terminal supports. Many of the terminal output routines ( the QNX term routines or curses ) keep track of a metric called "cost" of cursor motion. For the purposes of screen addressing, cost is simply the character count ( including padding ) for the output sequence necessary to accomplish a given cursor addressing request. Both curses and the QNX term routines compute relative costs for the various ways of addressing a cursor and will choose the least expensive way of accomplishing the desired output sequence. For example, if an application requests that the cursor be placed at coordinate (1,0) ( left margin, 2nd line ), it may be possible that the terminal has a home and linefeed character defined, allowing this motion to be accomplished in two characters, rather than the full 'cup' string, which could amount to four or more characters. The relative cursor motion strings are also worth defining, as they can often be "cheaper" than the fully specified cup string for short, relative movements of the cursor from its current position. 4.4 Area Clears Within the terminfo database are a number of capabilities defined as providing area clears such as clear screen, clear to end of line, clear to end of screen, etc. For applications which need to frequently clear portions of the screen, these sequences are valuable optimizations, as they replace what might otherwise be large numbers of space characters sent to overwrite areas of the screen. 4.5 Insert / Delete Line Many applications attempt to create a region on the screen that scrolls without disturbing the rest of the screen ( text editors, order entry forms, etc ). In order to make the implementation perform efficiently, there are a few classes of escape sequences which are worth defining. The most common way of accomplishing the "scrolling region" effect is to use an insert line command at the top of the region to make the region scroll down, or a delete line command at the top of the region to make it scroll up. The application can then use various line clear commands to fix up any side-effects from data being displayed where it shouldn't. Terminals such as the vt100, vt220, etc also implement a scroll region, defined by the 'csr' capability. This escape sequence allows the application to define a horizontal range of lines on the screen to scroll as if it were a terminal in itself. This technique is better than the insert/delete line approach because there are no side-effects to fix up after the scroll has taken place. Finally, high-end terminals also implement a scrolling window, which can be a box anywhere on the screen that scrolling commands can be sent to. This capability is defined with the 'wind' capability. Since applications often attempt to implement scrolling regions, defining at least the insert / delete line capabilities is very worthwhile, as the alternative for the application is to rewrite the entire scrolled region. 4.6 Insert / Delete Character In the same manner as insert / delete line codes can be used to boost the efficiency with which an application can animate a full screen interface, the insert / delete character capabilities are also useful. Full screen editors which need to perform operations such as inserting and deleting text within a line while the user types new information, or uses the delete key, can update the displayed representation of the line without needing to retransmit from the cursor position to the end of the line. Side-scrolling of the screen is also easier to perform with these sequences defined. The capability to delete a single character is 'dch1' while the capability to delete 'n' characters is 'dch'. Some older terminals require the 'smdc' and 'rmdc' capabilities be defined as strings that must be sent to the terminal to allow the delete character capability to function. 4.7 Highlighting, Underlining and Visible Bells Applications commonly have the need to highlight data on the screen in various ways. There are capability names in the terminfo database to set display modes such as 'blink', 'bold', etc. This table lists this display modes and the capability names used to turn them both on and off. Capability names for various visual effects: Mode Name Enable Mode Disable Mode Blink blink sgr0 Bold bold sgr0 Half intensity dim sgr0 Invisible invis sgr0 Protected field prot sgr0 Reverse video rev sgr0 Standout smso rmso Alternate character set smacs rmacs Underline smul rmul The 'enacs' capability ( enable alternate character set ), if defined, must be sent to the terminal to enable the toggling of the alternate character set on and off. If the terminal requires the 'enacs' sequences, then 'smacs' and 'rmacs' may not have any effect. This is true of the VT100, for example. Turning on any of these modes does not guarantee that the other modes enabled won't be modified as well. The sgr0 capability will restore normal display mode. Many applications need to use an attribute to display text in a "standout" mode to highlight text, and since this attribute is used often, the choice of a combination that is visually appealing is worthwhile. The 'smso' and 'rmso' capabilities define how to enter and exit standout mode, respectively. Applications should not assume that a terminal is able to move the cursor from line to line while standout mode is on unless the 'msgr' capability is present indicating that such cursor motion is allowed. Many older terminals have this limitation. Many older terminals have the unfortunate problem ( sometimes referred to as the "magic cookie glitch" ) that changes in display attributes occupy one or more locations on the screen. These occupied spaces appear as blanks before and after the text displayed in the new attribute. The number of locations occupied by the attribute change code should be indicated with the 'xmc' value. Before an application can begin to use these attribute and cursor positioning capabilities, it should, if defined, output the 'smcup' capability ( set mode for cursor positioning ) to the terminal. When finished execution, the application should reset this mode with the 'rmcup' capability. Most terminals don't require special escape sequences to enable cursor addressing, but some older terminals do. Probably the single most complex capability to define is the 'sgr' capability. The 'sgr' ( set attributes ) capability is used to set a combination of up to nine visual attributes. In a C program, this capability is passed to the tparm() routine to have the nine values instantiated within the output string which is then passed to putp() for output to the terminal. The 'sgr' capability is invoked in a C program as shown: putp( tparm( set_attributes, 0, /* standout */ 1, /* underline */ 1, /* reverse_video */ 0, /* blinking */ 0, /* half_intensity */ 0, /* bold */ 0, /* invisible */ 0, /* protected_field */ 0 ) ); /* alternate_character_set */ This particular example would cause the next output to the terminal to be displayed as underlined, reverse video text. Only the capabilities the terminal supports with the individual capability enable / disable strings need to be supported with the 'sgr' string. To build an 'sgr' string for a terminal, the following process should be followed. First, create a table that indicates the output escape sequence for each of the nine display modes possible in the 'sgr' string. For the purpose of this discussion, assume that the following table applies: Tparm Escape Parameter Attribute Sequence none \E[0m p1 standout \E[0;4;7m p2 underline \E[0;3m p3 reverse \E[0;4m p4 blinking \E[0;5m p5 half_intensity \E[0;7m p6 bold \E[0;3;4m p7 invisible \E[0;8m p8 protected \E[0;9m p9 alternate_charset ^O for ON, ^N for off For each capability to be enabled, note that the \E[0 is defined to disable any previously enabled modes. A few notes about the choice of attributes: standout is chosen to be the combination of reverse and dim. Bold, which does not exist for this terminal, is chosen to be the combination of reverse and underline. So, if all modes were to be turned on, the output sequence would be \E[0;3;4;5;7;8;9m^N. Looking at when the various output sequences are generated, ;3 is output whenever p2 or p6 is true ( either underline or bold ). The above dependencies can then be written out as: Character When to Terminfo Sequence Output RPN Expression \E[0 always \E[0 ;3 if p2 or p6 %?%p2%p6%|%t;3%; ;4 if p1 or p3 or p6 %?%p1%p3%p6%|%|%t;4%; ;5 if p4 %?%p4%t;5%; ;7 if p1 or p5 %?%p1%p5%|%t;7%; ;8 if p7 %?%p7%t;8%; ;9 if p8 %?%p8%t;9%; m always m ^N or ^O if p9 then ^N, else ^O %?%p9%t^N%e^O; The entire definition for the sgr capability string then becomes sgr=\E[0%?%p2%p6%|%t;3%;%?%p1%p3%p6%|%|%t;4%;%?%p4%t;5%; %?%p1%p5%|%t;7%;%?%p7%t;8%;%?%p8%t;9%;m%?%p9%t^N%e^O;, This string would appear as a single line within the terminfo definition for this fictional terminal. 4.8 Terminal Keypad Control For use in a QNX environment, it is desired that the keyboard of the terminal be as functional as possible so that the terminal is better able to provide the user with keys that can be used in place of the keys found on the console. Towards this end, if the terminal has a keypad it should be enabled so that the keys on it can be mapped into console-equivalent keys. The 'smkx' and 'rmkx' capabilities are used to enable and disable the keypad. Unfortunately, terminfo description files used on most Unix systems tend to be very limited in terms of their keyboard definitions. As a result, many Unix applications rely only on control key combinations that can be entered from even the most limited terminals. The function keys and cursor pads available on better terminals end up being ignored by many Unix applications. QNX applications can benefit from the full functionality of the console keyboard, and so a complete definition is provided ( see the qnx terminal definition given earlier in this technical note ). Developers writing applications for the QNX console should also take care to ensure that key sequences exist that will allow those applications to still operate on less functional terminals. The QNX console uses a keyboard compatible with an IBM PC or AT. Since the keyboard input strings defined by a conventional UNIX terminfo model do not map well to the key names available on the console keyboard, QNX adopts the convention of defining a mapping from UNIX terminfo key names to a QNX terminfo key name. The following table indicates the mapping of key names. The infocmp utility has a -Q option which will cause it to display terminfo entries with the key names displayed with names used from this table. Normally, infocmp will use conventional terminfo names. Although most terminfo and termcap terminal descriptions available on other UNIX systems concentrate only on defining the output escape sequences, a complete keyboard definition is also important because QNX applications are accustomed to having the full IBM keyboard available for user input. QNX applications tend to use features such as the cursor pad, function keys, Alt key, etc. Since few terminals have such a rich keyboard, this mapping is defined to allow terminal input definitions to be defined to the same key values as would be used on the console with the full keyboard. With a complete keyboard mapping done, the user at a terminal will have keystrokes available that match most ( if not all ) of the keys available on the console keyboard. The QNX terminfo entry for the vt100 ( found in the /usr/lib/terminfo/terminfo.src file ) terminal is a good example of the mapping that can be done. When defining a terminfo definition for a new terminal, or adding the keyboard definition to an existing terminal, this table can be used to determine what the string capability name used in the terminfo definition should be ( column 2 ) for a given key available on the console ( column 1 ). The third column is the name given to the key by the conventional terminfo definition. The "infocmp" command issued with the -LQ options will use the "QNX Terminfo Name" for the listing, omitting the 'Q' option will result in a listing containing the conventional names. QNX Terminfo Name Capname Terminfo Name key_a1 ka1 key_a1 key_a3 ka3 key_a3 key_alt_a kclr key_clear key_alt_b khts key_stab key_alt_c kclo key_close key_alt_d ktbc key_catab key_alt_delete ked key_eos key_alt_down kEOL key_seol key_alt_e kmsg key_message key_alt_end kel key_eol key_alt_f kfnd key_find key_alt_f1 kf37 key_f37 key_alt_f10 kf46 key_f46 key_alt_f12 kf48 key_f48 key_alt_f12 kf47 key_f47 key_alt_f2 kf38 key_f38 key_alt_f3 kf39 key_f39 key_alt_f4 kf40 key_f40 key_alt_f5 kf41 key_f41 key_alt_f6 kf42 key_f42 key_alt_f7 kf43 key_f43 key_alt_f8 kf44 key_f44 key_alt_f9 kf45 key_f45 key_alt_g krfr key_refresh key_alt_h khlp key_help key_alt_home kbeg key_beg key_alt_i kmov key_move key_alt_insert krmir key_eic key_alt_j krst key_restart key_alt_k kopt key_options key_alt_kpdfive kcrt key_create key_alt_kpdminus kSPD key_ssuspend key_alt_kpdplus kSAV key_ssave key_alt_l kref key_reference key_alt_left kMSG key_smessage key_alt_m kmrk key_mark key_alt_n kBEG key_sbeg key_alt_o kopn key_open key_alt_p kres key_resume key_alt_pgdn knxt key_next key_alt_pgup kprv key_previous key_alt_prtsc kRDO key_sredo key_alt_q ksav key_save key_alt_r krpl key_replace key_alt_right kMOV key_smove key_alt_s kCPY key_scopy key_alt_t kCRT key_screate key_alt_u kund key_undo key_alt_up kEND key_send key_alt_v kDL key_sdl key_alt_w kEXT key_sexit key_alt_x kFND key_sfind key_alt_y kHLP key_shelp key_alt_z kOPT key_soptions key_b2 kb2 key_b2 key_backspace kbs key_backspace key_btab kcbt key_btab key_c1 kc1 key_c1 key_c3 kc3 key_c3 key_ctl_delete kdl1 key_dl key_ctl_down kri key_sr key_ctl_end kext key_exit key_ctl_entry kent key_enter key_ctl_f1 kf25 key_f25 key_ctl_f10 kf34 key_f34 key_ctl_f11 kf35 key_f35 key_ctl_f12 kf36 key_f36 key_ctl_f2 kf26 key_f26 key_ctl_f3 kf27 key_f27 key_ctl_f4 kf28 key_f28 key_ctl_f5 kf29 key_f29 key_ctl_f6 kf30 key_f30 key_ctl_f7 kf31 key_f31 key_ctl_f8 kf32 key_f32 key_ctl_f9 kf33 key_f33 key_ctl_home kHOM key_shome key_ctl_insert kil1 key_il key_ctl_kpdfive kcpy key_copy key_ctl_kpdminus kCAN key_scancel key_ctl_kpdplus kCMD key_scommand key_ctl_left kLFT key_sleft key_ctl_pgdn kNXT key_snext key_ctl_pgup kPRV key_sprevious key_ctl_prtsc kPRT key_sprint key_ctl_right kRIT key_sright key_ctl_rubout krdo key_redo key_ctl_tab kctab key_ctab key_ctl_up kind key_sf key_delete kdch1 key_dc key_down kcud1 key_down key_end kend key_end key_f0 kf0 key_f0 key_f1 kf1 key_f1 key_f10 kf10 key_f10 key_f11 kf11 key_f11 key_f12 kf12 key_f12 key_f2 kf2 key_f2 key_f3 kf3 key_f3 key_f4 kf4 key_f4 key_f49 kf49 key_f49 key_f5 kf5 key_f5 key_f50 kf50 key_f50 key_f51 kf51 key_f51 key_f52 kf52 key_f52 key_f53 kf53 key_f53 key_f54 kf54 key_f54 key_f55 kf55 key_f55 key_f56 kf56 key_f56 key_f57 kf57 key_f57 key_f58 kf58 key_f58 key_f59 kf59 key_f59 key_f6 kf6 key_f6 key_f60 kf60 key_f60 key_f61 kf61 key_f61 key_f62 kf62 key_f62 key_f63 kf63 key_f63 key_f7 kf7 key_f7 key_f8 kf8 key_f8 key_f9 kf9 key_f9 key_home khome key_home key_insert kich1 key_ic key_kbdplus kslt key_select key_kpdfive kcmd key_command key_kpdminus kcan key_cancel key_left kcub1 key_left key_ll kll key_ll key_pgdn knp key_npage key_pgup kpp key_ppage key_prtsc kprt key_print key_right kcuf1 key_right key_sdc kDC key_sdc key_shf_enter kIC key_sic key_shf_f1 kf13 key_f13 key_shf_f10 kf22 key_f22 key_shf_f11 kf23 key_f23 key_shf_f12 kf24 key_f24 key_shf_f2 kf14 key_f14 key_shf_f3 kf15 key_f15 key_shf_f4 kf16 key_f16 key_shf_f5 kf17 key_f17 key_shf_f6 kf18 key_f18 key_shf_f7 kf19 key_f19 key_shf_f8 kf20 key_f20 key_shf_f9 kf21 key_f21 key_sreplace kRPL key_sreplace key_srsume kRES key_srsume key_sundo kUND key_sundo key_suspend kspd key_suspend key_up kcuu1 key_up lab_f0 lf0 lab_f0 lab_f1 lf1 lab_f1 lab_f10 lf10 lab_f10 lab_f2 lf2 lab_f2 lab_f3 lf3 lab_f3 lab_f4 lf4 lab_f4 lab_f5 lf5 lab_f5 lab_f6 lf6 lab_f6 lab_f7 lf7 lab_f7 lab_f8 lf8 lab_f8 lab_f9 lf9 lab_f9 req_for_input rfi req_for_input The following table provides the mapping of the keys at the console into the various values returned by the layers of the keyboard input model. Each column bears a number which refers to a note at the end of the table explaining the values in that column. 1 2 3 4 5 6 7 term- qnxterm.h kbd info curses octal full text #define value 8 name #define value name K_DOWN ffa9 251 kcud1 KEY_DOWN 0402 down arrow K_UP ffa1 241 kcuu1 KEY_UP 0403 up arrow K_LEFT ffa4 244 kcub1 KEY_LEFT 0404 left arrow K_RIGHT ffa6 246 kcuf1 KEY_RIGHT 0405 right arrow K_HOME ffa0 240 khome KEY_HOME 0406 home kbs KEY_BACKSPACE 0407 backspace kf0 KEY_F(0) 0410 f0 K_F1 ff81 201 kf1 KEY_F(1) 0411 f1 K_F2 ff82 202 kf2 KEY_F(2) 0412 f2 K_F3 ff83 203 kf3 KEY_F(3) 0413 f3 K_F4 ff84 204 kf4 KEY_F(4) 0414 f4 K_F5 ff85 205 kf5 KEY_F(5) 0415 f5 K_F6 ff86 206 kf6 KEY_F(6) 0416 f6 K_F7 ff87 207 kf7 KEY_F(7) 0417 f7 K_F8 ff88 210 kf8 KEY_F(8) 0420 f8 K_F9 ff89 211 kf9 KEY_F(9) 0421 f9 K_F10 ff8a 212 kf10 KEY_F(10) 0422 f10 K_F11 ffae 256 kf11 KEY_F(11) 0423 f11 K_F12 ffaf 257 kf12 KEY_F(12) 0424 f12 K_SHF_F1 ff8b 213 kf13 KEY_F(13) 0425 f13 K_SHF_F2 ff8c 214 kf14 KEY_F(14) 0426 f14 K_SHF_F3 ff8d 215 kf15 KEY_F(15) 0427 f15 K_SHF_F4 ff8e 216 kf16 KEY_F(16) 0430 f16 K_SHF_F5 ff8f 217 kf17 KEY_F(17) 0431 f17 K_SHF_F6 ff90 220 kf18 KEY_F(18) 0432 f18 K_SHF_F7 ff91 221 kf19 KEY_F(19) 0433 f19 K_SHF_F8 ff92 222 kf20 KEY_F(20) 0434 f20 K_SHF_F9 ff93 223 kf21 KEY_F(21) 0435 f21 K_SHF_F10 ff94 224 kf22 KEY_F(22) 0436 f22 K_SHF_F11 ffdb 333 kf23 KEY_F(23) 0437 f23 K_SHF_F12 ffdc 334 kf24 KEY_F(24) 0440 f24 K_CTL_F1 ff95 225 kf25 KEY_F(25) 0441 f25 K_CTL_F2 ff96 226 kf26 KEY_F(26) 0442 f26 K_CTL_F3 ff97 227 kf27 KEY_F(27) 0443 f27 K_CTL_F4 ff98 230 kf28 KEY_F(28) 0444 f28 K_CTL_F5 ff99 231 kf29 KEY_F(29) 0445 f29 K_CTL_F6 ff9a 232 kf30 KEY_F(30) 0446 f30 K_CTL_F7 ff9b 233 kf31 KEY_F(31) 0447 f31 K_CTL_F8 ff9c 234 kf32 KEY_F(32) 0450 f32 K_CTL_F9 ff9d 235 kf33 KEY_F(33) 0451 f33 K_CTL_F10 ff9e 236 kf34 KEY_F(34) 0452 f34 K_CTL_F11 ffbe 276 kf35 KEY_F(35) 0453 f35 K_CTL_F12 ffbf 277 kf36 KEY_F(36) 0454 f36 K_ALT_F1 ffd1 321 kf37 KEY_F(37) 0455 f37 K_ALT_F2 ffd2 322 kf38 KEY_F(38) 0456 f38 K_ALT_F3 ffd3 323 kf39 KEY_F(39) 0457 f39 K_ALT_F4 ffd4 324 kf40 KEY_F(40) 0460 f40 K_ALT_F5 ffd5 325 kf41 KEY_F(41) 0461 f41 K_ALT_F6 ffd6 326 kf42 KEY_F(42) 0462 f42 K_ALT_F7 ffd7 327 kf43 KEY_F(43) 0463 f43 K_ALT_F8 ffd8 330 kf44 KEY_F(44) 0464 f44 K_ALT_F9 ffd9 331 kf45 KEY_F(45) 0465 f45 K_ALT_F10 ffda 332 kf46 KEY_F(46) 0466 f46 K_ALT_F11 ffce 316 kf47 KEY_F(47) 0467 f47 K_ALT_F12 ffcf 317 kf48 KEY_F(48) 0470 f48 kf49 KEY_F(49) 0471 f49 kf50 KEY_F(50) 0472 f50 kf51 KEY_F(51) 0473 f51 kf52 KEY_F(52) 0474 f52 kf53 KEY_F(53) 0475 f53 kf54 KEY_F(54) 0476 f54 kf55 KEY_F(55) 0477 f55 kf56 KEY_F(56) 0500 f56 kf57 KEY_F(57) 0501 f57 kf58 KEY_F(58) 0502 f58 kf69 KEY_F(59) 0503 f59 kf10 KEY_F(60) 0504 f60 kf61 KEY_F(61) 0505 f61 kf62 KEY_F(62) 0506 f62 kf63 KEY_F(63) 0507 f63 K_CTL_DELETE ffbc 274 kdl1 KEY_DL 0510 delete line key K_CTL_INSERT ffbb 273 kil1 KEY_IL 0511 insert line K_DELETE ffac 254 kdch1 KEY_DC 0512 delete character key K_INSERT ffab 253 kich1 KEY_IC 0513 ins char/enter ins mode key K_ALT_INSERT ffcb 313 krmir KEY_EIC 0514 rmir or smir in insert mode K_ALT_A ffe1 341 kclr KEY_CLEAR 0515 clear screen or erase key K_ALT_DELETE ffcc 314 ked KEY_EOS 0516 clear-to-end-of-screen key K_ALT_END ffc8 310 kel KEY_EOL 0517 clear-to-end-of-line key K_CTL_UP ffb1 261 kind KEY_SF 0520 scroll-forward/down key K_CTL_DOWN ffb9 271 kri KEY_SR 0521 scroll-backward/up key K_PGDN ffaa 252 knp KEY_NPAGE 0522 next-page key K_PGUP ffa2 242 kpp KEY_PPAGE 0523 previous-page key K_ALT_B ffe2 342 khts KEY_STAB 0524 set-tab key K_CTL_TAB ff9f 237 kctab KEY_CTAB 0525 clear-tab key K_ALT_D ffe4 344 ktbc KEY_CATAB 0526 clear-all-tabs key K_CTL_ENTER ffd0 320 kent KEY_ENTER 0527 Enter/send (unreliable) K_PRTSC ffad 255 kprt KEY_PRINT 0532 print or copy kll KEY_LL 0533 home-down key ka1 KEY_A1 0534 Upper left of keypad ka3 KEY_A3 0535 Upper right of keypad kb2 KEY_B2 0536 Center of keypad kc1 KEY_C1 0537 Lower left of keypad kc3 KEY_C3 0540 Lower right of keypad K_BACKTAB ff80 200 kcbt KEY_BTAB 0541 Back tab key K_ALT_HOME ffc0 300 kbeg KEY_BEG 0542 beg(inning) key K_KPDMINUS ffa3 243 kcan KEY_CANCEL 0543 cancel key K_ALT_C ffe3 343 kclo KEY_CLOSE 0544 close key K_KPDFIVE ffa5 245 kcmd KEY_COMMAND 0545 cmd (command) key K_CTL_KPDFIVE ffb5 265 kcpy KEY_COPY 0546 copy key K_ALT_KPDFIVE ffc5 305 kcrt KEY_CREATE 0547 create key K_END ffa8 250 kend KEY_END 0550 end key K_CTL_END ffb8 270 kext KEY_EXIT 0551 exit key K_ALT_F ffe6 346 kfnd KEY_FIND 0552 find key K_ALT_H ffe8 350 khlp KEY_HELP 0553 help key K_ALT_M ffed 355 kmrk KEY_MARK 0554 mark key K_ALT_E ffe5 345 kmsg KEY_MESSAGE 0555 message key K_ALT_I ffe9 351 kmov KEY_MOVE 0556 move key K_ALT_PGDN ffca 312 knxt KEY_NEXT 0557 next object key K_ALT_O ffef 357 kopn KEY_OPEN 0560 open key K_ALT_K ffeb 353 kopt KEY_OPTIONS 0561 options key K_ALT_PGUP ffc2 302 kprv KEY_PREVIOUS 0562 previous object key K_CTL_RUBOUT ffde 336 krdo KEY_REDO 0563 redo key K_ALT_L ffec 354 kref KEY_REFERENCE 0564 ref(erence) key K_ALT_G ffe7 347 krfr KEY_REFRESH 0565 refresh key K_ALT_R fff2 362 krpl KEY_REPLACE 0566 replace key K_ALT_J ffea 352 krst KEY_RESTART 0567 restart key K_ALT_P fff0 360 kres KEY_RESUME 0570 resume key K_ALT_Q fff1 361 ksav KEY_SAVE 0571 save key K_ALT_N ffee 356 kBEG KEY_SBEG 0572 shifted beginning key K_CTL_KPDMINUS ffb3 263 kCAN KEY_SCANCEL 0573 shifted cancel key K_CTL_KPDPLUS ffb7 267 kCMD KEY_SCOMMAND 0574 shifted command key K_ALT_S fff3 363 kCPY KEY_SCOPY 0575 shifted copy key K_ALT_T fff4 364 kCRT KEY_SCREATE 0576 shifted create key kDC KEY_SDC 0577 shifted delete char key K_ALT_V fff6 366 kDL KEY_SDL 0600 shifted delete line key K_KBDPLUS ffa7 247 kslt KEY_SELECT 0601 select key K_ALT_UP ffc1 301 kEND KEY_SEND 0602 shifted end key K_ALT_DOWN ffc9 311 kEOL KEY_SEOL 0603 shifted clear line key K_ALT_W fff7 367 kEXT KEY_SEXIT 0604 shifted exit key K_ALT_X fff8 370 kFND KEY_SFIND 0605 shifted find key K_ALT_Y fff9 371 kHLP KEY_SHELP 0606 shifted help key K_CTL_HOME ffb0 260 kHOM KEY_SHOME 0607 shifted home key K_SHF_ENTER ffe0 340 kIC KEY_SIC 0610 shifted input key K_CTL_LEFT ffb4 264 kLFT KEY_SLEFT 0611 shifted left arrow key K_ALT_LEFT ffc4 304 kMSG KEY_SMESSAGE 0612 shifted message key K_ALT_RIGHT ffc6 306 kMOV KEY_SMOVE 0613 shifted move key K_CTL_PGDN ffba 272 kNXT KEY_SNEXT 0614 shifted next key K_ALT_Z fffa 372 kOPT KEY_SOPTIONS 0615 shifted options key K_CTL_PGUP ffb2 262 kPRV KEY_SPREVIOUS 0616 shifted prev key K_CTL_PRTSC ffbd 275 kPRT KEY_SPRINT 0617 shifted print key K_ALT_PRTSC ffcd 315 kRDO KEY_SREDO 0620 shifted redo key kRPL KEY_SREPLACE 0621 shifted replace key K_CTL_RIGHT ffb6 266 kRIT KEY_SRIGHT 0622 shifted right arrow kRES KEY_SRSUME 0623 shifted resume key K_ALT_KPDPLUS ffc7 307 kSAV KEY_SSAVE 0624 shifted save key K_ALT_KPDMINUS ffc3 303 kSPD KEY_SSUSPEND 0625 shifted suspend key kUND KEY_SUNDO 0626 shifted undo key kspd KEY_SUSPEND 0627 suspend key K_ALT_U fff5 365 kund KEY_UNDO 0630 undo key K_RUBOUT 007f 177 del K_ERASE 0018 030 ^x K_TAB 0009 tab Column descriptions: 1 - The key names assigned within the /usr/include/sys/qnxterm.h header file. These names indicate the actual key on the console 2 - The key values read by getchar() if this key were to be pressed. This value is either expressed as 4 hex digits, indicating that the key is read first as a 0xff value followed by a unique key code. This encoding allows foreign language keyboards to return key codes that are not confused with function keys on the console keyboard. 3 - The octal value returned as the final 8-bit code for the key. 4 - The terminfo capability name as it would appear within the terminfo description for the terminal. These names are similar to those used by curses. 5 - The key name as it appears in the main terminfo capabilities listing in this technical note. 6 - The octal value returned by the terminfo getch() routine or by the QNX term library term_key() routine. 7 - The full text name of the key, as named by terminfo. Note that these names do not map well onto the QNX console, hence the mapping indicated in column 1. 4.9 Terminal Initialization The terminfo capabilities 'is1', 'is2' and 'is3' contain strings to be emitted to the terminal to place it in a mode suitable for control by the terminfo routines. Additionally, the 'if' capability can define the name of a file to be copied out to the terminal if the initialization strings within the terminfo definition cannot be long enough to achieve the desired effect ( note that a compiled terminfo description cannot exceed 4096 bytes ). Finally, the 'iprog' capability can name a program to execute to initialize the terminal. The sequence with which these initialization capabilities is used is: 1) Execute 'iprog' if defined 2) Output 'is1' 3) Output 'is2' 4) Set the margins using 'mgc', 'smgl' and 'smgr'. 5) Set the tabs using 'tbc' and 'hts'. 6) Output the contents of the file 'if'. 7) Output the string 'is3'. Most terminfo entries use 'is2' to accomplish the terminal initialization. The combination of this initialization should put the terminal into a mode consistent with the remainder of the terminfo definition. For example, the QNX terminfo initialization turns off "auto-right-margin", so the terminfo entry does not contain the 'am' flag in order to be consistent with this. This is done so that the screen will not scroll if a full screen application attempts to write the bottom-right corner of the screen. In order to reset the terminal from an unknown state, or back into a state suitable for use at the shell prompt, the 'rs1', 'rs2', 'rf' and 'rs3' capabilities can be defined. They are used in this sequence for the reset. For example, the QNX terminfo entry turns the auto-right-margin back on so that long lines typed at the shell prompt will properly wrap to the next line. 4.10 Line Graphics Many terminals have a line drawing character set that can be used for line drawings, bar charts, etc. In order to enable this line drawing character set, the 'enacs' ( enable alternate character set ) sequence must be sent to the terminal. Exiting from this mode requires that the 'rmacs' sequence be sent. The string capability that describes the line drawing characters available is 'acsc' and it consists of a sequence of character pairs, the first character of each pair indicating which character is being described, the second character being the actual character to be sent to the terminal to invoke the required character on the terminal screen. The following table shows the leading character for the character pair for each glyph: Character name Mapping character arrow pointing right + arrow pointing left , arrow pointing down . solid square O lantern symbol I arrow pointing up - diamond ' checker board a degree symbol f plus/minus g board of squares h lower right corner j upper right corner k upper left corner l lower left corner m plus n scan line 1 o horizontal line q scan line 9 s left tee t right tee u bottom tee v top tee w vertical line x bullet ~ When preparing an acsc string for a new terminal, the capability should be expressed as: acsc=+1'2.3O4I5.... where the 1,2,3,4... is replaced with the character that particular terminal uses to display the glyph indicated by the first character in the pair. For example, the 'acsc' string for the QNX console is encoded as acsc=l\332m\300k\277j\331q\304x\263u\264t\303n\305v\301w\302O\333a\262o\337s\334, 4.11 Color Manipulation Most existing terminals manipulate color as a foreground and a background setting, such that if the terminal supports 'N' colors, any given character can be displayed with any of 'N' foreground and 'N' background colors. The variable 'colors' defines the number of colors that can be displayed on the terminal simultaneously. The QNX console makes use of the 'scp' ( set color pair ) capability to define the color pair that will be used by characters displayed as a foreground / background color pair. A terminal that supports individual setting of foreground and background colors could use the 'setf' and 'setb' cabailities to define each color independently. A QNX console does not support this mode of color setting, but ANSI emulators for PC's typically do. Terminals which erase background areas of the screen with the currently defined background color should have the 'bce' ( background color erase ) capability defined. When the application exits, it should use the 'op' ( original pair ) capability to force the terminal back to the colors in effect when the application started. If 'op' does not exist, 'oc' ( original colors ) should be used to force the terminal back to a color pair the user prefers. For terminals which substitute color for visual attributes, the 'ncv' ( no color video ) numeric capability should be defined to indicate how this is done. This numeric capability is bit encoded to indicate which video attributes should be emulated with color as follows: Attribute Bit Number in NCV Standout 0 Underline 1 Reverse 2 Blink 3 Dim 4 Bold 5 Invisible 6 Protected 7 Alternate charset 8 For each video attribute that should not be used with colors, the NCV bit should be set. For example, if the terminal must use color to indicate underline, the ncv#2 capability should appear in the terminfo definition. 4.12 Terminfo Library Routines The following documents some low level functions from the terminfo library. These functions are documented here, but are not likely to be heavily used, since programmers will choose to use either the curses or the QNX term routines. cbreak(); nocbreak(); This pair of routines put the terminal in and out of cbreak mode. Cbreak mode allows the individual characters typed by the user to be available to the program without the user needing to press the newline key. Most interactive programs use cbreak mode. Interrupt and flow control characters continue to function as before. nocbreak() will resume normal line editing for input. echo(); noecho(); These two routines enable and disable echo-on-input. Most interactive applications prefer to do their own output echoing, so that the positioning of the echoed input can be precisely positioned. nl(); nonl(); By default, translation of the carriage return on input to the newline is done. The nonl() routine can be used to disable this behaviour amd nl() to re-enable it. Note that cbreak() mode automatically disables this behavior. halfdelay( tenths ); This routine causes the getch() routine to wait up to "tenths" of a second for input. ERR ( -1 ) will be returned if no input data is available within the specified interval. The nocbreak() routine can be used to disable this behavior. keypad( int win, int state ); This option enables the function key processing inside the getch() routine so that getch() can discern between the user pressing the function key or pressing the keys that the function key itself would have sent. See the getch() routine for more details. nodelay(); Input from the getch() routine will be non-blocking, returning ERR ( -1 ) if no input is pending. notimeout(); Disable the timeout processing that getch() does that allows user to enter multi-character function key codes and have getch() be able to differentiate them from the user actually pressing the function key on the terminal. raw(); noraw(); Same as cbreak()/nocbreak() except that interrupt, quit, suspend and flow control characters are also passed through to the application. Use echo()/noecho() to control echo. The raw mode is not recommended for interactive applications unless absolutely necessary, since a terminal that relies on flow control will not operate properly in raw mode. int getch(); The getch() routine reads from the terminal and returns a character ( see the /usr/include/sys/qnxterm.h for a list of key values ). If nodelay() had been called, the getch() routine will not block for input and will return ERR ( -1 ) to indicate no input data was available, otherwise the input will be returned. In nodelay() was not in effect, getch() will block until data is available. If cbreak() had been called, getch() will return after a single character, in nocbreak() mode, the data will only be returned after a newline was entered. The halfdelay() input mode will wait until the interval specified by the halfdelay call and return either ERR ( -1 ) on timeout, or the input data. Unless noecho() was set, the output will also be echoed to the input device. The getch() routine is called by the term_key() routine, which will do a term_flush() before blocking for input. Programs which plan to directly call getch() are encouraged to flush their output before calling getch() as well. Note that getch() is a macro that actually invokes __getch() so as to not interfere with another getch() routine already present in the Watcom library. If the /usr/include/term.h file is included, calls to getch() will be defined to be calls to __getch(), causing the terminfo getch() routine to be linked into the executable program and not the Watcom getch() routine. If keypad( 0, TRUE ) was called, function keys pressed by the user will be processed into a single integer value, instead of being returned as the sequence of codes generated by the terminal when the function key is pressed. The values returned in keypad mode are defined in section 4.8 of this technical note and in /usr/include/sys/qnxterm.h. This function key processing is accomplished by the getch() routine noticing that the character received is one of a set known to be a lead-in for a function key. If so, the getch() function will set a timer used to limit how long it will wait for the next character in sequence. If the timer expires, the getch() routine assumes that the user is manually typing the characters, and had not pressed a function key. The benefit of this approach to function key processing is that the user can still manually press the escape key to exit a menu, even though the terminal in use might precede function keys with the escape code ( VT-series terminals do this ). Applications which use the escape key can then continue to use the escape key and document its use, independent of what terminal type the end user might actually be using. The default delay used for function key processing by getch() is 300 milliseconds. The print_rate ( cps ) parameter in the terminal definition can be used to change this value if necessary. Delays are expressed in 10ths of a second increments. The notimeout() function call can be used to disable function key processing. With notimeout mode in effect, the user could also manually type function key sequences, but the getch() routine would be unable to differentiate between the user typing the escape key, or an escape coming from the terminal as the lead-in for a function key. ungetch( int ch ); Push the character ch back on the input stream for the next call to getch(). Querying current settings: baudrate(); Return the baudrate of the console. Color Manipulation: has_colors(); Returns true or false if the terminal has colors. has_ic(); Returns true or false if the terminal has insert and delete character capabilities. has_il(); Returns true or false if the terminal has insert and delete line capabilities or can emulate them with a scrolling region. can_change_color(); Returns true or false if the terminal can redefine its colors. Low level Terminfo routines: setupterm( char *term, int filedes, int *error ); This routine will load the terminfo description for the terminal specified by the "char *term" variable into a TERMINAL data structure pointed to be 'curterm'. This data structure is detailed in the /usr/include/term.h file. If "char *term" is NULL, the terminal named in the TERM environment variable will be used instead. All output will be to the file descriptor 'filedes'. If 'error' is not NULL, then the return value from this function will be OK ( 0 ) or ERR ( -1 ) and a status value will be stored where 'error' points. This value will be one of: 1 - setupterm() succeeded 0 - The specified terminal could not be found -1 - The terminfo database could not be accessed. If the 'error' variable is NULL, setupterm() will print an appropriate error message and exit. The typical form of the call the setupterm() would be: setupterm( NULL, 1, NULL ); which would invoke all the defaults. set_curterm( TERMINAL *newterm ); This function call causes the terminfo functions to operate from the TERMINAL data structure pointed to by 'newterm'. del_curterm( TERMINAL *oldterm ); This function call frees the TERMINAL structure pointed to by 'oldterm'. If this happens to also be the 'curterm', further calls to the terminfo routines will be undefined. resetty(); savetty(); Reset the terminal state to a previously saved value or save the current terminal state for future restoration by resetty(). tputs( char *str, int numlines, char *putc() ); Output the terminfo capability string 'str', applying padding and using the putc routine whose address is passed. The 'numlines' parameter indicates how many lines will be affected by this capability and is used to scale the padding applied accordingly. putp( char *str ); Output the terminfo capability string 'str', applying padding as defined. This function effectively does a "tputs( str, 1, putchar);". char *tparm( char *str, ... ); Instantiate the optional passed parameters into the terminfo capability string 'str' and return a pointer to the instantiated string. The number of parameters to be passed is dependent on the capability string. The following routines return the value of the capability string specified by name: int tigetflag( char *capname ); This function returns the numeric value of the specified boolean terminfo variable. The value -1 is returned if the name is not a valid capname and 0 is returned if this capname is not asserted for this terminal. int tigetnum( char *capname ); This function returns the numeric value of the specified numeric terminfo variable. The value -2 is returned if the name is not a valid capname and -1 is returned if this capname is not defined for this terminal. char *tigetstr( char *capname ); This function returns a pointer to the string specified by the capname. The value (char *) -1 is returned if the name is not a valid capname and NULL is returned if this capname is not defined for this terminal. char *boolnames[], *boolcodes[], *boolfnames[]; char *numnames[], *numcodes[], *numfnames[]; char *strnames[], *strcodes[], *strfnames[]; These are null-terminated arrays that contain pointers to the capnames, the termcap codes and the full C names for each of the terminfo-recognized terminfo variables. Termcap Emulation As a conversion aid to programs that use the older termcap library, the following routines can be used. The functionality of these routines is achieved by accessing the data in the terminfo database, rather than from the /etc/termcap database. tgetflag( char *name ); Get the boolean entry for "char *name". tgetnum( char *name ); Get the numeric entry for "char *name". tgetent( bp, char *name ); Lookup the termcap entry for "char *name". The bp pointer is ignored by this emulation. char *tgetstr( char *name, char *area ); This function returns the pointer to the string capability 'name'. If the 'area' pointer is not NULL, then the string pointed to will be copied into 'area' and 'area' will be advanced. The 'tputs()' function should be used to output the string returned by tgetstr(). char *tgoto( char *capname, int col, int row ); The 'col' and 'row' parameters will be instantiated into the 'capname' and a pointer returned to the instantiated string. The 'tpus()' routine should be used to output the string to the terminal. tputs( char *str, int affected, int *putc() ); See 'tputs()' in the terminfo section. 4.13 Environment Variables The terminfo routines support some useful environment variables. These are: LINES - This environment variable can be set to override the number of lines for the terminal as defined in the terminfo definition. Note that applications running on the QNX console that have been compiled with the QNX term routines will automatically sense and adjust to the screen size if it differs from the terminfo definition. COLUMNS - This environment variable can be set to override the number of columns the screen supports, in the same manner as the LINES envar. TERMINFO - By default, the terminfo routines will pull the terminfo terminal description data from the /usr/lib/terminfo directory tree. This environment variable can be defined to force that description to come from a user-specified location. This is useful for testing new terminfo definitions, or for users who wish to maintain private terminfo databases. 4.14 Debugging terminfo applications Within the /usr/lib/terminfo/terminfo.src file is the definition of a test terminal that, instead of outputting escape sequences to a terminal when invoked by an application program, will output textual descriptions of the capabilities invoked. By executing: export TERM=test and running the program, it is easy to see exactly the sequence of terminfo capabilities invoked by the application as it runs, assuming your terminal supports the same capability set as test provides. For specific terminal testing, it can be worthwhile to modify the test definition to match the terminal the application is being debugged with. For more detailed testing with a real terminal definition in place, it is possible to 'tee' the output of an application into a logfile for later analysis with the QNX 'spatch' utility. For example, executing the command: program | tee logfile will allow 'program' to output to the console as normal, but the piping into the tee command will cause the character stream output by the application to be logged into the 'logfile'. ---------------------------------------------------------------------