home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
FNYESNO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
3KB
|
142 lines
/*
fnyesno.c 10/27/86
% yesno_funcs
Yes or No functions.
A boolean field that contains either Yes or No:
If the boolean is TRUE the field shows "Yes"
else the field returns "No ".
The strings for 'Yes' and 'No' are grabbed from the ocountry
struct. The default values are "Yes" and "No". You
can point these to the appropriate strings for other languages.
C-scape 3.2
Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
10/02/87 jmd Now works with any length record.
3/09/88 jmd Added space bar toggle.
4/06/88 jmd added call to sed_DoSpecial
9/15/88 jmd removed vid_Cursor calls
9/17/88 jmd added std_ funcs
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
6/01/89 gam added ocountry stuff
6/07/89 jmd added test for mouse code (later removed)
6/07/89 jmd added first letter toggle support
11/04/89 jdc changed toupper & tolower to otoupper & otolower
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 "scancode.h"
OGLOBAL field_funcs_struct yesno_funcs = {
stdNoCur_fenter,
yesno_fexit,
yesno_fkey,
yesno_senter,
yesno_sexit,
sizeof(boolean)
};
boolean yesno_fexit(sed_type sed)
/*
Convert user variable to value showing on the screen immediately.
*/
{
if (sed_GetBaton(sed) != SED_ABORT) {
yesno_sexit(sed, sed_GetFieldNo(sed));
yesno_senter(sed, sed_GetFieldNo(sed));
sed_UpdateCurrField(sed);
}
return(std_fexit(sed));
}
void yesno_fkey(sed_type sed)
/*
*/
{
int scancode, letter;
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;
letter = otoupper(ascii(scancode));
if (letter == otoupper(*ocountry.yes_ptr)) {
sed_SetCurrRecord(sed, ocountry.yes_ptr);
sed_UpdateCurrField(sed);
}
else if (letter == otoupper(*ocountry.no_ptr)) {
sed_SetCurrRecord(sed, ocountry.no_ptr);
sed_UpdateCurrField(sed);
}
else if (scancode == MOU_CLICK || letter == ' ') {
if (strncmp(sed_GetCurrRecord(sed), ocountry.yes_ptr, sed_GetCurrRecordLen(sed)) == 0) {
sed_SetCurrRecord(sed, ocountry.no_ptr);
}
else {
sed_SetCurrRecord(sed, ocountry.yes_ptr);
}
sed_UpdateCurrField(sed);
}
/* reset baton */
sed_SetBaton(sed, -1);
}
void yesno_senter(sed_type sed, int fieldno)
/*
This function goes from the native boolean to the record string.
*/
{
boolean yesno;
yesno = (* (boolean *) sed_GetVar(sed, fieldno));
if (yesno) {
sed_SetRecord(sed, ocountry.yes_ptr, fieldno);
}
else {
sed_SetRecord(sed, ocountry.no_ptr, fieldno);
}
std_senter(sed, fieldno);
}
void yesno_sexit(sed_type sed, int fieldno)
/*
Converts the record string into a boolean.
*/
{
if (sed_GetBaton(sed) != SED_ABORT) {
if (strncmp(sed_GetRecord(sed, fieldno), ocountry.yes_ptr, sed_GetRecordLen(sed, fieldno)) == 0) {
(* (boolean *) sed_GetVar(sed, fieldno)) = 1;
}
else {
(* (boolean *) sed_GetVar(sed, fieldno)) = 0;
}
}
}