home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
FUNCS
/
FNMARK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-08
|
3KB
|
144 lines
/*
fnmark.c 9/26/88
% mark_funcs
Marked field functions
for creating multiple choice lists
The field variable should be a boolean *.
You can change the color used to mark the field by setting
the global variable fnmark_color.
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
6/07/89 jmd added test for mouse code (later removed)
3/28/90 jmd ansi-fied
3/28/90 ted Added a switch case for MOU_CLICK test so click == spacebar.
9/21/90 pmcm made fnmark_color OGLOBAL
10/04/90 pmcm removed isprint from search
12/08/90 pmcm changed std_fenter to stdNoCur_fenter
*/
#include <stdio.h>
#include <ctype.h>
#include "cscape.h"
#include "fnfunc.h" /* for field functions */
#include "scancode.h"
/*** mark color is a global variable ***/
OGLOBAL byte fnmark_color = ATTR_BOLD;
OGLOBAL field_funcs_struct mark_funcs = {
stdNoCur_fenter,
std_fexit,
mark_fkey,
mark_senter,
mark_sexit,
sizeof(boolean)
};
void mark_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;
byte reg, sel, bck; /* sed colors */
scancode = kb_Read();
if (sed_DoSpecial(sed, scancode))
return;
if (special_key(sed, scancode))
return;
/* intercept key before inter_field() */
if (scancode == ENTER) {
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 letter search */
letter = ascii(scancode);
if ((choice = sed_SearchMerge(sed, (char)letter)) != -1) {
sed_GotoField(sed, choice);
}
else if (letter == ' ') {
if (sed_IsMarkedField(sed, sed_GetFieldNo(sed))) {
sed_UnMarkField(sed, sed_GetFieldNo(sed));
}
else {
sed_GetColors(sed, ®, &bck, &sel);
sed_MarkField(sed, sed_GetFieldNo(sed), fnmark_color, sel);
}
}
break;
}
/* reset baton */
sed_SetBaton(sed, -1);
}
void mark_senter(sed_type sed, int fieldno)
/*
Marks field if var is true
Unmarks otherwise
*/
{
byte reg, sel, bck; /* sed colors */
if (*((boolean *) sed_GetVar(sed, fieldno))) {
sed_GetColors(sed, ®, &bck, &sel);
sed_MarkField(sed, fieldno, fnmark_color, sel);
}
else {
sed_UnMarkField(sed, fieldno);
}
}
void mark_sexit(sed_type sed, int fieldno)
/*
Sets var true if field is marked
False otherwise
*/
{
if (sed_GetBaton(sed) != SED_ABORT) {
*((boolean *) sed_GetVar(sed, fieldno)) = sed_IsMarkedField(sed, fieldno);
}
}