home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / menu / cmenu / menusubs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-01  |  41.3 KB  |  1,226 lines

  1. #include "menudrv.h"
  2. #include "menudrv.def"
  3. #include <alloc.h>
  4. #include <conio.h>
  5. #include <ctype.h>
  6. #include <dos.h>
  7. #include <process.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11.  
  12. /*========================================================================*/
  13. /* EDIT subroutines                                                       */
  14. /*========================================================================*/
  15. /* declarations */
  16.  
  17. int insertx=60,inserty=1;
  18. int trimblanks=FALSE;
  19. int colx=0,coly=0;
  20.  
  21. /*-----------------------------------------------------------------------*/
  22.  
  23. void pad(char st[],int len)
  24. /* pad the length of string st to len chars */
  25. {
  26.    char *cp;
  27.    int i;
  28.  
  29.    /* find end of string */
  30.    for (cp=st,i=0; (*cp != 0) && (i<len); cp++,i++);
  31.    /* if not long enough, pad it */
  32.    while (i<len) {
  33.      *(cp++)=' ';
  34.      i++;
  35.    }
  36.    /* and reterminate it */
  37.    *cp=0;
  38. }
  39.  
  40. /*-----------------------------------------------------------------------*/
  41.  
  42. void trim(char st[])
  43. /* trim trailing blanks off of string st */
  44. {
  45.     int i;
  46.  
  47.     if ( st[0] != 0 ) {
  48.        i = strlen(st)-1;
  49.        while ( (i >= 0) && (st[i] == ' ') ) i--;
  50.        if (st[i] == ' ') st[i]=0;
  51.        else st[i+1]=0;
  52.     }
  53. }
  54.  
  55. /*-----------------------------------------------------------------------*/
  56.  
  57. void lcase(char st[])
  58. /* trim and convert string st to lower case */
  59. {
  60.    trim(st);
  61.    while (*st != NULL) tolower(*(st++));
  62. }
  63.  
  64. /*-----------------------------------------------------------------------*/
  65.  
  66. int getstring(int x,int y,int *c,char st[],int len)
  67. /* x,y are the position where the field begins; c is the cursor column
  68.    within the field (0 for 1st position); c is updated by getstring() */
  69. /* return codes (based on exit keystroke):
  70.     0:    CR, original entry changed
  71.     1:    CR, original entry unchanged
  72.     2:    Esc
  73.     3:    up arrow, ctrl-e
  74.     4:    left arrow, ctrl-s
  75.     5:    right arrow, ctrl-d
  76.     6:    down arrow, ctrl-x
  77.     7:    ctrl-w
  78.     8:    End
  79.     9:    PgUp, ctrl-r
  80.    10:    PgDn, ctrl-c
  81.    11-20: F1..F10
  82.    21:    ctrl-y
  83.    22:    ctrl-z
  84.    23:    ctrl-n
  85.    24:    Home
  86. */
  87. {
  88.    int _fret, i, n, nn;
  89.    char ch, c2, ch2, *cp;
  90.    string80 blankfield,model;
  91.  
  92. /* activate next section if colons (:) are desired around input fields */
  93. /* gotoxy(x - 1,y);
  94.    cprintf("%c", ':');
  95.    gotoxy(x + len,y);
  96.    cprintf("%c", ':');  */
  97.  
  98.    gotoxy(insertx,inserty);
  99.    if ( insert )
  100.         cputs(" INSERT    ");
  101.    else
  102.         cputs(" OVERWRITE ");
  103.  
  104.    strcpy(model,st);  /* make reference copy */
  105.    gotoxy(x,y);
  106.    strcpy(blankfield,blank);
  107.    blankfield[len]=0;  /* truncate length */
  108.  
  109.    pad(st,len);
  110.  
  111.    cputs(st);
  112.  
  113.    n = *c;
  114.    do {
  115.       gotoxy(x + n,y);
  116.       ch = getch();
  117.  
  118.       /*handle special characters*/
  119.       if ( ch == 0 ) {  /* IBM PC special char sequence */
  120.          c2 = getch();  /* get second char */
  121.          /* return predefined exit codes for F1..F10  (11..20) */
  122.          if ((c2 >= 59) && (c2 <= 68)) {
  123.             _fret = c2 - 48;
  124.             goto L99;
  125.          }
  126.          switch ( c2 ) {
  127.             case 72 :        /* up arrow */
  128.                ch = 5;       /* convert to ctrl-e */
  129.                break;
  130.             case 80 :        /* down arrow */
  131.                ch = 24;      /* convert to ctrl-x */
  132.                break;
  133.             case 75 :        /* left arrow */
  134.                ch = 19;      /* convert to ctrl-s */
  135.                break;
  136.             case 77 :        /* right arrow */
  137.                ch = 4;       /* convert to ctrl-d */
  138.                break;
  139.             case 73 :        /* PgUp */
  140.                ch = 18;      /* convert to ctrl-r */
  141.                break;
  142.             case 81 :        /* PgDn */
  143.                ch = 3;       /* convert to ctrl-c */
  144.                break;
  145.             case 82 :        /* Ins */
  146.                ch = 22;      /* convert to ctrl-v */
  147.                break;
  148.             case 83 :        /* Del */
  149.                ch = 7;       /* convert to ctrl-g */
  150.                break;
  151.             case 79 :        /* End */
  152.                _fret = 8;
  153.                goto L99;
  154.             case 71 :        /* Home */
  155.                _fret =  24;  /* return code 24 */
  156.                goto L99;
  157.             default:
  158.                ch = 0;
  159.                break;
  160.          }  /* switch */
  161.       }    /* if special */
  162.  
  163.       switch ( ch ) {        /* Esc */
  164.          case 27 :
  165.                _fret = 2;
  166.                goto L99;
  167.          case 13 :           /* CR */
  168.                if (strcmp(st,model)==0) _fret = 1;
  169.                else _fret = 0;
  170.                if (y<25) (y)++;
  171.                goto L99;
  172.          case 5 :            /* ctrl-e */
  173.                _fret = 3;
  174.                goto L99;
  175.          case 19 :           /* ctrl-s */
  176.                 if ( n == 1 ) {
  177.                   _fret = 4;
  178.                   goto L99;
  179.                 }
  180.                 else n--;
  181.                 break;
  182.          case 4 :            /* ctrl-d */
  183.                 if ( n == len ) {
  184.                   _fret = 5;
  185.                   goto L99;
  186.                 }
  187.                 else n++;
  188.                 break;
  189.          case 24 :           /* ctrl-x */
  190.                _fret = 6;
  191.                goto L99;
  192.          case 23 :           /* ctrl-w */
  193.                _fret = 7;
  194.                goto L99;
  195.          case 18 :           /* ctrl-r */
  196.                _fret = 9;
  197.                goto L99;
  198.          case 3 :            /* ctrl-c */
  199.                _fret = 10;
  200.                goto L99;
  201.          case 25 :           /* ctrl-y */
  202.                strcpy(st,blankfield);
  203.                n = 0;
  204.                gotoxy(x,y);
  205.                cputs(blankfield);
  206.               _fret = 21;
  207.               goto L99;
  208.          case 26 :           /* ctrl-z */
  209.               _fret = 22;
  210.               goto L99;
  211.          case 14 :           /* ctrl-n */
  212.               _fret = 23;
  213.               goto L99;
  214.          case 22 :           /* ctrl-v */
  215.                insert = !(insert);
  216.                gotoxy(insertx,inserty);
  217.                if ( insert )
  218.                   cputs(" INSERT    ");
  219.                else
  220.                   cputs(" OVERWRITE ");
  221.                break;
  222.          case 7 :            /* ctrl-g */
  223.                for ( i = n; i < len - 1; i++ )
  224.                   st[i] = st[i + 1];
  225.                st[len - 1] = ' ';
  226.                gotoxy(x,y);
  227.                cputs(st);
  228.                break;
  229.          case 20 :           /* ctrl-t */
  230.                p = n;
  231.                if (st[n] == ' ' )
  232.                   while ( (p < len) && (st[p] == ' ') ) p++;
  233.                else
  234.                   while ( (p < len) && (st[p] != ' ') ) p++;
  235.                strdel(st,n,p);
  236.                for ( i = 0; i <= p - n; i++ )
  237.                   strcat(st," ");
  238.                gotoxy(x,y);
  239.                cputs(st);
  240.                break;
  241.         case 9 :              /* ctrl-i or TAB */
  242.                n++;
  243.                while ((n<len) && (5 * (n / 5) != n)) n++;
  244.                gotoxy(x + n,y);
  245.                break;
  246.         case 17:             /* ctrl-q */
  247.                 ch2=getch();
  248.                 ch2=toupper(ch2);
  249.                 if ((ch2 =='D') || (ch2==4)) {  /* end of line */
  250.                     n=len;
  251.                     while ((st[n-1]==' ') && (n>0)) n--;
  252.                     if (n<len) n++;
  253.                 }
  254.                 else if ((ch2 == 'S') || (ch==13)) { /* beg of line */
  255.                     n=1;
  256.                     while ((st[n-1]==' ') && (n<len)) n++;
  257.                 }
  258.                 else if ((ch2=='R') || (ch2==12)) {
  259.                   _fret=9;
  260.                   goto L99;
  261.                 }
  262.                 else if ((ch2=='C') || (ch2== 3)) {
  263.                   _fret=10;
  264.                   goto L99;
  265.                 }
  266.                 else putch(7);
  267.                 break;
  268.          case 1 :            /* ctrl-a */
  269.                while ( (n > 0) && (st[n] != ' ')) n--;
  270.                while ( (n > 0) && (st[n] == ' ')) n--;
  271.                while ( (n > 0) && (st[n] != ' ' )) n--;
  272.                if ( st[n] == ' ') n++;
  273.                gotoxy(x + n,y);
  274.                break;
  275.          case 6 :            /* ctrl-f */
  276.                /* find end of current word */
  277.                while ( (n < len - 1) && (st[n] != ' ') ) n++;
  278.                nn = n;
  279.                /* find beginning of nextg word */
  280.                while ( (n < len) && (st[n] == ' ') ) n++;
  281.                if ( n == len ) {    /* no next word: back up */
  282.                  n = nn;
  283.                  if (n<len) n++;
  284.                }
  285.                gotoxy(x + n,y);
  286.                break;
  287.          default:
  288.            {
  289.            if ((insert) && !((ch >= 8) && (ch <= 13))){
  290.                   for ( i = len - 1; i > n ; i-- )
  291.                      st[i] = st[i - 1];
  292.                   st[n] = ch;
  293.                   gotoxy(x,y);
  294.                   cputs(st);
  295.                }
  296.                else {
  297.                   if (!((ch >= 8) && (ch <= 13)) ) {
  298.                      st[n] = ch;
  299.                      putch(ch);
  300.                   }
  301.                }
  302.                if ( (ch == '\x08') && (n > 0) )   /*backing up*/
  303.                   n--;
  304.                else if (ch != '\x08')
  305.                   n++;
  306.             }
  307.             break;
  308.       } /*switch/case*/
  309.  
  310.       if (colx != 0) {
  311.         gotoxy(colx,coly);
  312.         printf("%3d",n+1);
  313.       }
  314.  
  315.    } while ( ! ((ch == '\x0D') || (n > len)) );
  316.    if ( n >= len )  putch(7);
  317.    _fret = 0;
  318.  
  319. L99:
  320.  
  321.    if (trimblanks) {
  322.      if ( st[0] != 0 ) {
  323.        i = len-1;
  324.        while ( (i >= 0) && (st[i] == ' ') ) i--;
  325.        if (st[i] == ' ') st[i]=0;
  326.        else st[i+1]=0;
  327.      }
  328.    }
  329.  
  330.    (*c) = n;  /* update cursor position */
  331.    return(_fret);
  332.  
  333. } /*getstring*/
  334.  
  335. /*-----------------------------------------------------------------------*/
  336. #ifdef editable
  337. /*-----------------------------------------------------------------------*/
  338.  
  339. int getint(int x,int y,int *i,int w)
  340. {
  341.    int retcd,ret,col;
  342.    string80 temp;
  343.    col=0;
  344.  
  345.    do {
  346.      sprintf(temp,"%wd",*i);
  347.      retcd = getstring(x,y,&col,temp,w);
  348.      trim(temp);
  349.      ret = sscanf(temp, "%d", i);
  350.      if (ret==0) putch(7);
  351.    }
  352.    while (ret == 0);
  353.    gotoxy(x,y);
  354.    cprintf("%wd", (*i));
  355.    return(retcd);
  356. }  /*getint*/
  357.  
  358. /*-----------------------------------------------------------------------*/
  359.  
  360. int getachar(int x,int y,char *ch)
  361. {
  362.   int retval,col;
  363.   col=0;
  364.   retval = getstring(x,y,&col,ch,1);
  365.   return(retval);
  366. }
  367.  
  368. /*-----------------------------------------------------------------------*/
  369.  
  370. void editscreen (void)
  371. {
  372.     bclear(2);
  373.     bfore=(color(fore5));
  374.     bback=(color(back5));
  375.     bwrite(2,1,1,"╔══════════════════════════════════════════════════════════════════════════════╗");
  376.     bwrite(2,1,2,"║ Menu:       Item:         Descr:                                             ║");
  377.     bwrite(2,1,3,"╠══════════════════════════════════════════════════════════════════════════════╣");
  378.     bwrite(2,1,4,"║                                                                              ║");
  379.     bwrite(2,1,5,"║                                                                              ║");
  380.     bwrite(2,1,6,"║                                                                              ║");
  381.     bwrite(2,1,7,"║                                                                              ║");
  382.     bwrite(2,1,8,"║                                                                              ║");
  383.     bwrite(2,1,9,"║                                                                              ║");
  384.     bwrite(2,1,10,"║                                                                              ║");
  385.     bwrite(2,1,11,"║                                                                              ║");
  386.     bwrite(2,1,12,"║                                                                              ║");
  387.     bwrite(2,1,13,"║                                                                              ║");
  388.     bwrite(2,1,14,"║                                                                              ║");
  389.     bwrite(2,1,15,"║                                                                              ║");
  390.     bwrite(2,1,16,"║                                                                              ║");
  391.     bwrite(2,1,17,"║                                                                              ║");
  392.     bwrite(2,1,18,"║                                                                              ║");
  393.     bwrite(2,1,19,"║                                                                              ║");
  394.     bwrite(2,1,20,"║                                                                              ║");
  395.     bwrite(2,1,21,"║                                                                              ║");
  396.     bwrite(2,1,22,"║                                                                              ║");
  397.     bwrite(2,1,23,"╚══════════════════════════════════════════════════════════════════════════════╝");
  398.     bfore=(color(fore1));
  399.     bback=(color(back1));
  400.     restorescreen(2);
  401. }
  402.  
  403. /*-----------------------------------------------------------------------*/
  404.  
  405. void topfill (void)
  406. {
  407.     gotoxy(36,2);
  408.     cprintf("%-40s",cdescription);
  409.     gotoxy(9,2);
  410.     putchar(cmenu);
  411.     gotoxy(21,2);
  412.     putchar(citem);
  413. }
  414.  
  415. /*-----------------------------------------------------------------------*/
  416.  
  417. void topedit (void)
  418. {
  419.      int        xpos, ypos, col;
  420.      string80   temp;
  421.  
  422.     xpos=36;
  423.     ypos=2;
  424.     col=0;
  425.     getstring(xpos,ypos,&col,cdescription,40);
  426.     trim(cdescription);
  427. }
  428.  
  429. /*-----------------------------------------------------------------------*/
  430.  
  431. void redraw (void)   /* redraw internal part of screen */
  432. {
  433.  
  434.     int     i;
  435.  
  436.     savescreen(2);
  437.     bfore=(color(fore5));
  438.     bback=(color(back5));
  439.     for (i=1; i<20; i++) bwrite(2,2,i+3,edscreen[i]);
  440.     restorescreen(2);
  441.     bfore=(color(fore1));
  442.     bback=(color(back1));
  443. }
  444.  
  445. /*-----------------------------------------------------------------------*/
  446.  
  447. void redisplay (void)   /* redisplay current screen buffer */
  448. {
  449.     editscreen();
  450.     redraw();
  451.     topfill();
  452. }
  453.  
  454. /*-----------------------------------------------------------------------*/
  455.  
  456. void do_help (void)
  457. {
  458.  
  459.     char   ch;
  460.  
  461.     savescreen(2);
  462.     bclear(3);
  463.     bfore=(color(fore6));
  464.     bback=(color(back6));
  465.     bwrite(3,5,2,"╔═════════════════════════════════════════════════════════════════════╗");
  466.     bwrite(3,5,3,"║     EDIT HELP SCREEN                                                ║");
  467.     bwrite(3,5,4,"║                             F1 - show this help screen              ║");
  468.     bwrite(3,5,5,"║                             Home - goto line 1, column 1            ║");
  469.     bwrite(3,5,6,"║           ^e                PgUp, ^r - goto top of screen           ║");
  470.     bwrite(3,5,7,"║                             PgDn, ^c - goto bottom of screen        ║");
  471.     bwrite(3,5,8,"║            ^                End, ^w  - save changes, exit           ║");
  472.     bwrite(3,5,9,"║            |                Ins, ^v  - toggle insert mode           ║");
  473.     bwrite(3,5,10,"║            |                Del, ^g  - delete one character         ║");
  474.     bwrite(3,5,11,"║    ^s <----o----> ^d        Tab, ^i  - goto next tab position       ║");
  475.     bwrite(3,5,12,"║            |                ^y  -  delete line                      ║");
  476.     bwrite(3,5,13,"║            |                ^z  -  blank screen                     ║");
  477.     bwrite(3,5,14,"║            v                ^t  -  delete word right                ║");
  478.     bwrite(3,5,15,"║                             ^a/^f  -  advance word left/right       ║");
  479.     bwrite(3,5,16,"║           ^x                ^qs/^qd - goto beginning/end of line    ║");
  480.     bwrite(3,5,17,"║                             ^n  -  insert line                      ║");
  481.     bwrite(3,5,18,"║     Cursor Movement                                                 ║");
  482.     bwrite(3,5,19,"║    (or use cursor keys)                                             ║");
  483.     bwrite(3,5,20,"║                                                                     ║");
  484.     bwrite(3,5,21,"║    Note: ^ indicates hold the Ctrl key while pressing the key       ║");
  485.     bwrite(3,5,22,"╚═════════════════════════════════════════════════════════════════════╝");
  486.     bwrite(3,5,24,"Press any key to continue editing...");
  487.     restorescreen(3);
  488.     getch();
  489.     bfore=(color(fore5));
  490.     bback=(color(back5));
  491.     restorescreen(2);
  492.  
  493. }
  494.  
  495. /*-----------------------------------------------------------------------*/
  496.  
  497. void do_examples (void)
  498.  
  499. {
  500.     char     ch;
  501.  
  502.     savescreen(2);
  503.     bclear(4);
  504.     bfore=(color(fore6));
  505.     bback=(color(back6));
  506.     bwrite(4,5,1,"╔═════════════════════════════════════════════════════════════════════╗");
  507.     bwrite(4,5,2,"║     CREATING MENU ITEMS:                                            ║");
  508.     bwrite(4,5,3,"║          The lines which you supply for a menu item using this      ║");
  509.     bwrite(4,5,4,"║          editor ultimately become lines in a DOS batch file         ║");
  510.     bwrite(4,5,5,"║          when the item is selected--therefore, any legal batch      ║");
  511.     bwrite(4,5,6,"║          file commands may be used.  For example:                   ║");
  512.     bwrite(4,5,7,"║                  cd\\multimate                                       ║");
  513.     bwrite(4,5,8,"║                  wp                                                 ║");
  514.     bwrite(4,5,9,"║                  cd\\                                                ║");
  515.     bwrite(4,5,10,"║                  menu                                               ║");
  516.     bwrite(4,5,11,"║          would change the directory to 'multimate', execute 'wp',   ║");
  517.     bwrite(4,5,12,"║          change back to the root directory, and restore the menu.   ║");
  518.     bwrite(4,5,13,"║          (Note: you should always restart the menu as your last     ║");
  519.     bwrite(4,5,14,"║          item if you want the menu to return)                       ║");
  520.     bwrite(4,5,15,"║                                                                     ║");
  521.     bwrite(4,5,16,"║          Command line substitution may be accomplished by           ║");
  522.     bwrite(4,5,17,"║          enclosing a prompt string between square brackets ([]s)    ║");
  523.     bwrite(4,5,18,"║          at the position of a command line where the substitution   ║");
  524.     bwrite(4,5,19,"║          is needed.   For example:                                  ║");
  525.     bwrite(4,5,20,"║                    copy [Source?] [Destination?]                    ║");
  526.     bwrite(4,5,21,"║          will cause MENU to prompt the user for 'Source?' and       ║");
  527.     bwrite(4,5,22,"║          'Destination?' in turn, then use the replies to build      ║");
  528.     bwrite(4,5,23,"║          the DOS command line.                                      ║");
  529.     bwrite(4,5,24,"╚═════════════════════════════════════════════════════════════════════╝");
  530.     bwrite(4,5,25,"Press any key to continue....");
  531.     restorescreen(4);
  532.     getch();
  533.     bwrite(4,5,1,"╔═════════════════════════════════════════════════════════════════════╗");
  534.     bwrite(4,5,2,"║     CREATING MENU ITEMS (continued):                                ║");
  535.     bwrite(4,5,3,"║                                                                     ║");
  536.     bwrite(4,5,4,"║          Normally, a batch file is created by the menu driver       ║");
  537.     bwrite(4,5,5,"║          and the menu program exits to DOS, which executes the      ║");
  538.     bwrite(4,5,6,"║          batch file.  If you are executing a relatively short       ║");
  539.     bwrite(4,5,7,"║          stand-alone program, however, you may do so as a           ║");
  540.     bwrite(4,5,8,"║          subprocess while the menu system remains resident.         ║");
  541.     bwrite(4,5,9,"║                                                                     ║");
  542.     bwrite(4,5,10,"║          To execute a program as a subprocess, place a '&'          ║");
  543.     bwrite(4,5,11,"║          in the first column of the command line, e.g.:             ║");
  544.     bwrite(4,5,12,"║                                                                     ║");
  545.     bwrite(4,5,13,"║                   &c:\\dos\\link.exe parm1 parm2 ...                  ║");
  546.     bwrite(4,5,14,"║                                                                     ║");
  547.     bwrite(4,5,15,"║          The '&' will be trimmed off by the menu driver,            ║");
  548.     bwrite(4,5,16,"║          and the remaining command will be executed as a child      ║");
  549.     bwrite(4,5,17,"║          process.  This is noticeably faster than the batch file    ║");
  550.     bwrite(4,5,18,"║          approach, and may extend to multiple command lines.        ║");
  551.     bwrite(4,5,19,"║          Command line parameters and [] substitution are permitted. ║");
  552.     bwrite(4,5,20,"║                                                                     ║");
  553.     bwrite(4,5,21,"║          Notice that the FULL PATH and FILENAME must be specified   ║");
  554.     bwrite(4,5,22,"║          for the subprocess.  Error messages will be returned if    ║");
  555.     bwrite(4,5,23,"║          the call is not successful.                                ║");
  556.     bwrite(4,5,24,"╚═════════════════════════════════════════════════════════════════════╝");
  557.     bwrite(4,5,25,"Press any key to continue editing...");
  558.     restorescreen(4);
  559.     getch();
  560.     if (color(back1)>7) textcolor(color(fore1)+blink);
  561.     else textcolor(color(fore1));
  562.     textbackground(color(back1));
  563.     restorescreen(2);
  564. }
  565.  
  566. /*-----------------------------------------------------------------------*/
  567.  
  568. void edit (void)    /* edit the screen */
  569. {
  570.     char        ch,ch2,c2;
  571.     int         a,b;
  572.     int         i,j,n,retcd,col;
  573.     int         xx;
  574.  
  575.     insert=FALSE;
  576.     editscreen();
  577.     for (i=1; i<20; i++) pad(edscreen[i],77); /* pad length to 77 */
  578.     topfill();
  579.     redraw();
  580.     topedit();
  581.     x=1;
  582.     y=1;
  583.     col=0;
  584.     colx=24;
  585.     coly=24;
  586.     do  {
  587.         if (color(back1)>7) textcolor(color(fore1)+blink);
  588.         else textcolor(color(fore1));
  589.         textbackground(color(back1));
  590.         gotoxy(5,24);
  591.         cprintf("Row: %3d   Column: %3d",y,col+1);
  592.         cprintf("  Use F1 for help, F2 for examples     ");
  593.         if (color(back5)>7) textcolor(color(fore5)+blink);
  594.         else textcolor(color(fore5));
  595.         textbackground(color(back5));
  596.  
  597.         retcd=getstring(x+1,y+3,&col,edscreen[y],77);
  598.         switch (retcd) {
  599.           case 0 :
  600.           case 1 :
  601.             col=0;
  602.           case 6 :
  603.             if (y<19) y++;
  604.             break;
  605.           case 3 :
  606.             if (y>1) y--;
  607.             break;
  608.           case 11 :         /* F1 */
  609.             do_help();
  610.             break;
  611.           case 12 :         /* F2 */
  612.             do_examples();
  613.             break;
  614.           case 24 :         /* Home */
  615.             y = 1;
  616.             col = 0;
  617.             break;
  618.           case 9 :          /* PgUp */
  619.             y = 1;
  620.             break;
  621.           case 10:          /* PgDn */
  622.             y = 19;
  623.             break;
  624.           case 21:          /* ctrl-y */
  625.             for (i=y; i<19; i++)
  626.                 strcpy(edscreen[i],edscreen[i+1]);
  627.             edscreen[19][0]=0;
  628.             pad(edscreen[19],77);
  629.             redisplay();
  630.             break;
  631.           case 22:          /* ctrl-z */
  632.             gotoxy(10,24);
  633.             clreol();
  634.             cprintf("Zap entire screen -- you sure (Y/N)?");
  635.             ch=getch();
  636.             ch=toupper(ch);
  637.             if (ch == 'Y') {
  638.                 for (i=1; i<20; i++) {
  639.                     edscreen[i][0]=0;
  640.                     pad(edscreen[i],77);
  641.                 }
  642.                 y=1;
  643.                 col=0;
  644.                 redisplay();
  645.             }
  646.             else {
  647.              gotoxy(10,24);
  648.                 clreol();
  649.             }
  650.             break;
  651.           case 23:      /* ctrl-n */
  652.             for (i=19; i>y; i--) strcpy(edscreen[i],edscreen[i-1]);
  653.             edscreen[y][col]=0; /* cut orig line short */
  654.             if (y<19) {
  655.               strdel(edscreen[y+1],0,col);
  656.               pad(edscreen[y],77);
  657.               y++;
  658.               col=0;
  659.             }
  660.             redraw();
  661.             break;
  662.         } /* switch retcd */
  663.     }
  664.     while ((retcd != 7) && (retcd != 8));
  665.  
  666.     gotoxy(1,24);
  667.     if (color(back1)>7) textcolor(color(fore1)+blink);
  668.     else textcolor(color(fore1));
  669.     textbackground(color(back1));
  670.     clreol();
  671.     colx=0;
  672.     coly=0;
  673.  
  674.     for (i=1; i<20; i++) trim(edscreen[i]);  /* trim trailing blanks */
  675.  
  676. } /* edit */
  677.  
  678. /*-----------------------------------------------------------------------*/
  679. #endif
  680. /*-----------------------------------------------------------------------*/
  681.  
  682. void getdata (void)
  683. {
  684.  
  685.     char        *p;
  686.     lineptr     cp,np;
  687.     char        inpline[128];
  688.  
  689.     items=lines=0;
  690.     cp=np=NULL;
  691.     datafile=fopen(fname,"r");
  692.  
  693.     if (datafile==NULL) {
  694.         cprintf("Unable to open %s.\n",fname);
  695.         cprintf("Press any key to continue...");
  696.         ch=getch();
  697.         clrscr();
  698.         exit(1);
  699.     }
  700.     while (fgets(inpline,127,datafile) != NULL) {
  701.         p=strstr(inpline,"\n");
  702.         if (p!=NULL) *p=0;  /* delete carriage returns */
  703.         if (inpline[0]=='&') {   /* continuation of previous item */
  704.             strdel(inpline,0,1);
  705.             while ((strlen(inpline)>0) && (inpline[0]==' '))
  706.               strdel(inpline,0,1);
  707.             goto L10; /* process parameters */
  708.         }
  709.         while (inpline[0]==' ') strdel(inpline,0,1);  /* trim it */
  710.         while (inpline[strlen(inpline)-1]==' ')
  711.             strdel(inpline,strlen(inpline)-1,1);
  712.         items++;
  713.         if (items>maxitem) {
  714.             cprintf("Item overflow \7\n");
  715.             items--;
  716.             cprintf("Press any key to continue...");
  717.             ch=getch();
  718.             clrscr();
  719.             exit(1);
  720.         }
  721.         item[items]=(menuptr) calloc(1,sizeof(*(item[items])));
  722.         if (item[items]==NULL) {
  723.             cprintf("Unable to allocate storage for menu items.\n");
  724.             exit(1);
  725.         }
  726.         item[items]->id=toupper(inpline[0]);
  727.         item[items]->tomenu=toupper(inpline[2]);
  728.         item[items]->prompt=toupper(inpline[4]);
  729.         strdel(inpline,0,6);
  730.         p=strstr(inpline,",");
  731.         if (p==NULL) {
  732.             strcpy(item[items]->description,inpline);
  733.             inpline[0]=0;
  734.         }
  735.         else {
  736.             *p=0;   /* mark comma position as temporary end of string */
  737.             strcpy(item[items]->description,inpline);
  738.             *p=' '; /* replace null with ASCII blank */
  739.             strdel(inpline,0,(p-inpline)+1);  /* delete thru blank */
  740.         }
  741.  
  742.     item[items]->firstline=NULL;
  743.  
  744. L10:
  745.         p=strstr(inpline,",");
  746.         while (p!=NULL) {  /* capture parameters */
  747.             if (p==inpline) strdel(inpline,0,1); /* first char */
  748.             else {
  749.                 np=(lineptr)calloc(1,sizeof(*np));  /*allocate new line*/
  750.                 if (np==NULL) {
  751.                     cprintf("Unable to allocate storage for next line.\n");
  752.                     exit(1);
  753.                 }
  754.                 *p=0;
  755.                 strcpy(np->line,inpline);
  756.                 np->next=NULL;
  757.                 if (item[items]->firstline==NULL)
  758.                     item[items]->firstline=np;
  759.                 else cp->next=np; /* make the previous line point to this */
  760.                 cp=np;
  761.                 *p=' ';
  762.                 strdel(inpline,0,(p-inpline)+1);
  763.             } /* else */
  764.             p=strstr(inpline,",");
  765.         }  /* while p!=NULL */
  766.         if (strlen(inpline)>0) {   /*1 last item*/
  767.             np=(lineptr)calloc(1,sizeof(*np));   /*allocate new line*/
  768.             if (np==NULL) {
  769.                     cprintf("Unable to allocate storage for next line.\n");
  770.                     exit(1);
  771.                 }
  772.             strcpy(np->line,inpline);
  773.             np->next=NULL;
  774.             if (item[items]->firstline==NULL)
  775.                 item[items]->firstline=np;
  776.             else cp->next=np; /* make previous line point to this one */
  777.             cp=np;
  778.             inpline[0]=0; /* done with line */
  779.         }
  780.     } /* while more input remains */
  781.  
  782.     parmfile=fopen(parmfname,"r");
  783.     if (parmfile!=NULL) {
  784.         fscanf(parmfile,"%s\n",fore1);
  785.         fscanf(parmfile,"%s\n",back1);
  786.         fscanf(parmfile,"%s\n",fore2);
  787.         fscanf(parmfile,"%s\n",back2);
  788.         fscanf(parmfile,"%s\n",fore3);
  789.         fscanf(parmfile,"%s\n",back3);
  790.         fscanf(parmfile,"%s\n",fore4);
  791.         fscanf(parmfile,"%s\n",back4);
  792.         fscanf(parmfile,"%s\n",fore5);
  793.         fscanf(parmfile,"%s\n",back5);
  794.         fscanf(parmfile,"%s\n",fore6);
  795.         fscanf(parmfile,"%s\n",back6);
  796.         fclose(parmfile);
  797.     }
  798. } /*getdata*/
  799.  
  800. /*-----------------------------------------------------------------------*/
  801.  
  802. void savemenu (void)
  803. /* save menu data if user has changed it */
  804. {
  805.     int         i,j,n;
  806.     char        otline[128];
  807.     lineptr     cp,np;
  808.  
  809.     datafile=fopen(tempfname,"w");
  810.     for (i=1; i<=items; i++) if (item[i] != NULL){
  811.         sprintf(otline,"%c,%c,%c %s",item[i]->id,item[i]->tomenu,
  812.           item[i]->prompt,item[i]->description);
  813.         cp=item[i]->firstline;
  814.         while (cp != NULL) {
  815.             if ((strlen(cp->line)+strlen(otline))>79) {
  816.                 fprintf(datafile,"%s\n",otline);
  817.                 strcpy(otline,"& ");
  818.             }
  819.             else strcat(otline,",");
  820.             strcat(otline,cp->line);
  821.             cp=cp->next;
  822.         }
  823.         fprintf(datafile,"%s\n",otline);
  824.     } /* for */
  825.     fclose(datafile);
  826.  
  827.     unlink(bakfname);
  828.     rename(fname,bakfname);
  829.     rename(tempfname,fname);
  830. } /* savemenu */
  831.  
  832. /*-----------------------------------------------------------------------*/
  833.  
  834. void saveparm (void)
  835. /* save color parameters */
  836. {
  837.     parmfile=fopen(parmfname,"w");
  838.     fprintf(parmfile,"%s\n",fore1);
  839.     fprintf(parmfile,"%s\n",back1);
  840.     fprintf(parmfile,"%s\n",fore2);
  841.     fprintf(parmfile,"%s\n",back2);
  842.     fprintf(parmfile,"%s\n",fore3);
  843.     fprintf(parmfile,"%s\n",back3);
  844.     fprintf(parmfile,"%s\n",fore4);
  845.     fprintf(parmfile,"%s\n",back4);
  846.     fprintf(parmfile,"%s\n",fore5);
  847.     fprintf(parmfile,"%s\n",back5);
  848.     fprintf(parmfile,"%s\n",fore6);
  849.     fprintf(parmfile,"%s\n",back6);
  850.     fclose(parmfile);
  851. }
  852.  
  853. /*-----------------------------------------------------------------------*/
  854.  
  855. void getsysdate (void)
  856. {
  857.     union REGS regs;
  858.     regs.h.ah=42;   /* DOS get date function */
  859.     int86(33,®s,®s);
  860.     month=regs.h.dh;
  861.     day=regs.h.dl;
  862.     year=regs.x.cx;
  863.     weekday=regs.h.al;
  864. }
  865.  
  866. /*-----------------------------------------------------------------------*/
  867.  
  868. void dispdate (void)
  869. {
  870.     string80 temp;
  871.  
  872.     sprintf(temp,"%s, %s %d, %d",wdname[weekday],mname[month],
  873.             day,year);
  874.     bwrite(1,1,1,temp);
  875. }
  876.  
  877. /*-----------------------------------------------------------------------*/
  878.  
  879. void getsystime (void)
  880. {
  881.     union REGS regs;
  882.  
  883.     regs.h.ah=44;   /* DOS get time function */
  884.     int86(33,®s,®s);
  885.     hour=regs.h.ch;
  886.     min=regs.h.cl;
  887.     sec=regs.h.dh;
  888.     hun=regs.h.dl;
  889. }
  890.  
  891. /*-----------------------------------------------------------------------*/
  892.  
  893. void disptime (void)
  894. {
  895.  
  896.     int pm,h;
  897.     string80 temp;
  898.  
  899.     if (hour>12) {
  900.         h=hour - 12;
  901.         pm=TRUE;
  902.     }
  903.     else {
  904.         h=hour;
  905.         pm=FALSE;
  906.     }
  907.     cprintf("%2d:%02d:%02d %s",h,min,sec,(pm ? "pm" : "am"));
  908.  
  909. }
  910.  
  911. /*-----------------------------------------------------------------------*/
  912.  
  913. void bcalendar(int x,int y)
  914. {
  915.  
  916.     int     i,d,w,cw,cd;
  917.     char    syear[11];
  918.     char    sn[20];
  919.  
  920.     bfore=color(fore2);
  921.     bback=color(back2);
  922.     bwrite(1,x,y,"┌");
  923.     for (i=1;i<=26;i++) bwrite(1,x+i,y,"─");
  924.     bwrite(1,x+27,y,"┐");
  925.     for (i=1;i<=8;i++) {
  926.         bwrite(1,x,y+i,"│                          │");
  927.     }
  928.     bwrite(1,x,y+9,"└");
  929.     for (i=1;i<=26;i++) bwrite(1,x+i,y+9,"─");
  930.     bwrite(1,x+27,y+9,"┘");
  931.     sprintf(syear,"%4d",year);
  932.     bwrite(1,x+3,y+1,syear);
  933.     bwrite(1,x+14-strlen(mname[month]) / 2,y+1,mname[month]);
  934.     bwrite(1,x+21,y+1,syear);
  935.     bwrite(1,x+2,y+2,"S   M   T   W   T   F   S");
  936.     d=weekday;
  937.     w=((day+5-d) / 7)+1;  /*weeks into month*/
  938.     cw=w;
  939.     cd=d;
  940.     for (i=day;i>0;i--) {
  941.         sprintf(sn,"%2d",i);
  942.         if (holiday[month][i]) bfore=color(fore3);
  943.         if (specialday[month][i]) {
  944.           bfore=color(back2);
  945.           bback=color(fore2);
  946.         }
  947.         bwrite(1,x+1+(cd*4),y+2+cw,sn);
  948.         if (holiday[month][i]) bfore=color(fore2);
  949.         if (specialday[month][i]) {
  950.           bfore=color(fore2);
  951.           bback=color(back2);
  952.         }
  953.         cd--;
  954.         if (cd<0) {
  955.             cd=6;
  956.             cw--;
  957.         }
  958.     } /* for */
  959.     cw=w;
  960.     cd=d;
  961.     /* leap year correction */
  962.     if ((year % 4 == 0) &&
  963.         ((year % 100 !=0) || (year % 400==0))) days[2]=29;
  964.     for (i=day;i<=days[month];i++) {
  965.         sprintf(sn,"%2d",i);
  966.         if (holiday[month][i]) bfore=color(fore3);
  967.         if (specialday[month][i]) {
  968.           bfore=color(back2);
  969.           bback=color(fore2);
  970.         }
  971.         bwrite(1,x+1+(cd*4),y+2+cw,sn);
  972.         if (holiday[month][i]) bfore=color(fore2);
  973.         if (specialday[month][i]) {
  974.           bfore=color(fore2);
  975.           bback=color(back2);
  976.         }
  977.         cd++;
  978.         if (cd>6) {
  979.             cd=0;
  980.             cw++;
  981.         } /* if */
  982.     } /* for */
  983.     bfore=color(fore1);
  984.     bback=color(back1);
  985.     sprintf(sn,"%2d",day);
  986.     bwrite(1,x+1+(d*4),y+2+w,sn);
  987.     bfore=color(fore2);
  988.     bback=color(back2);
  989.     d=0;
  990.     for (i=1; i<=(month-1);i++) d=d+days[i];
  991.     d=d+day;
  992.     sprintf(sn,"Day of year: %3d",d);
  993.     bwrite(1,x+10,y+8,sn);
  994. }    /* calendar */
  995.  
  996. /*-----------------------------------------------------------------------*/
  997.  
  998. #ifdef editable
  999.  
  1000. void menued(void)
  1001. {
  1002.     bfore=color(fore1);
  1003.     bback=color(back1);
  1004.     bclear(2);
  1005.     bfore=color(fore5);
  1006.     bback=color(back5);
  1007.     bwrite(2,1,3,"╔══════════════════════════════════════════════════════════════════════════════╗");
  1008.     bwrite(2,1,4,"║ Menu:       Item:         Descr:                                             ║");
  1009.     bwrite(2,1,5,"║ Menu to transfer to:                                                         ║");
  1010.     bwrite(2,1,6,"╠══════════════════════════════════════════════════════════════════════════════╣");
  1011.     bwrite(2,1,7,"║ Note: This menu entry transfers control to another menu.                     ║");
  1012.     bwrite(2,1,8,"║       It has no DOS action items of its own.                                 ║");
  1013.     bwrite(2,1,9,"╚══════════════════════════════════════════════════════════════════════════════╝");
  1014.     bfore=color(fore1);
  1015.     bback=color(back1);
  1016.     restorescreen(2);
  1017. }
  1018.  
  1019. /*-----------------------------------------------------------------------*/
  1020.  
  1021. void menufill(void)
  1022. {
  1023.     gotoxy(36,4);
  1024.     cprintf("%-40s",cdescription);
  1025.     gotoxy(9,4);
  1026.     cprintf("%c",cmenu);
  1027.     gotoxy(21,4);
  1028.     cprintf("%c",citem);
  1029.     gotoxy(24,5);
  1030.     cprintf("%c",ctomenu);
  1031. }
  1032.  
  1033. /*-----------------------------------------------------------------------*/
  1034.  
  1035. void menuedit(void)
  1036. {
  1037.     int     rcode,pos;
  1038.  
  1039.     pos=0;
  1040. L20:
  1041.     rcode=getachar(21,4,&citem);
  1042.     if (rcode==2 || rcode==7) goto L50;
  1043.     if (rcode==3 || rcode==4) goto L40;
  1044. L30:
  1045.     rcode=getstring(36,4,&pos,cdescription,40);
  1046.     if (rcode==2 || rcode==7) goto L50;
  1047.     if (rcode==3 || rcode==4) goto L20;
  1048. L40:
  1049.     rcode=getachar(24,5,&ctomenu);
  1050.     if (rcode==2 || rcode==7) goto L50;
  1051.     if (rcode==3 || rcode==4) goto L30;
  1052. L50:
  1053.     ;
  1054. }
  1055.  
  1056. void editmenu(void)
  1057. {
  1058.     menued();
  1059.     menufill();
  1060.     menuedit();
  1061. }
  1062.  
  1063. #endif
  1064.  
  1065. /*-----------------------------------------------------------------------*/
  1066.  
  1067. void colorhelp(void)
  1068. {
  1069.     int i;
  1070.  
  1071.     bfore=(color(fore6));
  1072.     bback=(color(back6));
  1073.     bwrite(2,2,22,"╔════════════════════════════════════════════════════════════════════════════╗");
  1074.     bwrite(2,2,23,"║ COLORS: black, blue, green, cyan, red, magenta, brown, lightgray, darkgray ║");
  1075.     bwrite(2,2,24,"║ lightblue, lightgreen, lightcyan, lightred, lightmagenta, yellow, white    ║");
  1076.     bwrite(2,2,25,"╚════════════════════════════════════════════════════════════════════════════╝");
  1077.     for (i=0; i<16; i++) {
  1078.         bback=i;
  1079.         bwrite(2,1,i+4,"    ");
  1080.     }
  1081.     bfore=(color(fore1));
  1082.     bback=(color(back1));
  1083. }
  1084.  
  1085. /*-----------------------------------------------------------------------*/
  1086.  
  1087. void dispcolors(void)
  1088. {
  1089.  
  1090.     bfore=(color(fore1));
  1091.     bback=(color(back1));
  1092.     border(color(back1));
  1093.     bclear(2);
  1094.     bwrite(2,10,1,"Set Display Colors");
  1095.     bfore=(color(fore5));
  1096.     bback=(color(back5));
  1097.     bwrite(2,8,2,"╔═══════════════════════════════════════════════════════════════════╗");
  1098.     bwrite(2,8,3,"║ DEFAULT (date, time, today's date, messages)                      ║");
  1099.     bwrite(2,8,4,"║ Foreground:                      Background:                      ║");
  1100.     bwrite(2,8,5,"║═══════════════════════════════════════════════════════════════════║");
  1101.     bwrite(2,8,6,"║ CALENDAR                                                          ║");
  1102.     bwrite(2,8,7,"║ Foreground:                      Background:                      ║");
  1103.     bwrite(2,8,8,"║═══════════════════════════════════════════════════════════════════║");
  1104.     bwrite(2,8,9,"║ MENU SELECTIONS                                                   ║");
  1105.     bwrite(2,8,10,"║ Foreground:                      Background:                      ║");
  1106.     bwrite(2,8,11,"║═══════════════════════════════════════════════════════════════════║");
  1107.     bwrite(2,8,12,"║ ALARM ITEMS (under calendar, and when alerted)                    ║");
  1108.     bwrite(2,8,13,"║ Foreground:                      Background:                      ║");
  1109.     bwrite(2,8,14,"║═══════════════════════════════════════════════════════════════════║");
  1110.     bwrite(2,8,15,"║ EDIT SCREEN                                                       ║");
  1111.     bwrite(2,8,16,"║ Foreground:                      Background:                      ║");
  1112.     bwrite(2,8,17,"║═══════════════════════════════════════════════════════════════════║");
  1113.     bwrite(2,8,18,"║ EDIT HELP                                                         ║");
  1114.     bwrite(2,8,19,"║ Foreground:                      Background:                      ║");
  1115.     bwrite(2,8,20,"╚═══════════════════════════════════════════════════════════════════╝");
  1116.     bfore=(color(fore1));
  1117.     bback=(color(back1));
  1118.     bwrite(2,10,21,"Use cursor arrows to move between fields, ctrl-W when done.");
  1119.     colorhelp();
  1120.     restorescreen(2);
  1121. }
  1122.  
  1123. /*-----------------------------------------------------------------------*/
  1124.  
  1125. void fillcolors(void)
  1126. {
  1127.     gotoxy(21,4);
  1128.     cprintf("%-14s",fore1);
  1129.     gotoxy(54,4);
  1130.     cprintf("%-14s",back1);
  1131.     gotoxy(21,7);
  1132.     cprintf("%-14s",fore2);
  1133.     gotoxy(54,7);
  1134.     cprintf("%-14s",back2);
  1135.     gotoxy(21,10);
  1136.     cprintf("%-14s",fore3);
  1137.     gotoxy(54,10);
  1138.     cprintf("%-14s",back3);
  1139.     gotoxy(21,13);
  1140.     cprintf("%-14s",fore4);
  1141.     gotoxy(54,13);
  1142.     cprintf("%-14s",back4);
  1143.     gotoxy(21,16);
  1144.     cprintf("%-14s",fore5);
  1145.     gotoxy(54,16);
  1146.     cprintf("%-14s",back5);
  1147.     gotoxy(21,19);
  1148.     cprintf("%-14s",fore6);
  1149.     gotoxy(54,19);
  1150.     cprintf("%-14s",back6);
  1151. }
  1152.  
  1153. /*-----------------------------------------------------------------------*/
  1154.  
  1155. void edcolors(void)
  1156. {
  1157.     int rcode,i,col,field;
  1158.  
  1159.     field=1;
  1160.     do {
  1161.       col=0;
  1162.       switch (field) {
  1163.       case 1:
  1164.             rcode=getstring(21,4,&col,fore1,12);
  1165.             lcase(fore1);
  1166.             break;
  1167.       case 2:
  1168.             rcode=getstring(54,4,&col,back1,12);
  1169.             lcase(back1);
  1170.             break;
  1171.       case 3:
  1172.             rcode=getstring(21,7,&col,fore2,12);
  1173.             lcase(fore2);
  1174.             break;
  1175.       case 4:
  1176.             rcode=getstring(54,7,&col,back2,12);
  1177.             lcase(back2);  /* convert to lower case */
  1178.             break;
  1179.       case 5:
  1180.             rcode=getstring(21,10,&col,fore3,12);
  1181.             lcase(fore3);  /* convert to lower case */
  1182.             break;
  1183.       case 6:
  1184.             rcode=getstring(54,10,&col,back3,12);
  1185.             lcase(back3);  /* convert to lower case */
  1186.             break;
  1187.       case 7:
  1188.             rcode=getstring(21,13,&col,fore4,12);
  1189.             lcase(fore4);  /* convert to lower case */
  1190.             break;
  1191.       case 8:
  1192.             rcode=getstring(54,13,&col,back4,12);
  1193.             lcase(back4);  /* convert to lower case */
  1194.             break;
  1195.       case 9:
  1196.             rcode=getstring(21,16,&col,fore5,12);
  1197.             lcase(fore5);  /* convert to lower case */
  1198.             break;
  1199.       case 10:
  1200.             rcode=getstring(54,16,&col,back5,12);
  1201.             lcase(back5);  /* convert to lower case */
  1202.             break;
  1203.       case 11:
  1204.             rcode=getstring(21,19,&col,fore6,12);
  1205.             lcase(fore6);  /* convert to lower case */
  1206.             break;
  1207.       case 12:
  1208.             rcode=getstring(54,19,&col,back6,12);
  1209.             lcase(back6);  /* convert to lower case */
  1210.       } /* switch/case */
  1211.       if (rcode==3 || rcode==4) field--;
  1212.       else field++;
  1213.       if (field>12) field=1;
  1214.       if (field<1) field=12;
  1215.     } while ((rcode != 2) && (rcode != 7)); /* do */
  1216. }
  1217.  
  1218. /*-----------------------------------------------------------------------*/
  1219.  
  1220. void editcolor(void)
  1221. {
  1222.     dispcolors();
  1223.     fillcolors();
  1224.     edcolors();
  1225. }
  1226.