/* **************************************************************************** * * Mnemonic: FMceject * Abstract: This rotine ejects the current column such that the next tokin * is placed at the top of the next column on the page. If the * current column is the last defined column then pflush is * called to flush the page and then the first column is selected. * FMflush MUST be called prior to this routine... This routine * cannot call FMflush as it is called by FMflush and a loop might * occur. * Parms: force - forces hard eject if true * Date: 6 May 1992 * Returns: Nothing. * Author: E. Scott Daniels * * Modified: 13 Jul 1994 - To convert t rfm * 8 Dec 1994 - To write par mark at top only if not in def list. * 27 Jan 2000 - To not put hard page if in single col mode to * prevent small # words with large spaces on last ln * 17 Jul 2016 - Changes for better prototype generation. **************************************************************************** */ extern void FMceject( int force ) { int diff; /* difference between lmar in col block and current lmar */ int diffh; /* difference betweeh header lmar in col block and current */ int diffx; /* diff between x value in list blk and curcol lmar */ if( flags2 & F2_BOX ) /* if a box is inprogress */ FMbxend( ); /* then end the box right here */ FMendlist( FALSE ); /* putout listitem mark characters if in list */ diffh = hlmar - cur_col->lmar; /* figure difference between col left mar */ diff = lmar - cur_col->lmar; /* and what has been set using .in and .hm */ if( lilist != NULL ) /* if list in progress */ diffx = lilist->xpos - cur_col->lmar; /* then calc difference */ if( cur_col->next != NULL ) /* if this is not the last on the page */ { cur_col = cur_col->next; /* then select it */ if( ((rflags & RF_PAR) == 0) && (lilist == NULL) ) AFIwrite( ofile, "\\par" ); /* need a par mark */ FMsetcol( col_gutter ); /* write out col def information */ } else { if( force || firstcol->next ) /* only do a hard page if in multi col mode */ FMpflush( ); /* force a page eject with headers etc */ cur_col = firstcol; /* select the first column */ } lmar = cur_col->lmar + diff; /* set lmar based on difference calculated */ hlmar = cur_col->lmar + diffh; /* earlier and next columns left edge */ if( lilist != NULL ) /* if list then reset xpos for next col */ lilist->xpos = cur_col->lmar + diffx; cury = topy; /* make sure were at the top */ if( rtopy > 0 && rtopcount > 0 ) /* reset real topy if needed */ if( (--rtopcount) == 0 ) /* need to reset */ { topy = rtopy; rtopy = 0; } if( flags2 & F2_BOX ) /* if a box is inprogress */ FMbxstart( FALSE, 0, 0, 0, 0 ); } /* FMceject */
/* **************************************************************************** * * Mnemonic: FMcd * Abstract: This routine parses the parameters on the .cd command and * builds the required column blocks. * Parms: None. * Returns: Nothing. * Date: 1 December 1988 * Author: E. Scott Daniels * * .cd n w i=value[i|p] g=value[i|p] * n - The number of columns (required) * w - The width of each column (optional) * i=- The indention of col 1 from edge of page (optional) * g=- The gutter space between each column (optional) * * Modified: 13 Jul 1994 - To convert to rfm * 9 Sep 1994 - To check first parameter properly *************************************************************************** */ void FMcd( ) { char *buf; /* pointer at the token */ int gutter = DEF_GUTTER; /* gutter value between cols */ int i; /* loop index */ int j; /* " " */ int len; /* length of parameter token */ struct col_blk *ptr; /* pointer at newly allocated blocks */ char wbuf[50]; /* work buffer */ len = FMgetparm( &buf ); /* get the number of columns requested */ if( len <= 0 ) /* if nothing then get lost */ return; while( firstcol != NULL ) /* lets delete the blocks that are there */ { ptr = firstcol; firstcol = firstcol->next; /* step ahead */ free( ptr ); /* loose it */ } i = atoi( buf ); /* convert parm to integer - number to create */ if( i <= 0 || i > MAX_COLS ) i = 1; /* default to one column if none entered */ firstcol = NULL; /* initially nothing */ for( i; i > 0; i-- ) /* create new col management blocks */ { ptr = (struct col_blk *) malloc( sizeof( struct col_blk ) ); ptr->next = firstcol; /* add to list */ firstcol = ptr; } /* end for */ firstcol->width = MAX_X; /* default if not set by parameter */ firstcol->lmar = DEF_LMAR; /* default incase no overriding parm */ while( (len = FMgetparm( &buf )) > 0 ) /* while parameters to get */ { switch( buf[0] ) /* check it out */ { case 'i': /* indention value set for col 1 */ case 'I': firstcol->lmar = FMgetpts( &buf[2], len-2 ); /* convert to points */ firstcol->lmar = firstcol->lmar < 0 ? 18 : firstcol->lmar; break; case 'g': /* gutter value supplied */ case 'G': gutter = FMgetpts( &buf[2], len-2 ); /* convert to points */ break; default: /* assume a number is a width */ if( isdigit( buf[0] ) || buf[0] == '.' ) firstcol->width = FMgetpts( buf, len ); /* convert to points */ break; } /* end switch */ } /* end while */ if( firstcol->next != NULL ) /* if in multiple column mode */ { /* adjust margins and set col lmar to 0 */ sprintf( wbuf, "\\margl%d", firstcol->lmar * 20 ); AFIwrite( ofile, wbuf ); firstcol->lmar = 0; } /* in rfm all column blocks have same info */ for( ptr = firstcol; ptr->next != NULL; ptr = ptr->next ) { ptr->next->width = ptr->width; /* set width of next block */ ptr->next->lmar = 0; /*ptr->lmar; */ /*+ ptr->width + gutter; */ } if( linelen > firstcol->width ) /* change if too big incase they dont set */ linelen = firstcol->width -5; /* no msg, becuase they may set later */ cur_col = firstcol; /* set up current column pointer */ FMsetcol( gutter ); /* put col setup info into document */ col_gutter = gutter; /* save current gutter value for later */ } /* FMcd */