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"
-
- # ifdef ANSI
- static void select_0(struct help_hdr *);
- static void select_1(struct help_hdr *);
- static void select_2(struct help_hdr *);
- static void select_3(struct help_hdr *);
- static void select_4(struct help_hdr *);
- extern void change_setup(struct help_hdr *);
- # else
- static void select_0();
- static void select_1();
- static void select_2();
- static void select_3();
- static void select_4();
- extern void change_setup();
- # endif
-
- # define SET_HEIGHT 10
- # define SET_WIDTH 31
-
- # define MAX_SELECT 4
- # define MAX_ATTR 16
-
-
- static struct optab options[MAX_SELECT+1] =
- {
- {3, 3, "Style of box "},
- {4, 3, "Attribute of box "},
- {7, 3, "Display Attribute"},
- {8, 3, "Tab setting "},
- {NORMAL, REVVID, NULL }
- };
-
-
- static char tabstop[9][2] =
- {
- "0",
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8"
- };
-
- # ifdef WaitBabe
- static char yn[2][3] =
- {
- "yes",
- "no"
- };
- # endif
-
- static void select_0(hptr)
- struct help_hdr * hptr;
- {
- extern int boxmax; /* bench.c */
-
- /* increment the combination of box style and attribute to next one */
- if (++boxset >= boxmax)
- boxset = 0;
- hptr->box_style = boxset;
-
- box_w(2, 22, hptr->box_attr, 4, 8);
- }
-
- static void select_1(hptr)
- struct help_hdr * hptr;
- {
- /* 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);
- }
-
- static void select_2(hptr)
- struct help_hdr * hptr;
- {
- /* increment the text display type */
- hptr->disp_attr = (hptr->disp_attr + 1) % MAX_ATTR;
- poke_w(7, 22, hptr->disp_attr, '*');
- }
-
- # ifdef WaitBabe
- /* this function will be used after FREE TEXT has been implemented */
- static void select_3(hptr)
- struct help_hdr * hptr;
- {
- /* toggle word wrap */
- hptr->wrap = (hptr->wrap + 1) % 2;
- bdisp_w(7, 22, REVVID, 3, yn[hptr->wrap]);
- }
-
- # endif
-
- static void select_4(hptr)
- struct help_hdr * hptr;
- {
- /* change the tab stop */
- hptr->tabs = hptr->tabs % 8;
- hptr->tabs++;
- bdisp_w(8, 22, REVVID, 8, tabstop[hptr->tabs]);
- }
-
- /*
- * put up a box and allow the user to
- * change any of the various settings
- */
- void change_setup(hptr)
- 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, '*');
- bdisp_w(8, 22, NORMAL, 1, tabstop[hptr->tabs]);
-
- cur = 0;
- while (TRUE) /* loop until <ESC> is pressed */
- {
- dsp_opt(options, &cur);
- ch = inchar();
- if (!(ch == ' ' || ch == K_ESC))
- {
- if (cur == 3)
- bdisp_w(8, 22, NORMAL, 1, tabstop[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:
- /* Box style */
- select_0(hptr);
- break;
-
- case 1:
- /* Box attribute */
- select_1(hptr);
- break;
-
- case 2:
- select_2(hptr);
- break;
-
- case 3:
- select_4(hptr);
- break;
-
- default:
- break;
- }
- break;
-
- case K_ESC:
- delete_w();
- boxset = curbox;
- # ifdef MOUSE
- mouse_delete_level(mouse_level--);
- # endif
- return;
-
- default:
- break;
- }
- if (cur == 3 || cur == -1)
- bdisp_w(8, 22, REVVID, 1, tabstop[hptr->tabs]);
- }
- }
-
-