X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/a204c1d8d0f13b786a37354c6aa68f0716e7a58a..b041ccece3687baa46a947a5695b634ef113edfd:/usr/src/usr.bin/window/cmd1.c diff --git a/usr/src/usr.bin/window/cmd1.c b/usr/src/usr.bin/window/cmd1.c index aa8fce5980..0962c4be50 100644 --- a/usr/src/usr.bin/window/cmd1.c +++ b/usr/src/usr.bin/window/cmd1.c @@ -1,8 +1,15 @@ #ifndef lint -static char *sccsid = "@(#)cmd1.c 3.18 83/12/17"; +static char sccsid[] = "@(#)cmd1.c 3.29 %G%"; #endif +/* + * Copyright (c) 1983 Regents of the University of California, + * All rights reserved. Redistribution permitted subject to + * the terms of the Berkeley Software License Agreement. + */ + #include "defs.h" +#include "char.h" c_window() { @@ -12,15 +19,15 @@ c_window() if ((id = findid()) < 0) return; if (!terse) - (void) wwputs("Upper left corner: ", cmdwin); + wwputs("New window (upper left corner): ", cmdwin); col = 0; row = 1; wwadd(boxwin, framewin->ww_back); for (;;) { wwbox(boxwin, row - 1, col - 1, 3, 3); wwsetcursor(row, col); - while (bpeekc() < 0) - bread(); + while (wwpeekc() < 0) + wwiomux(); switch (getpos(&row, &col, row > 1, 0, wwnrow - 1, wwncol - 1)) { case 3: @@ -38,7 +45,7 @@ c_window() break; } if (!terse) - (void) wwputs("\r\nLower right corner: ", cmdwin); + wwputs("\nNew window (lower right corner): ", cmdwin); xcol = col; xrow = row; for (;;) { @@ -46,8 +53,8 @@ c_window() xrow - row + 3, xcol - col + 3); wwsetcursor(xrow, xcol); wwflush(); - while (bpeekc() < 0) - bread(); + while (wwpeekc() < 0) + wwiomux(); switch (getpos(&xrow, &xcol, row, col, wwnrow - 1, wwncol - 1)) { case 3: @@ -66,23 +73,10 @@ c_window() } wwdelete(boxwin); if (!terse) - (void) wwputs("\r\n", cmdwin); + wwputc('\n', cmdwin); wwcurtowin(cmdwin); (void) openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline, - (char *) 0); -} - -findid() -{ - register i; - - for (i = 0; i < NWINDOW && window[i] != 0; i++) - ; - if (i >= NWINDOW) { - error("Too many windows."); - return -1; - } - return i; + (char *) 0, 1, 1, shellfile, shell); } getpos(row, col, minrow, mincol, maxrow, maxcol) @@ -90,12 +84,12 @@ register int *row, *col; int minrow, mincol; int maxrow, maxcol; { - static int scount = 0; + static int scount; int count; char c; int oldrow = *row, oldcol = *col; - while ((c = bgetc()) >= 0) { + while ((c = wwgetc()) >= 0) { switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -133,56 +127,17 @@ int maxrow, maxcol; case 'K': *row = minrow; break; - case CTRL([): + case ctrl([): if (!terse) - (void) wwputs("\r\nCancelled. ", cmdwin); + wwputs("\nCanceled. ", cmdwin); return 3; case '\r': return 2; default: if (!terse) - (void) wwputs("\r\nType [hjklHJKL] to move, return to enter position, escape to cancel.", cmdwin); + wwputs("\nType [hjklHJKL] to move, return to enter position, escape to cancel.", cmdwin); wwbell(); } } return oldrow != *row || oldcol != *col; } - -struct ww * -openwin(id, row, col, nrow, ncol, nline, label) -int id, nrow, ncol, row, col; -char *label; -{ - register struct ww *w; - - if (id < 0 && (id = findid()) < 0) - return 0; - if (row + nrow <= 0 || row > wwnrow - 1 - || col + ncol <= 0 || col > wwncol - 1) { - error("Illegal window position."); - return 0; - } - if ((w = wwopen(WWO_PTY, nrow, ncol, row, col, nline)) == 0) { - error("%s.", wwerror()); - return 0; - } - w->ww_id = id; - window[id] = w; - w->ww_hasframe = 1; - w->ww_altpos.r = 1; - w->ww_altpos.c = 0; - if (label != 0 && setlabel(w, label) < 0) - error("No memory for label."); - wwcursor(w, 1); - wwadd(w, framewin); - selwin = w; - reframe(); - wwupdate(); - wwflush(); - if (wwspawn(w, shell, shellname, (char *)0) < 0) { - c_close(w); - error("%s: %s.", shell, wwerror()); - return 0; - } - return w; -}