Genero-specific termcap definitions

Extending Function Key Definitions

In TUI mode, the runtime system recognizes function keys F1 through F36. These keys correspond to the termcap capabilities k0 through k9, followed by kA through kZ.

The termcap entry for these capabilities is the sequence of ASCII characters your terminal sends when you press the function keys (or any other keys you choose to use as function keys).

This example shows some function key definitions for the xterm terminal:
k0=\E[11~:k1=\E[12~:k2=\E[13~:k3=\E[14~:\
... 
k9=\E[21~:kA=\E[23~:kB=\E[24~:\

Defining dialog action keys

Dialog action keys for insert, delete and list navigation can be defined with the following capabilities:

Note: You can also use the OPTIONS statement to name other function keys or CTRL keys for these operations.

Specifying Characters for Window Borders

The runtime system uses the graphics characters in the termcap file when you specify a window border in an OPEN WINDOW statement.

The runtime system uses characters defined in the termcap file to draw the border of a window. If no characters are defined in this file, the runtime system uses the hyphen ( - ) for horizontal lines, the vertical bar ( | ) for vertical lines, and the plus sign ( + ) for corners.

Steps to define the graphical characters for window borders for your terminal type:

  1. Determine the escape sequences for turning the terminal graphics mode ON and OFF (Refer to the manual of your terminal). For example, on Wyse 50 terminals, the escape sequence for entering graphics mode is ESC H^B, and the escape sequence for leaving graphics mode is ESC H^C.
  2. Identify the ASCII equivalents for the six graphics characters that Genero requires to draw the window borders. The ASCII equivalent of a graphics character is the key you would press in graphics mode to obtain the indicated character. The six graphical characters needed by Genero are:
    1. The upper left corner
    2. The lower left corner
    3. The upper right corner
    4. The lower right corner
    5. The horizontal line
    6. The vertical line
  3. Edit the termcap entry for your terminal, and define the following string capabilities:
    • gs : The escape sequence for entering graphics mode. In the termcap file, ESCAPE is represented as a backslash ( \ ) followed by the letter E; CTRL is represented as a caret ( ^ ). For example, the Wyse 50 escape sequence ESC-H CTRL-B is represented as \EH^B.
    • ge : The escape sequence for leaving graphics mode. For example, the Wyse 50 escape sequence ESC-H CTRL-C is represented as \EH^C.
    • gb : The concatenated, ordered list of ASCII equivalents for the six graphics characters used to draw the border. Using the order as listed in (2).

      For example, if you are using a Wyse 50 terminal, you would add the following, in a linear sequence:

      :gs=\EH^B:ge=\EH^C:gb=2135z6:\

For terminals without graphics capabilities, you must enter a blank value for the gs and ge capabilities. For gb, enter the characters you want Genero to use for the window border. The following example shows possible values for gs, ge, and gb in an entry for a terminal without graphics capabilities:
:gs=:ge=:gb=.|.|_|:

With these settings, window borders would be drawn using underscores ( _ ) for horizontal lines, vertical bars ( | ) for vertical lines, periods ( . ) for the top corners, and vertical bars ( | ) for the lower corners.

Adding Color and Intensity

In TUI mode, a Genero program can be written either for a monochrome or a color terminal, and then you can run the program on either type of terminal. If you set up the termcap files as described, the color attributes and the intensity attributes are related.

Table 1. Relationship between color attributes and intensity attributes
Number Color Intensity Note
0 WHITE NORMAL  
1 YELLOW BOLD  
2 MAGENTA BOLD  
3 RED BOLD (*) If the keyword BOLD is indicated as the attribute, the field will be RED on a color terminal
4 CYAN DIM  
5 GREEN DIM  
6 BLUE DIM (*) If the keyword DIM is indicated as the attribute, the field will be BLUE on a color terminal
7 BLACK INVISIBLE  

The background for colors is BLACK in all cases. In either color or monochrome mode, you can add the REVERSE, BLINK, or UNDERLINE attributes if your terminal supports them.

The ZA String Capability

Genero uses a parameterized string capability named ZA in the termcap file to determine color assignments. Unlike other termcap string capabilities that you set to a literal sequence of ASCII characters, ZA is a function string that depends on the following four parameters:
Table 2. ZA function parameters
Parameter Name Description
1 p1 Color number between 0 and 7 (see Table 1).
2 p2 0 = Normal; 1 = Reverse.
3 p3 0 = No-Blink; 1 = Blink.
4 p3 0 = No-underscore; 1 = Underscore.

ZA uses the values of these four parameters and a stack machine to determine which characters to send to the terminal. The ZA function is called, and these parameters are evaluated, when a color or intensity attribute is encountered in a Genero program. Use the information in your terminal manual to set the ZA parameters to the correct values for your terminal.

The ZA string uses stack operations to push values onto the stack or to pop values off the stack. Typically, the instructions in the ZA string push a parameter onto the stack, compare it to one or more constants, and then send an appropriate sequence of characters to the terminal. More complex operations are often necessary; by storing the display attributes in static stack machine registers (named a through z), you can have terminal-specific optimizations.

The different stack operators that you can use to write the descriptions are summarized here. For a complete discussion of stack operators, see your operating system documentation.

Operators That Send Characters to the Terminal

Operators That Manipulate the Stack

Arithmetic Operators

Each arithmetic operator pops the top two values from the stack, performs an operation, and pushes the result on the stack.

Bit Operators

The following bit operators pop the top two values from the stack, perform an operation, and push the result on the stack:

The following unary operator pops the top value from the stack, performs an operation, and pushes the result on the stack:

Logical Operators

The following logical operators pop the top two values from the stack, perform an operation, and push the logical result (0 for false or 1 for true) on the stack:

The following unary operator pops the top value from the stack, performs an operation, and pushes the logical result (0 or 1) on the stack.

Conditional Statements

The conditional statement has the following format:

%? expr %t thenpart %e elsepart %;

The %e elsepart is optional. You can nest conditional statements in the thenpart or the elsepart .

When Genero evaluates a conditional statement, it pops the top value from the stack and evaluates it as either true or false. If the value is true, the runtime performs the operations after the %t; otherwise it performs the operations after the %e (if any).

For example, the expression:
%?%p1%{3}%=%t;31%;
is equivalent to:
if p1 = 3 then print ";31"

Assuming that p1 in the example has the value 3, Genero would perform the following steps:

ZA example

The ZA sequence for the ID Systems Corporation ID231 (color terminal) is:

ZA =
\E[0;                # Print lead-in
%?%p1%{0}%=%t%{7}    # Encode color number (translate color number
                     # to number for the ID231 term)
%e%p1%{1}%=%t%{3}    # 
%e%p1%{2}%=%t%{5}    # 
%e%p1%{3}%=%t%{1}    #
%e%p1%{4}%=%t%{6}    #
%e%p1%{5}%=%t%{2}    #
%e%p1%{6}%=%t%{4}    #
%e%p1%{7}%=%t%{0}%;  #
%?%p2%t30;%{40}%+%2d # if p2 is set, print '30' and '40' + color number (reverse)
%e40;%{30}%+%2d%;    #  else print '40' and '30' + color number (normal)
%?%p3%t;5%;          # if p3 is set, print 5 (blink)
%?%p4%t;4%;          # if p4 is set, print 4 (underline)
m                    # print 'm' to end character sequence