[net.sources] ped - REGIS picture editor

colonel@sunybcs.UUCP (Col. G. L. Sicherman) (03/16/87)

: See comp.graphics for explanation.

: This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# Makefile gigi.h ped.c ped.1

echo x - Makefile
sed -e 's/^X//' > "Makefile" << '//E*O*F Makefile//'
X#	Makefile for ped, version 1.
X#
X#	Installation parameters:
XBINDIR=$$HOME/bin
XMANDIR=/dev/null
X#
XCFLAGS= -O
XSOURCES=Makefile gigi.h ped.c ped.1
Xall: ped
Xped: ped.o gigi.h
X	cc -o ped ped.o
Xinstall: ped ped.1
X	install -c ped $(BINDIR)
X	install -c ped.1 $(MANDIR)
Xshar: ped.shar
Xped.shar: $(SOURCES)
X	shar $(SOURCES) > ped.shar
Xclean: rm -f *.o ped
//E*O*F Makefile//

echo x - gigi.h
sed -e 's/^X//' > "gigi.h" << '//E*O*F gigi.h//'
X/*
X *	GIGI graphics commands
X */
X
X#define GR_ON "\033Pp"
X#define GR_OFF "\033\\"
X#define RESET ";S(I0N0A)S(E)W(VI7A0S0M1N0P1M2)T(I0A0D0S1)P[0,0]\n"
X
X#define GR_RED 2
X#define GR_WHITE 7
X#define GR_YELLOW 6
X#define GR_BLACK 0
//E*O*F gigi.h//

echo x - ped.c
sed -e 's/^X//' > "ped.c" << '//E*O*F ped.c//'
X/*
X *	ped - the picture editor for GIGIs.
X *	Col. G. L. Sicherman (decvax!sunybcs!colonel).  Circa 1984.
X *	Version 1. (This does not imply that any newer versions will
X *	be developed!)
X *
X *	Copyright 1987 by G. L. Sicherman.  You may use and alter
X *	this program however you like, so long as you do not claim
X *	it as your own, try to get money for it, or alter this
X *	message.
X *
X *	This is meant for UNIX BSD4.  It has not been extensively
X *	tested.  It comes with no guarantees.
X */
X
X#include <sgtty.h>
X#include <signal.h>
X
X#include <ctype.h>
X#include <stdio.h>
X
X#include "gigi.h"
X
X/*
X *	Shell escape.
X */
X
X#define SHELL "/bin/csh"
X
X/*
X *	Storage parameters.
X */
X
X#define MAXPOINTS 300
X#define MAXLINES 384
X#define MAXCIRC 50
X#define MAXOPECURV 100
X#define MAXLOOPS 100
X
Xchar *version = "1";
X
Xint x=300, y=200;	/* STARTING POINT */
Xint xfac=1, yfac=1;
Xint vx, vy, vp;
Xint cx, cy, cp;
Xstruct spl_ *cs;
Xint npoints=0, nlines=0, nsplines=0, ncirc=0, nloops=0;
Xint grid=0;	/* DRAW A GRID? */
Xint labelpts=1;	/* LABEL THE POINTS? */
Xchar splinetype;	/* S FOR OPEN, B FOR CLOSED */
Xint vector=0;	/* DRAWING VECTORS? */
Xint curve=0;	/* DRAWING SPLINE? */
Xint circle=0;	/* DRAWING CIRCLE? */
Xint moving=0;	/* RELOCATING A POINT? */
Xint param=0;
Xint nchanges = 0;
Xchar fname[72];
XFILE *fstr;
Xint atpoint=0;
Xstruct sgttyb oldt, newt;
Xstruct ct {
X	int cce, cci;
X}
Xcirc[MAXCIRC];
Xstruct pt {
X	int px, py;
X} 
Xpoint[MAXPOINTS];
Xstruct ln {
X	int l0, l1;
X} 
Xline[MAXLINES];
Xstruct spl_ {
X	int s0;
X	struct spl_ *s1;
X} 
X*spline[MAXOPECURV], *loop[MAXLOOPS];
X
Xmain(argc,argv)
Xint argc;
Xchar **argv;
X{
X	int i, quit();
X	int nquits = 0, nexpunges = 0;
X	char cmd, oldcmd='q';
X	if (argc>2) {
X		fprintf(stderr,"usage: ped [file]\n");
X		exit(1);
X	}
X	gtty(0,&oldt);
X	signal(SIGINT,quit);
X	newt=oldt;
X	newt.sg_flags |= CBREAK;
X	newt.sg_flags &= ~ECHO;
X	stty(0,&newt);
X	puts(GR_ON,stdout);
X	puts(RESET,stdout);
X	printf("S(E)(I(D))\n");
X	if (argc==2) {
X		loadfrom(argv[1]);
X		redraw(stdout);
X	}
X	mvcur();
X/*
X *	The command loop.
X */
X	for (;;) {
X		if (1>read(0,&cmd,1)) quit();
X		if (cmd!='q') nquits=0;
X		if (cmd!='x') nexpunges=0;
X		if (cmd!='h' && cmd!='l' && !isdiag(cmd)) xfac=1;
X		if (cmd!='j' && cmd!='k' && !isdiag(cmd)) yfac=1;
X		if (isorth(cmd) || isdiag(cmd)) atpoint=0;
X		if (cmd!=oldcmd) xfac=yfac=1;
X		if (isdigit(cmd)) {
X			param=param*10+cmd-'0';
X			continue;
X		}
X		switch (cmd) {
X		case '?':
X			help();
X			break;
X		case '!':
X			escape();
X			break;
X		case 'q':
X			if (nchanges && !nquits++) beep();
X			else quit();
X			break;
X		case 'r':
X			redraw(stdout);
X			break;
X		case 's':
X			scaleup();
X			break;
X		case 'g':
X			grid = !grid;
X			redraw(stdout);
X			break;
X		case 'f':
X			for (i=0; i<npoints; i++) point[i].py=479-point[i].py;
X			redraw(stdout);
X			nchanges++;
X			break;
X		case 'J':
X			if (!param) param=1;
X			for (i=0; i<npoints; i++) point[i].py+=param;
X			redraw(stdout);
X			nchanges++;
X			break;
X		case 'K':
X			if (!param) param=1;
X			for (i=0; i<npoints; i++) point[i].py-=param;
X			redraw(stdout);
X			nchanges++;
X			break;
X		case 'L':
X			dsplines();
X			break;
X		case 'm':
X			if (param) {
X				if (param>npoints) {
X					beep();
X					break;
X				}
X				gopoint(param);
X			}
X			else if (!atpoint) mkpoint();
X			moving=atpoint;
X			vector=0;
X			printf("W(I%d)V[]W(I%d)\n",GR_RED,GR_WHITE);
X			nchanges++;
X			break;
X		case 'k':
X			hjkl(0,-1);
X			break;
X		case 'j':
X			hjkl(0,1);
X			break;
X		case 'h':
X			hjkl(-1,0);
X			break;
X		case 'l':
X			hjkl(1,0);
X			break;
X		case 'y':
X			hjkl(-1,-1);
X			break;
X		case 'u':
X			hjkl(1,-1);
X			break;
X		case 'b':
X			hjkl(-1,1);
X			break;
X		case 'n':
X			hjkl(1,1);
X			break;
X		case 'e':
X			printf("%s\n",GR_OFF);
X			stty(0,&oldt);
X			printf("File name:  ");
X			if (1==scanf(" %s",fname)) loadfrom(fname);
X			stty(0,&newt);
X			printf("%s\n",GR_ON);
X			redraw(stdout);
X			break;
X		case 'w':
X			printf("%s\n",GR_OFF);
X			stty(0,&oldt);
X			printf("File name:  ");
X			if (1==scanf(" %s",fname)) {
X				fstr=fopen(fname,"w");
X				if (fstr==NULL)
X					printf("cannot open %s\n",fname);
X				else {
X					labelpts=0;
X					fprintf(fstr,"%s\n",GR_ON);
X					fprintf(fstr,"%s\n",RESET);
X					strucdump(fstr);
X					redraw(fstr);
X					fprintf(fstr,"%s\n",GR_OFF);
X					labelpts=1;
X					fclose(fstr);
X					printf("Dumped.\n");
X				}
X			}
X			while ('\n'!=getchar());	/* FLUSH INPUT LINE */
X			nchanges=0;
X			stty(0,&newt);
X			printf("%s\n",GR_ON);
X			break;
X		case 'x':
X			if (!atpoint) beep();
X			else if (!nexpunges++ && pointused(atpoint)) beep();
X			else {
X				delpoint(atpoint);
X				redraw(stdout);
X			}
X			break;
X		case 'V':
X			for (i=1; i<=npoints; i++)
X			if (!pointused(i)) delpoint(i);
X			redraw(stdout);
X			break;
X		case 'o':
X		case 'z':
X			if (vector || curve || circle) beep();
X			else {
X				curve=1;
X				splinetype = 'o'==cmd? 'S': 'B';
X				cx=x;
X				cy=y;
X				if (!atpoint) mkpoint();
X				cs = (struct spl_ *)malloc(sizeof(struct spl_));
X				if (cmd=='o') spline[nsplines]=cs;
X				else loop[nloops]=cs;
X				cs->s0 = cp = atpoint;
X				cs->s1 = NULL;
X			}
X			break;
X		case 'c':
X			if (vector || curve || circle) beep();
X			else {
X				circle=1;
X				cx=x;
X				cy=y;
X			}
X			if (!atpoint) mkpoint();
X			cp=atpoint;
X			break;
X		case 'v':
X			if (vector || curve || circle) beep();
X			else {
X				vector=1;
X				vx=x;
X				vy=y;
X			}
X			if (!atpoint) mkpoint();
X			vp=atpoint;
X			break;
X		case 'p':
X			if (param) {
X				if (param>npoints || moving) {
X					beep();
X					break;
X				}
X				else gopoint(param);
X			}
X			else if (moving) {
X				point[moving-1].px=x;
X				point[moving-1].py=y;
X				printf("V[]T'%d'P[%d,%d]\n",moving,x,y);
X				moving=0;
X			}
X			else mkpoint();
X			if (curve) xtndspline();
X			else if (circle) {
X				printf("P[%d,%d]C[%d,%d]\n",cx,cy,x,y);
X				circ[ncirc].cce=cp;
X				circ[ncirc].cci=param;
X				ncirc++;
X				nchanges++;
X				circle=0;
X			}
X			else if (vector) {
X				printf("P[%d,%d]V[%d,%d]\n",vx,vy,x,y);
X				vx=x;
X				vy=y;
X				line[nlines].l0=vp;
X				line[nlines].l1=param;
X				nlines++;
X				nchanges++;
X				vp=param;
X			}
X			break;
X		case 'i':
X			if (vector) vector=0;
X			else if (curve) {
X				curve=0;
X				if (!atpoint) {
X					mkpoint();
X					xtndspline();
X				}
X				if (splinetype=='S') nsplines++;
X				else nloops++;
X			}
X			else beep();
X			break;
X		default:
X			beep();
X		}
X		oldcmd=cmd;
X		param=0;
X	}
X}
X
Xescape() {
X	printf("%s\n",GR_OFF);
X	system(SHELL);
X	cntinu();
X}
X
Xhelp() {
X	printf("%s\n",GR_OFF);
X	printf("?\tmenu\t\t\tn\tdown right\n");
X	printf("J\tpicture down\n");
X	printf("K\tpicture up\n");
X	printf("L\tshow lines\t\to\topen curve\n");
X	printf("V\tdelete unused points\tp\tpoint\n");
X	printf("b\tdown left\t\tq\tquit\n");
X	printf("c\tcircle\t\t\tr\tredraw screen\n");
X	printf("e\tedit a ped file\t\ts\tscale up or down\n");
X	printf("f\tflip picture\n");
X	printf("g\tdraw/erase grid\t\tu\tup right\n");
X	printf("h\tleft\t\t\tv\tbegin vectors\n");
X	printf("i\tend vector/curve\tw\twrite to file\n");
X	printf("j\tdown\t\t\tx\tremove point\n");
X	printf("k\tup\t\t\ty\tup left\n");
X	printf("l\tright\t\t\tz\tloop (closed curve)\n");
X	printf("m\tmove point\n");
X	cntinu();
X}
X
Xmvcur() {
X	printf("P[%d,%d]\n",x,y);
X}
X
Xquit()
X{
X	puts(GR_OFF,stdout);
X	stty(0,&oldt);
X	exit(0);
X}
X
Xbeep()
X{
X	printf("\007");
X	fflush(stdout);
X}
X
Xredraw(stm)
XFILE *stm;
X{
X	int i;
X	fprintf(stm,";S(E)\n");
X	if (labelpts && grid) {
X		fprintf(stm,"W(I(G))\n");
X		for (i=1; i<8; i++) fprintf(stm,"P[%d,1]V[,+470]\n",i*100);
X		for (i=1; i<5; i++) fprintf(stm,"P[1,%d]V[+760]\n",i*100);
X		fprintf(stm,"W(I(W))\n");
X	}
X	for (i=0; i<npoints; i++) {
X		if (labelpts)
X		fprintf(stm,"P[%d,%d]V[]T'%d'\n",point[i].px,point[i].py, i+1);
X		fprintf(stm,"P[%d,%d]\n",point[i].px,point[i].py);
X		x=point[i].px;
X		y=point[i].py;
X		atpoint=i;
X	}
X	for (i=0; i<nlines; i++) {
X		fprintf(stm,"P[%d,%d]V[%d,%d]\n",
X		point[line[i].l0-1].px,point[line[i].l0-1].py,
X		point[line[i].l1-1].px,point[line[i].l1-1].py);
X		x=point[line[i].l1-1].px;
X		y=point[line[i].l1-1].py;
X		atpoint=line[i].l1;
X	}
X	if (labelpts) fprintf(stm,"W(I%d)\n",GR_YELLOW);
X	for (i=0; i<ncirc; i++) fprintf(stm,"P[%d,%d]C[%d,%d]\n",
X		point[circ[i].cce-1].px, point[circ[i].cce-1].py,
X		point[circ[i].cci-1].px, point[circ[i].cci-1].py);
X	if (labelpts) fprintf(stm,"W(I%d)\n",GR_WHITE);
X	for (i=0; i<nsplines; i++) drawspl(stm,'S',i+1);
X	for (i=0; i<nloops; i++) drawspl(stm,'B',i+1);
X}
X
Xmkpoint()
X{
X	point[npoints].px=x;
X	point[npoints].py=y;
X	printf("V[]T'%d'P[%d,%d]\n",++npoints,x,y);
X	atpoint=param=npoints;
X	nchanges++;
X}
X
Xdsplines() {
X	int i;
X	puts(GR_OFF,stdout);
X	printf("LineNo\tStart\tX\tY\tEnd\tX\tY\n");
X	for (i=0; i<nlines; i++) printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
X	i+1,line[i].l0,point[line[i].l0-1].px,point[line[i].l0-1].py,
X	line[i].l1,point[line[i].l1-1].px,point[line[i].l1-1].py);
X	cntinu();
X}
X
Xgopoint(param)
Xint param;
X{
X	x=point[param-1].px;
X	y=point[param-1].py;
X	mvcur();
X	atpoint=param;
X}
X
Xxtndspline()
X{
X	cs->s1 = (struct spl_ *)malloc(sizeof (struct spl_));
X	cs=cs->s1;
X	cs->s0 = atpoint;
X	cs->s1 = NULL;
X	drawspl(stdout,splinetype,(splinetype=='S'? nsplines: nloops)+1);
X	nchanges++;
X}
X
Xdrawspl(stm,t,i)
Xchar t;
Xint i;
XFILE *stm;
X{
X	struct spl_ *s;
X	if (t=='S') s = spline[i-1];
X	else s = loop[i-1];
X	fprintf(stm,"P[%d,%d]C(%c)\n",
X	point[s->s0-1].px,point[s->s0-1].py,t);
X	while (s = s->s1)
X	    fprintf(stm,"[%d,%d]\n",
X	x=point[(atpoint=s->s0)-1].px,y=point[s->s0-1].py);
X	fprintf(stm,"C(E)\n");
X}
X
Xhjkl(dx,dy)
Xint dx, dy;
X{
X	if (param) {
X		x+=param*dx;
X		xfac=1;
X		y+=param*dy;
X		yfac=1;
X	}
X	else {
X		x+=xfac*dx;
X		xfac*=2;
X		if (xfac>100) xfac=100;
X		y+=yfac*dy;
X		yfac*=2;
X		if (yfac>100) yfac=100;
X	}
X	if (x<0) x=0;
X	if (x>767) x=767;
X	if (y<0) y=0;
X	mvcur();
X}
X
Xint
Xisorth(c)
Xchar c;
X{
X	return c=='h' || c=='j' || c=='k' || c=='l';
X}
X
Xint
Xisdiag(c)
Xchar c;
X{
X	return c=='y' || c=='u' || c=='b' || c=='n';
X}
X
Xcntinu()
X{
X	char c;
X	printf("\nType space to continue");
X	fflush(stdout);
X	while (1==read(0,&c,1)) if (c==' ') break;
X	puts(GR_ON,stdout);
X	redraw(stdout);
X}
X
Xstrucdump(str)
XFILE *str;
X{
X	int i;
X	struct spl_ *s;
X	fprintf(str,";\"\n");
X	fprintf(str,"%d\n",npoints);
X	for (i=0; i<npoints; i++) fprintf(str,"%d %d\n",point[i].px,point[i].py);
X	fprintf(str,"%d\n",nlines);
X	for (i=0; i<nlines; i++) fprintf(str,"%d %d\n",line[i].l0,line[i].l1);
X	fprintf(str,"%d\n",ncirc);
X	for (i=0; i<ncirc; i++) fprintf(str,"%d %d\n",circ[i].cce,circ[i].cci);
X	fprintf(str,"%d\n",nsplines);
X	for (i=0; i<nsplines; i++) {
X		for (s=spline[i]; s; s=s->s1) fprintf(str,"%d ",s->s0);
X		fprintf(str,"-1 \n");
X	}
X	fprintf(str,"%d\n",nloops);
X	for (i=0; i<nloops; i++) {
X		for (s=loop[i]; s; s=s->s1) fprintf(str,"%d ",s->s0);
X		fprintf(str,"-1 \n");
X	}
X	fprintf(str,"\"\n");
X}
X
Xloadfrom(fname)
Xchar *fname;
X{
X	FILE *str;
X	char k;
X	int i, j;
X	struct spl_ *s;
X	str=fopen(fname,"r");
X	if (str==NULL) {
X		printf("cannot read %s\n",fname);
X		return;
X	}
X	for (i=0; i<2; i++)
X	while (';'!=(k=getc(str))) if (EOF==k) {
X		printf("Error in file; load aborted.\n");
X		return;
X	}
X	if ('"'!=getc(str)) {
X		printf("Error in file; load aborted.\n");
X		return;
X	}
X	fscanf(str," %d",&npoints);
X	for (i=0; i<npoints; i++) fscanf(str," %d %d",&point[i].px,&point[i].py);
X	fscanf(str," %d",&nlines);
X	for (i=0; i<nlines; i++) fscanf(str," %d %d",&line[i].l0,&line[i].l1);
X	fscanf(str," %d",&ncirc);
X	for (i=0; i<ncirc; i++) fscanf(str," %d %d",&circ[i].cce,&circ[i].cci);
X	fscanf(str," %d",&nsplines);
X	for (i=0; i<nsplines; i++) {
X		s=spline[i]=(struct spl_ *)malloc(sizeof (struct spl_));
X		fscanf(str," %d",&(s->s0));
X		for (;;) {
X			fscanf(str," %d",&j);
X			if (j<0) break;
X			s=s->s1=(struct spl_ *)malloc(sizeof (struct spl_));
X			s->s0=j;
X		}
X		s->s1=0;
X	}
X	fscanf(str," %d",&nloops);
X	for (i=0; i<nloops; i++) {
X		s=loop[i]=(struct spl_ *)malloc(sizeof (struct spl_));
X		fscanf(str," %d",&(s->s0));
X		for (;;) {
X			fscanf(str," %d",&j);
X			if (j<0) break;
X			s=s->s1=(struct spl_ *)malloc(sizeof (struct spl_));
X			s->s0=j;
X		}
X		s->s1=0;
X	}
X	fclose(str);
X}
X
Xscaleup()
X/* SCALE THE WHOLE PICTURE UP OR DOWN */
X{
X	int i;
X	double fac;
X	printf("%s\n",GR_OFF);
X	stty(0,&oldt);
X	printf("Scale factor:  ");
X	if (1==scanf(" %lf",&fac)) {
X		if (0.0==fac) printf("That's too small\n");
X		else for (i=0; i<npoints; i++) scalpoint(&point[i],fac);
X	}
X	else printf("* Ignored *\n");
X	while ('\n'!=getchar());	/* FLUSH INPUT LINE */
X	stty(0,&newt);
X	printf("%s\n",GR_ON);
X	redraw(stdout);
X}
X
Xscalpoint(p,f)
Xstruct pt *p;
Xdouble f;
X{
X	int newx, newy;
X	newx=384+f*(p->px-384);
X	newy=240+f*(p->py-240);
X	if (newx<0) {
X		newy=((p->py-240)*(p->px-384))/384 + 240;
X		newx=0;
X	}
X	else if (newx>767) {
X		newy=((p->py-240)*(p->px-384))/384 + 240;
X		newx=767;
X	}
X	if (newy<0) {
X		newx=((p->px-384)*(p->py-240))/240 + 384;
X		newy=0;
X	}
X	else if (newy>479) {
X		newx=((p->py-384)*(p->px-240))/240 + 384;
X		newy=479;
X	}
X	p->px=newx;
X	p->py=newy;
X}
X
Xdelpoint(n)
Xint n;
X/* DELETE POINT N AND RENUMBER REMAINING POINTS */
X{
X	int i;
X	struct spl_ *s;
X	if (n>npoints) {
X		beep();
X		return;
X	}
X	if (pointused(n)) delrefs(n);
X	for (i=n-1; i<npoints-1; i++) point[i]=point[i+1];
X	for (i=0; i<nlines; i++) {
X		if (line[i].l0>n) line[i].l0--;
X		if (line[i].l1>n) line[i].l1--;
X	}
X	for (i=0; i<ncirc; i++) {
X		if (circ[i].cce>n) circ[i].cce--;
X		if (circ[i].cci>n) circ[i].cci--;
X	}
X	for (i=0; i<nsplines; i++) {
X		s=spline[i];
X		while (s) {
X			if (s->s0>n) s->s0--;
X			s=s->s1;
X		}
X	}
X	for (i=0; i<nloops; i++) {
X		s=loop[i];
X		while (s) {
X			if (s->s0>n) s->s0--;
X			s=s->s1;
X		}
X	}
X	npoints--;
X}
X
Xdelrefs(n)
X/* DELETE LINES & CURVES CONTAINING POINT n */
X{
X	int i, j;
X	struct spl_ **s;
X	for (i=0; i<nlines; i++)
X	if (line[i].l0==n || line[i].l1==n) {
X		for (j=i; j<nlines-1; j++) line[j]=line[j+1];
X		nlines--;
X		i--;
X	}
X	for (i=0; i<ncirc; i++)
X	if (circ[i].cce==n || circ[i].cci==n) {
X		for (j=i; j<ncirc-1; j++) circ[j]=circ[j+1];
X		ncirc--;
X		i--;
X	}
X	for (i=0; i<nsplines; i++) {
X		s = &spline[i];
X		while (*s) {
X			if ((*s)->s0==n) *s = (*s)->s1;
X			else s = &((*s)->s1);
X		}
X	}
X	for (i=0; i<nloops; i++) {
X		s = &loop[i];
X		while (*s) {
X			if ((*s)->s0==n) *s = (*s)->s1;
X			else s = &((*s)->s1);
X		}
X	}
X}
X
Xint
Xpointused(n)
Xint n;
X/* IS POINT PART OF A LINE OR CURVE? */
X{
X	int i;
X	struct spl_ *s;
X	for (i=0; i<nlines; i++) if (line[i].l0==n || line[i].l1==n) return 1;
X	for (i=0; i<ncirc; i++) if (circ[i].cce==n || circ[i].cci==n) return 1;
X	for (i=0; i<nsplines; i++) {
X		s=spline[i];
X		while (s) {
X			if (s->s0==n) return 1;
X			s=s->s1;
X		}
X	}
X	for (i=0; i<nloops; i++) {
X		s=loop[i];
X		while (s) {
X			if (s->s0==n) return 1;
X			s=s->s1;
X		}
X	}
X	return 0;
X}
X
Xmrgpts(i,j)
X/* MERGE TWO POINTS INTO ONE */
Xint i, j;
X{
X	int k;
X	struct spl_ *s;
X	if (i>j) {
X		k=i;
X		i=j;
X		j=k;
X	}
X	for (k=0; k<nlines; k++) {
X		if (line[k].l0==j) line[k].l0=i;
X		if (line[k].l1==j) line[k].l1=i;
X	}
X	for (k=0; k<ncirc; k++) {
X		if (circ[k].cce==j) circ[k].cce=i;
X		if (circ[k].cci==j) circ[k].cci=i;
X	}
X	for (k=0; k<nsplines; k++) {
X		s=spline[k];
X		while (s) {
X			if (s->s0==j) s->s0=i;
X			s=s->s1;
X		}
X	}
X	for (k=0; k<nloops; k++) {
X		s=loop[k];
X		while (s) {
X			if (s->s0==j) s->s0=i;
X			s=s->s1;
X		}
X	}
X	delpoint(j);
X}
//E*O*F ped.c//

echo x - ped.1
sed -e 's/^X//' > "ped.1" << '//E*O*F ped.1//'
X.TH PED 1 "16 Mar 1987" Local
X.UC 4
X.SH NAME
Xped \- edit a REGIS picture interactively
X.SH SYNOPSIS
X.B ped
X[
X.I file
X]
X.br
X.SH DESCRIPTION
X.I Ped
Xlets you interactively create and edit a REGIS line drawing
Xon a DEC graphics terminal.
XIf you specify a
X.I file,
Xit must be a
X.I ped
Xsave file.
XWhile such files will draw your picture when sent to the terminal,
Xthey have special structures and information.
XYou cannot use
X.I ped
Xon any old file of REGIS commands.
X.PP
X.I Ped
Xworks only with points, lines, and curves.
XYou cannot specify colors or fill.
X.SH "COMMAND SUMMARY"
X.PP
XThe commands
X.BR h ,
X.BR j ,
X.BR k ,
Xand
X.B l
Xmove the cursor left, down, up, and right.
XYou can prefix them with numbers; e.g.,
X.B 100h
Xmoves 100 pixels leftward.
XSimilarly,
X.BR b ,
X.BR n ,
X.BR u ,
Xand
X.B y
Xmove down and left, down and right, up and right, and up and left.
X.PP
XThe
X.B p
Xcommand plants a numbered
X.I point
Xat the cursor position.
XYou can relocate it with the
X.B m
Xcommand,
Xor remove it with
X.BR x .
X.PP
XYou can make a chain of lines through labeled points with
X.B v
X(vector mode),
Xan open spline curve with
X.B o
X(open curve mode),
Xor a closed spline loop with
X.B z
X(closed curve mode).
XExit from these modes with
X.BR i .
XYou can draw a circle with
X.BR c .
X.PP
XThe
X.B J
Xand
X.B K
Xcommands move the whole picture down or up.
XUse
X.B g
Xto toggle a square grid imposed on the picture.
XThe
X.B f
Xcommand reflects the picture horizontally or vertically,
Xand
X.B s
Xexpands or shrinks it.
XIf your picture is messed up, you can redraw it from scratch with
X.BR r .
X.PP
XThe
X.B L
Xcommand displays a table of all lines (not curves),
Xshowing their endpoints.
XThe
X.B V
Xcommand deletes all points not currently used in lines, circles, or splines.
X.PP
XThe
X.B ?
Xcommand displays a menu, and
X.B !
Xis a shell escape.
X.PP
XYou can write your picture to a
X.I ped
Xsave file with
X.BR w ,
Xspecify a new file to edit with
X.BR e ,
Xand exit from
X.I ped
Xwith
X.BR q .
X.SH BUGS
X.I Ped
Xhas been tested only on GIGI terminals.
XWhether it works on other REGIS terminals is a matter for speculation.
XIn any case,
X.I Ped 's
Xuse of color will probably fall flat on VT240s.
X.PP
XThis program is a
X.SM HACK.
XIf you don't like it, go modify it yourself.
X.SH AUTHOR
XCol. Sicherman
//E*O*F ped.1//

exit 0
-- 
Col. G. L. Sicherman
UU: ...{rocksvax|decvax}!sunybcs!colonel
CS: colonel@buffalo-cs
BI: colonel@sunybcs, csdsiche@ubvms