1: #ifndef lint
   2: static char sccsid[] = "@(#)cmd.c	3.33 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: docmd()
  15: {
  16:     register char c;
  17:     register struct ww *w;
  18:     char out = 0;
  19: 
  20:     for (;;) {
  21:         while ((c = wwgetc()) >= 0) {
  22:             if (!terse)
  23:                 wwputc('\n', cmdwin);
  24:             switch (c) {
  25:             default:
  26:                 if (c == escapec)
  27:                     goto foo;
  28:                 break;
  29:             case 'h': case 'j': case 'k': case 'l':
  30:             case ctrl(y):
  31:             case ctrl(e):
  32:             case ctrl(u):
  33:             case ctrl(d):
  34:             case ctrl(b):
  35:             case ctrl(f):
  36:             case ctrl(s):
  37:             case ctrl(q):
  38:             case ctrl([):
  39:             foo:
  40:                 if (selwin == 0) {
  41:                     error("No window.");
  42:                     continue;
  43:                 }
  44:             }
  45:             switch (c) {
  46:             case '1': case '2': case '3': case '4': case '5':
  47:             case '6': case '7': case '8': case '9':
  48:                 if ((w = window[c - '1']) == 0) {
  49:                     error("%c: No such window.", c);
  50:                     break;
  51:                 }
  52:                 setselwin(w);
  53:                 if (checkproc(selwin) >= 0)
  54:                      out = 1;
  55:                 break;
  56:             case '%':
  57:                 if ((w = getwin()) != 0)
  58:                     setselwin(w);
  59:                 break;
  60:             case ctrl(^):
  61:                 if (lastselwin != 0) {
  62:                     setselwin(lastselwin);
  63:                     if (checkproc(selwin) >= 0)
  64:                         out = 1;
  65:                 } else
  66:                     error("No previous window.");
  67:                 break;
  68:             case 'c':
  69:                 if ((w = getwin()) != 0)
  70:                     c_close(w);
  71:                 break;
  72:             case 'w':
  73:                 c_window();
  74:                 break;
  75:             case 'm':
  76:                 if ((w = getwin()) != 0)
  77:                     c_move(w);
  78:                 break;
  79:             case 'M':
  80:                 if ((w = getwin()) != 0)
  81:                     movewin(w, w->ww_alt.t, w->ww_alt.l);
  82:                 break;
  83:             case 's':
  84:                 if ((w = getwin()) != 0)
  85:                     c_size(w);
  86:                 break;
  87:             case 'S':
  88:                 if ((w = getwin()) != 0)
  89:                     sizewin(w, w->ww_alt.nr, w->ww_alt.nc);
  90:                 break;
  91:             case ':':
  92:                 c_colon();
  93:                 break;
  94:             case 'h':
  95:                 (void) wwwrite(selwin, "\b", 1);
  96:                 break;
  97:             case 'j':
  98:                 (void) wwwrite(selwin, "\n", 1);
  99:                 break;
 100:             case 'k':
 101:                 (void) wwwrite(selwin, "\033A", 2);
 102:                 break;
 103:             case 'l':
 104:                 (void) wwwrite(selwin, "\033C", 2);
 105:                 break;
 106:             case ctrl(e):
 107:                 wwscroll(selwin, 1);
 108:                 break;
 109:             case ctrl(y):
 110:                 wwscroll(selwin, -1);
 111:                 break;
 112:             case ctrl(d):
 113:                 wwscroll(selwin, selwin->ww_w.nr / 2);
 114:                 break;
 115:             case ctrl(u):
 116:                 wwscroll(selwin, - selwin->ww_w.nr / 2);
 117:                 break;
 118:             case ctrl(f):
 119:                 wwscroll(selwin, selwin->ww_w.nr);
 120:                 break;
 121:             case ctrl(b):
 122:                 wwscroll(selwin, - selwin->ww_w.nr);
 123:                 break;
 124:             case ctrl(s):
 125:                 stopwin(selwin);
 126:                 break;
 127:             case ctrl(q):
 128:                 startwin(selwin);
 129:                 break;
 130:             case ctrl(l):
 131:                 wwredraw();
 132:                 break;
 133:             case '?':
 134:                 c_help();
 135:                 break;
 136:             case ctrl([):
 137:                 if (checkproc(selwin) >= 0)
 138:                     out = 1;
 139:                 break;
 140:             case ctrl(z):
 141:                 wwsuspend();
 142:                 break;
 143:             case 'q':
 144:                 c_quit();
 145:                 break;
 146:             /* debugging stuff */
 147:             case '&':
 148:                 if (debug) {
 149:                     c_debug();
 150:                     break;
 151:                 }
 152:             default:
 153:                 if (c == escapec) {
 154:                     if (checkproc(selwin) >= 0) {
 155:                         (void) write(selwin->ww_pty,
 156:                             &escapec, 1);
 157:                         out = 1;
 158:                     }
 159:                 } else {
 160:                     if (!terse)
 161:                         wwbell();
 162:                     error("Type ? for help.");
 163:                 }
 164:             }
 165:         }
 166:         if (out || quit)
 167:             break;
 168:         if (terse)
 169:             wwsetcursor(0, 0);
 170:         else {
 171:             wwputs("Command: ", cmdwin);
 172:             wwcurtowin(cmdwin);
 173:         }
 174:         while (wwpeekc() < 0)
 175:             wwiomux();
 176:     }
 177:     if (!quit)
 178:         setcmd(0);
 179: }
 180: 
 181: struct ww *
 182: getwin()
 183: {
 184:     register int c;
 185:     struct ww *w = 0;
 186: 
 187:     if (!terse)
 188:         wwputs("Which window? ", cmdwin);
 189:     wwcurtowin(cmdwin);
 190:     while ((c = wwgetc()) < 0)
 191:         wwiomux();
 192:     if (debug && c == 'c')
 193:         w = cmdwin;
 194:     else if (debug && c == 'f')
 195:         w = framewin;
 196:     else if (debug && c == 'b')
 197:         w = boxwin;
 198:     else if (c >= '1' && c < NWINDOW + '1')
 199:         w = window[c - '1'];
 200:     if (w == 0)
 201:         wwbell();
 202:     if (!terse)
 203:         wwputc('\n', cmdwin);
 204:     return w;
 205: }
 206: 
 207: checkproc(w)
 208: struct ww *w;
 209: {
 210:     if (w->ww_state != WWS_HASPROC) {
 211:         error("No process in window.");
 212:         return -1;
 213:     }
 214:     return 0;
 215: }
 216: 
 217: setcmd(new)
 218: char new;
 219: {
 220:     if (new && !incmd) {
 221:         if (!terse)
 222:             wwadd(cmdwin, &wwhead);
 223:         if (selwin != 0)
 224:             wwcursor(selwin, 1);
 225:         wwcurwin = 0;
 226:     } else if (!new && incmd) {
 227:         if (!terse) {
 228:             wwdelete(cmdwin);
 229:             reframe();
 230:         }
 231:         if (selwin != 0)
 232:             wwcursor(selwin, 0);
 233:         wwcurwin = selwin;
 234:     }
 235:     incmd = new;
 236: }
 237: 
 238: setterse(new)
 239: char new;
 240: {
 241:     if (incmd)
 242:         if (new && !terse) {
 243:             wwdelete(cmdwin);
 244:             reframe();
 245:         } else if (!new && terse)
 246:             wwadd(cmdwin, &wwhead);
 247:     terse = new;
 248: }
 249: 
 250: /*
 251:  * Set the current window.
 252:  */
 253: setselwin(w)
 254: struct ww *w;
 255: {
 256:     if (selwin == w)
 257:         return;
 258:     if (selwin != 0)
 259:         lastselwin = selwin;
 260:     if ((selwin = w) != 0)
 261:         front(selwin, 1);
 262: }

Defined functions

checkproc defined in line 207; used 4 times
docmd defined in line 14; used 1 times
getwin defined in line 181; used 9 times
setcmd defined in line 217; used 5 times
setselwin defined in line 253; used 8 times

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: 2961
Valid CSS Valid XHTML 1.0 Strict