# 2.11BSD#431 - /usr/src/ucb/window/cmd1.c

##### Functions

    c_window          X
    getpos            X

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

#### Defined functions

c_window defined in line 14; used 1 times

- in /usr/src/ucb/window/cmd.c line 73

getpos defined in line 82; used 4 times

- in line 31, 58
- in /usr/src/ucb/window/cmd5.c line 39
- in /usr/src/ucb/window/cmd7.c line 33

#### Defined variables

sccsid defined in line 2; never used

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 768 |