home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / c / curses / src / _scroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-30  |  3.3 KB  |  116 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.6  92/06/21  01:14:47  sie
  42.  * Now marks scroll lines as requiring refreshing.
  43.  * 
  44.  * Revision 1.5  92/06/10  23:45:15  sie
  45.  * Added serial support.
  46.  * 
  47.  * Revision 1.4  91/12/30  10:31:10  sie
  48.  * Removed LRLine and LRATTRS.
  49.  * The speed increase caused by them was too insignificant.
  50.  * 
  51.  * Revision 1.3  91/12/28  22:46:25  sie
  52.  * changed attrs to UBYTE from short + some tidying up.
  53.  * 
  54.  * Revision 1.2  91/12/28  14:02:06  sie
  55.  * Removed WinStat.
  56.  * Renamed LineElement as lnel.
  57.  * 
  58.  * Revision 1.1  91/09/07  11:53:21  sie
  59.  * Initial revision
  60.  * 
  61.  *
  62.  */
  63.  
  64. static char *rcsid = "$Header: SRC:lib/curses/src/RCS/_scroll.c,v 1.6 92/06/21 01:14:47 sie Exp $";
  65.  
  66. #include <string.h>
  67. #include "acurses.h"
  68.  
  69.  
  70. Scroll(WINDOW *WinPtr, int Top, int Bottom, int Direction)
  71. {
  72.   int Step, SLine, DLine;
  73.   char *TLine;
  74.   UBYTE *TATTRS;
  75.   
  76.   /* Store pointers to line that will be lost */
  77.   if(Direction == SCROLL_UP) {
  78.     Step = +1;
  79.     DLine = Top;
  80.     SLine = Top + Step;
  81.   } else {
  82.     Step = -1;
  83.     DLine = Bottom;
  84.     SLine = Bottom + Step;
  85.   }
  86.   TLine = WinPtr->LnArry[DLine].Line;
  87.   TATTRS = WinPtr->LnArry[DLine].ATTRS;
  88.   /* Move the lines */
  89.   for(;;) {
  90.     /* This line now needs refreshing */
  91.     WinPtr->LnArry[DLine].Touched = TRUE;
  92.     WinPtr->LnArry[DLine].StartCol = 0;
  93.     WinPtr->LnArry[DLine].EndCol = WinPtr->_maxx;
  94.     /* check if we've finished */
  95.     if((Direction == SCROLL_UP) && (DLine >= Bottom))
  96.       break;  /* Done */
  97.     if((Direction == SCROLL_DOWN) && (DLine <= Top))
  98.       break;  /* Done */
  99.     /* move the lines and attrs */
  100.     WinPtr->LnArry[DLine].Line = WinPtr->LnArry[SLine].Line;
  101.     WinPtr->LnArry[DLine].ATTRS = WinPtr->LnArry[SLine].ATTRS;
  102.     memset(WinPtr->LnArry[DLine].ATTRS, WinPtr->_attrs, WinPtr->_maxx+1);
  103.     /* next line */
  104.     SLine += Step;
  105.     DLine += Step;
  106.   }
  107.   /* Blank the Temp line */
  108.   memset(TLine, ' ', WinPtr->_maxx+1);
  109.   memset(TATTRS, WinPtr->_attrs, WinPtr->_maxx+1);
  110.   /* move in temp line */
  111.   WinPtr->LnArry[DLine].Line = TLine;
  112.   WinPtr->LnArry[DLine].ATTRS = TATTRS;
  113.   
  114.   return OK;
  115. }
  116.