URI:
       tframe.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tframe.c (1591B)
       ---
            1 #include <stdio.h>
            2 #include <stdlib.h>
            3 #include "grap.h"
            4 #include "y.tab.h"
            5 
            6 double        frame_ht;        /* default frame height */
            7 double        frame_wid;        /* and width */
            8 
            9 int        nsides        = 0;                /* how many sides given on this frame */
           10 char        *sides[] = {
           11                 "\tline from Frame.nw to Frame.ne",
           12                 "\tline from Frame.sw to Frame.se",
           13                 "\tline from Frame.sw to Frame.nw",
           14                 "\tline from Frame.se to Frame.ne"
           15 };
           16 char        *newsides[4] = { 0, 0, 0, 0 };        /* filled in later */
           17 
           18 void frame(void)                /* pump out frame definition, reset for next */
           19 {
           20         int i;
           21 
           22         fprintf(tfd, "\tframeht = %g\n", frame_ht);
           23         fprintf(tfd, "\tframewid = %g\n", frame_wid);
           24         fprintf(tfd, "Frame:\tbox ht frameht wid framewid with .sw at 0,0 ");
           25         if (nsides == 0)
           26                 fprintf(tfd, "\n");
           27         else {
           28                 fprintf(tfd, "invis\n");
           29                 for (i = 0; i < 4; i++) {
           30                         if (newsides[i]) {
           31                                 fprintf(tfd, "%s\n", newsides[i]);
           32                                 free(newsides[i]);
           33                                 newsides[i] = 0;
           34                         } else
           35                                 fprintf(tfd, "%s\n", sides[i]);
           36                 }
           37                 nsides = 0;
           38         }
           39 }
           40 
           41 void frameht(double f)        /* set height of frame */
           42 {
           43         frame_ht = f;
           44 }
           45 
           46 void framewid(double f)        /* set width of frame */
           47 {
           48         frame_wid = f;
           49 }
           50 
           51 void frameside(int type, Attr *desc)        /* create and remember sides */
           52 {
           53         int n;
           54         char buf[100];
           55 
           56         n = 0; /* gcc */
           57 
           58         nsides++;
           59         switch (type) {
           60         case 0:                /* no side specified; kludge up all */
           61                 frameside(TOP, desc);
           62                 frameside(BOT, desc);
           63                 frameside(LEFT, desc);
           64                 frameside(RIGHT, desc);
           65                 return;
           66         case TOP:        n = 0; break;
           67         case BOT:        n = 1; break;
           68         case LEFT:        n = 2; break;
           69         case RIGHT:        n = 3; break;
           70         }
           71         sprintf(buf, "%s %s", sides[n], desc_str(desc));
           72         newsides[n] = tostring(buf);
           73 }