home *** CD-ROM | disk | FTP | other *** search
- /*
- *
- *!AU: Michael A. Shiels
- *!CD: 1-Jun-86
- *!FR: Dr. Dobbs July 1985
- *
- */
-
- #define LINT_ARGS
- #include <stdio.h>
- #include <signal.h>
-
- #include "masdos.h"
-
- #include "waitfork.x"
-
- #define PTEXT_IBM
-
- static int ptextctrlchit = 0;
- static int (*oldsignal)();
-
- static ptextctrlc()
- {
- ptextctrlchit = 1;
- signal( SIGINT, ptextctrlc );
- }
-
- /* ptext( dirc, dirv, Arg_Num_Cols, 79 / Arg_Num_Cols,
- (dirc/Arg_Num_Cols) + (dirc % Arg_Num_Cols != 0) ); */
-
- fptexth( linec, linev, numcols, colwidth, numrows, where )
- int linec, numcols, colwidth;
- char **linev;
- int numrows;
- FILE *where;
- {
- register int j,i;
- register char **lineend, **line, **nextline;
- register int linenum = 0;
-
- ptextctrlchit = 0;
- oldsignal = signal( SIGINT, ptextctrlc );
-
- for( j = numrows ; --j >= 0 && !ptextctrlchit ; )
- {
- #ifdef PTEXT_IBM
- putc( ' ', where );
- #endif
- lineend = &linev[numcols - 1];
-
- for( i = numcols ; --i >= 0 && *linev ; linev++ )
- {
- pr_line( *linev, colwidth,
- linev < lineend, where );
- }
- mynewline( where );
- }
- fflush( where );
- signal( SIGINT, oldsignal );
- D_OUT("ptexth");
- }
-
- fptextv( linec, linev, numcols, colwidth, numrows, where )
- int linec, numcols, colwidth;
- char **linev;
- int numrows;
- FILE *where;
- {
- register int j;
- register char **lineend, **line, **nextline;
- register int linenum = 0;
-
- lineend = &linev[linec - 1];
-
- for( j = numrows ; --j >= 0 ; )
- {
- #ifdef PTEXT_IBM
- putc( ' ', where );
- #endif
- for( line = linev++ ; line <= lineend ; line = nextline )
- {
- nextline = line + numrows;
- pr_line( *line, colwidth,
- nextline <= lineend );
- }
- mynewline( where );
- }
- D_OUT("ptextv");
- }
-
- static pr_line( str, width, padded, where )
- register char *str;
- int width, padded;
- FILE *where;
- {
- int col = 0;
-
- while( col < width && *str )
- {
- if( *str == '\n' )
- break;
-
- else if( *str == '\r' )
- {
- while( col > 0 )
- {
- --col;
- putc( '\b', where );
- }
-
- str++;
- }
- else if( *str == '\t' )
- {
- str++;
- col++;
- putc( ' ', where );
-
- while( ( col % 8 ) && col < width )
- {
- putc( ' ', where );
- col++;
- }
- }
- else
- {
- if( *str == Q_ESC )
- {
- putc( *str++, where );
- if( !*str )
- break;
-
- putc( *str++, where );
- if( !*str )
- break;
-
- putc( *str++, where );
- if( !*str )
- break;
- }
- else if( *str == '\b' )
- --col;
- else if( *str >= ' ' )
- ++col;
-
- putc( *str++, where );
- }
- }
- if( padded )
- while( col++ < width )
- putc( ' ', where );
- }
-