home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / amethyst / auxil.dif < prev    next >
Text File  |  1984-01-16  |  2KB  |  123 lines

  1. /* AUXIL.C -- Scribble auxilliary routines
  2.  
  3.     written January 1981 by Craig A. Finseth
  4.     Copyright (c) 1981 by Mark of the Unicorn Inc.
  5.  
  6. Modifications Record:
  7.     8/3/81    Table of contents Hacks by Jsffrey D. Stone.
  8. */
  9.     
  10. #include "scribble.gbl"
  11.  
  12. TableOfContents()            /* generate the table of contents */
  13. {
  14.     int app, chap, sec, sub, para;
  15.     char type, oldtype;
  16.     TITLELIST *tptr;
  17.     MICA LGetCol();
  18.  
  19.     if (!titlehead->entnextptr) return;
  20.  
  21.     TNL();
  22.     TNL();
  23.     TPuts("Table of Contents");
  24.     TNL();
  25.     TNL();
  26.     TPuts("     ");
  27.  
  28.     PNewPage();
  29.     PPutVert(4*LINEHEIGHT);
  30.  
  31.     EPush();
  32.     env.name="contents";
  33.     env.howclose=NUL;
  34.     env.iswhiteintact=FALSE;
  35.     env.isfill=FALSE;
  36.     env.iswrap=TRUE;
  37.     env.justifytype='c';
  38.     env.preveleft=env.eleft=pag.pleft;
  39.     env.cureleft=env.preveleft+3*INCH/2;
  40.     env.eright=pag.pright-INCH;
  41.     env.linespacing=LINEHEIGHT;
  42.     PutStr("Table of Contents");
  43.     BreakLine();
  44.  
  45.     PPutVert(2*LINEHEIGHT);
  46.     env.justifytype='l';
  47.     app=0;
  48.     chap=0;
  49.     sec=0;
  50.     sub=0;
  51.     para=0;
  52.  
  53.     tptr=titlehead->entnextptr;
  54.     oldtype='c';
  55.     repeat {
  56.         type=tptr->enttype;
  57.         if (oldtype!=type || type=='c' || type=='a') {
  58.             BreakLine();
  59.             PPutVert(LINEHEIGHT);
  60.             }
  61.         oldtype=type;
  62.         env.eleft=env.preveleft;
  63.         if (type=='c') {
  64.             PutNum("Chapter ",++chap,":");
  65.             sec=0;
  66.             sub=0;
  67.             para=0;
  68.             }        
  69.         else if (type=='s') {
  70.             LPutWhite(3*CHARWIDTH);
  71.             if (chap != 0)    PutNum(NULL,chap,"."); /* jds */
  72.             PutNum(NULL,++sec, (chap==0)? "." : NULL); /* jds */
  73.             sub=0;
  74.             para=0;
  75.             }
  76.         else if (type=='b') {
  77.             LPutWhite(6*CHARWIDTH);
  78.             if (chap != 0) PutNum(NULL,chap,"."); /* jds */
  79.             PutNum(NULL,sec,NULL); /* jds */
  80.             PutNum(".",++sub,NULL);
  81.             para=0;
  82.             }
  83.         else if (type=='p') {
  84.             LPutWhite(9*CHARWIDTH);
  85.             if (chap != 0)    PutNum(NULL,chap,"."); /* jds */
  86.             PutNum(NULL,sec,NULL); /* jds */
  87.             PutNum(".",sub,NULL);
  88.             PutNum(".",++para,NULL);
  89.             }
  90.         else if (type=='a') {
  91.             PutInit();
  92.             PutStr("Appendix ");
  93.             PutChr('A'-1+(++app));
  94.             PutFini();
  95.             sec=0;
  96.             sub=0;
  97.             para=0;
  98.             }
  99.         else {
  100.             LPutWhite(3*CHARWIDTH);
  101.             PutInit();
  102.             PutChr('A'-1+app);
  103.             PutNum(".",++sec,NULL);
  104.             PutFini();
  105.             sub=0;
  106.             para=0;
  107.             }
  108.         BreakTok();
  109.         PutStr(SSToC(tptr->entptr));
  110.         BreakTok();
  111.         if (LGetCol()>env.eright-HALFINCH) BreakLine();
  112.         LPutWhite(env.eright+HALFINCH-LGetCol());
  113.         env.iswrap=FALSE;
  114.         PutNum(NULL,tptr->entpage,NULL);
  115.         BreakLine();
  116.         env.iswrap=TRUE;
  117.         tptr=tptr->entnextptr;
  118.         if (!tptr) break;
  119.         }
  120.     EPop();
  121.     }
  122.  
  123.