home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
FNSTRCOM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-20
|
2KB
|
108 lines
/*
fnstrcom.c
-jmd 8/07/89
% StrCommon_fkey
Common routines used by string editing field functions
C-scape 3.2
Copyright (c) 1986-1989 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
1/31/90 jmd don't reset baton on MOU_CLICK
3/24/90 jmd added sfilter_func define
3/28/90 jmd ansi-fied
10/20/90 mla fixed padding bug in clear record on first keystroke case
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "cscape.h"
#include "fnfunc.h"
#include "scancode.h"
void StrCommon_fkey(sed_type sed, sfilter_fptr filter)
/*
fkey function for various string field functions.
Uses the 'filter' function to test characters
as they are typed in. if 'filter' returns TRUE
the character is accepted.
*/
{
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 RIGHT:
sed_IncChar(sed);
break;
case LEFT:
sed_DecChar(sed);
break;
case HOME:
sed_GoHome(sed);
break;
case END:
sed_GoEnd(sed);
break;
case INS:
if (kb_Insert()) {
sed_SetCursorType(sed, CURSOR_HALF);
}
else {
sed_SetCursorType(sed, CURSOR_NORMAL);
}
break;
case BACKSPACE:
if (sed_DecChar(sed)) {
sed_PullRight(sed);
}
break;
case DEL:
sed_PullRight(sed);
break;
default:
key = ascii(scancode);
if ((*filter)(key)) {
if (sed_GetBaton(sed) == SED_FIRST) {
/* clear record on first keystroke */
sed_SetCurrRecord(sed, "");
sed_GoHome(sed);
sed_UpdateCurrField(sed);
}
if (kb_Insert()) {
sed_PushRight(sed, key);
}
else {
sed_Overwrite(sed, key);
}
sed_IncChar(sed);
}
break;
}
/* reset baton */
if (scancode != MOU_CLICK) {
sed_SetBaton(sed, -1);
}
}