| 1 | #ifndef lint |
| 2 | static char sccsid[] = "@(#)keyboard.c 1.1 (Lucasfilm) %G%"; |
| 3 | #endif |
| 4 | |
| 5 | /* |
| 6 | * Keyboard input support. |
| 7 | */ |
| 8 | |
| 9 | #include "systat.h" |
| 10 | |
| 11 | keyboard() |
| 12 | { |
| 13 | char ch, line[80]; |
| 14 | |
| 15 | for (;;) { |
| 16 | col = 0; |
| 17 | move(22, 0); |
| 18 | do { |
| 19 | refresh(); |
| 20 | ch = getch() & 0177; |
| 21 | if (ch == 0177 && ferror(stdin)) { |
| 22 | clearerr(stdin); |
| 23 | continue; |
| 24 | } |
| 25 | if (ch >= 'A' && ch <= 'Z') |
| 26 | ch += 'a' - 'A'; |
| 27 | if (col == 0) { |
| 28 | #define mask(s) (1 << ((s) - 1)) |
| 29 | if (ch == CTRL(l)) { |
| 30 | int oldmask = sigblock(mask(SIGALRM)); |
| 31 | |
| 32 | wrefresh(curscr); |
| 33 | sigsetmask(oldmask); |
| 34 | continue; |
| 35 | } |
| 36 | if (ch == CTRL(g)) { |
| 37 | status(); |
| 38 | continue; |
| 39 | } |
| 40 | if (ch != ':') |
| 41 | continue; |
| 42 | move(22, 0); |
| 43 | clrtoeol(); |
| 44 | } |
| 45 | if (ch == _tty.sg_erase && col > 0) { |
| 46 | if (col == 1 && line[0] == ':') |
| 47 | continue; |
| 48 | col--; |
| 49 | goto doerase; |
| 50 | } |
| 51 | if (ch == CTRL(w) && col > 0) { |
| 52 | while (--col >= 0 && isspace(line[col])) |
| 53 | ; |
| 54 | col++; |
| 55 | while (--col >= 0 && !isspace(line[col])) |
| 56 | if (col == 0 && line[0] == ':') |
| 57 | break; |
| 58 | col++; |
| 59 | goto doerase; |
| 60 | } |
| 61 | if (ch == _tty.sg_kill && col > 0) { |
| 62 | col = 0; |
| 63 | if (line[0] == ':') |
| 64 | col++; |
| 65 | doerase: |
| 66 | move(22, col); |
| 67 | clrtoeol(); |
| 68 | continue; |
| 69 | } |
| 70 | if (isprint(ch)) { |
| 71 | line[col] = ch; |
| 72 | mvaddch(22, col, ch); |
| 73 | col++; |
| 74 | } |
| 75 | } while (col == 0 || (ch != '\r' && ch != '\n')); |
| 76 | line[col] = '\0'; |
| 77 | command(line + 1); |
| 78 | } |
| 79 | /*NOTREACHED*/ |
| 80 | } |