Video attribute commands are stored in the terminal interface variable _va_cmd[ ]. In order to accommodate as many terminals as possible, the _va_cmd[ ] array is two-dimensional. The first column contains the command to turn on the specified attribute and the second column contains the command to turn off that same attribute.
Some terminals require unique commands to turn off individual video attributes, instead of supporting a command that directly sets the NORMAL video attribute. Because of this, Vermont Views does not support a direct command to set the NORMAL video attribute. Rather, the terminal is assumed to be initialized to the NORMAL attribute. Commands are then given to enter other attribute states and to exit these states and return to the initial (NORMAL) state.
Presently, the _va_cmd[ ] array is large enough to support the following video attributes: Normal, Reverse, High Intensity, Underline, Blink, Block Graphics, Invisible, and 16 color combinations. Space must always be allocated to hold these video attribute commands and the order must be maintained. A terminal need not support all of these video attributes. If an attempt is made to turn-on or turn-off a non-supported video attribute, the current video attribute is left unchanged.
To add new color definitions, take the following steps:
| 1 | Edit vvtermcap to add the new set color commands (scl) and reset color commands (rcl) to the entries for all terminals you wish to support. |
| 2 | Increment the value of the #defined constant QVA_CMDS in vv_sys.h by the number of colors you are adding. QVA_CMDS is equal to the number of video attribute commands and is used to set the maximum size of the _va_cmd[ ] array. |
| 3 | In vv_sys.h, add #defined values to access the members of the _va_cmd[ ] array. These values are named in the series of constants VA_REVERSE, ..., VA_COLOR15, VA_COLOR16. Add your color values at the end of the list. |
| 4 | In vv_main.h, edit the array terminal definition parse table _td_tbl[ ] by adding two new TD_DEF structures in the array for each color definition you add—one for setting the color and another for resetting the color. For the pointer to the terminal interface variable to hold the commands found in vvtermcap, specify a pointer to one of the new elements in the _va_cmd[ ] array. See _td_tbl[ ] for an example. |
| 5 | In order to access these new color combinations from your program, you will need to #define new color attribute codes (COLOR17, COLOR18, etc.). Also, you will probably want to add more mnemonic definitions for these new color codes (e.g. GRAY or PINK). These definitions should be made in vv_sys.h. |
The Vermont Views initialization function will automatically load all of the color commands in the terminal definition.
There is no limit on the number of color commands that can be defined in the vvtermcap definition, but the terminal definition cannot be longer than 3072 characters.
Caution: The control sequences assigned to COLOR9 through COLOR16 are currently mapped to certain logical attributes and should convey the appropriate visual impression. For example, you would not want COLOR11 to be a white foreground on a black background because COLOR11 is currently mapped to LREVERSE. You can, of course, change this mapping. Color attribute codes are mapped to logical attributes in vv_main.h.