|
|
1.1 root 1: /* readline.c 4.1 83/03/09 */
2: /*
3: * Read a line from the keyboard in the message line. The line
4: * goes into caller provided buffer msg, whos size is maxlen bytes.
5: */
6:
7: #include "2648.h"
8:
9: readline(prompt, msg, maxlen)
10: char *prompt;
11: char *msg;
12: int maxlen;
13: {
14: register char c;
15: register char *cp;
16: int oldx, oldy;
17: int oldcuron;
18: int oldquiet;
19: extern int QUIET;
20:
21: oldx = _curx; oldy = _cury;
22: oldcuron = _cursoron;
23: areaclear(4, 4, 4+8, 719);
24: setset();
25: zoomout();
26: curon();
27: movecurs(4, 4);
28: texton();
29:
30: oldquiet = QUIET;
31: QUIET = 0;
32: outstr(prompt);
33: if (oldquiet)
34: outstr("\r\n");
35: QUIET = oldquiet;
36:
37: for (cp=msg; ; cp) {
38: fflush(stdout);
39: c = getchar();
40: switch (c) {
41: case '\n':
42: case '\r':
43: case ESC:
44: *cp++ = 0;
45: textoff();
46: movecurs(oldx, oldy);
47: if (oldcuron == 0)
48: curoff();
49: return;
50: case '\b':
51: if (--cp >= msg)
52: outchar(c);
53: else
54: cp = msg;
55: break;
56: default:
57: *cp++ = c;
58: outstr(rdchar(c));
59: if (cp-msg >= maxlen)
60: error("line too long");
61: }
62: }
63: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.