home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / AMETHYST / COMTOO.DIF < prev    next >
Text File  |  2000-06-30  |  6KB  |  291 lines

  1. /* COMMTOO.C -- Scribble command interpeter, continued
  2.  
  3.     written March 1981 by Craig A. Finseth
  4.     Copyright (c) 1981 by Mark of the Unicorn
  5.  
  6. Modifications Record:
  7.     8/3/81        Indent mode and Table of contents by Jeffrey D. Stone.
  8.  
  9. */
  10.  
  11. #include "scribble.gbl"
  12.  
  13. FLAG
  14. CheckEnv(tkn)                /* deal with environments */
  15.     char *tkn;
  16. {
  17.     char which;
  18.     int ParaOut(), ParaStan(), ParaEnum(), ParaItem();
  19.  
  20.     if (Test(tkn,"indent")) { /* jds */
  21.         env.eleft=env.cureleft+=HALFINCH;
  22.         StartEnv();
  23.         return(TRUE);
  24.             }
  25.  
  26.     if (which=MulTest(tkn,"address","flushleft")) {
  27.         env.isfill=FALSE;
  28.         env.iswrap=FALSE;
  29.         if (which==1) env.preveleft=env.eleft=
  30.             env.cureleft= (pag.pright+pag.pleft)/2;
  31.         env.justifytype='l';
  32.         env.paraproc=NULL;
  33.         StartEnv();
  34.         return(TRUE);
  35.         }
  36.     if (which=MulTest(tkn,"center","flushright")) {
  37.         env.isfill=FALSE;
  38.         env.iswrap=FALSE;
  39.         env.justifytype= (which==1)? 'c' : 'r';
  40.         env.paraproc=NULL;
  41.         StartEnv();
  42.         return(TRUE);
  43.         }
  44.     if (Test(tkn,"description")) {
  45.         env.eleft=env.cureleft+=(env.eright-env.cureleft)/4;
  46.         env.linespacing=LINEHEIGHT;
  47.         env.paraproc= &ParaOut;
  48.         StartEnv();
  49.         return(TRUE);
  50.         }
  51.     if (MulTest(tkn,"display","example")) {
  52.         env.eleft=env.cureleft+=HALFINCH;
  53.         env.eright-=HALFINCH/2;
  54.         env.isfill=FALSE;
  55.         env.iswrap=TRUE;
  56.         env.justifytype='l';
  57.         env.iswhiteintact=TRUE;
  58.         env.paraproc=NULL;
  59.         StartEnv();
  60.         return(TRUE);
  61.         }
  62.     if (Test(tkn,"enumerate")) {
  63.         env.preveleft=env.cureleft+2*CHARWIDTH;
  64.         env.eleft=env.cureleft+=6*CHARWIDTH;
  65.         env.enumcount=1;
  66.         env.paraproc= &ParaEnum;
  67.         StartEnv();
  68.         return(TRUE);
  69.         }
  70.     if (MulTest(tkn,"format","verbatim")) {
  71.         env.linespacing=LINEHEIGHT;
  72.         env.isfill=FALSE;
  73.         env.iswrap=FALSE;
  74.         env.justifytype='l';
  75.         env.iswhiteintact=TRUE;
  76.         env.paraproc=NULL;
  77.         StartEnv();
  78.         return(TRUE);
  79.         }
  80.     if (Test(tkn,"itemize")) {
  81.         env.preveleft=env.cureleft+2*CHARWIDTH;
  82.         env.eleft=env.cureleft+=HALFINCH;
  83.         env.paraproc= &ParaItem;
  84.         env.itemlevel++;
  85.         StartEnv();
  86.         return(TRUE);
  87.         }
  88.     if (Test(tkn,"quotation")) {
  89.         env.eleft=env.cureleft+=HALFINCH;
  90.         env.eright-=HALFINCH;
  91.         env.linespacing=LINEHEIGHT;
  92.         StartEnv();
  93.         return(TRUE);
  94.         }
  95.     if (Test(tkn,"text")) {
  96.         env.linespacing=sty.spacing;
  97.         StartEnv();
  98.         return(TRUE);
  99.         }
  100.     if (Test(tkn,"verse")) {
  101.         env.eleft=env.preveleft+=3*CHARWIDTH;
  102.         env.cureleft=env.preveleft+2*CHARWIDTH;
  103.         env.eright-=10*CHARWIDTH;
  104.         env.linespacing=LINEHEIGHT;
  105.         env.isfill=FALSE;
  106.         env.justifytype='l';
  107.         env.paraproc= &ParaOut;
  108.         StartEnv();
  109.         return(TRUE);
  110.         }
  111.     return(FALSE);
  112.     }
  113.     
  114. FLAG
  115. CheckSec(tkn)            /* deal with sectioning commands */
  116.     char *tkn;
  117. {
  118.     TITLELIST *tptr;
  119.     STRING *token;
  120.     char which;
  121.  
  122.     if (which=MulComp(tkn,"chapter","appendix")) {
  123.         tptr=GetMem(sizeof(*tptr));
  124.         titletail->entnextptr=tptr;
  125.         titletail=tptr;
  126.         if (which==1) tptr->enttype='c';
  127.         else {
  128.             tptr->enttype='a';
  129.             num.chapnum= ++num.appnum;
  130.             }
  131.         num.chaptitle=tptr->entptr=GetOneArg('r');
  132.         tptr->entnextptr=NULL;
  133.         num.secnum=0;
  134.         num.subnum=0;
  135.         num.paranum=0;
  136.         ++num.chapnum;
  137.  
  138.         BreakLine();
  139.         PNewPage();
  140.         PPutVert(6*LINEHEIGHT);
  141.  
  142.         tptr->entpage=num.pagenum;
  143.  
  144.         TPuts(" (");
  145.         if (which==1) TPutn(num.chapnum);
  146.         else TPut('A'-1+num.chapnum);
  147.         TPut(')');
  148.  
  149.         EPush();
  150.         env.isfill=FALSE;
  151.         env.justifytype='c';
  152.         PutInit();
  153.         PutChr(BOLDON);
  154.         if (which==1) PutNum("Chapter ",num.chapnum,NULL);
  155.         else {
  156.             PutStr("Appendix ");
  157.             PutChr('A'-1+num.chapnum);
  158.             }
  159.         PutFini();
  160.         BreakLine();
  161.         PPutVert(LINEHEIGHT);
  162.         PutInit();
  163.         PutStr(SSToC(tptr->entptr));
  164.         PutChr(BOLDOFF);
  165.         PutFini();
  166.         BreakLine();
  167.         PPutVert(3*LINEHEIGHT);
  168.         EPop();
  169.         return(TRUE);
  170.         }
  171.     if (which=MulComp(tkn,"section","appendixsection")) {
  172.         tptr=GetMem(sizeof(*tptr));
  173.         titletail->entnextptr=tptr;
  174.         titletail=tptr;
  175.         tptr->enttype= (which==1)? 's' : 'n';
  176.         num.sectitle=tptr->entptr=GetOneArg('r');
  177.         tptr->entnextptr=NULL;
  178.         num.subnum=0;
  179.         num.paranum=0;
  180.         ++num.secnum;
  181.  
  182.         BreakLine();
  183.         PPutVert(4*LINEHEIGHT);
  184.         EPush();
  185.         env.isfill=FALSE;
  186.         env.justifytype='l';
  187.         PutInit();
  188.         if (num.chapnum != 0) {  /* jds */
  189.             if (which==1) PutNum(NULL,num.chapnum,NULL);
  190.             else PutChr('A'-1+num.chapnum);
  191.             PutNum(".",num.secnum," ");
  192.                     }
  193.         else    {  /* jds */
  194.             PutNum(NULL,num.secnum,".");
  195.             PutChr(' ');
  196.             }
  197.         PutStr(SSToc(tptr->entptr));
  198.         PutFini();
  199.         BreakLine();
  200.  
  201.         tptr->entpage=num.pagenum;
  202.  
  203.         TPuts(" (");
  204.         if (num.chapnum != 0) {  /* jds */
  205.             if (which==1) TPutn(num.chapnum);
  206.             else TPut('A'-1+num.chapnum);
  207.             TPut('.');
  208.                     }
  209.         TPutn(num.secnum);
  210.         TPut(')');
  211.  
  212.         PPutVert(2*LINEHEIGHT);
  213.         EPop();
  214.         return(TRUE);
  215.         }
  216.     if (which=MulComp(tkn,"subsection","paragraph")) {
  217.         tptr=GetMem(sizeof(*tptr));
  218.         titletail->entnextptr=tptr;
  219.         titletail=tptr;
  220.         tptr->enttype= (which==1)? 'b' : 'p';
  221.         tptr->entptr=GetOneArg('r');
  222.         if (which==1) {
  223.             num.subtitle=tptr->entptr;
  224.             num.paranum=0;
  225.             ++num.subnum;
  226.             }
  227.         else {
  228.             num.paratitle=tptr->entptr;
  229.             ++num.paranum;
  230.             }
  231.         tptr->entnextptr=NULL;
  232.  
  233.         BreakLine();
  234.         PPutVert(2*LINEHEIGHT);
  235.         EPush();
  236.         env.isfill=FALSE;
  237.         env.justifytype='l';
  238.         if (num.chapnum != 0) PutNum(NULL,num.chapnum,".");  /* jds */
  239.         PutNum(NULL,num.secnum,".");
  240.         if (which==1) PutNum(NULL,num.subnum," ");
  241.         else {
  242.             PutNum(NULL,num.subnum,".");
  243.             PutNum(NULL,num.paranum," ");
  244.             }
  245.         PutStr(SSToC(tptr->entptr));
  246.         BreakLine();
  247.  
  248.         tptr->entpage=num.pagenum;
  249.  
  250.         PPutVert(LINEHEIGHT);
  251.         EPop();
  252.         return(TRUE);
  253.         }
  254.     if ((which=MulComp(tkn,"unnumbered","majorheading")) ||
  255.          SCComp(tkn,"heading")) {
  256.         BreakLine();
  257.         if (which==1) PNewPage();
  258.         PPutVert((which?6:4)*LINEHEIGHT);
  259.  
  260.         EPush();
  261.         env.isfill=FALSE;
  262.         env.justifytype='c';
  263.         PutInit();
  264.         PutChr(BOLDON);
  265.         PutStr(SSToC(token=GetOneArg('r')));
  266.         SFree(token);
  267.         PutChr(BOLDOFF);
  268.         PutFini();
  269.         BreakLine();
  270.         PPutVert(3*LINEHEIGHT);
  271.         EPop();
  272.         return(TRUE);
  273.         }
  274.     if (which=MulComp(tkn,"prefacesection","subheading")) {
  275.         BreakLine();
  276.         PPutVert(4*LINEHEIGHT);
  277.         EPush();
  278.         env.isfill=FALSE;
  279.         env.justifytype='l';
  280.         PutStr(SSToC(token=GetOneArg('r')));
  281.         SFree(token);
  282.         BreakLine();
  283.         PPutVert(2*LINEHEIGHT);
  284.         EPop();
  285.         return(TRUE);
  286.         }
  287.     return(FALSE);
  288.     }
  289.  
  290. /* end of modified COMMTOO.C */
  291.