home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
FNSLUG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-08
|
3KB
|
152 lines
/*
fnslug.c
% slug_funcs
C-scape 3.2
Copyright (c) 1988-1989, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
8/30/88 jdc created
5/24/89 jdc added sed_DoSpecial and special_key
8/30/89 gam added check for MENU_VERTICAL before sed_Pop (again)
11/12/89 jmd added check for MOU_CLICK
11/27/89 ted Made slug_fkey static.
12/12/89 ted overhauled.
2/20/90 jmd changed Repaint to Update in ENTER case
3/28/90 jmd ansi-fied
9/11/90 pmcm changed sed_SetMouseCode to kb_Stuff
10/04/90 pmcm removed isprint from search
10/31/90 ted changed 'letter' from char to int to avoid int/char compiler warning.
12/08/90 pmcm changed std_fenter to stdNoCur_fenter
*/
#include <stdio.h>
#include <ctype.h>
#include "cscape.h"
#include "scancode.h"
#include "oaktag.h" /* For IDs in msys.h */
#include "msys.h"
#include "helpdecl.h"
OSTATIC void slug_fkey(sed_type sed);
/* -------------------------------------------------------------------------- */
OGLOBAL field_funcs_struct slug_funcs = {
stdNoCur_fenter,
std_fexit,
slug_fkey,
FNULL,
FNULL,
0
};
/* -------------------------------------------------------------------------- */
static void slug_fkey(sed_type sed)
/*
modifies: sed.
effects: Standard menu functions.
Up and down keys change choices.
Baton contains field number + 1 when ENTER is pressed
or 0 if ESC pressed.
*/
{
unsigned scancode;
scancode = kb_Read();
if (sed_DoSpecial(sed, scancode))
return;
if (special_key(sed, scancode))
return;
slug_dokey(sed, scancode);
}
/* -------------------------------------------------------------------------- */
void slug_dokey(sed_type sed, unsigned scancode)
{
switch(scancode) {
case MOU_CLICK:
case ENTER:
{
int ret;
if (msys_dir(sed) == MENU_VERTICAL) {
sed_Pop(sed);
}
ret = msys_bobgo(sed, ENTER); /* 'ENTER' because no mouse suck needed */
if (ret != 0) {
sed_ToggleExit(sed);
sed_SetBaton(sed, ret);
}
else {
sed_Update(sed);
}
break;
}
case ESC:
sed_SetBaton(sed, 0);
sed_ToggleExit(sed);
break;
case DOWN:
case RIGHT:
if ((msys_dir(sed) == MENU_VERTICAL) ^ (scancode == RIGHT)) {
if (sed_IncField(sed) == SED_STUCK) {
sed_GotoFirstField(sed);
}
}
break;
case UP:
case LEFT:
if ((msys_dir(sed) == MENU_VERTICAL) ^ (scancode == LEFT)) {
if (sed_DecField(sed) == SED_STUCK) {
sed_GotoLastField(sed);
}
}
break;
case PGUP:
sed_PageUp(sed);
break;
case PGDN:
sed_PageDown(sed);
break;
case HOME:
sed_GotoFirstField(sed);
break;
case END:
sed_GotoLastField(sed);
break;
default:
{
int choice, letter;
/* do first letter search */
letter = ascii(scancode);
if ((choice = sed_SearchMerge(sed, (char) letter)) != -1) {
sed_GotoField(sed, choice);
kb_Stuff(ENTER); /* select choice immediately */
}
break;
}
}
}
/* -------------------------------------------------------------------------- */