/* ___________________________________________________________ view.c Displays the contents of an ASCII text file to the screen as 22 line pages Each line in the disk file must be terminated with a \n. There is no filtering of Control characters. This is a freeware product, courtesy of Basil K Johnson beejay@micor.ocunix.on.ca _____________________________________________________________ */ #include #ifndef curson() #define curson() putchr(0x05) /* not in original std.h */ #endif #ifndef cursoff() #define cursoff() putchr(0x06) /* not in original std.h */ #endif #define MAX_LEN 80 /* length of line */ #define EOF -1 #define height 21 /* displaying 22 lines - 0 - 21 */ FILE fp; /* Display a 22 line block of text from an open file */ BYTE DispBlock() { TEXT buf[MAX_LEN]; int line_size; int count = 0; putchr(0x0c); cursor(0, 0); while ((line_size = getl(fp, buf, MAX_LEN-1)) > 0 ) { uf[line_size] ='\0'; putstr(buf); count++; if (count > height) return(NIL); } if (!line_size) return(EOF); } main(argc, argv) int argc; TEXT **argv; { TEXT quit_msg[55]; char c; BYTE p; quit_msg = "<< Press [q/Q] to quit; any other key to continue >>"; if (argc < 2) { printf("Syntax: view \n"); exit(2); } if (0 >= (fp = open (argv[1]))) { printf( "Cannot open %s\n", argv[1]); exit(2); } while (c = DispBlock() != EOF) { cursor(23, 20); vidinv(); putstr(quit_msg); vidnorm(); cursoff(); p = getkey(YES); if (p == 'q' || p == 'Q') { close(fp); cursor(23,0); curson(); exit(0); } } /* end while */ close(fp); cursor(23,0); curson(); }