- if (TERMTYPE_CHAR == p->type) {
- (*p->footf)(p, p->argf);
- return;
- }
-
- printf("%s\n", "%%END");
-}
-
-
-static void
-endline(struct termp *p)
-{
-
- if (TERMTYPE_CHAR == p->type) {
- putchar('\n');
- return;
- }
-
- if (PS_INLINE & p->psstate) {
- printf(") show\n");
- p->psstate &= ~PS_INLINE;
- }
-
- if (PS_MARGINS & p->psstate)
- return;
-
- p->pscol = PS_CHAR_LEFT;
- if (p->psrow >= PS_CHAR_HEIGHT + PS_CHAR_BOT) {
- p->psrow -= PS_CHAR_HEIGHT;
- return;
- }
-
- /*
- * XXX: can't run pageopen() until we're certain a flushln() has
- * occured, else the buf will reopen in an awkward state on the
- * next line.
- */
- printf("showpage\n");
- p->psrow = PS_CHAR_TOP;
-}
-
-
-/*
- * Advance the output engine by a certain amount of whitespace.
- */
-static void
-advance(struct termp *p, size_t len)
-{
- size_t i;
-
- if (TERMTYPE_CHAR == p->type) {
- /* Just print whitespace on the terminal. */
- for (i = 0; i < len; i++)
- putchar(' ');
- return;
- }
-
- if (PS_INLINE & p->psstate) {
- /* Dump out any existing line scope. */
- printf(") show\n");
- p->psstate &= ~PS_INLINE;
- }
-
- p->pscol += len ? len * PS_CHAR_WIDTH : 0;
-}
-
-
-static struct termp *
-alloc(char *outopts, enum termenc enc, enum termtype type)
-{
- struct termp *p;
- const char *toks[2];
- char *v;
- size_t width;
-
- toks[0] = "width";
- toks[1] = NULL;
-
- p = calloc(1, sizeof(struct termp));
- if (NULL == p) {
- perror(NULL);
- exit(EXIT_FAILURE);
- }
-
- p->type = type;
- p->tabwidth = 5;
- p->enc = enc;
-
- width = 80;
-
- while (outopts && *outopts)
- switch (getsubopt(&outopts, UNCONST(toks), &v)) {
- case (0):
- width = (size_t)atoi(v);
- break;
- default:
- break;
- }
-
- /* Enforce some lower boundary. */
- if (width < 60)
- width = 60;
- p->defrmargin = width - 2;
- return(p);