home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
FNCHECK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-04
|
3KB
|
148 lines
/*
fncheck.c 9/26/88
% check_funcs
Check marked field functions
for creating multiple choice lists
The field variable should be a boolean *.
The record should contain a writable position for the check mark.
C-scape 3.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
10/09/88 jmd added SED_ABORT support
10/14/88 jdc added var_size element to field_funcs_struct
12/20/88 jmd added mouse support
3/01/89 jmd changed CS_DOS to OAK_DOS
6/07/89 jmd added test for mouse code (later removed)
3/28/90 jmd ansi-fied
3/28/90 ted Moved MOU_CLICK test into a switch case.
10/04/90 pmcm removed isprint from search
*/
#include <stdio.h>
#include <ctype.h>
#include "cscape.h"
#include "fnfunc.h" /* for field functions */
#include "scancode.h"
#ifdef OAK_DOS
# define CHECK_MARK "\xfb"
#endif
#ifdef OAK_OS2
# define CHECK_MARK "\xfb"
#endif
#ifndef CHECK_MARK
# define CHECK_MARK "*"
#endif
OGLOBAL field_funcs_struct check_funcs = {
stdNoCur_fenter,
std_fexit,
check_fkey,
check_senter,
check_sexit,
sizeof(boolean)
};
void check_fkey(sed_type sed)
/*
Up and down keys move cursor.
letters search for choices.
space bar toggles choice selection.
Baton contains field number + 1 when ENTER is pressed
or 0 if ESC pressed.
*/
{
int scancode, letter, choice;
char *p;
scancode = kb_Read();
if (sed_DoSpecial(sed, scancode))
return;
if (special_key(sed, scancode))
return;
if (scancode == ENTER) { /* intercept inter_field() */
sed_SetBaton(sed, sed_GetFieldNo(sed) + 1);
sed_ToggleExit(sed);
return;
}
if (inter_field(sed, scancode))
return;
if (inter_page(sed, scancode))
return;
switch(scancode) {
case HOME:
sed_GotoFirstField(sed);
break;
case END:
sed_GotoLastField(sed);
break;
case MOU_CLICK: /* same as pressing space */
scancode = ' ';
/* no break; */
default:
/* do first letter search */
letter = ascii(scancode);
if ((choice = sed_SearchMerge(sed, (char)letter)) != -1) {
sed_GotoField(sed, choice);
}
else if (letter == ' ') {
p = sed_GetRecord(sed, sed_GetFieldNo(sed));
if (*p == '\0') {
sed_SetRecord(sed, CHECK_MARK, sed_GetFieldNo(sed));
}
else {
sed_SetRecord(sed, "", sed_GetFieldNo(sed));
}
sed_UpdateField(sed, sed_GetFieldNo(sed));
}
break;
}
/* reset baton */
sed_SetBaton(sed, -1);
}
void check_senter(sed_type sed, int fieldno)
/*
Marks field if var is true
Unmarks otherwise
*/
{
if (*((boolean *) sed_GetVar(sed, fieldno))) {
sed_SetRecord(sed, CHECK_MARK, fieldno);
}
else {
sed_SetRecord(sed, "", fieldno);
}
}
void check_sexit(sed_type sed, int fieldno)
/*
Sets var true if field is marked
False otherwise
*/
{
char *p;
if (sed_GetBaton(sed) != SED_ABORT) {
p = sed_GetRecord(sed, fieldno);
*((boolean *) sed_GetVar(sed, fieldno)) = !(*p == '\0');
}
}