home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
SDSCRLDN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-28
|
3KB
|
123 lines
/*
sdscrldn.c
% sed_ScrollDown
C-scape 3.2
Copyright (c) 1986, 1987, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
9/22/86 jmd added call to fenter()
10/30/86 jmd removed ifdefs
11/05/86 jmd converted to boolean
11/05/86 jmd replaced d_ymin and
sng d_ymax with disp_size
11/08/86 jmd added calls to do_funcs
11/18/86 jmd rewrote completely.
1/22/87 jmd added new borders.
2/14/86 jmd replaced scroll.
3/11/87 jmd replaced scroll for horizontal scrolling.
4/21/87 jmd check for active mode
5/05/87 jmd added multilines
11/18/87 jmd changed names of some low-level funcs
4/08/88 jmd changed sed>fieldcount to sed_GetFieldCount()
7/07/88 jmd added call to sed_GetHeight
8/25/88 jmd monkeyed with DownField loop
12/12/88 jmd revised use of menu_Find...
12/16/88 jmd fixed use of menu_Find
3/24/89 jmd added sed_ macros
3/17/90 jmd added Cache/Flush
3/28/90 jmd ansi-fied
*/
#include "ted.h"
int sed_ScrollDown(sed_type sed, int lines)
/*
modifies: sed passed.
effects: scrolls the window down by a line.
tries to be smart about scrolling past the edge.
tries to be smarter about repositioning the field.
returns: SED_MOVED if successful.
SED_STUCK if it couldn't move.
SED_INVALID if the fexit function of the current field failed.
*/
{
register int newfld, lastfld;
int yoffset, disp_size, menu_hgt, dif;
menu_type menu;
cs_Assert(sed_Ok(sed), CS_SD_SCRD_SED, 0);
menu = sed_GetMenu(sed);
/* Get current position data. */
menu_hgt = menu_GetHeight(menu);
yoffset = sed_GetYoffset(sed);
disp_size = sed_GetHeight(sed);
/* Are we at the bottom of the screen? */
if (menu_hgt - disp_size - yoffset <= 0) {
return(SED_STUCK);
}
/* Don't scroll too much */
lines = (lines > 0) ? lines : 0;
lines = (lines < menu_hgt - disp_size - yoffset)
? lines : menu_hgt - disp_size - yoffset;
/* If there are fields, move if the current field will leave the window.*/
if (menu_GetFieldCount(menu) > 0) {
newfld = sed_GetFieldNo(sed);
while (menu_GetFieldRow(menu, newfld) < yoffset + lines) {
lastfld = newfld;
do {
if ((newfld = menu_FindDownField(menu, newfld)) < 0) {
/* No more down fields */
newfld = lastfld;
break;
}
} while (menu_IsProtected(menu, newfld));
if (newfld == lastfld) {
/* We're stuck */
break;
}
}
/* Don't move if the new field is beneath the window */
if (menu_GetFieldRow(menu, newfld) > yoffset + lines + disp_size-1) {
newfld = sed_GetFieldNo(sed);
}
/* If the field will change, test fexit function of old field. */
if ((sed_GetFieldNo(sed) != newfld) && !sd_exitfield(sed)) {
return(SED_INVALID);
}
}
disp_Cache();
/* Scroll. */
sd_scroll(sed, lines, 0, TRUE);
/* Go to the new field if necessary. */
if (menu_GetFieldCount(menu) >0 && sed_GetFieldNo(sed) != newfld) {
sd_goto_field(sed, newfld);
if (sed_IsActive(sed)) {
sed_DoFieldFenter(sed, sed_GetFieldNo(sed));
}
}
/* do it for teds too */
if ( (dif = sed_GetYoffset(sed) - sed_GetTrow(sed)) > 0 ) {
ted_GotoPosition(sed, sed_GetTrow(sed) + dif, sed_GetTcol(sed));
}
disp_Flush();
return(SED_MOVED);
}