home *** CD-ROM | disk | FTP | other *** search
- /*
- sdpgrt.c
-
- % sed_PageRight
-
- C-scape 3.2
- Copyright (c) 1986, 1987, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 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_GetWidth
- 8/25/88 jmd monkeyed with RightField loop
- 12/16/88 jmd fixed search
-
- 3/24/89 jmd added sed_ macros
-
- 3/17/90 jmd added Cache/Flush
- 3/28/90 jmd ansi-fied
- */
-
- #include "sed.h"
-
- int sed_PageRight(sed_type sed)
- /*
- modifies: sed passed.
- effects: scrolls the window right by a screen. 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 menu_wid, fld_x, disp_size, xoffset, lines;
- menu_type menu;
-
- cs_Assert(sed_Ok(sed), CS_SD_PGDN_SED, 0);
-
- menu = sed_GetMenu(sed);
-
- /* Get current position data. */
- menu_wid = menu_GetWidth(menu);
- disp_size = sed_GetWidth(sed);
- xoffset = sed_GetXoffset(sed);
-
- /* Figure out how much to scroll. */
- /* display size menusize - display size - offset */
- lines = int_min(disp_size, menu_wid - (disp_size) - xoffset);
- if (lines < 1) {
- return(SED_STUCK);
- }
-
- /* If there are fields, find the best one to move to. */
- if (menu_GetFieldCount(menu) > 0) {
- newfld = sed_GetFieldNo(sed);
- fld_x = menu_GetFieldCol(menu, sed_GetFieldNo(sed));
- while (menu_GetFieldCol(menu, newfld) < fld_x + lines) {
- lastfld = newfld;
- do {
- if ((newfld = menu_GetFieldRight(menu, newfld)) < 0) {
- newfld = lastfld;
- break;
- }
- } while (menu_IsProtected(menu, newfld));
- if (newfld == lastfld) {
- break;
- }
- }
-
- /* If newfld won't be visible find best alternative.
- If newfld is off the right then try lastfld which should
- the closest field to the left of the correct position.
- */
-
- if (menu_GetFieldCol(menu, newfld) > xoffset + lines + disp_size-1) {
- newfld = lastfld;
- }
-
- /* Now see if the field will be past the left edge the window
- If so, don't change fields.
- */
-
- if (menu_GetFieldCol(menu, newfld) < xoffset+lines) {
- 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, 0, lines, 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));
- }
- }
- disp_Flush();
-
- return(SED_MOVED);
- }
-
-