home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / udos / fgrep103 / printlin.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-24  |  1.5 KB  |  63 lines

  1. #include "bm.h"     /* N2 03-17-91 */
  2. #include <stdlib.h> /* N2 03-17-91 */
  3. #include <conio.h>  // 11-28-91 for wherey
  4. #include "extern.h"
  5. #include "proto.h" /* N2 04-05-91 */
  6.  
  7. void pausescr(void) // not too fast but speed don't count here
  8.  {
  9.   while(kbhit()) getch();       // 11-28-91 clear kb buffer
  10.   printf("<Hit a key to continue>");
  11.   while(!kbhit());
  12.   getch();
  13.   putchar('\n');
  14.   scrnlines = 1; // start again
  15.  }
  16.  
  17. void PrintLine(int OffSet,char *LineStart, char *LineEnd,int patlen)
  18.  {
  19.   char OffStr[80];
  20.   char tempstr[80]; // 11-28-91
  21.  
  22.   if(lFlag)
  23.    {
  24.     sprintf(OffStr,"%s\n",FileName);
  25.     write(1,OffStr,strlen(OffStr));
  26.     return;
  27.    }
  28.   else
  29.    {
  30.     if(showfname)
  31.      {
  32.       strcpy(tempstr,FileName);
  33.       strcat(tempstr," ->");
  34.       puts(tempstr);
  35.       ++scrnlines; // 11-28-91 show the lines
  36.       showfname = 0;
  37.      }
  38.    }
  39.  
  40.   if(FileName && !hFlag)
  41.    {
  42.     if (strlen(FileName) > 76)
  43.      {
  44.       fprintf(stderr,"bm: filename too long\n");
  45.       exit(2);
  46.      } /* if */
  47.     sprintf(OffStr,"%s: ",FileName);
  48.     write(1,OffStr,strlen(OffStr));
  49.    } // !hFlag
  50.  
  51.   if(nFlag)
  52.    {
  53.     sprintf(OffStr,"%d: ",OffSet - patlen);
  54.     write(1,OffStr,strlen(OffStr));
  55.    } // nFlag
  56.  
  57.   write(1,LineStart,LineEnd-LineStart+1);
  58.  
  59.   if (*LineEnd != '\n') write(1,"\n",1);  // 11-28-91
  60.   if(strlen(OffStr) > 77) ++scrnlines;    // 11-28-91 if wraps on screen
  61.   if(++scrnlines >= 20) pausescr();       // 8-24-92 was 23 for safety
  62.  } /* PrintLine */
  63.