DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T p

⟦cb67e40e5⟧ TextFile

    Length: 1383 (0x567)
    Types: TextFile
    Names: »prt.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Adv/Program/prt.c« 

TextFile

/*
 * Print string s in an orderly fashion.  (Provide linebreaks
 * where necessary.)
 */

#include "adv.h"

#ifndef CURSED
int (*nl_proc)();		/* if not null, called before printing \n */

#endif CURSED
static char pbuf[256];
static int pp;

prt(s)
	register char *s;
{
	if (s == 0) {
		pflush();
		return;
	}
	while (*s)
		if (*s == '\n') {
			pflush();
#ifndef CURSED
			if (nl_proc)
				(*nl_proc)();
#endif CURSED
			Wputc(*s++, CurWin);
		}
		else
			pput(*s++);
}

/*
 * Put character into buffer up to blank; then flush buffer
 * If current character would "spill over", go to next line.
 */
pput(c)
	register int c;
{
	register char *p;
#ifdef CURSED
	int	y, x;
#endif CURSED

	pbuf[pp++] = c;
#ifndef CURSED
	if (CurWin->w_cursor.col + pp >= COLS) {
#else CURSED
	getyx(CurWin, y, x);
	if (x + pp >= COLS) {
#endif CURSED
		p = &pbuf[pp];
		*p = 0;
		while (--p >= pbuf)
			if (*p == ' ')
				break;
		if (p < pbuf)
			p = &pbuf[pp];
		c = *p;
		*p = 0;
		Wputs(pbuf, CurWin);
		*p = c;
#ifndef CURSED
		if (CurWin->w_cursor.col) {
			if (nl_proc)
				(*nl_proc)();
#else CURSED
		getyx(CurWin, y, x);
		if (x) {
#endif CURSED
			Wputc('\n', CurWin);
		}
		while (*p == ' ')
			p++;
		if (*p) {
			strcpy(pbuf, p);
			pp = strlen(pbuf);
		}
		else
			pp = 0;
	}
}

/*
 * Write the buffered chars to the window
 */
pflush()
{

	pbuf[pp] = 0;
	Wputs(pbuf, CurWin);
	pp = 0;
}