home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 125.img / PRO-C4.ZIP / BENCH1.ZIP / HELP / SETUP.C < prev   
Encoding:
C/C++ Source or Header  |  1990-05-28  |  5.2 KB  |  271 lines

  1. /* ==( help/setup.c )== */
  2. /* ----------------------------------------------- */
  3. /* Pro-C  Copyright (C) 1988 - 1990 Vestronix Inc. */
  4. /* Modification to this source is not supported    */
  5. /* by Vestronix Inc.                               */
  6. /*            All Rights Reserved                  */
  7. /* ----------------------------------------------- */
  8. /* Written   JPK  26-Sep-88                        */
  9. /* Modified  Geo  12-Dec-89  See comments below    */
  10. /* ----------------------------------------------- */
  11. /* %W%  (%H% %T%) */
  12.  
  13. /*
  14.  *  Modifications
  15.  *
  16.  *  12-Dec-89  Geo - V2 version with variable lines
  17.  *  25-Oct-89  Geo - 1.32 Merge
  18.  *
  19.  *
  20. */
  21.  
  22. # include <stdio.h>
  23. # include <bench.h>
  24. # include "help.h"
  25.  
  26. # ifdef ANSI
  27. static  void select_0(struct help_hdr *);
  28. static  void select_1(struct help_hdr *);
  29. static  void select_2(struct help_hdr *);
  30. static  void select_3(struct help_hdr *);
  31. static  void select_4(struct help_hdr *);
  32. extern  void change_setup(struct help_hdr *);
  33. # else
  34. static  void select_0();
  35. static  void select_1();
  36. static  void select_2();
  37. static  void select_3();
  38. static  void select_4();
  39. extern  void change_setup();
  40. # endif
  41.  
  42. # define SET_HEIGHT    10
  43. # define SET_WIDTH    31
  44.  
  45. # define MAX_SELECT    4
  46. # define MAX_ATTR    16
  47.  
  48.  
  49. static struct optab options[MAX_SELECT+1] =
  50. {
  51.     {3, 3, "Style of box     "},
  52.     {4, 3, "Attribute of box "},
  53.     {7, 3, "Display Attribute"},
  54.     {8, 3, "Tab setting      "},
  55.     {NORMAL, REVVID, NULL }
  56. };
  57.  
  58.  
  59. static char tabstop[9][2] =
  60. {
  61.     "0",
  62.     "1",
  63.     "2",
  64.     "3",
  65.     "4",
  66.     "5",
  67.     "6",
  68.     "7",
  69.     "8"
  70. };
  71.  
  72. # ifdef WaitBabe
  73. static char yn[2][3] =
  74. {
  75.     "yes",
  76.     "no"
  77. };
  78. # endif
  79.  
  80. static void select_0(hptr)
  81.     struct    help_hdr * hptr;
  82. {
  83.     extern int boxmax; /* bench.c */
  84.  
  85. /* increment the combination of box style and attribute to next one     */
  86.     if (++boxset >= boxmax)
  87.         boxset = 0;
  88.     hptr->box_style = boxset;
  89.  
  90.     box_w(2, 22, hptr->box_attr, 4, 8);
  91. }
  92.  
  93. static void select_1(hptr)
  94.     struct    help_hdr * hptr;
  95. {
  96.     /* increment the box attribute by one */
  97.     hptr->box_attr = (char)(hptr->box_attr + 0x01) % MAX_ATTR;
  98.     box_w(2, 22, hptr->box_attr, 4, 8);
  99. }
  100.  
  101. static void select_2(hptr)
  102.     struct    help_hdr * hptr;
  103. {
  104.     /* increment the text display type */
  105.     hptr->disp_attr = (hptr->disp_attr + 1) % MAX_ATTR;
  106.     poke_w(7, 22, hptr->disp_attr, '*');
  107. }
  108.  
  109. # ifdef WaitBabe
  110. /* this function will be used after FREE TEXT has been implemented */
  111. static void select_3(hptr)
  112.     struct    help_hdr * hptr;
  113. {
  114.     /* toggle word wrap */
  115.     hptr->wrap = (hptr->wrap + 1) % 2;
  116.     bdisp_w(7, 22, REVVID, 3, yn[hptr->wrap]);
  117. }
  118.  
  119. # endif
  120.  
  121. static void select_4(hptr)
  122.     struct    help_hdr * hptr;
  123. {
  124.     /* change the tab stop */
  125.     hptr->tabs = hptr->tabs % 8;
  126.     hptr->tabs++;
  127.     bdisp_w(8, 22, REVVID, 8, tabstop[hptr->tabs]);
  128. }
  129.  
  130. /*
  131.  * put up a box and allow the user to
  132.  * change any of the various settings
  133. */
  134. void change_setup(hptr)
  135.     struct help_hdr * hptr;
  136. {
  137.     int        curbox;
  138.     int        row;
  139.     int        col;
  140.     int        ch;
  141.     int        cur;
  142. # ifdef MOUSE
  143.     int      iopt;
  144. # endif
  145.  
  146.     curbox = boxset;
  147.  
  148.     row = hptr->row + 1;
  149.     row = (row > (w_nrows - SET_HEIGHT) ? w_nrows - SET_HEIGHT : row);
  150.     col = hptr->col + 4;
  151.     col = (col > (w_ncols - SET_WIDTH) ? w_ncols - SET_WIDTH : col);
  152.  
  153. # ifdef MOUSE
  154.     /*
  155.      * make menu items "clickable"
  156.     */
  157.     mouse_level++;
  158.     for (iopt = 0; options[iopt].text != NULL ; iopt++) 
  159.     {
  160.     int dummy;
  161.  
  162.         mouse_add_object( 
  163.             (unsigned char)(row + options[iopt].row), 
  164.             (unsigned char)(col + options[iopt].col), 
  165.             (unsigned char)(row + options[iopt].row), 
  166.             (unsigned char)(col + options[iopt].col) + 
  167.             strlen( options[iopt].text ) - 1, 
  168.             (int)keytrig( options[iopt].text,&dummy), iopt, NULL );
  169.     }
  170. # endif
  171.  
  172.     create_w(++row, col, SET_HEIGHT, SET_WIDTH);
  173.     border_w(0, NORMAL);
  174.  
  175.     keys_w( K_UP, "," ,K_DOWN, "," ,K_CR, select_prompt, 
  176.         (int)' ', toggle_prompt, K_ESC, exit_prompt, 0);
  177.  
  178.     boxset = hptr->box_style;
  179.  
  180.     /* setup the window with defaults */
  181.     box_w(2, 22, hptr->box_attr, 4, 8);
  182.     poke_w(7, 22, hptr->disp_attr, '*');
  183.     bdisp_w(8, 22, NORMAL, 1, tabstop[hptr->tabs]);
  184.  
  185.     cur = 0;
  186.     while (TRUE)        /* loop until <ESC> is pressed */
  187.     {
  188.         dsp_opt(options, &cur);
  189.         ch = inchar();
  190.         if (!(ch == ' ' || ch == K_ESC))
  191.         {
  192.             if (cur  ==  3)
  193.                 bdisp_w(8, 22, NORMAL, 1, tabstop[hptr->tabs]);
  194.         }
  195.         switch (ch)
  196.         {
  197. # ifdef MOUSE
  198.         case M_RELEASE:
  199.             {
  200.             int dummy;
  201.  
  202.                 mouse_click(&dummy, ch); 
  203.                 if (dummy == cur)
  204.                     unget_inchar( (int)' ' );
  205.                 else
  206.                     cur = dummy;
  207.                 break;
  208.             }
  209. # endif
  210.  
  211.         case K_DOWN:
  212.         case K_CR:
  213.             cur++;
  214.             break;
  215.  
  216.         case K_UP:
  217.             cur--;
  218.             break;
  219.  
  220.         case K_HOME:
  221.             cur = 0;
  222.             break;
  223.  
  224.         case K_END:
  225.             cur = MAX_SELECT - 1;
  226.             break;
  227.  
  228.         case ' ':
  229.             /* offer the next selection depending on cur */
  230.             switch (cur)
  231.             {
  232.             case 0:
  233.                 /* Box style */
  234.                 select_0(hptr);
  235.                 break;
  236.  
  237.             case 1:
  238.                 /* Box attribute */
  239.                 select_1(hptr);
  240.                 break;
  241.  
  242.             case 2:
  243.                 select_2(hptr);
  244.                 break;
  245.  
  246.             case 3:
  247.                 select_4(hptr);
  248.                 break;
  249.  
  250.             default:
  251.                 break;
  252.             }
  253.             break;
  254.  
  255.         case K_ESC:
  256.             delete_w();
  257.             boxset = curbox;
  258. # ifdef MOUSE
  259.             mouse_delete_level(mouse_level--);
  260. # endif
  261.             return;
  262.  
  263.         default:
  264.             break;
  265.         }
  266.         if (cur == 3 || cur == -1)
  267.             bdisp_w(8, 22, REVVID, 1, tabstop[hptr->tabs]);
  268.     }
  269. }
  270.  
  271.