home *** CD-ROM | disk | FTP | other *** search
- /*
- menuifld.c 4/10/88
-
- % menu_InsertRows
-
- C-scape 3.2
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 6/07/88 jmd added call to tb_InsertRow
- 6/24/88 jmd converted to new xarray/iarray calls
-
- 4/16/89 jmd adjusted for jarray
- 7/02/89 jdc added frowcount change
-
- 3/28/90 jmd ansi-fied
- 5/30/90 jdc made menu_InsRowTB a function and put it in here
- 10/31/90 ted changed menu_InsRowTB declaration to ansii style.
- */
-
- #include "menu.h"
-
- boolean menu_InsertRows(menu_type menu, int row, int count)
- /*
- Inserts count rows in the menu before row.
- */
- {
- register int i;
- int fno;
-
- /* test menu and row number */
- cs_Assert(menu_Ok(menu), CS_M_IR_MENU, 0); /* passed bad menu */
- cs_Assert(row >= 0 && row < menu_GetRowCount(menu) && count > 0, CS_M_IR_ARG, 0); /* passed bad args */
-
- /* insert rows into the text buffer */
- for (i = 0; i < count; i++) {
- menu_InsRowTB(menu, row, 0);
- }
-
- /* slide the row array */
- /* adjust the row position for all the fields below */
- for (i = menu->frowcount - 1; i >= row; i--) {
- fno = ia_Get(menu->fgrid, i);
- ia_Put(menu->fgrid, i + count, fno);
- if (fno > 0) {
- for (fno = fno - 1; fno >= 0; fno = menu_GetFieldRight(menu, fno)) {
- field_SetRow(menu_GetField(menu, fno), i + count);
- }
- }
- }
- menu->frowcount += count;
-
- /* clear the inserted area of the row array */
- fno = 0;
- for (i = row; i < row + count; i++) {
- ia_Put((menu)->fgrid, i, fno);
- }
-
- /* menu size is now incorrect */
- menu_SetDirty(menu, TRUE);
-
- return(TRUE);
- }
-
- boolean menu_InsRowTB(menu_type menu, int row, int col)
- {
- boolean ret;
- int ins;
-
- ins = menu_GetTextbuf(menu)->insert;
-
- menu_GetTextbuf(menu)->insert = TED_INSERT;
- ret = menu_Addc(menu, row, col, '\n', 1);
-
- menu_GetTextbuf(menu)->insert = ins;
-
- return(ret);
- }
-