QNX Community Resources
This chapter covers the following topics:
- Terminal capabilities
- Setting the terminal type
- The termcap database
- The terminfo database
- Extended capabilities for mouse events
Two kinds of terminal capabilities files give programmers the freedom to write terminal-independent programs. Older full-screen programs rely on the control codes in the terminal capabilities file /etc/termcap to make use of a terminal's capabilities. Newer programs and utilities query the terminfo capabilities database (under /usr/lib/terminfo).
The TERM environment variable specifies a terminal type. Initially, a program queries the TERM environment variable to determine what kind of terminal it's running on. Given a terminal type, the program would then look up the terminal's capabilities either in the termcap file or in the applicable terminfo file.
The terminal type setting is typically inherited from the environment through sinit immediately after boot:
sinit -r //$(bnode)/ TERM=qnx
As an alternative, the terminal type can be defined in a user's .profile file.
For hardwired terminals that run canned applications, you can preset the TERM environment variable when the application is launched:
TERM=vt100 on -t /dev/ser1 custom_application
But you can't do that for users logging in via login through tinit. If the type of terminal is known, tinit can be told to define the TERM environment variable before launching login:
tinit -c login -t /dev/ser1 TERM=ansi &
Unless you restrict dial-up access to only a particular type of terminal, modem users will need to run the termdef utility to query for a terminal type. The termdef utility can display all of the supported terminal types and ask the user to select one:
tinit -c "modem -c termdef" -t /dev/ser1 &
Once a terminal type has been selected, termdef sets the TERM environment variable accordingly and presents the login prompt to the user.
Control codes in the QNX termcap file can define the input and output capabilities of a number of terminal types, including:
- Generic ANSI standard terminal (ansi)
- QNX console (qnx)
- QNX ANSI (qansi, qansi-g, qansi-t, qansi-m, or qansi-w)
- QNX terminal (qnxt)
- QNX terminal with mouse events (qnxm)
- QNX windows (qnxw)
- QNX monochrome terminal or console (qnxtmono)
- QNX 2.15 serial terminal (qnxt2 or qnxs2)
- VT100 with Auto-margin (vt100)
- VT102 (vt102 or vt102-plus)
- X-term terminal emulator (xterm, xterms, xterm-m, or xterm-q)
For a complete list of terminal types, see /etc/termcap.
Each entry in the termcap file begins with a line of terminal aliases. The remaining sequence of control codes is a list of terminal capabilities.
Each capability string can be identified by a two-character name. In general, a string describes the terminal's behavior when the user presses a key, or the visual effect displayed through program control. If there's more than one entry for the same terminal type, the first entry is used.
The terminfo subdirectories /usr/lib/terminfo/... contain binary files. Each file in the terminfo database contains the capability definitions associated with a single terminal type. QNX is shipped with several of these files, including:
/usr/lib/terminfo/q/qnx (the QNX console)
/usr/lib/terminfo/v/vt100 (a VT100 terminal)
/usr/lib/terminfo/a/ansi (an ANSI terminal)
The corresponding source definitions for all QNX-supported terminal types are contained in /usr/lib/terminfo/terminfo.src.
The termcap and terminfo source files are similar in that they both contain descriptions of terminal capabilities. However, the capability names in a terminfo file can be two to five characters long. And because the terminfo files are compiled, they load and execute faster.
If you need to convert from terminfo to termcap (as is the case for some older applications), the infocmp utility has a -C option that generates a termcap entry from an existing terminfo definition. If there's more than one entry for the same terminal type in a terminfo file, the last entry is used.
If you don't have a terminfo file for your type of terminal, you could look for the appropriate terminfo file on any UNIX system, or create a new terminfo file through the infocmp and tic utilities.
To view or change the information in an existing terminfo capabilities file, you must first decompile the file through the infocmp utility. To use a modified source file, you must recompile it into binary form using tic, the terminfo compiler utility. Applications can extract the capabilities they need for a given terminal directly from the compiled version.
|You may want to choose capabilities from the higher-level library curses instead.|
The QNX termcap and terminfo files support many of the standard terminal capabilities. In addition to these, QNX supports the following extensions to the string and numeric capabilities to handle mouse events.
|termcap name||terminfo name||Description:|
|ZZ||mcud1||micro_down. Don't return press.|
|Za||mcub1||micro_left. Return mouse movement.|
|Zb||mcuf1||micro_right. Don't return mouse movement.|
|Zd||mcuu1||micro_up. Don't report release.|
|Zf||mcud||parm_down_micro. Return ADJUST press.|
|Zg||mcub||parm_left_micro. Return SELECT press.|
|Zh||mcuf||parm_right_micro. Return MENU press.|
|Zi||mcuu||parm_up_micro. Report button release.|
|ZJ||smicm||enter_micro_mode. Report screen size changes.|
|ZT||rmicm||exit_micro_mode. Don't report screen size changes.|
|Yd||maddr||max_micro_address. Maximum value in micro_..._ address (a numeric capability).|
For a complete list of capability names and their meanings, see the terminfo technote on QUICS. For more information about termcap and terminfo, we recommend termcap & terminfo, by Strang, Mui, & O'Reilly (ISBN 0-937175-22-6).