fix .sp bug for eqn and other vertical motions.
authorDave Slattengren <slatteng@ucbvax.Berkeley.EDU>
Sat, 8 Oct 1983 14:03:42 +0000 (06:03 -0800)
committerDave Slattengren <slatteng@ucbvax.Berkeley.EDU>
Sat, 8 Oct 1983 14:03:42 +0000 (06:03 -0800)
SCCS-vsn: local/ditroff/ditroff.old.okeeffe/grn/hgraph.c 1.6

usr/src/local/ditroff/ditroff.old.okeeffe/grn/hgraph.c

index b9945c7..e43a4e7 100644 (file)
@@ -1,4 +1,4 @@
-/*     hgraph.c        1.5     (Berkeley) 83/09/19
+/*     hgraph.c        1.6     (Berkeley) 83/10/07
  *
  *     This file contains the graphics routines for converting gremlin
  * pictures to troff input.
  *
  *     This file contains the graphics routines for converting gremlin
  * pictures to troff input.
@@ -68,6 +68,7 @@ ELT *element;
                                 dy((double) p1->y);
                             }  /* end while */;
                            putchar('\'');
                                 dy((double) p1->y);
                             }  /* end while */;
                            putchar('\'');
+                           cr();
                             break;
 
               case VECTOR:  length = 1;                /* keep track of line length */
                             break;
 
               case VECTOR:  length = 1;                /* keep track of line length */
@@ -78,10 +79,12 @@ ELT *element;
                                 dy((double) p1->y);
                                putchar('\'');
                                if (length++ > MAXVECT) {
                                 dy((double) p1->y);
                                putchar('\'');
                                if (length++ > MAXVECT) {
+                                   cr();
                                    tmove (p1);
                                    length = 1;
                                }
                             }  /* end while */
                                    tmove (p1);
                                    length = 1;
                                }
                             }  /* end while */
+                           cr();
                             break;
             }  /* end switch */
         }  /* end else Text */
                             break;
             }  /* end switch */
         }  /* end else Text */
@@ -107,8 +110,8 @@ char string[];
     int savelasty = lasty;             /* vertical motion for text is to be */
                                        /*   ignored.  save current y here */
 
     int savelasty = lasty;             /* vertical motion for text is to be */
                                        /*   ignored.  save current y here */
 
-    printf(".nr g8 \\n(.d\n", string); /* save current vertical position. */
-    printf(".ds g9 \"%s", string);     /* define string containing the text. */
+    printf(".nr g8 \\n(.d\n");         /* save current vertical position. */
+    printf(".ds g9 \"%s\n", string);   /* define string containing the text. */
     tmove(&pnt);                       /* move to positioning point */
     switch (justify) {
                                        /* local vertical motions */
     tmove(&pnt);                       /* move to positioning point */
     switch (justify) {
                                        /* local vertical motions */
@@ -135,10 +138,11 @@ char string[];
        case CENTRIGHT:
         case TOPRIGHT: printf("\\h'-\\w'\\*(g9'u'");           /* back whole */
     }
        case CENTRIGHT:
         case TOPRIGHT: printf("\\h'-\\w'\\*(g9'u'");           /* back whole */
     }
+
     printf("\\*(g9\n");                        /* now print the text. */
     printf("\\*(g9\n");                        /* now print the text. */
-    printf(".sp |\\n(g8u");            /* restore vertical position */
-    lasty = savelasty;         /* vertical position is restored to */
-                               /*   what it was before text was printed */
+    printf(".sp |\\n(g8u\n");  /* restore vertical position */
+    lasty = savelasty;         /* vertical position restored to where it was */
+    lastx = xleft;             /*   before text, also horizontal is at left */
 } /* end HGPutText */
 
 
 } /* end HGPutText */
 
 
@@ -180,6 +184,7 @@ int angle;
            printf("\\D'c %du", (int) ((radius + radius) * troffscale));
        }
        putchar('\'');          /* finish the command */
            printf("\\D'c %du", (int) ((radius + radius) * troffscale));
        }
        putchar('\'');          /* finish the command */
+       cr();
 }
 
 
 }
 
 
@@ -193,7 +198,6 @@ int angle;
 HGSetFont(font, size)
 int font, size;
 {
 HGSetFont(font, size)
 int font, size;
 {
-    cr();
     printf(".ft %s\n.ps %s\n", tfont[font-1], tsize[size-1]);
 }
 
     printf(".ft %s\n.ps %s\n", tfont[font-1], tsize[size-1]);
 }
 
@@ -210,13 +214,10 @@ int font, size;
 HGSetBrush(mode)
 int mode;
 {
 HGSetBrush(mode)
 int mode;
 {
-    if (linmod != style[--mode]) {
-       cr();
+    if (linmod != style[--mode] || linethickness != thick[mode]) {
        printf ("\\D's %du'",linmod = style[mode]);
        printf ("\\D's %du'",linmod = style[mode]);
-    }
-    if (linethickness != thick[mode]) {
-       cr();
        printf ("\\D't %du'", linethickness = thick[mode]);
        printf ("\\D't %du'", linethickness = thick[mode]);
+       cr();
     }
 }
 
     }
 }
 
@@ -264,7 +265,8 @@ double y;
  | Routine:    tmove (point_pointer)
  |
  | Results:    produces horizontal and vertical moves for troff given the
  | Routine:    tmove (point_pointer)
  |
  | Results:    produces horizontal and vertical moves for troff given the
- |             pointer of a point to move to.
+ |             pointer of a point to move to.  Adds -1v to the movement to
+ |             counteract the vertical space generated by input "lines"
  *----------------------------------------------------------------------------*/
 
 tmove(ptr)
  *----------------------------------------------------------------------------*/
 
 tmove(ptr)
@@ -275,7 +277,6 @@ POINT *ptr;
     register int dx;
     register int dy;
 
     register int dx;
     register int dy;
 
-    cr();
     if (dy = iy - lasty) {
        printf(".sp %du\n", dy);
     }
     if (dy = iy - lasty) {
        printf(".sp %du\n", dy);
     }
@@ -298,6 +299,6 @@ POINT *ptr;
 
 cr()
 {
 
 cr()
 {
-    putchar('\n');
+    printf("\n.sp -1\n");
     lastx = xleft;
 }
     lastx = xleft;
 }