ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/editline.c
Revision: 1.1
Committed: Thu Feb 2 10:41:22 1989 UTC (35 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# Content
1 /* Copyright (c) 1987 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * editline.c - routine for editing raw input for rview.
9 *
10 * 10/5/88
11 */
12
13 #include <ctype.h>
14
15
16 editline(buf, c_get, s_put, c_erase, c_kill) /* edit input line */
17 char *buf;
18 int (*c_get)(), (*s_put)();
19 int c_erase, c_kill;
20 {
21 static char erases[] = "\b \b";
22 static char obuf[4];
23 register int i;
24 register int c;
25
26 i = 0;
27 while ((c = (*c_get)()&0177) != '\n' && c != '\r')
28 if (c == c_erase) { /* single char erase */
29 if (i > 0) {
30 (*s_put)(erases);
31 --i;
32 }
33 } else if (c == c_kill) { /* kill line */
34 while (i > 0) {
35 (*s_put)(erases);
36 --i;
37 }
38 } else if (iscntrl(c)) { /* control char */
39 i = 0;
40 buf[i++] = c;
41 obuf[0] = '^'; obuf[1] = c|0100; obuf[2] = '\0';
42 (*s_put)(obuf);
43 break;
44 } else { /* regular char */
45 buf[i++] = c;
46 obuf[0] = c; obuf[1] = '\0';
47 (*s_put)(obuf);
48 }
49 buf[i] = '\0';
50 (*s_put)("\n");
51 }