dmt@mtunb.ATT.COM (Dave Tutelman) (09/13/88)
In article <7375@umn-cs.cs.umn.edu> randy@umn-cs.cs.umn.edu (Randy Orrison) writes: >Could someone tell me how to set up my IBM Personal Computer Graphics >Printer so that it understands what a backspace is, instead of just >ignoring it? ... I have a big document with >lots of _^Hs_^Ht_^Hu_^Hf_^Hf in it that I would really like to be able >to print. It also has IBM printer specific escape codes in it, so I can't >just use a different printer. Gee, that's the second such request I've seen this morning. I had the same problem last week with my AT&T 473 printer (a "clone"), and wrote a little filter that fixes the problem. It scans through a line at a time, and converts overstrikes to full-line overstrikes; backspace may not work on my printer, but carriage return does. I've attached the C source. I compiled it using Turbo 1.0, but it's vanilla C and even compiles on UNIX systems. I call it NOBS (for NO BackSpace). > >Thanks! (Please reply my mail, I don't read this group anymore) I'm posting because this seems to be a general problem, not just Randy's (indeed, it was mine last week). But personally, I'm offended by this reasoning. Paraphrase: "I'm too busy to be bothered by this group, but it's OK for you to take the time to read my request and help me." I'm all for "reply by mail and I'll summarize", but if this newsgroup degenerates into all queries and no answers EVERYONE will stop reading it, and it will become useless. There's such a thing as good net citizenship. +---------------------------------------------------------------+ | Dave Tutelman | | Physical - AT&T Bell Labs - Lincroft, NJ | | Logical - ...att!mtunb!dmt | | Audible - (201) 576 2442 | +---------------------------------------------------------------+ /********************************************************************** * * This program is a filter to fix up text for a printer that * doesn't support BackSpace (NO BackSpace = NOBS). * It replaces backspace sequences with carriage return sequences. * * Dave Tutelman - September 1988 */ /* #define DEBUG */ #include <stdio.h> #define LL 200 /* line length */ #define LD 8 /* line (overstrike) depth */ #define CR 13 #define LF 10 #define FF 12 #define VT 11 char line [LD] [LL]; int quit=0; main () { while ( !quit ) do_line (); } /*********************************************************************/ do_line () { int col=0; /* current column */ int c; /* current input character */ int eol=0; /* end of line.. "quit" for do_line */ clear_line (); /* zero out the array */ while (!eol) { /* get characters till end of line */ c = getchar (); switch (c) { case EOF: col=0; eol=1; quit=1; break; case FF: /* Form Feed - done with page */ case LF: /* Line Feed - done with line */ col=0; eol=1; break; case VT: /* Vertical Tab - no more line */ eol = 1; break; case CR: /* Carriage Return - back to col 0 */ col = 0; break; case '\t': /* Tab - move to good col */ col = (col / 8)*8 + 8; break; case '\b': /* BackSpace - back off a column */ if (col>0) col--; break; default: /* put c into lines [..] array */ insert_c (c, col); col ++; break; } } print_line (col); putchar (c); /* use same line-ender that we got */ } /********************************************************************** * clear the line[][] array to nulls */ clear_line () { int i,j; for (i=0; i<LD; i++) for (j=0; j<LL; j++) line [i][j] = '\0'; } /********************************************************************** * Put c into the line[..] array at column n. */ insert_c (c, n) char c; int n; { int d; if (n >= LL) /* past end of line */ return; for (d=0; d<LD-1; d++) /* how deep? */ if (line [d][n] == '\0') break; line [d][n] = c; } /********************************************************************** * The line is done. Put to stdout from line[..] array. */ print_line (col) int col; { int i,j; int jmax; char c; for (i=0; i<LD; i++) { if (i>0) { putchar (CR); #ifdef DEBUG putchar (LF); #endif col = 0; } for (jmax=LL-1; jmax>=0; jmax--) if (line [i][jmax]) break; if (jmax < 0) break; for (j=col; j<=jmax; j++) { c = line [i] [j]; if (c == '\0') c = ' '; putchar (c); } } }