|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that the above copyright notice and this paragraph are ! 7: * duplicated in all such forms and that any documentation, ! 8: * advertising materials, and other materials related to such ! 9: * distribution and use acknowledge that the software was developed ! 10: * by the University of California, Berkeley. The name of the ! 11: * University may not be used to endorse or promote products derived ! 12: * from this software without specific prior written permission. ! 13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 16: */ ! 17: ! 18: #ifndef lint ! 19: static char sccsid[] = "@(#)wwgets.c 3.12 (Berkeley) 6/29/88"; ! 20: #endif /* not lint */ ! 21: ! 22: #include "ww.h" ! 23: #include "char.h" ! 24: ! 25: wwgets(buf, n, w) ! 26: char *buf; ! 27: int n; ! 28: register struct ww *w; ! 29: { ! 30: register char *p = buf; ! 31: register char c; ! 32: char uc = w->ww_unctrl; ! 33: ! 34: w->ww_unctrl = 0; ! 35: for (;;) { ! 36: wwcurtowin(w); ! 37: while ((c = wwgetc()) < 0) ! 38: wwiomux(); ! 39: if (c == wwoldtty.ww_sgttyb.sg_erase) { ! 40: if (p > buf) ! 41: rub(*--p, w); ! 42: } else if (c == wwoldtty.ww_sgttyb.sg_kill) { ! 43: while (p > buf) ! 44: rub(*--p, w); ! 45: } else if (c == wwoldtty.ww_ltchars.t_werasc) { ! 46: while (--p >= buf && (*p == ' ' || *p == '\t')) ! 47: rub(*p, w); ! 48: while (p >= buf && *p != ' ' && *p != '\t') ! 49: rub(*p--, w); ! 50: p++; ! 51: } else if (c == '\r' || c == '\n') { ! 52: break; ! 53: } else { ! 54: if (p >= buf + n - 1) ! 55: wwputc(ctrl('g'), w); ! 56: else ! 57: wwputs(unctrl(*p++ = c), w); ! 58: } ! 59: } ! 60: *p = 0; ! 61: w->ww_unctrl = uc; ! 62: } ! 63: ! 64: static ! 65: rub(c, w) ! 66: struct ww *w; ! 67: { ! 68: register i; ! 69: ! 70: for (i = strlen(unctrl(c)); --i >= 0;) ! 71: (void) wwwrite(w, "\b \b", 3); ! 72: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.