home *** CD-ROM | disk | FTP | other *** search
- /*
- menucfld.c
-
- % menu_CopyField
-
- C-scape 3.2
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/24/88 jdc created
-
- 4/21/89 jmd now uses @fD syntax
- 4/25/89 jdc added funcname array stuff
- 4/28/89 jdc copied field's var now points to the scratchpad
- 5/29/89 jdc added varname array
- 7/02/89 jdc added functype array
- 7/26/89 jmd added menu_Unprintf arg
- 8/13/89 jmd added failure test
- 3/28/90 jmd ansi-fied
- */
-
- #include "sed.h"
- #include "sfile.h"
-
- int menu_CopyField(menu_type dmenu, int row, int col, menu_type smenu, int fldno)
- /*
- copies fldno from smenu to dmenu at row, col ( uses same if -1, -1 ).
- returns: the new field's no. or -1 if it fails.
- */
- {
- int i, ret = -1;
- char *s;
- field_type field;
-
- field = menu_GetField(smenu, fldno);
-
- if ((s = (char *) omalloc(CSA_MCOPYFLD, menu_GetScratchSize(smenu) + 10)) == NULL) {
- goto QUIT1;
- }
-
- if (!menu_Printf(dmenu, menu_UnPrintf(smenu, fldno, s, row, col, 1),
- menu_GetScratchPad(dmenu), field_GetFuncs(field))) {
- goto QUIT2;
- }
-
- for (i = 0; i < field_GetDataCount(field); i++) {
- menu_SetFieldData(dmenu, dmenu->fieldcount - 1, i, field_GetData(field, i));
- }
-
- if (field_GetMarked(field)) {
- menu_MarkField(dmenu, dmenu->fieldcount - 1,
- field_GetRegAttr(field),
- field_GetSelAttr(field));
- }
-
- if (smenu->funcnamea != NULL && dmenu->funcnamea != NULL) {
-
- i = ia_Get(smenu->funcnamea, SED_FSYM_COUNT + fldno);
- if (!ia_Put(dmenu->funcnamea, SED_FSYM_COUNT + dmenu->fieldcount - 1, i)) {
- goto QUIT2;
- }
-
- i = ia_Get(smenu->functypea, fldno);
- if (!ia_Put(dmenu->functypea, dmenu->fieldcount - 1, i)) {
- goto QUIT2;
- }
-
- i = menu_PutVarName(dmenu, menu_GetVarName(smenu, fldno));
- if (!ia_Put(dmenu->varnamea, dmenu->fieldcount - 1, i)) {
- goto QUIT2;
- }
- }
-
- ret = dmenu->fieldcount - 1;
-
- QUIT2:
- ofree(CSA_MCOPYFLD, s);
- QUIT1:
-
- return(ret);
- }
-