home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
FUNCS
/
FNSTRING.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-09-11
|
2KB
|
108 lines
/*
fnstring.c 10/27/86
% string_funcs
String editing functions.
Supports insert mode (with big cursor).
The field variable should be a char *.
C-scape 3.2
Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
4/06/88 jmd added call to sed_DoSpecial
6/23/88 jmd added casting to char * in senter
9/15/88 jmd removed vid_Cursor calls
9/17/88 jmd added validation
9/17/88 jmd added global error msg strings for easy changing
9/17/88 jmd added std_ funcs
10/09/88 jmd added SED_ABORT support
10/12/88 jmd added SED_FIRST support
10/14/88 jdc added var_size element to field_funcs_struct
6/07/89 jmd added test for mouse code (later removed)
1/25/90 jmd converted kb_Check to kb_CheckWait
3/14/90 jmd moved formatting before validation
3/16/90 jmd added support for KEY_INVALID in fexit
3/28/90 jmd ansi-fied
9/11/90 pmcm changed sed_SetMouseCode to kb_Stuff
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "cscape.h"
#include "fnfunc.h" /* for field functions */
#include "scancode.h"
OSTATIC sfilter_func (string_filter);
OGLOBAL field_funcs_struct string_funcs = {
stdBigCur_fenter,
string_fexit,
string_fkey,
string_senter,
string_sexit,
VAR_STRING
};
boolean string_fexit(sed_type sed)
{
if (sed_GetBaton(sed) != SED_ABORT) {
/* format the field's record */
std_format(sed);
if (!valid_String(sed_GetCurrRecord(sed), (char *) sed_GetCurrFieldData(sed, 1)) ) {
kb_Stuff(KEY_INVALID);
return(FALSE);
}
}
return(std_fexit(sed));
}
void string_fkey(sed_type sed)
/*
Hands its work to StrCommon_fkey (fnstrcom.c)
Passes a filter function (below) to decide which
characters can be typed in.
*/
{
StrCommon_fkey(sed, string_filter);
}
static boolean string_filter(int key)
/*
Filter function for string_funcs
for use with StrCommon_fkey
*/
{
return(isprint(key));
}
void string_senter(sed_type sed, int fieldno)
/*
Copy the native string into the record string.
*/
{
sed_SetRecord(sed, (char *) sed_GetVar(sed, fieldno), fieldno);
std_senter(sed, fieldno);
}
void string_sexit(sed_type sed, int fieldno)
/*
Copy the record string back into the native string.
*/
{
if (sed_GetBaton(sed) != SED_ABORT) {
strcpy((char *) sed_GetVar(sed, fieldno), sed_GetRecord(sed, fieldno));
}
}