Annotation of 43BSDTahoe/ucb/window/cmd1.c, revision 1.1

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[] = "@(#)cmd1.c     3.33 (Berkeley) 6/29/88";
        !            20: #endif /* not lint */
        !            21: 
        !            22: #include "defs.h"
        !            23: #include "char.h"
        !            24: 
        !            25: c_window()
        !            26: {
        !            27:        int col, row, xcol, xrow;
        !            28:        int id;
        !            29: 
        !            30:        if ((id = findid()) < 0)
        !            31:                return;
        !            32:        if (!terse)
        !            33:                wwputs("New window (upper left corner): ", cmdwin);
        !            34:        col = 0;
        !            35:        row = 1;
        !            36:        wwadd(boxwin, framewin->ww_back);
        !            37:        for (;;) {
        !            38:                wwbox(boxwin, row - 1, col - 1, 3, 3);
        !            39:                wwsetcursor(row, col);
        !            40:                while (wwpeekc() < 0)
        !            41:                        wwiomux();
        !            42:                switch (getpos(&row, &col, row > 1, 0,
        !            43:                        wwnrow - 1, wwncol - 1)) {
        !            44:                case 3:
        !            45:                        wwunbox(boxwin);
        !            46:                        wwdelete(boxwin);
        !            47:                        return;
        !            48:                case 2:
        !            49:                        wwunbox(boxwin);
        !            50:                        break;
        !            51:                case 1:
        !            52:                        wwunbox(boxwin);
        !            53:                case 0:
        !            54:                        continue;
        !            55:                }
        !            56:                break;
        !            57:        }
        !            58:        if (!terse)
        !            59:                wwputs("\nNew window (lower right corner): ", cmdwin);
        !            60:        xcol = col;
        !            61:        xrow = row;
        !            62:        for (;;) {
        !            63:                wwbox(boxwin, row - 1, col - 1,
        !            64:                        xrow - row + 3, xcol - col + 3);
        !            65:                wwsetcursor(xrow, xcol);
        !            66:                wwflush();
        !            67:                while (wwpeekc() < 0)
        !            68:                        wwiomux();
        !            69:                switch (getpos(&xrow, &xcol, row, col, wwnrow - 1, wwncol - 1))
        !            70:                {
        !            71:                case 3:
        !            72:                        wwunbox(boxwin);
        !            73:                        wwdelete(boxwin);
        !            74:                        return;
        !            75:                case 2:
        !            76:                        wwunbox(boxwin);
        !            77:                        break;
        !            78:                case 1:
        !            79:                        wwunbox(boxwin);
        !            80:                case 0:
        !            81:                        continue;
        !            82:                }
        !            83:                break;
        !            84:        }
        !            85:        wwdelete(boxwin);
        !            86:        if (!terse)
        !            87:                wwputc('\n', cmdwin);
        !            88:        wwcurtowin(cmdwin);
        !            89:        (void) openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline,
        !            90:                (char *) 0, 1, 1, shellfile, shell);
        !            91: }
        !            92: 
        !            93: getpos(row, col, minrow, mincol, maxrow, maxcol)
        !            94: register int *row, *col;
        !            95: int minrow, mincol;
        !            96: int maxrow, maxcol;
        !            97: {
        !            98:        static int scount;
        !            99:        int count;
        !           100:        char c;
        !           101:        int oldrow = *row, oldcol = *col;
        !           102: 
        !           103:        while ((c = wwgetc()) >= 0) {
        !           104:                switch (c) {
        !           105:                case '0': case '1': case '2': case '3': case '4':
        !           106:                case '5': case '6': case '7': case '8': case '9':
        !           107:                        scount = scount * 10 + c - '0';
        !           108:                        continue;
        !           109:                }
        !           110:                count = scount ? scount : 1;
        !           111:                scount = 0;
        !           112:                switch (c) {
        !           113:                case 'h':
        !           114:                        if ((*col -= count) < mincol)
        !           115:                                *col = mincol;
        !           116:                        break;
        !           117:                case 'H':
        !           118:                        *col = mincol;
        !           119:                        break;
        !           120:                case 'l':
        !           121:                        if ((*col += count) > maxcol)
        !           122:                                *col = maxcol;
        !           123:                        break;
        !           124:                case 'L':
        !           125:                        *col = maxcol;
        !           126:                        break;
        !           127:                case 'j':
        !           128:                        if ((*row += count) > maxrow)
        !           129:                                *row = maxrow;
        !           130:                        break;
        !           131:                case 'J':
        !           132:                        *row = maxrow;
        !           133:                        break;
        !           134:                case 'k':
        !           135:                        if ((*row -= count) < minrow)
        !           136:                                *row = minrow;
        !           137:                        break;
        !           138:                case 'K':
        !           139:                        *row = minrow;
        !           140:                        break;
        !           141:                case ctrl('['):
        !           142:                        if (!terse)
        !           143:                                wwputs("\nCancelled.  ", cmdwin);
        !           144:                        return 3;
        !           145:                case '\r':
        !           146:                        return 2;
        !           147:                default:
        !           148:                        if (!terse)
        !           149:                                wwputs("\nType [hjklHJKL] to move, return to enter position, escape to cancel.", cmdwin);
        !           150:                        wwbell();
        !           151:                }
        !           152:        }
        !           153:        return oldrow != *row || oldcol != *col;
        !           154: }

unix.superglobalmegacorp.com

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