ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/editline.c
(Generate patch)

Comparing ray/src/rt/editline.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:41:22 1989 UTC vs.
Revision 2.3 by greg, Fri Sep 29 20:49:37 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1987 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *      10/5/88
11   */
12  
13 < #include  <ctype.h>
13 > #define iscntrl(c)      ((c) < ' ')
14 > #define isblank(c)      ((c) == ' ')
15 > #define iserase(c)      ((c) == '\b' || (c) == 127)
16 > #define iswerase(c)     ((c) == 'W'-'@')
17 > #define iskill(c)       ((c) == 'U'-'@' || (c) == 'X'-'@')
18  
19  
20 < editline(buf, c_get, s_put, c_erase, c_kill)    /* edit input line */
20 > editline(buf, c_get, s_put)     /* edit input line */
21   char  *buf;
22   int  (*c_get)(), (*s_put)();
19 int  c_erase, c_kill;
23   {
24          static char  erases[] = "\b \b";
25          static char  obuf[4];
# Line 25 | Line 28 | int  c_erase, c_kill;
28          
29          i = 0;
30          while ((c = (*c_get)()&0177) != '\n' && c != '\r')
31 <                if (c == c_erase) {             /* single char erase */
31 >                if (iserase(c)) {               /* single char erase */
32                          if (i > 0) {
33                                  (*s_put)(erases);
34                                  --i;
35                          }
36 <                } else if (c == c_kill) {       /* kill line */
36 >                } else if (iswerase(c)) {       /* word erase */
37 >                        while (i > 0 && isblank(buf[i-1])) {
38 >                                (*s_put)(erases);
39 >                                --i;
40 >                        }
41 >                        while (i > 0 && !isblank(buf[i-1])) {
42 >                                (*s_put)(erases);
43 >                                --i;
44 >                        }
45 >                } else if (iskill(c)) {         /* kill line */
46                          while (i > 0) {
47                                  (*s_put)(erases);
48                                  --i;
# Line 48 | Line 60 | int  c_erase, c_kill;
60                  }
61          buf[i] = '\0';
62          (*s_put)("\n");
63 + }
64 +
65 +
66 + #include  "driver.h"
67 +
68 + static char  mybuf[512];
69 +
70 +
71 + tocombuf(b, d)                          /* add command(s) to my buffer */
72 + register char  *b;
73 + register struct driver  *d;
74 + {
75 +        register char  *cp;
76 +        char  *comstart;
77 +
78 +        for (cp = mybuf; *cp; cp++)
79 +                ;
80 +        comstart = cp;
81 +        while (*cp++ = *b)
82 +                if (cp >= mybuf+sizeof(mybuf)) {
83 +                        *comstart = '\0';
84 +                        return;         /* what should I do about this? */
85 +                } else if (*b++ == '\n') {
86 +                        d->inpready++;
87 +                        comstart = cp;
88 +                }
89 + }
90 +
91 +
92 + fromcombuf(b, d)                        /* get command from my buffer */
93 + char  *b;
94 + struct driver  *d;
95 + {
96 +        register char   *cp;
97 +                                                /* get next command */
98 +        for (cp = mybuf; *cp != '\n'; cp++)
99 +                if (!*cp)
100 +                        return(0);
101 +        *cp++ = '\0';
102 + #ifdef DEBUG
103 +        (*d->comout)(mybuf);                    /* echo my command */
104 +        (*d->comout)("\n");
105 + #endif
106 +                                                /* send it as reply */
107 +        strcpy(b, mybuf);
108 +        d->inpready--;
109 +                                                /* advance commands */
110 +        strcpy(mybuf, cp);
111 +        return(1);
112   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines