Annotation of 43BSDReno/usr.bin/window/cmd5.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * This code is derived from software contributed to Berkeley by
                      6:  * Edward Wang at The University of California, Berkeley.
                      7:  *
                      8:  * Redistribution and use in source and binary forms are permitted provided
                      9:  * that: (1) source distributions retain this entire copyright notice and
                     10:  * comment, and (2) distributions including binaries display the following
                     11:  * acknowledgement:  ``This product includes software developed by the
                     12:  * University of California, Berkeley and its contributors'' in the
                     13:  * documentation or other materials provided with the distribution and in
                     14:  * all advertising materials mentioning features or use of this software.
                     15:  * Neither the name of the University nor the names of its contributors may
                     16:  * be used to endorse or promote products derived from this software without
                     17:  * specific prior written permission.
                     18:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     19:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     20:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     21:  */
                     22: 
                     23: #ifndef lint
                     24: static char sccsid[] = "@(#)cmd5.c     3.18 (Berkeley) 6/6/90";
                     25: #endif /* not lint */
                     26: 
                     27: #include "defs.h"
                     28: 
                     29: /*
                     30:  * Window movement.
                     31:  */
                     32: 
                     33: c_move(w)
                     34: register struct ww *w;
                     35: {
                     36:        int col, row;
                     37:        int mincol, minrow;
                     38:        int maxcol, maxrow;
                     39:        int curcol, currow;
                     40: 
                     41:        if (!terse)
                     42:                wwputs("New window position: ", cmdwin);
                     43:        col = w->ww_w.l;
                     44:        row = w->ww_w.t;
                     45:        wwadd(boxwin, framewin->ww_back);
                     46:        for (;;) {
                     47:                wwbox(boxwin, row - 1, col - 1, w->ww_w.nr + 2, w->ww_w.nc + 2);
                     48:                getminmax(row, w->ww_w.nr, 1, wwnrow,
                     49:                        &currow, &minrow, &maxrow);
                     50:                getminmax(col, w->ww_w.nc, 0, wwncol,
                     51:                        &curcol, &mincol, &maxcol);
                     52:                wwsetcursor(currow, curcol);
                     53:                while (wwpeekc() < 0)
                     54:                        wwiomux();
                     55:                switch (getpos(&row, &col, minrow, mincol, maxrow, maxcol)) {
                     56:                case 3:
                     57:                        wwunbox(boxwin);
                     58:                        wwdelete(boxwin);
                     59:                        return;
                     60:                case 2:
                     61:                        wwunbox(boxwin);
                     62:                        break;
                     63:                case 1:
                     64:                        wwunbox(boxwin);
                     65:                case 0:
                     66:                        continue;
                     67:                }
                     68:                break;
                     69:        }
                     70:        wwdelete(boxwin);
                     71:        if (!terse)
                     72:                wwputc('\n', cmdwin);
                     73:        wwcurtowin(cmdwin);
                     74:        movewin(w, row, col);
                     75: }
                     76: 
                     77: movewin(w, row, col)
                     78: register struct ww *w;
                     79: {
                     80:        struct ww *back = w->ww_back;
                     81: 
                     82:        w->ww_alt.t = w->ww_w.t;
                     83:        w->ww_alt.l = w->ww_w.l;
                     84:        wwdelete(w);
                     85:        wwmove(w, row, col);
                     86:        wwadd(w, back);
                     87:        reframe();
                     88: }
                     89: 
                     90: /*
                     91:  * Weird stufff, don't ask.
                     92:  */
                     93: getminmax(x, n, a, b, curx, minx, maxx)
                     94: register x, n, a, b;
                     95: int *curx, *minx, *maxx;
                     96: {
                     97:        if (x < 0)
                     98:                *curx = x + n - 1;
                     99:        else
                    100:                *curx = x;
                    101: 
                    102:        if (x <= a)
                    103:                *minx = 1 - n;
                    104:        else if (x <= b - n)
                    105:                *minx = a;
                    106:        else
                    107:                *minx = b - n;
                    108: 
                    109:        if (x >= b - n)
                    110:                *maxx = b - 1;
                    111:        else if (x >= a)
                    112:                *maxx = b - n;
                    113:        else
                    114:                *maxx = a;
                    115: }

unix.superglobalmegacorp.com

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