home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 186_01 / txtplot.c < prev    next >
Text File  |  1985-08-21  |  2KB  |  73 lines

  1. /* TXTPLOT -- Enhanced version of BDS C txtplot() function.
  2.  *
  3.  * This version is in C, and does not use memory-mapped video.
  4.  * It is written to be used in VIEW, version 1.51, for systems
  5.  * without memory-mapped video.
  6.  *
  7.  * Version 1.0 -- 12/09/85
  8.  * James Pritchett
  9.  *
  10.  */
  11.  
  12. #define MAXCOL  79      /* Width of screen - 1*/
  13. #define CR  0x0d
  14. #define TAB 0x09
  15. #define ESC 0x1b
  16. #define MASK 0x7f       /* For parity strip */
  17.  
  18. /* This "gotoxy" function should be customized for your specific
  19.  * system.  The following is for an NEC PC-8801A.
  20.  */
  21.  
  22. void gotoxy(row,col)
  23. int row;
  24. int col;
  25. {
  26.     putch(ESC);
  27.     putch('=');
  28.     putch(row + 32);
  29.     putch(col + 32);
  30. }
  31.  
  32. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  33.  
  34. int txtplot(s,row,col,tabsize)
  35. char *s;        /* string to plot */
  36. int  row,col;   /* coordinates */
  37. int  tabsize;   /* Size of tabs */
  38. {
  39.     int curcol;     /* Current location */
  40.     int numsp;      /* Number of spaces to fill tabs */
  41.     char c;
  42.  
  43.     gotoxy(row,col);    /* Locate the cursor */
  44.  
  45. /* txtplot quits plotting when it hits the end of a row or when it
  46.  * sees a NULL or CR.
  47.  */
  48.  
  49.     for (curcol = col; curcol < MAXCOL && *s && *s != CR; s++) {
  50.         c = (*s) & MASK;
  51.         if (c < ' ') {      /* If a control char . . . */
  52.             if (c == TAB) {
  53.                 for (numsp = tabsize - (curcol % tabsize); 
  54.                             numsp && curcol < MAXCOL; curcol++, numsp--)
  55.                     putch(' ');
  56.             }
  57.         }
  58.         else {      /* All other controls ignored */
  59.             putch(*s);
  60.             curcol++;
  61.         }
  62.     }
  63.     return curcol;
  64. }
  65.  
  66. /* end */
  67.  
  68. 2);
  69. }
  70.  
  71. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  72.  
  73.