home *** CD-ROM | disk | FTP | other *** search
- /*
- menufind.c
-
- % menu_FindUpField, FindDownField, etc.
-
- menu field finding functions
-
- C-scape 3.2
- Copyright (c) 1986, 1987, 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/25/88 jmd changed to true geographical operation
- 12/11/88 jmd changed to old, improved scheme
- 7/02/89 jdc added frowcount change
-
- 3/28/90 jmd ansi-fied
- */
-
- #include "menu.h"
-
- int menu_FindUpField(menu_type menu, int fieldno)
- /*
- returns: this routine takes the number of a field, and returns
- the number of the field above that one.
- Returns (-1) if no field was found.
- */
- {
- int row, col, up, next;
-
- cs_Assert(menu_Ok(menu), CS_M_GUF_MENU, 0);
-
- row = menu_GetFieldRow(menu, fieldno) - 1;
- col = menu_GetFieldGCol(menu, fieldno);
-
- /* find the row above */
- for (;(up = menu_GetGRow(menu, row)) <= 0; row--) {
- if (row < 0) {
- return(-1);
- }
- }
-
- /* now find the matching field in the line */
- up--;
- while (col > 0) {
- if ((next = menu_GetFieldRight(menu, up)) < 0) {
- break;
- }
- up = next;
- col--;
- }
-
- return(up);
- }
-
- /*---------------------------------------------------------------------------*/
- int menu_FindDownField(menu_type menu, int fieldno)
- /*
- returns: this routine takes the number of a field, and returns
- the number of the field below that one.
- Returns (-1) if no field was found.
- */
- {
- int row, col, down, next;
-
- cs_Assert(menu_Ok(menu), CS_M_GDF_MENU, 0);
-
- row = menu_GetFieldRow(menu, fieldno) + 1;
- col = menu_GetFieldGCol(menu, fieldno);
-
- /* find the row below */
- for (;(down = menu_GetGRow(menu, row)) <= 0; row++) {
- if (row >= menu->frowcount) {
- return(-1);
- }
- }
-
- /* now find the matching field in the line */
- down--;
- while (col > 0) {
- if ((next = menu_GetFieldRight(menu, down)) < 0) {
- break;
- }
- down = next;
- col--;
- }
-
- return(down);
- }
-
- /*---------------------------------------------------------------------------*/
- int menu_FindLeftField(menu_type menu, int fieldno)
- /*
- returns: this routine takes the number of a field, and returns
- the number of the field to the left of that one.
- Returns (-1) if no field was found.
- */
- {
- cs_Assert(menu_Ok(menu), CS_M_GLF_MENU, 0);
-
- return(menu_GetFieldLeft(menu, fieldno));
- }
-
- /*---------------------------------------------------------------------------*/
- int menu_FindRightField(menu_type menu, int fieldno)
- /*
- returns: this routine takes the number of a field, and returns
- the number of the field to the right of that one.
- Returns (-1) if no field was found.
- */
- {
- cs_Assert(menu_Ok(menu), CS_M_GRF_MENU, 0);
-
- return(menu_GetFieldRight(menu, fieldno));
- }
-
-
-