home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PROCWRKB.ZIP / BENCH1.ZIP / HELP / SETUP.C < prev   
Encoding:
C/C++ Source or Header  |  1990-08-07  |  4.3 KB  |  205 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. extern PROTO (void change_setup, (struct help_hdr *));
  27.  
  28. # define SET_HEIGHT    10
  29. # define SET_WIDTH    31
  30.  
  31. # define MAX_SELECT    4
  32. # define MAX_ATTR    16
  33.  
  34. static struct optab options[] =
  35. {
  36.     { 3, 3, "Style of box     " },
  37.     { 4, 3, "Attribute of box " },
  38.     { 7, 3, "Display Attribute" },
  39.     { 8, 3, "Tab setting      " },
  40.     { NORMAL, REVVID, NULL }
  41. };
  42.  
  43. extern int boxmax; /* win/wdata.c */
  44.  
  45. /*
  46.  * put up a box and allow the user to
  47.  * change any of the various settings
  48. */
  49. void change_setup(hptr)
  50. register struct help_hdr *hptr;
  51. {
  52.     int        curbox;
  53.     int        row;
  54.     int        col;
  55.     int        ch;
  56.     int        cur;
  57. # ifdef MOUSE
  58.     int      iopt;
  59. # endif
  60.  
  61.     curbox = boxset;
  62.  
  63.     row = hptr->row + 1;
  64.     row = (row > (w_nrows - SET_HEIGHT) ? w_nrows - SET_HEIGHT : row);
  65.     col = hptr->col + 4;
  66.     col = (col > (w_ncols - SET_WIDTH) ? w_ncols - SET_WIDTH : col);
  67.  
  68. # ifdef MOUSE
  69.     /*
  70.      * make menu items "clickable"
  71.     */
  72.     mouse_level++;
  73.     for (iopt = 0; options[iopt].text != NULL; iopt++) 
  74.     {
  75.     int dummy;
  76.  
  77.         mouse_add_object( 
  78.             (unsigned char)(row + options[iopt].row), 
  79.             (unsigned char)(col + options[iopt].col), 
  80.             (unsigned char)(row + options[iopt].row), 
  81.             (unsigned char)(col + options[iopt].col) + 
  82.             strlen( options[iopt].text) - 1, 
  83.             (int)keytrig( options[iopt].text,&dummy), iopt, NULL );
  84.     }
  85. # endif
  86.  
  87.     create_w(++row, col, SET_HEIGHT, SET_WIDTH);
  88.     border_w(0, NORMAL);
  89.  
  90.     keys_w(K_UP, ",", K_DOWN, "," ,K_CR, select_prompt, 
  91.         (int)' ', toggle_prompt, K_ESC, exit_prompt, 0);
  92.  
  93.     boxset = hptr->box_style;
  94.  
  95.     /* setup the window with defaults */
  96.     box_w(2, 22, hptr->box_attr, 4, 8);
  97.     poke_w(7, 22, hptr->disp_attr, '*');
  98.     disp_w(8, 22, NORMAL, "%d", hptr->tabs); /* 1 char */
  99.  
  100.     cur = 0;
  101.     while (TRUE)        /* loop until <ESC> is pressed */
  102.     {
  103.         dsp_opt(options, &cur);
  104.         ch = inchar();
  105.         if (!(ch == ' ' || ch == K_ESC))
  106.         {
  107.             if (cur == 3)
  108.                 disp_w(8, 22, NORMAL, "%d", hptr->tabs);
  109.         }
  110.         switch (ch)
  111.         {
  112. # ifdef MOUSE
  113.         case M_RELEASE:
  114.             {
  115.             int dummy;
  116.  
  117.                 mouse_click(&dummy, ch); 
  118.                 if (dummy == cur)
  119.                     unget_inchar( (int)' ' );
  120.                 else
  121.                     cur = dummy;
  122.                 break;
  123.             }
  124. # endif
  125.  
  126.         case K_DOWN:
  127.         case K_CR:
  128.             cur++;
  129.             break;
  130.  
  131.         case K_UP:
  132.             cur--;
  133.             break;
  134.  
  135.         case K_HOME:
  136.             cur = 0;
  137.             break;
  138.  
  139.         case K_END:
  140.             cur = MAX_SELECT - 1;
  141.             break;
  142.  
  143.         case ' ':
  144.             /* offer the next selection depending on cur */
  145.             switch (cur)
  146.             {
  147.             case 0:
  148.                 /* increment box style and attribute */
  149.                 if (++boxset >= boxmax)
  150.                     boxset = 0;
  151.                 hptr->box_style = boxset;
  152.                 box_w(2, 22, hptr->box_attr, 4, 8);
  153.                 break;
  154.  
  155.             case 1:
  156.                 /* increment the box attribute by one */
  157.                 hptr->box_attr = (char)(hptr->box_attr + 0x01) % MAX_ATTR;
  158.                 box_w(2, 22, hptr->box_attr, 4, 8);
  159.                 break;
  160.  
  161.             case 2:
  162.                 /* increment the text display type */
  163.                 hptr->disp_attr = (hptr->disp_attr + 1) % MAX_ATTR;
  164.                 poke_w(7, 22, hptr->disp_attr, '*');
  165.                 break;
  166.  
  167.             case 3:
  168.                 /* change the tab stop */
  169.                 hptr->tabs = hptr->tabs % 8;
  170.                 hptr->tabs++;
  171.                 disp_w(8, 22, REVVID, "%d", hptr->tabs);
  172.                 break;
  173.             }
  174.             break;
  175.  
  176.         case K_ESC:
  177.             delete_w();
  178.             boxset = curbox;
  179. # ifdef MOUSE
  180.             mouse_delete_level(mouse_level--);
  181. # endif
  182.             return;
  183.         }
  184.         if (cur == 3 || cur == -1)
  185.             disp_w(8, 22, REVVID, "%d", hptr->tabs);
  186.     }
  187. }
  188.  
  189. # ifdef WaitBabe
  190. static char yn[2][3] =
  191. {
  192.     "yes",
  193.     "no"
  194. };
  195.  
  196. /* this function will be used after FREE TEXT has been implemented */
  197. static void select_x(hptr)
  198.     struct    help_hdr * hptr;
  199. {
  200.     /* toggle word wrap */
  201.     hptr->wrap = (hptr->wrap + 1) % 2;
  202.     bdisp_w(7, 22, REVVID, 3, yn[hptr->wrap]);
  203. }
  204. # endif
  205.