Character mode applications that run under the Terminal Access Method (TAM) on the UNIX PC can now run under ETI with a wide range of terminals. This appendix explains how to use the TAM transition library, the source of this portability. In addition, it explains how you can eventually rewrite your TAM application programs to run more efficiently under ETI without the TAM transition library.
The TAM transition library consists of a header file tam.h and a set of library routines. The file tam.h translates between TAM routines and equivalent sets of low-level ETI routines. For example, the TAM function wcreate() is mapped to the conversion library function TAMwcreate(), which consists of a series of low-level calls, such as newwin() and subwin().
To use the TAM transition library, be sure to include the standard TAM header file tam.h in your application program. So at the beginning of your TAM application program, you should already have
#include <tam.h> /* as usual, for TAM calls */
Next, you recompile and link your application program, say tamprog.c, to form an executable, as follows:
cc -I /usr/add-on/include tamprog.c -ltam -lcurses -o executable_name
Note the use of the -I option, which tells the compiler where to find the TAM header files. The two uses of the -l option link to requisite library subroutines, the TAM transition library and the low-level ETI library.
Alternatively, you might separately compile one or more TAM application files (say, tam1.c, tam2.c, and main.c) and later link them to form an executable program.
cc -c -I /usr/add-on/include/ tam1.c /* compile files individually*/ cc -c -I /usr/add-on/include/ tam2.c cc -c -I /usr/add-on/include/ main.c /* link objects to form executable */ cc -o executable_name tam1.o tam2.o main.o -ltam -lcurses
Note that the -I option is required for the compilation of any file that uses the TAM library.
To enable the code in your TAM application program to run smoothly under ETI, you should do the following:
Eliminating the superfluous code in the first three cases reduces your program's size and execution time.
The TAM Transition Library translates between TAM function calls and low-level ETI function calls. It also ensures that escape and control sequences entered at a terminal's keyboard are properly interpreted.
The following table summarizes the translation of TAM to low-level ETI (curses) functions. Eventually, if you want to rewrite your TAM applications to make ETI calls directly and to run more efficiently, you can use this table as a guide.
TAM Call |
ETI Call |
winit () |
Call initscr(). |
wexit () |
Call endwin() and exit(). |
iswind () |
Return FALSE. |
wcreate () |
Call newwin() or new_panel(). |
wdelete () |
Call delwin() or del_panel(). |
wselect () |
Call touchwin() and wrefresh(), then update the list of windows to indicate the new ordering. |
wgetsel () |
Call top_panel() or bottom_panel() with NULL pointer. |
wgetstat () |
Call getyx(), getmaxyx(), or getbegyx(). |
wsetstat () |
Call del_panel(), then new_panel(). |
wputc () |
Call waddch(). |
wputs () |
Call waddstr(). |
wprintf () |
Call wprintw(). |
wslk () |
Create small window at bottom and use curses routines with wprintw(). |
wcmd () |
The character string passed by wcmd() is copied to the bottom of the screen. |
wprompt () |
The character string passed by wprompt() is copied to the bottom of the screen. |
wlabel () |
The character string is printed in the upper left corner of the specified window. |
wrefresh () |
Call wrefresh(). If the window index is -1, all windows should be refreshed in the appropriate order. |
wuser () |
This functionality is not necessary. Remove this from you code. |
wgoto () |
Call wmove(). |
wgetpos () |
Call getyx(). |
wgetc () |
Call wgetch(). Character translation from ETI to ANSI may be required depending on the current keypad mode. |
kcodemap () |
This functionality is not necessary. Remove this from your code. |
keypad () |
Call keypad(). |
wsetmouse () |
This is a null operation. |
wgetmouse () |
This is a null operation. |
wreadmouse () |
This is a null operation. |
wprexec () |
Call erase() and refresh(). |
wpostwait () |
Call wrefresh() for each window in the window list. |
wnl () |
The functionality of this routine is not supported by curses. |
wicon () |
This is a null operation. |
wicoff () |
This is a null operation. |
wrastop () |
This is a null operation. |
track () |
Call wgetch(). |
initscr () |
Call initscr(). |
nl () |
The functionality of this routine is not supported by curses. |
nonl |
The functionality of this routine is not supported by curses. |
cbreak () |
Call cbreak(). |
nocbreak () |
Call nocbreak(). |
echo () |
Call echo(). |
noecho () |
Call noech(). |
insch () |
Call insch(). |
getch () |
Call getch(). |
flushinp () |
Call flushinp(). |
attron () |
Call attron(). |
attroff () |
Call attroff(). |
savetty () |
Call savetty(). |
resetty () |
Call resetty(). |
addch () |
Call addch(). |
addstr () |
Call addstr(). |
beep () |
Call beep(). |
clear () |
Call clear(). |
clearok () |
This is a null operation. |
clrtobot () |
Call clrtobot(). |
clrtoeol () |
Call clrtoeol(). |
delch () |
Call delch(). |
deleteln () |
Call deleteln(). |
erase () |
Call erase(). |
flash () |
Call flash(). |
getyx () |
Call wgetyx(). |
insertln () |
Call insertln(). |
leaveok () |
This is a null operation. |
move () |
Call move(). |
mvaddch () |
Call move() and addch(). |
mvaddstr () |
Call move() and addstr(). |
mvinch () |
Call move() and inch(). |
nodelay () |
Call nodelay(). |
wndelay () |
Call nodelay(). |
refresh () |
Call refresh(). |
resetterm () |
Call resetterm(). |
baudrate () |
Call baudrate(). |
endwin () |
Call endwin(). |
fixterm () |
Call fixterm(). |
printw () |
Call printw(). |
Because the high-level TAM functions in the following table make calls only to the low-level functions in the previous table, you can continue to use those high-level TAM functions in your application programs as well. However, with ETI, you cannot use other TAM high-level functions such as wtargeton().
form() menu() message() pb_empty() pb_gets() adf_gttok() pb_open() pb_check() pb_seek() pb_name() pb_puts() pb_weof() pb_gbuf() adf_gtwrd()) adf_gtxcd() wind() exhelp()
Both TAM and ETI use a set of virtual function keys that translate between an escape character sequence entered at the keyboard and a bit pattern inside the machine. Under the TAM transition library, the TAM virtual key values are translated into ETI virtual key values.
The following table lists these equivalent virtual key values. Entering the escape sequence listed in the left column will generate the corresponding TAM virtual function key value given in the middle column. The right column lists the ETI equivalent of the TAM virtual key and is for reference only.
ESC-! s_F1 KEY_F(8) ESC-@ s_F2 KEY_F(9) ESC-# s_F3 KEY_F(10) ESC-$ s_F4 KEY_F(11) ESC-% s_F5 KEY_F(12) ESC-^ s_F6 KEY_F(13) ESC-$ s_F7 KEY-F(14) ESC-* s_F8 KEY_F(15) ESC-f1 PF1 KEY_F(16) ESC-f2 PF2 KEY_F(17) ESC-f3 PF3 KEY_F(18) ESC-f4 PF4 KEY_F(19) ESC-f5 PF5 KEY_F(20) ESC_f6 PF6 KEY_F(21) ESC_f7 PF7 KEY_F(22) ESC_f8 PF8 KEY_F(23) ESC_f9 PF9 KEY_F(24) ESC_f0 PF10 KEY_F(25) ESC-f- PF11 KEY_F(26) ESC-f= PF12 KEY_F(27) ESC-1 F1 KEY_F(0) ESC-2 F2 KEY_F(1) ESC-3 F3 KEY_F(2) ESC-4 F4 KEY_F(3) ESC-5 F5 KEY_F(4) ESC-6 F6 KEY_F(5) ESC-7 F7 KEY_F(6) ESC-8 F8 KEY_F(7) ESC-bg Beg KEY_BEG ESC_BG s_Beg KEY_SBEG ESC-br Break KEY_BREAK ESC-bw Back KEY_LEFT ESC-BW s-Back KEY_SLEFT ESC-ce Clear KEY_CLEAR ESC-CE Clear KEY_CLEAR ESC-ci ClearLine KEY_EOL ESC-CI s_ClearLine KEY_SEOL ESC-cl Close KEY_CLOSE ESC-CL Close KEY_CLOSE ESC-cm Cmd KEY_COMMAND ESC-CM s_Cmd KEY_SCOMMAND ESC-cn Cancl KEY_CANCEL ESC-CN s_Cancl KEY_SCANCEL ESC-cp Copy KEY_COPY ESC-CP s_Copy KEY_SCOPY ESC-cr Creat KEY_CREATE ESC-CR s_Creat KEY_SCREATE ESC-dc DleteChar KEY_DC ESC-Del DleteChar KEY_DC ESC-DC s_DleteChar KEY_SDC ESC-dl Dlete KEY_DL ESC-DL s_Dlete KEY_SDL ESC-dn Down KEY_DOWN ESC-DN RollDn KEY_SF ESC-en End KEY_END ESC-EN s_End KEY_SEND ESC-ESC Esc none ESC-ex Exit KEY_EXIT ESC-EX s_Exit KEY_SEXIT ESC-fi Find KEY_FIND ESC-FI s_Find KEY_SFIND ESC-fw Forward KEY_RIGHT ESC-FW s_Forward KEY_SRIGHT ESC-hl Help KEY_HELP ESC-? Help KEY_HELP ESC-HL s_Help KEY_SHELP ESC-hm Home KEY_HOME ESC-HM s_Home KEY_SHOME ESC-im InputMode KEY_IC ESC-NJ s_InputMode KEY_SIC ESC-mk Mark KEY_MARK ESC-MK Slect KEY_SELECT ESC-ms Msg KEY_MESSAGE ESC-MS s_Msg KEY_SMESSAGE ESC-mv Move KEY_MOVE ESC-MV s_Move KEY_SMOVE ESC-nx Next KEY_NEXT ESC-NX s_Next KEY_SNEXT ESC-op Open KEY_OPEN ESC-OP Close KEY_CLOSE ESC-ot Opts KEY_OPTIONS ESC-OT s_Opts KEY_SOPTIONS ESC-pg Page KEY_NPAGE ESC-PG s_Page KEY_PPAGE ESC-pr Print KEY_PRINT ESC-PR s_Print KEY_SPRINT ESC-pv Prev KEY_PREVIOUS ESC-PV s_Prev KEY_SPREVIOUS ESC-rd RollDn KEY_SF ESC-RD RollDn KEY_SF ESC-re Ref KEY_REFERENCE ESC-RE Rstrt KEY_RESTART ESC-rf Rfrsh KEY_RREFRESH ESC-RF Clear KEY_CLEAR ESC-rm Rsume KEY_RESUME ESC-RM s_Rsume KEY_SRSUME ESC-ro Redo KEY_REDO ESC-RO s_Redo KEY_SREDO ESC-rp Rplac KEY_REPLACE ESC-RP s_Rplac KEY_SREPLACE ESC-rs Rstrt KEY_REFERENCE ESC-RS Rstrt KEY_RESTART ESC-ru RollUp KEY_SR ESC-RU RollUp KEY_SR ESC-sl Slect KEY_SELECT ESC-SL Slect KEY_SELECT ESC-ss Suspd KEY_SUSPEND ESC-SS s_Suspd KEY_SSUSPEND ESC-sv Save KEY_SAVE ESC-SV s_Save KEY_SSAVE ESC-ud Undo KEY_UNDO ESC-UD s_Undo KEY_SUNDO ESC-up Up KEY_UP ESC-UP RollUp KEY_SR
Some keyboards have one or more keys that emit escape sequences that are identical to the UNIX PC keyboard sequences but do not match in terms of functionality. The function of an operationally incompatible key will always map to its terminfo specification. The TAM specific function implied by the same escape sequence will be accessible through the technique describe above. Mechanisms in curses(3X) automatically handle timing conflicts between actual keyboard function keys and UNIX PC keyboard escape sequences.