home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / c / curses / src / _scroll.c < prev    next >
C/C++ Source or Header  |  1994-02-21  |  4KB  |  125 lines

  1. /* -*-C-*-
  2.  *
  3.  *
  4.  * Filename : _scroll.c
  5.  *
  6.  * Author   : Simon J Raybould.    (sie@fulcrum.bt.co.uk).
  7.  *
  8.  * Date     : Friday 23rd August 1991.
  9.  *
  10.  * Desc     : scrolls any region of lines up or down by one line.
  11.  *
  12.  *
  13.  * THIS CODE IS NOT PUBLIC DOMAIN
  14.  * ==============================
  15.  * 
  16.  * This code is copyright Simon J Raybould 1991, all rights are reserved.
  17.  * All code, ideas, data structures and algorithms remain the property of the
  18.  * author. Neither the whole nor sections of this code may be used as part
  19.  * of other code without the authors consent. If you wish to use some of this
  20.  * code then please email me at (sie@fulcrum.bt.co.uk).
  21.  *
  22.  * This source is not public domain, so you do not have any right to alter it
  23.  * or sell it for personal gain. The source is provided purely for reference
  24.  * purposes. You may re-compile the source with any compiler you choose.
  25.  * You must not distribute altered copies without the authors consent. My
  26.  * intention is that the source will help people isolate any bugs much more
  27.  * effectivly.
  28.  *
  29.  * Disclaimer
  30.  * ==========
  31.  *
  32.  * No implication is made as to this code being fit for any purpose at all.
  33.  * I (the author) shall not be held responsible for any loss of data or damage 
  34.  * to property that may result from its use or misuse.
  35.  *
  36.  *
  37.  * Revision History
  38.  * ================
  39.  *
  40.  * $Log: _scroll.c,v $
  41.  * Revision 1.9  1993/05/17  23:29:43  sie
  42.  * Underscores added to names.
  43.  *
  44.  * Revision 1.8  1992/12/25  23:42:17  sie
  45.  * Set x coord to 0 after a scroll operation.
  46.  *
  47.  * Revision 1.7  92/08/13  23:08:06  sie
  48.  * Fixed bug that corrupted colours when screen scrolled.
  49.  * 
  50.  * Revision 1.6  92/06/21  01:14:47  sie
  51.  * Now marks scroll lines as requiring refreshing.
  52.  * 
  53.  * Revision 1.5  92/06/10  23:45:15  sie
  54.  * Added serial support.
  55.  * 
  56.  * Revision 1.4  91/12/30  10:31:10  sie
  57.  * Removed LRLine and LRATTRS.
  58.  * The speed increase caused by them was too insignificant.
  59.  * 
  60.  * Revision 1.3  91/12/28  22:46:25  sie
  61.  * changed attrs to UBYTE from short + some tidying up.
  62.  * 
  63.  * Revision 1.2  91/12/28  14:02:06  sie
  64.  * Removed WinStat.
  65.  * Renamed LineElement as lnel.
  66.  * 
  67.  * Revision 1.1  91/09/07  11:53:21  sie
  68.  * Initial revision
  69.  * 
  70.  *
  71.  */
  72.  
  73. static char *rcsid = "$Header: /SRC/lib/curses/src/RCS/_scroll.c,v 1.9 1993/05/17 23:29:43 sie Exp $";
  74.  
  75. #include <string.h>
  76. #include "acurses.h"
  77.  
  78.  
  79. _Scroll(WINDOW *WinPtr, int Top, int Bottom, int Direction)
  80. {
  81.   int Step, SLine, DLine;
  82.   char *TLine;
  83.   UBYTE *TATTRS;
  84.   
  85.   /* Store pointers to line that will be lost */
  86.   if(Direction == SCROLL_UP) {
  87.     Step = +1;
  88.     DLine = Top;
  89.     SLine = Top + Step;
  90.   } else {
  91.     Step = -1;
  92.     DLine = Bottom;
  93.     SLine = Bottom + Step;
  94.   }
  95.   TLine = WinPtr->LnArry[DLine].Line;
  96.   TATTRS = WinPtr->LnArry[DLine].ATTRS;
  97.   /* Move the lines */
  98.   for(;;) {
  99.     /* This line now needs refreshing */
  100.     WinPtr->LnArry[DLine].Touched = TRUE;
  101.     WinPtr->LnArry[DLine].StartCol = 0;
  102.     WinPtr->LnArry[DLine].EndCol = WinPtr->_maxx;
  103.     /* check if we've finished */
  104.     if((Direction == SCROLL_UP) && (DLine >= Bottom))
  105.       break;  /* Done */
  106.     if((Direction == SCROLL_DOWN) && (DLine <= Top))
  107.       break;  /* Done */
  108.     /* move the lines and attrs */
  109.     WinPtr->LnArry[DLine].Line = WinPtr->LnArry[SLine].Line;
  110.     WinPtr->LnArry[DLine].ATTRS = WinPtr->LnArry[SLine].ATTRS;
  111.     /* next line */
  112.     SLine += Step;
  113.     DLine += Step;
  114.   }
  115.   /* Blank the Temp line */
  116.   memset(TLine, ' ', WinPtr->_maxx+1);
  117.   memset(TATTRS, WinPtr->_attrs, WinPtr->_maxx+1);
  118.   /* move in temp line */
  119.   WinPtr->LnArry[DLine].Line = TLine;
  120.   WinPtr->LnArry[DLine].ATTRS = TATTRS;
  121.   WinPtr->_curx = 0;            /* back to left margin */
  122.   
  123.   return OK;
  124. }
  125.