home *** CD-ROM | disk | FTP | other *** search
- /* ==( help/setup.c )== */
- /* ----------------------------------------------- */
- /* Pro-C Copyright (C) 1988 - 1990 Vestronix Inc. */
- /* Modification to this source is not supported */
- /* by Vestronix Inc. */
- /* All Rights Reserved */
- /* ----------------------------------------------- */
- /* Written JPK 26-Sep-88 */
- /* Modified Geo 12-Dec-89 See comments below */
- /* ----------------------------------------------- */
- /* %W% (%H% %T%) */
-
- /*
- * Modifications
- *
- * 12-Dec-89 Geo - V2 version with variable lines
- * 25-Oct-89 Geo - 1.32 Merge
- *
- *
- */
-
- # include <stdio.h>
- # include <bench.h>
- # include "help.h"
-
- extern PROTO (void change_setup, (struct help_hdr *));
-
- # define SET_HEIGHT 10
- # define SET_WIDTH 31
-
- # define MAX_SELECT 4
- # define MAX_ATTR 16
-
- static struct optab options[] =
- {
- { 3, 3, "Style of box " },
- { 4, 3, "Attribute of box " },
- { 7, 3, "Display Attribute" },
- { 8, 3, "Tab setting " },
- { NORMAL, REVVID, NULL }
- };
-
- extern int boxmax; /* win/wdata.c */
-
- /*
- * put up a box and allow the user to
- * change any of the various settings
- */
- void change_setup(hptr)
- register struct help_hdr *hptr;
- {
- int curbox;
- int row;
- int col;
- int ch;
- int cur;
- # ifdef MOUSE
- int iopt;
- # endif
-
- curbox = boxset;
-
- row = hptr->row + 1;
- row = (row > (w_nrows - SET_HEIGHT) ? w_nrows - SET_HEIGHT : row);
- col = hptr->col + 4;
- col = (col > (w_ncols - SET_WIDTH) ? w_ncols - SET_WIDTH : col);
-
- # ifdef MOUSE
- /*
- * make menu items "clickable"
- */
- mouse_level++;
- for (iopt = 0; options[iopt].text != NULL; iopt++)
- {
- int dummy;
-
- mouse_add_object(
- (unsigned char)(row + options[iopt].row),
- (unsigned char)(col + options[iopt].col),
- (unsigned char)(row + options[iopt].row),
- (unsigned char)(col + options[iopt].col) +
- strlen( options[iopt].text) - 1,
- (int)keytrig( options[iopt].text,&dummy), iopt, NULL );
- }
- # endif
-
- create_w(++row, col, SET_HEIGHT, SET_WIDTH);
- border_w(0, NORMAL);
-
- keys_w(K_UP, ",", K_DOWN, "," ,K_CR, select_prompt,
- (int)' ', toggle_prompt, K_ESC, exit_prompt, 0);
-
- boxset = hptr->box_style;
-
- /* setup the window with defaults */
- box_w(2, 22, hptr->box_attr, 4, 8);
- poke_w(7, 22, hptr->disp_attr, '*');
- disp_w(8, 22, NORMAL, "%d", hptr->tabs); /* 1 char */
-
- cur = 0;
- while (TRUE) /* loop until <ESC> is pressed */
- {
- dsp_opt(options, &cur);
- ch = inchar();
- if (!(ch == ' ' || ch == K_ESC))
- {
- if (cur == 3)
- disp_w(8, 22, NORMAL, "%d", hptr->tabs);
- }
- switch (ch)
- {
- # ifdef MOUSE
- case M_RELEASE:
- {
- int dummy;
-
- mouse_click(&dummy, ch);
- if (dummy == cur)
- unget_inchar( (int)' ' );
- else
- cur = dummy;
- break;
- }
- # endif
-
- case K_DOWN:
- case K_CR:
- cur++;
- break;
-
- case K_UP:
- cur--;
- break;
-
- case K_HOME:
- cur = 0;
- break;
-
- case K_END:
- cur = MAX_SELECT - 1;
- break;
-
- case ' ':
- /* offer the next selection depending on cur */
- switch (cur)
- {
- case 0:
- /* increment box style and attribute */
- if (++boxset >= boxmax)
- boxset = 0;
- hptr->box_style = boxset;
- box_w(2, 22, hptr->box_attr, 4, 8);
- break;
-
- case 1:
- /* increment the box attribute by one */
- hptr->box_attr = (char)(hptr->box_attr + 0x01) % MAX_ATTR;
- box_w(2, 22, hptr->box_attr, 4, 8);
- break;
-
- case 2:
- /* increment the text display type */
- hptr->disp_attr = (hptr->disp_attr + 1) % MAX_ATTR;
- poke_w(7, 22, hptr->disp_attr, '*');
- break;
-
- case 3:
- /* change the tab stop */
- hptr->tabs = hptr->tabs % 8;
- hptr->tabs++;
- disp_w(8, 22, REVVID, "%d", hptr->tabs);
- break;
- }
- break;
-
- case K_ESC:
- delete_w();
- boxset = curbox;
- # ifdef MOUSE
- mouse_delete_level(mouse_level--);
- # endif
- return;
- }
- if (cur == 3 || cur == -1)
- disp_w(8, 22, REVVID, "%d", hptr->tabs);
- }
- }
-
- # ifdef WaitBabe
- static char yn[2][3] =
- {
- "yes",
- "no"
- };
-
- /* this function will be used after FREE TEXT has been implemented */
- static void select_x(hptr)
- struct help_hdr * hptr;
- {
- /* toggle word wrap */
- hptr->wrap = (hptr->wrap + 1) % 2;
- bdisp_w(7, 22, REVVID, 3, yn[hptr->wrap]);
- }
- # endif
-