home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SDLOAD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-18
|
5KB
|
189 lines
/*
sdload.c
% sfile_LoadSed, sf_loadsed, sf_savesed
C-scape 3.2
Copyright (c) 1988-1990 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
8/21/89 jdc added bord_Do(sed, BDM_SCROLL) fixes lights
8/31/89 jmd removed long ifdefs
10/25/89 jmd added static to definition
11/06/89 jmd removed DoRaw Macro
12/17/89 jdc fixed attrs
12/19/89 jmd fixed hilite attrs
1/23/90 jdc added default defines
3/28/90 jmd ansi-fied
4/16/90 jdc renamed _bfile_gets to bf_gets
4/19/90 jdc preened
5/02/90 jdc preened one more time
5/11/90 jdc added sed_ReallyGo default
5/20/90 jmd added test for NULL gofuncname in sed_load
6/27/90 jdc preened the GoFunc code
8/08/90 jdc moved aux function down to window level
8/12/90 jdc added opendata arg to sfile_LoadObj
9/24/90 jdc removed gofunc code
11/01/90 ted put (void) in arg list of sedwin_LoadInit.
12/12/90 jdc fixed stripping aux funcs from 3.0, 3.1 files bug
12/15/90 jdc fixed bob positioning
*/
#include "sed.h"
#include "sfile.h"
#include "sfilpriv.h"
#include "sedwinod.h"
#include "ufuncobj.h"
#include "teddecl.h"
OSTATIC objreq_func (sdwinreq_load);
OSTATIC VOID_FPTR null_funcptr = FNULL;
#define DEFAULT_MOVE (move_method)null_funcptr;
#define DEFAULT_SPEC (spc_fptr)null_funcptr;
#define DEFAULT_AUX (aux_fptr)null_funcptr;
void sedwin_LoadInit(void)
{
sdwinreq_loadfptr = sdwinreq_load;
win_LoadInit();
ufunc_LoadInit();
}
sed_type sfile_LoadSed(sfile_type sfile, char *name, boolean allocate)
{
sedwin_LoadInit();
sfile->alloc = allocate;
return(sfile_LoadObj(sfile, name, NULL));
}
static int sdwinreq_load(VOID *objdata, int msg, VOID *indata, VOID *outdata)
{
sed_type sed;
sfile_type sfile;
oak_notused(outdata);
oak_notused(msg);
sed = sedod_GetSelf((sedwin_od *)objdata);
sfile = (sfile_type)indata;
if (!win_Class(&((sedwin_od *)objdata)->wd, msg, indata, outdata)
|| !sed_Init(sed, sf_loadmenu(sfile))
|| !sed_load(sfile, sed)) {
sed_Close(sed);
return(FALSE);
}
return(TRUE);
}
int sed_load(sfile_type sfile, sed_type sed)
{
int back, reg, sel, label, i, fld, frow, fcol;
int handle, is_lnf;
menu_type menu;
move_method move;
aux_fptr aux;
spc_fptr special;
bfile_type bfile;
char *sbuf;
int hireg = -1;
int hisel = -1;
bob_type bob;
bfile = sfile->bfile;
sbuf = sfile->buf;
is_lnf = (sfile->oslist_array[FSYM_TY] == NULL) ? FALSE:TRUE;
menu = sed_GetMenu(sed);
/* set the position of dependent bobs */
for (i = 0; i < menu_GetBobCount(menu); i++) {
if (bob_IsDepend(bob = menu_GetBob(menu, i))) {
fld = menu_GetBobFieldNo(menu, i);
frow = menu_GetFieldRow(menu, fld);
fcol = menu_GetFieldCol(menu, fld);
win_SetPosition(bob,
frow + win_GetTopRow(sed),
fcol + win_GetLeftCol(sed));
}
}
/* sed info:
label, back, reg, sel, hireg, hisel, move method, special, ox
*/
if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
return(FALSE);
}
sscanf(sbuf, "%d %d %d %d %d %d", &label, &back, ®, &sel,
&hireg, &hisel);
sed_SetColors(sed, (byte)reg, (byte)back, (byte)sel);
if (hireg != -1) {
sed_SetHiColors(sed, (byte)hireg, (byte)hisel);
}
sed_SetLabel(sed, label);
/* move method */
if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
return(FALSE);
}
if ((move = sfile_FindMoveMethodFunc(sfile, sbuf, &handle)) == FNULL) {
move = DEFAULT_MOVE;
}
ted_SetMoveMethod(sed, move);
if (is_lnf) {
if (handle == -1) {
handle = sfile_PutMoveMethodFunc(sfile, sbuf, move);
}
menu_SetMoveMethodHandle(menu, handle);
}
/* special */
if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
return(FALSE);
}
if ((special = sfile_FindSpecialFunc(sfile, sbuf, &handle)) == FNULL) {
special = DEFAULT_SPEC;
}
sed_SetSpecial(sed, special);
if (is_lnf) {
if (handle == -1) {
handle = sfile_PutSpecialFunc(sfile, sbuf, special);
}
menu_SetSpecialHandle(menu, handle);
}
ted_GotoPosition(sed, sed_GetCRow(sed), sed_GetCCol(sed));
/* send BDM_SCROLL to adjust border lights (suppressed in sf_loadwin) */
bord_Do(sed, BDM_SCROLL, NULL, NULL);
if (sfile->alloc == SED_ALLOC && !sd_alloc(sed, FALSE)) {
return(FALSE);
}
/* aux (moved to window level, use only in not "") */
if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
return(FALSE);
}
if (*sbuf != '\0') {
aux = sfile_FindAuxFunc(sfile, sbuf, &handle);
sed_SetAux(sed, aux);
if (is_lnf) {
if (handle == -1) {
handle = sfile_PutAuxFunc(sfile, sbuf, aux);
}
win_SetAuxHandle(sed, handle);
}
}
return(TRUE);
}