Configuring a text terminal / TERMCAP terminal capabilities |
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).
k0=\E[11~:k1=\E[12~:k2=\E[13~:k3=\E[14~:\ ... k9=\E[21~:kA=\E[23~:kB=\E[24~:\
Dialog action keys for insert, delete and list navigation can be defined with the following capabilities:
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:
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:\
: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.
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.
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.
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.
Each arithmetic operator pops the top two values from the stack, performs an operation, and pushes the result on the stack.
For example, %{2}%{3}%+ is equivalent to 2+3.
For example, %{7}%{3}%- is equivalent to 7-3.
For example, %{6}%{3}%* is equivalent to 6*3.
For example, %{7}%{3}%/ is equivalent to 7/3 and produces a result of 2.
For example, %{7}%{3}%m is equivalent to (7 mod 3) and produces a result of 1.
The following bit operators pop the top two values from the stack, perform an operation, and push the result on the stack:
For example, %{12}%{21}%& is equivalent to (12 and 21) and produces a result of 4.
For example, %{12}%{21}%| is equivalent to (12 or 21) and produces a result of 29.
For example, %{12}%{21}%^ is equivalent to (12 exclusive-or 21) and produces a result of 25.
The following unary operator pops the top value from the stack, performs an operation, and pushes the result on the stack:
For example, %{25}%~ results in a value of -26.
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:
For example, if the parameter p1 has the value 3, the expression %p1%{2}%= is equivalent to 3=2 and produces a result of 0 (false).
For example, if the parameter p1 has the value 3, the expression %p1%{0}%> is equivalent to 3>0 and produces a result of 1 (true).
For example, if the parameter p1 has the value 3, the expression %p1%{4}%< is equivalent to 3<4 and produces a result of 1 (true).
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.
This operator produces a value of zero for all nonzero numbers and a value of 1 for zero. For example, %{2}%! results in a value of 0, and %{0}%! results in a value of 1.
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).
%?%p1%{3}%=%t;31%;
if p1 = 3 then print ";31"
Assuming that p1 in the example has the value 3, Genero would perform the following steps:
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