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

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: dspc.c,v 1.7 1995/06/06 00:35:32 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    dspc.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    07 Jun 1984
  9.  * Last update:
  10.  *        19 Feb 1995, prototyped
  11.  *        17 Jan 1985, recode so we only do init/move functions here,
  12.  *                 under control of caller.
  13.  *        25 Aug 1984, cleanup buffer sizes
  14.  *        18 Jun 1984
  15.  */
  16.  
  17. #include    <stdio.h>
  18. #include    <ctype.h>
  19. #include    <string.h>
  20.  
  21. #include    "dspc.h"
  22. #include    "crt.h"
  23. #include    "getpad.h"
  24. #include    "getraw.h"
  25.  
  26. #include    "strutils.h"
  27.  
  28. /*
  29.  * Title:    dspc_init
  30.  *
  31.  * Function:    This procedure displays the current cursor location in-screen
  32.  *        for the BROWSE program.
  33.  *
  34.  * Parameters:    scale    text buffer to load with basic scale.
  35.  *        coladj    amount by which to right-shift the display to account
  36.  *            for prefix-text.
  37.  *        col    column number of home-position on screen.
  38.  */
  39.  
  40. void
  41. dspc_init (char *scale, int coladj, int col)
  42. {
  43.     int    width    = crt_width() - coladj,
  44.         width2    = width - 6;
  45.     char    sline    [CRT_COLS];
  46.  
  47.     if (width2 < 0)
  48.     {
  49.         scale[0] = '\0';
  50.         return;
  51.     }
  52.  
  53.     strscale (scale, col, width2);
  54.     if (coladj)    /* If "home" is not true origin, adjust scale */
  55.     {
  56.         char    format[20];
  57.         strcpy (sline, scale);
  58.         sprintf (format, "%%%ds%%s", coladj);
  59.         sprintf (scale, format, " ", sline);
  60.     }
  61.     crt_high (&scale[coladj], strlen(&scale[coladj]));
  62. }
  63.  
  64. /*
  65.  * Function:    Move the cursor to the specified column, updating the highlight
  66.  *        in the scale.
  67.  *
  68.  * Arguments:    scale    => text of scale, from init-call
  69.  *        col    = column number (adjusting for home-position) of
  70.  *              cursor (0..width-1).
  71.  *        line    = line number on which cursor resides (0..filesize-1)
  72.  */
  73. void
  74. dspc_move (char *scale, int col, int line)
  75. {
  76.     char    sline[CRT_COLS];
  77.  
  78.     line++;
  79.     if (*scale)
  80.     {
  81.         sprintf (sline, "%s%5d", scale, line);
  82.         if (crt_vt52())
  83.             sline[col] = '*';
  84.         else
  85.             sline[col] = toascii (sline[col]);
  86.             /* de-highlight cursor */
  87.         crt_text (sline, crt_lpp()-1, 2);
  88.     }
  89.     crt_move (line - crt_top(), ++col);
  90. }
  91.