[comp.unix.ultrix] lg02's

hubcap@hubcap.clemson.edu (System Janitor) (03/16/90)

I'm trying to configure a serially connected lg02 into an ULTRIX 3.1
system on a 3400.

I've been poking around for a few hours, looking in all the manuals, 
and now I'm stuck...

It says in lg02of(4):
  ``If the value of the width is greater than 80 the job will be printed in
    landscape mode with a slightly smaller font.''

ARRGGHHHHH!!! This is a 132 column printer. I've got 132 column printout
to print. I don't want it to come out vertically. I've tried tried 2 hours
worth of ideas, and haven't come up with anything acceptable. My printout 
either comes out vertical, truncated, unfiltered, or otherwise spoogified.
Any ideas?

Thanks all...

-Mike Marshall

jan@cft.philips.nl (Jan Stevens) (03/28/90)

There are two possible solutions :
1) Writing your own filter
2) Patching the code

Because of this problem I can not use any LG02 printer. Another problem
occured with our LN03 printers. Some of them use paper with holes in the
left margin. The default ln03 filter can avoid these holes when
identation is used. Unfortunately it also limits the number of
characters on a page. The problem was solved by creating an own filter
which is not capable to convert nroff and/or troff files. 
The source of this filter is included.


-------------------------------------------------------------------------
#include <stdio.h>
#include <strings.h>
#include <ctype.h>

/* LEFTMARGIN and TOPMARGIN are calculated values to take care the text
   will not write on the left side of the paper because of the possible
   presence of holes.
   The values are device specific and do not have to be altered.
*/
#define LEFTMARGIN 9
#define TOPMARGIN  4


resetln03()
{
printf("\033c");
}

pageformat(number)
int number;
{
printf("\033[%d J",number);
}

selectfont(fontnumber)
int fontnumber;
{
   /* assuming default fonts for ln03 printer */
   /* 10 = DEC built in family type */
   /* 11 = Courier family type */
   /* 12 = Elite family type */
   /* 13 = Courier 10 point, 10 pitch */
   /* 14 = Elite 10 point, 12 pitch */
   /* 15 = Courier 6.7 point, 13.6 pitch */
   /* 16 = Courier 10 point, 10.3 pitch */
   /* 17 = DEC built in family type */
   /* 18 = DEC built in family type */
   /* 19 = DEC built in family type */
printf("\033[%dm", fontnumber);
}

fontsize()
{
}

charperline(number)
int number;
{
int select = 0;
switch (number)
   {
   case 0 : select=0;
            break;
   case 1 : select=1;
            break;
   case 2 : select=2;
            break;
   case 3 : select=3;
            break;
   }
printf("\033[%d K", select);
}


hormargin(beginmargin, endmargin)
int beginmargin, endmargin;
{
printf("\033[%d;%ds", beginmargin, endmargin);
}

vermargin(beginmargin, endmargin)
int beginmargin, endmargin;
{
printf("\033[%d;%dr", beginmargin, endmargin);
}

setnowrap()
{
printf("\033[?7l");
}

formfeed()
{
printf("\f");
}

softreset()
{
printf("\033[!p");
}

main(argc, argv)
int argc;
char *argv[];
{
int rawmode = 0;
int widht   = 0;
int length  = 0;
int indent  = 0;
int account = 0;
int name    = 0;
int host    = 0;
int pages   = 2; /* at least 2 pages for flag page and first page */
FILE *accfile;

int lines, j, i = 1;
char c;
char tempstring[10];

while (i < argc)
   {
    if (argv[i][0] == '-')
       {
        switch(argv[i][1])
           {
            case 'c' :
                       rawmode = 1;
                       break;
            case 'w' :
                       for (j = 1 ; argv[i][j] != '\0'; j++)
                          tempstring[j - 1] = argv[i][j + 1];    
                       widht = atoi(tempstring);
                       break;
            case 'l' :
                       for (j = 1 ; argv[i][j] != '\0'; j++)
                          tempstring[j - 1] = argv[i][j + 1];    
                       length = atoi(tempstring);
                       break;
            case 'i' :
                       for (j = 1 ; argv[i][j] != '\0'; j++)
                          tempstring[j - 1] = argv[i][j + 1];    
                       indent = atoi(tempstring);
                       if (j == 1)
                          indent = 8;
                       break;
            case 'n' :
                       i++;
                       if (i < argc)
                          name = i;
                       break;
            case 'h' :
                       i++;
                       if (i < argc)
                          host = i;
                       break;
            default  :
                       exit(1);
                       break;
           }
       }
    else
       {
        accfile = fopen(argv[i], "a");
        if (accfile != NULL)
           account = i;
       }
    i++;
   }


resetln03();         /* hard reset of ln03 filter */
pageformat(6);       /* use tall A4 page format */
hormargin(LEFTMARGIN + indent,LEFTMARGIN + widht);    /* set hor. margins */
if (length > 0)
   length--;
vermargin(TOPMARGIN,TOPMARGIN + length);     /* set vert. margins */
selectfont(14);      /* selected font is Courier 10 point, 12 pitch */
setnowrap();         /* disable wrapping */
lines = 0;
if (rawmode == 1)
   {
    while ((c=getchar()) != EOF)
       {
        if (lines == length)
           {
            pages++;
            lines = 0;
           }
        if (c == '\n')
           lines++;
        putchar(c);
       }
   }
else
   {
    while ((c=getchar()) != EOF)
       {
        if (lines == length)
           {
            pages++;
            lines = 0;
           }
        /* 11-08-1989 backspace added as allowed character */
        if ((isprint(c) != 0) || (isspace(c) != 0) || (c =='\010')
            || (c == '\t'))
           {
            if (c == '\n')
               lines++;
            putchar(c);
           }
       }
   }
formfeed();          /* unload last sheet */
softreset();         /* set printer in default state */
if (account != 0)
   {
    fprintf(accfile, "%4d.00\t%s:%s\n", pages, argv[host], argv[name]);
    fclose(accfile);
   }
}


Jan Stevens, Unix Support Engineer
Philips CFT Building SAQ room 718
e-mail : jan@philtis.cft.philips.nl