home *** CD-ROM | disk | FTP | other *** search
- /*
- fnselect.c 10/15/86
-
- % select_funcs
-
- Selector Functions:
-
- A field has multiple choices.
- The Space bar changes the selection.
- The Variable is the address of select_struct.
- To build a select_struct, use the MACRO select_build().
- select_build takes the name of the struct and the name of a list
- of choices.
- The choices are in the order that they will be displayed.
- The last choice must be NULL.
-
- Note: SED_ABORT will not affect this routine.
-
- The select_struct has a member (number) which is the number of the item
- in the list currently selected.
-
- To get the number of the choice made use the MACRO select_number().
- To get the text of the choice made use the MACRO select_choice().
-
- The cursor is turned off.
-
- C-scape 3.2
- Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 11/19/86 jmd Got rid of structure. (later put back)
- 4/06/88 jmd added call to sed_DoSpecial
- 5/12/88 jmd added calls to sed_GetScratchPad()
- 9/15/88 jmd removed vid_Cursor calls
- 9/17/88 jmd added std_ funcs
- 10/14/88 jdc added var_size element to field_funcs_struct
-
- 6/07/89 jmd added test for mouse code (later removed)
- 3/28/90 jmd ansi-fied
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
-
- #include "cscape.h"
- #include "fnfunc.h" /* for field functions */
- #include "strdecl.h" /* for C-scape string functions */
- #include "scancode.h"
-
- OGLOBAL field_funcs_struct select_funcs = {
- stdNoCur_fenter,
- std_fexit,
- select_fkey,
- select_senter,
- FNULL,
- VAR_INVALID
- };
-
- void select_fkey(sed_type sed)
- /*
- Cycle through list of changes when the SPACE bar is pressed.
- */
- {
- int scancode;
- struct select_struct *select;
-
- select = (struct select_struct *) sed_GetCurrVar(sed);
-
- scancode = kb_Read();
-
- if (sed_DoSpecial(sed, scancode))
- return;
- if (special_key(sed, scancode))
- return;
- if (inter_field(sed, scancode))
- return;
- if (inter_page(sed, scancode))
- return;
-
- switch(scancode) {
- case 0: /* this case is just here to trick certain compilers */
- default:
- if (scancode == MOU_CLICK || (ascii(scancode)) == ' ') {
- ++(select->number);
-
- if (select_choice(*select) == NULL) {
- select->number = 0;
- }
- select_senter(sed, sed_GetFieldNo(sed));
- sed_UpdateCurrField(sed);
- }
- }
-
- /* reset baton */
- sed_SetBaton(sed, -1);
- }
-
- void select_senter(sed_type sed, int fieldno)
- /*
- this function goes from the native select list to the record string.
- */
- {
- struct select_struct *select;
-
- select = (struct select_struct *) sed_GetVar(sed, fieldno);
-
- strcpy(sed_GetScratchPad(sed), select_choice(*select));
- strcenter(sed_GetScratchPad(sed), sed_GetRecordLen(sed, fieldno));
- sed_SetRecord(sed, sed_GetScratchPad(sed), fieldno);
-
- std_senter(sed, fieldno);
- }
-
-