fixed up ellipse, circle and RoundEnd routines for speed
[unix-history] / usr / src / usr.bin / window / wwgets.c
CommitLineData
20c927a9 1#ifndef lint
8fa6d94c 2static char *sccsid = "@(#)wwgets.c 3.3 84/01/16";
20c927a9
EW
3#endif
4
8fa6d94c 5#include "ww.h"
20c927a9 6
8fa6d94c 7wwgets(buf, n, w)
059a7be6
EW
8char *buf;
9int n;
10register struct ww *w;
11{
12 register char *p = buf;
13 register char c;
14
15 for (;;) {
85af59e4 16 wwcurtowin(w);
8fa6d94c
EW
17 while ((c = wwgetc()) < 0)
18 wwiomux();
5b912384
EW
19 if (c == wwoldtty.ww_sgttyb.sg_erase) {
20 if (p > buf)
21 rub(*--p, w);
22 else
85af59e4 23 wwbell();
5b912384
EW
24 } else if (c == wwoldtty.ww_sgttyb.sg_kill) {
25 while (p > buf)
26 rub(*--p, w);
27 } else if (c == wwoldtty.ww_ltchars.t_werasc) {
28 while (--p >= buf && (*p == ' ' || *p == '\t'))
29 rub(*p, w);
30 while (p >= buf && *p != ' ' && *p != '\t')
31 rub(*p--, w);
32 p++;
33 } else if (c == '\r' || c == '\n') {
059a7be6 34 break;
5b912384 35 } else {
059a7be6 36 if (p >= buf + n - 1)
85af59e4 37 wwbell();
5b912384 38 else
85af59e4 39 (void) wwputs(unctrl(*p++ = c), w);
059a7be6
EW
40 }
41 }
5b912384
EW
42 *p = 0;
43}
44
8fa6d94c 45static
5b912384
EW
46rub(c, w)
47struct ww *w;
48{
49 register i;
50
51 for (i = strlen(unctrl(c)); --i >= 0;)
85af59e4 52 (void) wwputs("\b \b", w);
059a7be6 53}