home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / flpage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-06  |  2.2 KB  |  96 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: flpage.c,v 1.4 1995/06/06 10:10:06 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    flpage.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    02 May 1985 (from code in main program)
  9.  * Last update:
  10.  *        18 Mar 1995, prototypes
  11.  *        03 Jul 1985, added import-definition.  Use 'scanint' to bypass
  12.  *                 bug in 'sscanf' in CC2.0
  13.  *        04 May 1985
  14.  *
  15.  * Function:    This module performs scrolling/cursor-movement operations
  16.  *        for FLIST.
  17.  */
  18.  
  19. #include    <ctype.h>
  20. #include    <string.h>
  21.  
  22. #include    "flist.h"
  23. #include    "dirent.h"
  24. #include    "dds.h"
  25. #include    "dircmd.h"
  26. #include    "strutils.h"
  27.  
  28. import(numfiles);
  29.  
  30. tDIRCMD(flpage)
  31. {
  32.     DCLARG    *next_    = xdcl_->dcl_next;
  33.     int    lines    = 0, st;
  34.     char    command = _toupper (xdcl_->dcl_text[0]),
  35.         *c_;
  36.  
  37.     /*
  38.      * Interpret the argument, if given, as the number of lines by which
  39.      * to scroll.  We accept only a positive argument.  A zero is used to
  40.      * set the direction-flag only.
  41.      */
  42.     if (next_)
  43.     {
  44.         if (strchr ("FBP", command))
  45.         {
  46.             c_ = scanint (next_->dcl_text, &lines);
  47.             if (*c_ || lines < 0)
  48.                 warn ("Illegal line count");
  49.             else
  50.             {
  51.                 if (command == 'B')
  52.                     dircmd_dirflg (FALSE);
  53.                 else if (command == 'F')
  54.                     dircmd_dirflg (TRUE);
  55.                 if (dircmd_dirflg (-1))
  56.                     command = DDS_D_1;
  57.                 else
  58.                     command = DDS_U_1;
  59.                 while (lines-- > 0 && !didwarn())
  60.                     flist_move (curfile_, *curfile_, command);
  61.             }
  62.         }
  63.         else
  64.             warn ("Command '%s' uses no arguments", xdcl_->dcl_text);
  65.     }
  66.     else switch (command)
  67.     {
  68.     case 'B':        /* Scroll backward on screen    */
  69.         dircmd_dirflg (-1);
  70.         flist_move (curfile_, *curfile_, DDS_U_S);
  71.         break;
  72.     case 'E':        /* Scroll to end of list    */
  73.         flist_move (curfile_, numfiles-1, DDS_D_1);
  74.         break;
  75.     case 'F':        /* Scroll forward one screen    */
  76.         dircmd_dirflg (1);
  77.         flist_move (curfile_, *curfile_, DDS_D_S);
  78.         break;
  79.     case 'H':        /* Move to top-of-screen    */
  80.         flist_move (curfile_, *curfile_, DDS_U_C);
  81.         break;
  82.     case 'L':        /* Move to end-of-screen    */
  83.         flist_move (curfile_, *curfile_, DDS_D_C);
  84.         break;
  85.     case 'M':        /* Move to middle-of-screen    */
  86.         flist_move (curfile_, *curfile_, DDS_0);
  87.         break;
  88.     case 'P':        /* Scroll by one page    */
  89.         flist_move (curfile_, *curfile_, dircmd_dirflg(-1) ? DDS_D_S
  90.                                    : DDS_U_S);
  91.         break;
  92.     case 'T':        /* Scroll to top of list    */
  93.         flist_move (curfile_, 0, DDS_U_1);
  94.     }
  95. }
  96.