--- ray/src/rt/editline.c 1989/09/29 13:23:54 1.2 +++ ray/src/rt/editline.c 2003/02/25 02:47:22 2.5 @@ -1,15 +1,18 @@ -/* Copyright (c) 1987 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: editline.c,v 2.5 2003/02/25 02:47:22 greg Exp $"; #endif - /* * editline.c - routine for editing raw input for rview. * - * 10/5/88 + * External symbols declared in driver.h */ +#include "copyright.h" + +#include "color.h" + +#include "driver.h" + #define iscntrl(c) ((c) < ' ') #define isblank(c) ((c) == ' ') #define iserase(c) ((c) == '\b' || (c) == 127) @@ -17,9 +20,11 @@ static char SCCSid[] = "$SunId$ LBL"; #define iskill(c) ((c) == 'U'-'@' || (c) == 'X'-'@') +void editline(buf, c_get, s_put) /* edit input line */ char *buf; -int (*c_get)(), (*s_put)(); +int (*c_get)(); +void (*s_put)(); { static char erases[] = "\b \b"; static char obuf[4]; @@ -60,4 +65,53 @@ int (*c_get)(), (*s_put)(); } buf[i] = '\0'; (*s_put)("\n"); +} + + +static char mybuf[512]; + + +void +tocombuf(b, d) /* add command(s) to my buffer */ +register char *b; +register struct driver *d; +{ + register char *cp; + char *comstart; + + for (cp = mybuf; *cp; cp++) + ; + comstart = cp; + while (*cp++ = *b) + if (cp >= mybuf+sizeof(mybuf)) { + *comstart = '\0'; + return; /* what should I do about this? */ + } else if (*b++ == '\n') { + d->inpready++; + comstart = cp; + } +} + + +int +fromcombuf(b, d) /* get command from my buffer */ +char *b; +struct driver *d; +{ + register char *cp; + /* get next command */ + for (cp = mybuf; *cp != '\n'; cp++) + if (!*cp) + return(0); + *cp++ = '\0'; +#ifdef DEBUG + (*d->comout)(mybuf); /* echo my command */ + (*d->comout)("\n"); +#endif + /* send it as reply */ + strcpy(b, mybuf); + d->inpready--; + /* advance commands */ + strcpy(mybuf, cp); + return(1); }