home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SDGRID.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
2KB
|
94 lines
/*
sdgrid.c
% sed_GotoGridField etc., grid routines
Field grid addressing routines.
C-scape 3.2
Copyright (c) 1986, 1987, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
3/28/90 jmd ansi-fied
*/
#include "sed.h"
int sed_GotoGridField(sed_type sed, int row, int col)
/*
requires: a field row and column number.
modifies: the sed.
effects: moves to the field specified. if the field is off the
screen, scroll the screen until it's just on.
If the sed is active, call the fenter and fexit functions.
*/
{
int fld;
fld = sed_GetGridField(sed, row, col);
if (fld == -1) {
return(SED_STUCK);
}
return(sed_GotoField(sed, fld));
}
int sed_GetGridField(sed_type sed, int row, int col)
/*
requires: a field row and column number.
returns: the field number corresponding to the row
column position.
(-1) if no field there.
*/
{
int r, fld;
menu_type menu;
menu = sed_GetMenu(sed);
/* find the row */
for (r = 0; r < menu_GetHeight(menu); r++) {
if ((fld = menu_GetGRow(menu, r)) > 0 && (--row < 0)) {
break;
}
}
if (row >= 0) {
return(-1);
}
/* find the col */
fld--;
while (col > 0) {
if ((fld = menu_GetFieldRight(menu, fld)) == -1) {
return(-1);
}
col--;
}
return(fld);
}
int sed_GetGridRow(sed_type sed, int fieldno)
/*
Returns the the grid row number for the field
*/
{
int row, count;
menu_type menu;
menu = sed_GetMenu(sed);
count = -1;
for (row = menu_GetFieldRow(menu, fieldno); row >= 0; row--) {
if (menu_GetGRow(menu, row) > 0) {
count++;
}
}
return(count);
}