home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
MENUXFLD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-19
|
3KB
|
93 lines
/*
menuxfld.c
% menu_ExchangeFields(menu, f1, f2)
exchanges the fields number, but not position
C-scape 3.2
Copyright (c) 1988, 1989 by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
4/24/89 jdc fixed namelist and funcnamea
05/29/89 jdc added varname array
06/01/89 jdc fixed grid
7/02/89 jdc added functype array
7/17/89 jdc added f1 == f2 check
3/28/90 jmd ansi-fied
4/19/90 jdc fixed problem when many fields have the same name
*/
#include "sed.h"
#include "sfile.h" /* for os_list stuff */
void menu_ExchangeFields(menu_type menu, int f1, int f2)
{
field_type fld1, fld2;
int i, temp1, temp2, hit = FALSE;
if (f1 == f2) {
return;
}
/* remove the fields from the grid */
menu_TakeFieldFromGrid(menu, f1);
menu_TakeFieldFromGrid(menu, f2);
/* swap the field array */
fld1 = (field_type)xa_Get(menu->fa, f1);
fld2 = (field_type)xa_Get(menu->fa, f2);
xa_Put(menu->fa, f2, (VOID *)fld1);
xa_Put(menu->fa, f1, (VOID *)fld2);
/* swap the names, if applicable */
if (fld1->nameno != -1
&& *((int *)oslist_GetData(menu->namelist, fld1->nameno)) == f1) {
oslist_SetData(menu->namelist, fld1->nameno, (VOID *)&f2);
hit = TRUE;
}
if ((!hit || fld2->nameno != fld1->nameno)
&& fld2->nameno != -1
&& *((int *)oslist_GetData(menu->namelist, fld2->nameno)) == f2) {
oslist_SetData(menu->namelist, fld2->nameno, (VOID *)&f1);
}
/* take care of the bob array */
for (i = 0; i < menu->bobcount; i++) {
if (ia_Get(menu->boba, i) == f1) {
ia_Put(menu->boba, i, f2);
}
else if (ia_Get(menu->boba, i) == f2) {
ia_Put(menu->boba, i, f1);
}
}
if (menu->funcnamea != NULL) {
/* take care of funcname array */
temp1 = ia_Get(menu->funcnamea, SED_FSYM_COUNT + f1);
temp2 = ia_Get(menu->funcnamea, SED_FSYM_COUNT + f2);
ia_Put(menu->funcnamea, SED_FSYM_COUNT + f1, temp2);
ia_Put(menu->funcnamea, SED_FSYM_COUNT + f2, temp1);
/* take care of functype array */
temp1 = ia_Get(menu->functypea, f1);
temp2 = ia_Get(menu->functypea, f2);
ia_Put(menu->functypea, f1, temp2);
ia_Put(menu->functypea, f2, temp1);
/* take care of varname array */
temp1 = ia_Get(menu->varnamea, f1);
temp2 = ia_Get(menu->varnamea, f2);
ia_Put(menu->varnamea, f1, temp2);
ia_Put(menu->varnamea, f2, temp1);
}
/* put them back into the grid in their original positions */
menu_AddFieldToGrid(menu, f1, field_GetRow(fld2), field_GetCol(fld2));
menu_AddFieldToGrid(menu, f2, field_GetRow(fld1), field_GetCol(fld1));
}