home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 14view / vf_dspy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  1.1 KB  |  62 lines

  1. /*
  2.  *    vf_dspy -- display a screen page
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <ctype.h>
  9. #include <local\video.h>
  10. #include <local\std.h>
  11. #include <local\bioslib.h>
  12. #include "vf.h"
  13.  
  14. /* number field width */
  15. #define NFW    8
  16.  
  17. void
  18. vf_dspy(buf, lp, os, numbers)
  19. DNODE *buf;
  20. register DNODE *lp;
  21. int os;
  22. BOOLEAN numbers;
  23. {
  24.     register int i;
  25.     int j;
  26.     int textwidth;
  27.     char *cp;
  28.     char nbuf[NFW + 1];
  29.  
  30.     textwidth = Maxcol[Vmode];
  31.     if (numbers == TRUE)
  32.         textwidth -= NFW;
  33.         
  34.     for (i = 0; i < NROWS; ++i) {
  35.         putcur(TOPROW + i, 0, Vpage);
  36.         cp = lp->d_line;
  37.         if (numbers == TRUE) {
  38.             sprintf(nbuf, "%6u", lp->d_lnum);
  39.             putfld(nbuf, NFW, Vpage);
  40.             putcur(TOPROW + i, NFW, Vpage);
  41.         }
  42.         if (os < strlen(cp))
  43.             putfld(cp + os, textwidth, Vpage);
  44.         else
  45.             writec(' ', textwidth, Vpage);
  46.         if (lp == buf->d_prev) {
  47.             ++i;
  48.             break;    /* no more displayable lines */
  49.         }
  50.         else
  51.             lp = lp->d_next;
  52.     }
  53.  
  54.     /* clear and mark any unused lines */
  55.     for ( ; i < NROWS; ++i) {
  56.         putcur(i + TOPROW, 0, Vpage);
  57.         writec(' ', Maxcol[Vmode], Vpage);
  58.         writec('~', 1, Vpage);
  59.     }
  60.     return;
  61. }
  62.