home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
FUNCS
/
FNCHAR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
2KB
|
96 lines
/*
fnchar.c 10/27/86
% char_funcs
Character editing functions.
Assumes the field has one position.
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
5/12/88 jmd added calls to sed_GetScratchPad()
6/23/88 jmd added casting to char * in senter
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
6/07/89 jmd added test for mouse code (later removed)
11/12/89 jdc changed char_fexit to string_fexit
3/28/90 jmd ansi-fied
*/
#include <stdio.h>
#include <ctype.h>
#include "cscape.h"
#include "fnfunc.h"
#include "scancode.h"
OGLOBAL field_funcs_struct char_funcs = {
std_fenter,
string_fexit,
char_fkey,
char_senter,
char_sexit,
sizeof(char)
};
void char_fkey(sed_type sed)
{
int scancode, key;
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 BACKSPACE:
case DEL:
sed_Overwrite(sed, ' ');
break;
default:
key = ascii(scancode);
if (isprint(key)) {
sed_Overwrite(sed, key);
}
break;
}
/* reset baton */
sed_SetBaton(sed, -1);
}
void char_senter(sed_type sed, int fieldno)
/*
Convert native type to string for record.
*/
{
sprintf(sed_GetScratchPad(sed), "%c", *((char *) sed_GetVar(sed, fieldno)));
sed_SetRecord(sed, sed_GetScratchPad(sed), fieldno);
std_senter(sed, fieldno);
}
void char_sexit(sed_type sed, int fieldno)
/*
Converts record back to native type.
*/
{
if (sed_GetBaton(sed) != SED_ABORT) {
sscanf(sed_GetRecord(sed, fieldno), "%c", sed_GetVar(sed, fieldno));
}
}