home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SPCSLED.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-11
|
4KB
|
163 lines
/*
spcsled.c
% spc_Sled
C-scape 3.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
10/14/88 jdc created
2/12/89 jmd Put sed_GoHome after DoFenter
3/24/89 jmd added sed_ macros
7/17/89 gam took wraparound out of TAB and SHFT_TAB
7/31/89 gam removed obsolete code from DOWN case
8/04/89 gam changed name of sledwin.h to sled.h
8/12/89 jmd removed call to sed_GetBob
9/08/89 gam added sed_GoHome calls to fix vanishing field problem
9/08/89 gam now returns proper value when not a bob
11/13/89 jmd added non-DOS scancodes
2/22/90 jdc removed extra sed_GoHomes & tweeked
2/23/90 jdc added full BOB return code support
2/24/90 jdc removed sled_GetHeight
3/28/90 jmd ansi-fied
5/07/90 jdc made consistant with spc_Embed
7/25/90 jdc Remap now returns SED_STUCK, SED_INVALID, or SED_MOVED
8/08/90 pmcm added BOB_INC support
8/08/90 pmcm restored ENTER case
10/05/90 pmcm removed CTRL_I, CTRL_D aliases for GREYPLUS, GREYMINUS
(GREYPLUS & GREYMINUS are now meta keys on non-DOS systems)
12/11/90 jdc changed paging cases to use new macros
*/
#include <stdio.h>
#include "cscape.h"
#include "sled.h"
#include "scancode.h"
boolean spc_Sled(sed_type sed, int scancode)
/*
the sed passed in here is the sled's sed.
effects: Handles movement between fields.
ESC sets baton to 0, exits
ENTER goes to next field if possible
else sets baton to BOB_DOWN, exits
UP goes to the above field,
DOWN goes to the below field,
TAB goes to the right field,
SHFT_TAB goes to the left field,
PGUP,
PGDN,
GREYPLUS inserts a row,
GREYMINUS deletes a row,
returns: the value of spc_subshft()
(TRUE if intercepted a key, FALSE otherwise)
*/
{
switch (scancode) {
case BOB_QUIT:
case ESC:
sed_SetBaton(sed, (bob_GetParent(sed) != NULL) ? BOB_QUIT : 0);
sed_ToggleExit(sed);
return(TRUE);
case BOB_INC:
if (bob_GetParent(sed) != NULL) {
sed_SetBaton(sed, BOB_INC);
sed_ToggleExit(sed);
}
return(TRUE);
case UP:
if (sed_UpField(sed) != SED_STUCK
|| sled_Remap(sed, -1) != SED_STUCK) {
return(TRUE);
}
/* no break */
case BOB_UP:
if (bob_GetParent(sed) != NULL) {
sed_SetBaton(sed, BOB_UP);
sed_ToggleExit(sed);
}
return(TRUE);
case ENTER:
if (sed_RightField(sed) != SED_STUCK) {
return(TRUE);
}
else {
sed_GotoGridField(sed, sed_GetGridRow(sed, sed_GetFieldNo(sed)), 0);
}
/* no break, let ENTER fall through to DOWN case */
case DOWN:
if (sed_DownField(sed) != SED_STUCK
|| sled_Remap(sed, 1) != SED_STUCK) {
return(TRUE);
}
/* no break, let DOWN fall thru to BOB_DOWN */
case BOB_DOWN:
/* we are at the bottom of the column array (and, in the ENTER
case, in the rightmost field)
*/
if (bob_GetParent(sed) != NULL) {
sed_SetBaton(sed, (scancode == ENTER) ? BOB_INC : BOB_DOWN);
sed_ToggleExit(sed);
}
else if (scancode == ENTER) {
/* if not bobbed and ENTER, then exit */
sed_SetBaton(sed, sed_GetFieldNo(sed) + 1);
sed_ToggleExit(sed);
}
return(TRUE);
case TAB:
case BOB_RIGHT:
if (sed_RightField(sed) == SED_STUCK && bob_GetParent(sed) != NULL) {
sed_SetBaton(sed, BOB_RIGHT);
sed_ToggleExit(sed);
}
return(TRUE);
case SHFT_TAB:
case BOB_LEFT:
if (sed_LeftField(sed) == SED_STUCK && bob_GetParent(sed) != NULL) {
sed_SetBaton(sed, BOB_LEFT);
sed_ToggleExit(sed);
}
return(TRUE);
case PGUP:
sled_PageUp(sed);
return(TRUE);
case PGDN:
sled_PageDown(sed);
return(TRUE);
case GREYPLUS:
sled_InsertRows(sed, sled_GetRow(sed), 1);
sled_Repaint(sed);
return(TRUE);
case GREYMINUS:
sled_DeleteRows(sed, sled_GetRow(sed), 1);
sled_Repaint(sed);
return(TRUE);
default:
break;
}
return(FALSE);
}