ANSI Terminal Emulation and Informix 4GL Terminal Capabilities

Published on May 1, 1993 by Lester Knutsen

First Published in the Washington Area Informix User Group Newsletter, Volume 3, No. 3 - May 1993

In the Q&A sessions at our user group meetings several questions have been asked about creating termcap entries for PCs using ansi terminal emulation software to work with Informix 4GL. The following is the ansi termcap entry I have used with Procomm, Xtalk for Windows, SCO Unix ansi console and SCO ansi X terminal emulation. It provides graphic lined boxes around a window, function keys 1 to 10, and the 8 basic colors Informix 4GL programs support. Be very careful in changing your termcap file. This may break other applications or leave out capabilities used in other applications.

# modified Informix 4GL ansi color, function keys, and box borders
ansi|Ansi standard crt:\
	:al=\E[L:am:bs:cd=\E[J:ce=\E[K:cl=\E[2J\E[H:cm=\E[%i%d;%dH:co#80:\
	:dc=\E[P:dl=\E[M:dn=\E[B:ei=:ho=\E[H:ic=\E[@:im=:li#24:\
	:nd=\E[C:ms:pt:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:up=\E[A:\
	:kb=^h:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:eo:\
	# capability to display graphic boxes using the PC ansi character set \
	:gs=:ge=:gb=\332\300\277\331\304\263:\
	# function keys F1 (k0) to F10 (k9) \
	:k0=\E[M:k1=\E[N:k2=\E[O:k3=\E[P:k4=\E[Q:\
	:k5=\E[R:k6=\E[S:k7=\E[T:k8=\E[U:k9=\E[V:\
	# informix 4gl color support  - the next line is one very long line \
:ZA=\E[%?%p1%{0}%=%t0m\E[37%e%p1%{1}%=%t33%e%p1%{2}%=%t35%e%p1%{3}%=%t31%e%p1%
{4}%=%t36%e%p1%{5}%=%t32%e%p1%{6}%=%t34%e%p1%{7}%=%t30%;m\E[40m%?%p2%t\E[7m%;%?%p3%t\E[5m%;%?%p4%t\E[4m%;:

To test the results, set up a working directory ( e.g. $HOME/work ) and create the termcap file listed above. The lines beginning with a # are comments. All lines need to end with a \ which indicates that the commands continue on the next line. The last line that begins with :ZA= is one long line and cannot be separated by returns. In vi just keep typing until you reach the final :. To test the termcap set the following variables:

TERMCAP=$HOME/work/termcap; export TERMCAP
TERM=ansi; export TERM

There is one difference between the SCO ansi console and PC based terminal emulation packages like Procomm and Xtalk. Procomm and Xtalk use the 25th line for a status line leaving only 24 lines for the terminal emulation. The SCO console and ansi X term can use 25 lines. You can change the capability li#24 to li#25 if you only use an SCO console or X terminal. I have had problems with Procomm and vi because vi uses terminfo and terminfo was set to 25 lines per screen for an ansi terminal.

The following is the terminal setup in Procomm. Press Alt-S to get the setup menu and select Terminal - General.

PROCOMM PLUS SETUP UTILITY TERMINAL OPTIONS
A- Terminal emulation ................ ANSI
B- Duplex ............................ FULL
C- Software flow control (XON/XOFF) .. ON
D- Hardware flow control (RTS/CTS) ... ON
E- Line wrap ......................... ON
F- Screen scroll ..................... ON
G- CR translation .................... CR
H- BS translation .................... NON-DESTRUCTIVE
I- Break length (milliseconds) ....... 350
J- Enquiry (ENQ) ..................... OFF

To define and setup the function keys press Alt-F8 in Procomm. The following function keys need to be defined.

F1 ..... ^[[M
F2 ..... ^[[N
F3 ..... ^[[O
F4 ..... ^[[P
F5 ..... ^[[Q
F6 ..... ^[[R
F7 ..... ^[[S
F8 ..... ^[[T
F9 ..... ^[[U
F10 .... ^[[V

On the next page is a 4GL program I use to test the capabilities and the termcap entries for a new terminal. It creates a window with a border to test the line graphics capability. Then it displays 12 lines with different attributes. Finally, using the prompt command you can test each of the function keys.

The bold, dim, and underline attributes will display somewhat differently from what you would expect. Using Procomm, an X term or SCO ansi console, bold displays as red and dim displays as blue. The underline attribute displays as blue under Procomm, as an underline under X term, and as white under SCO ansi. All the other attributes display as expected except the last attribute. The last line displays the attribute black which is the same as the background color so it will be invisible.

I would be interested in your comments or other additional termcap suggestions. Please leave any messages or comments on the user group bulletin board or call me at 703-256-0267.

#############################################################################
# Copyright 1993 Advanced DataTools Corporation
# Module: @(#)termtest.4gl 1.4 Date: 93/05/10
# Author: Lester B. Knutsen
# Discription: Program to test the Informix 4GL capabilities of a terminal
#############################################################################
main
define ans char(1)
# Test if border line graphics are displayed correctly
open window test_box at 5,10 with 16 rows, 60 columns
attribute ( border , prompt line last )
display "Terminal Color, Graphics and Function key Test" at 1,7

# Test color and display attributes
display "Line 1 - reverse" at 2,1 attribute( reverse )
display "Line 2 - bold" at 3,1 attribute( bold )
display "Line 3 - dim" at 4,1 attribute( dim )
display "Line 4 - underline" at 5,1 attribute( underline )
display "Line 5 - white" at 6,1 attribute( white )
display "Line 6 - yellow" at 7,1 attribute( yellow )
display "Line 7 - magenta" at 8,1 attribute( magenta )
display "Line 8 - red" at 9,1 attribute( red )
display "Line 9 - cyan" at 10,1 attribute( cyan )
display "Line 10 - green" at 11,1 attribute( green )
display "Line 11 - blue" at 12,1 attribute( blue )
display "Line 12 - black" at 13,1 attribute( black ) # invsible line

# Test Function keys F1 to F10
while ( true )
    prompt "Press a Function Key [F1-F10] or Q to quit" for char ans
        on key (F1) error "F1 Function key pressed"
        on key (F2) error "F2 Function key pressed"
        on key (F3) error "F3 Function key pressed"
        on key (F4) error "F4 Function key pressed"
        on key (F5) error "F5 Function key pressed"
        on key (F6) error "F6 Function key pressed"
        on key (F7) error "F7 Function key pressed"
        on key (F8) error "F8 Function key pressed"
        on key (F9) error "F9 Function key pressed"
        on key (F10) error "F10 Function key pressed"
    end prompt
    if ans = "q" or ans = "Q" then exit while end if
end while
end main