Annotation of 43BSDTahoe/ucb/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:  * 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[] = "@(#)cmd5.c     3.16 (Berkeley) 6/29/88";
                     20: #endif /* not lint */
                     21: 
                     22: #include "defs.h"
                     23: 
                     24: /*
                     25:  * Window movement.
                     26:  */
                     27: 
                     28: c_move(w)
                     29: register struct ww *w;
                     30: {
                     31:        int col, row;
                     32:        int mincol, minrow;
                     33:        int maxcol, maxrow;
                     34:        int curcol, currow;
                     35: 
                     36:        if (!terse)
                     37:                wwputs("New window position: ", cmdwin);
                     38:        col = w->ww_w.l;
                     39:        row = w->ww_w.t;
                     40:        wwadd(boxwin, framewin->ww_back);
                     41:        for (;;) {
                     42:                wwbox(boxwin, row - 1, col - 1, w->ww_w.nr + 2, w->ww_w.nc + 2);
                     43:                getminmax(row, w->ww_w.nr, 1, wwnrow,
                     44:                        &currow, &minrow, &maxrow);
                     45:                getminmax(col, w->ww_w.nc, 0, wwncol,
                     46:                        &curcol, &mincol, &maxcol);
                     47:                wwsetcursor(currow, curcol);
                     48:                while (wwpeekc() < 0)
                     49:                        wwiomux();
                     50:                switch (getpos(&row, &col, minrow, mincol, maxrow, maxcol)) {
                     51:                case 3:
                     52:                        wwunbox(boxwin);
                     53:                        wwdelete(boxwin);
                     54:                        return;
                     55:                case 2:
                     56:                        wwunbox(boxwin);
                     57:                        break;
                     58:                case 1:
                     59:                        wwunbox(boxwin);
                     60:                case 0:
                     61:                        continue;
                     62:                }
                     63:                break;
                     64:        }
                     65:        wwdelete(boxwin);
                     66:        if (!terse)
                     67:                wwputc('\n', cmdwin);
                     68:        wwcurtowin(cmdwin);
                     69:        movewin(w, row, col);
                     70: }
                     71: 
                     72: movewin(w, row, col)
                     73: register struct ww *w;
                     74: {
                     75:        struct ww *back = w->ww_back;
                     76: 
                     77:        w->ww_alt.t = w->ww_w.t;
                     78:        w->ww_alt.l = w->ww_w.l;
                     79:        wwdelete(w);
                     80:        wwmove(w, row, col);
                     81:        wwadd(w, back);
                     82:        reframe();
                     83: }
                     84: 
                     85: /*
                     86:  * Weird stufff, don't ask.
                     87:  */
                     88: getminmax(x, n, a, b, curx, minx, maxx)
                     89: register x, n, a, b;
                     90: int *curx, *minx, *maxx;
                     91: {
                     92:        if (x < 0)
                     93:                *curx = x + n - 1;
                     94:        else
                     95:                *curx = x;
                     96: 
                     97:        if (x <= a)
                     98:                *minx = 1 - n;
                     99:        else if (x <= b - n)
                    100:                *minx = a;
                    101:        else
                    102:                *minx = b - n;
                    103: 
                    104:        if (x >= b - n)
                    105:                *maxx = b - 1;
                    106:        else if (x >= a)
                    107:                *maxx = b - n;
                    108:        else
                    109:                *maxx = a;
                    110: }

unix.superglobalmegacorp.com

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