/* $Header:_scroll.c 12.0$ */
/* $ACIS:_scroll.c 12.0$ */
/* $Source: /ibm/acis/usr/src/usr.lib/libaed/RCS/_scroll.c,v $ */

#ifndef lint
static char *rcsid = "$Header:_scroll.c 12.0$";
#endif

#include "whim.h"
VI_Scroll(sx,sy,wd,ty,scr)
  INT16 sx,sy,wd,ty,scr;	/* x,y,width,bottom y, scroll amount */
  begin
#include "whimdcl.h"
    if (saving) { JOURNL(V_SCROLL);
		  JOURNL(sx);
		  JOURNL(sy);
		  JOURNL(wd);
		  JOURNL(ty);
		  JOURNL(scr);}

    sx = max(0,min(sx,1023));
    sy = max(0,min(sy,799));
    wd = max(0,min(1024,1024-sx));
    ty = max(sy,min(ty,799));
    scr = max(0,min(scr,ty-sy));
    if ( (scr && wd) == 0) return; 	/* nothing to do */

    clear(6);	  /* 6-word order */
    vikint[vikoff++] = 0;	    /* scroll order */
    vikint[vikoff++] = sx;	    /* x position */
    vikint[vikoff++] = sy;	    /* y position */
    vikint[vikoff++] = wd;	    /* width */
    vikint[vikoff++] = ty;	    /* bottom y */
    vikint[vikoff++] = scr;	    /* scroll amount */
  end
