Annotation of 43BSDReno/usr.bin/systat/keyboard.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.