/* lborder.c -- an example program showing how to set up Logical Attributes for borders with Vermont Views. One of the problem areas when porting an application from the DOS environment to the UNIX or VMS environment is handling borders with different video attributes. Most terminals don't recognize the extended-ASCII characters that IBM used for the line drawing symbols on the PC. Some terminals support a line drawing character set, but you must switch into this "line drawing mode" and then send normal ASCII characters (0-127) that are displayed as line drawing characters. Vermont Views treats this "line drawing mode" as a video attribute (BLK_GRAPH) just the same a REVERSE video or HIGH_INTENSITY video. If you want a reverse video border, you must turn on both the BLK_GRAPH video mode *and* the REVERSE video mode. The only way to do this is to create a new "physical" attribute that is the combination of these two modes. This is the approach that this sample program uses. In order to write code that ports from DOS to UNIX/VMS with a minimum of changes, we're going to create a Logical Attribute for each different color combination that we're going to use for borders. This way, we only have to make sure that the appropriate Logical Attribute to Physical Attribute mappings are set up when moving from DOS to UNIX/VMS. Everything else falls out automatically. This sample program is going to create 2 windows. One window will have a border with the LBORDER1 attribute and the second window will have a border with the LBORDER2 attribute. You can see that after the initial set-up work is done, using LBORDER1 and LBORDER2 is simply and easy. If you make the indicated changes to vvtermcap and vv_main.h and compile, link and run this program on a vt100, you will see two windows - one with a NORMAL video attribute border and the second one with a REVERSE video attribute border. On UNIX and VMS systems, the following lines must be added to _td_tbl[] in vv_main.h. The location is unimportant: {(UCHAR *) "scl16", (PTR) &_va_cmd[VA_BORDER_1_COLOR][VA_ON], TDF_STR, 0}, {(UCHAR *) "rcl16", (PTR) &_va_cmd[VA_BORDER_1_COLOR][VA_OFF], TDF_STR, 0}, {(UCHAR *) "scl17", (PTR) &_va_cmd[VA_BORDER_2_COLOR][VA_ON], TDF_STR, 0}, {(UCHAR *) "rcl17", (PTR) &_va_cmd[VA_BORDER_2_COLOR][VA_OFF], TDF_STR, 0}, {(UCHAR *) "scl18", (PTR) &_va_cmd[VA_REV_BLK_GRAPH][VA_ON], TDF_STR, 0}, {(UCHAR *) "rcl18", (PTR) &_va_cmd[VA_REV_BLK_GRAPH][VA_OFF], TDF_STR, 0}, */ #include /*----------------------------------------------------------------------------*/ /* We're going to add 2 new Logical Attributes so we have to increase the */ /* size of several tables. This is accomplished by increasing LATTQ. To */ /* keep things easy to understand, we'll also define 2 symbolic constants */ /* to use when referencing the 2 new Logical Attributes. These changes and */ /* additions could have been made in vv_sys.h. */ /*----------------------------------------------------------------------------*/ #define LBORDER1 (UCHAR) 41 #define LBORDER2 (UCHAR) 42 #undef LATTQ #define LATTQ 43 #if UNIX | VMS /*----------------------------------------------------------------------------*/ /* When running on a terminal, we need to increase the size of the table */ /* that holds the escape strings to set/reset video modes. Since we're */ /* adding 3 new "physical" attributes, we need to make the table 3 entries */ /* bigger. While we're at it, we'll also define some symbolic constants for */ /* referencing these new positions in the table. These changes/additions */ /* could have been made in vv_sys.h. */ /* */ /* We'll also have to add some new fields to the wfctermcap definitions. */ /* Here are the additions for the vt100 definition. I've duplicated the */ /* last line in the vt100 definition here (adding the continuation character)*/ /* and shown the additions that I made: */ /* */ /* :k8=\E9: :k9=\E0:\ */ /* :scl16=^N\E[37m\E[44m: :rcl16=^O\E[m:\ */ /* :scl17=^N\E[34m\E[47m: :rcl17=^O\E[m:\ */ /* :scl18=^N\E[7m: :rcl18=^O\E[m: */ /* */ /* The scl18/rcl18 entries define the escape strings to set and reset */ /* REV_BLK_GRAPH video mode. The scl16/rcl16 entries define the escape */ /* strings to set and reset BORDER_1_COLOR video mode. The scl17 and rcl17 */ /* entries define the escape strings to set and reset BORDER_2_COLOR video */ /* mode. Since the vt100 is not a color terminal, I didn't really need to */ /* add scl16, rcl16, scl17 and rcl17. I just wanted to show what they would */ /* look like. If you had a color terminal you should add scl16, rcl16, */ /* scl17, rcl17. /*----------------------------------------------------------------------------*/ #define VA_BORDER_1_COLOR 22 #define VA_BORDER_2_COLOR 23 #define VA_REV_BLK_GRAPH 24 #undef QVA_CMDS #define QVA_CMDS 25 /*----------------------------------------------------------------------------*/ /* We need some symbolic constants for the 3 new "physical" attributes that */ /* we created. These additions could have been made in vv_sys.h. */ /*----------------------------------------------------------------------------*/ #define BORDER_1_COLOR VA_BORDER_1_COLOR + 1 #define BORDER_2_COLOR VA_BORDER_2_COLOR + 1 #define REV_BLK_GRAPH VA_REV_BLK_GRAPH + 1 #endif #include int main(void); int main() { WINDOWPTR wnp1, wnp2; vv_init(); /*----------------------------------------------------------------------------*/ /* Initialize the 2-dimensional Logical Attribute Table for the 2 new Logical*/ /* Attributes that we created: LBORDER1 and LBORDER2. We could have */ /* changed vv_main.h directly and omitted this step. */ /*----------------------------------------------------------------------------*/ #if PCDOS latt_rpl(LBORDER1, NORMAL, WHITE, BLUE, LATT_SYS); latt_rpl(LBORDER2, REVERSE, BLUE, WHITE, LATT_SYS); #endif #if UNIX | VMS #if SCO_UNIX /*----------------------------------------------------------------------------*/ /* If we're running on an IBM (or clone) under SCO XENIX, then we have to use*/ /* special MM (memory-mapped) attributes. */ /*----------------------------------------------------------------------------*/ if (_wnmemmap) { latt_rpl(LBORDER1, MMNORMAL, MMWHITE, MMBLUE, LATT_SYS); latt_rpl(LBORDER2, MMREVERSE, MMBLUE, MMWHITE, LATT_SYS); } else #endif /*SCO_UNIX */ { latt_rpl(LBORDER1, BLK_GRAPH, BORDER_1_COLOR, 0, LATT_SYS); latt_rpl(LBORDER2, REV_BLK_GRAPH, BORDER_2_COLOR, 0, LATT_SYS); } #endif /*UNIX | VMS */ /*----------------------------------------------------------------------------*/ /* All of the set-up work is done. Now it is time to do "normal" VV stuff. */ /*----------------------------------------------------------------------------*/ wnp1 = wn_def(5, 0, 10, 40, LNORMAL, BDR_SLNP); sw_bdr(wnp1->bdr_linep, LBORDER1, wnp1); sw_title(" Window 1 ", LNORMAL, TOPRIGHT, wnp1); wnp2 = wn_def(5, 40, 10, 40, LNORMAL, BDR_SLNP); sw_bdr(wnp2->bdr_linep, LBORDER2, wnp2); sw_title(" Window 2 ", LREVERSE, TOPLEFT, wnp2); wn_set(wnp1); wn_set(wnp2); csr_mv(vs_rowq() - 1, 0); /*put the cursor on the last line */ exit_vv(); #if VMS return; #else return(0); #endif }