chris@umcp-cs.UUCP (07/04/83)
: Run this shell script with "sh" not "csh" PATH=:/bin:/usr/bin:/usr/ucb export PATH all=FALSE if [ $1x = -ax ]; then all=TRUE fi /bin/echo 'Extracting read.c' sed 's/^X//' <<'//go.sysin dd *' >read.c X#include "win.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Read back from window at cursor, and advance cursor */ X/* If charonly set returns only char (not mode<<NBPB | char) */ X/* If winonly set returns only char from window (even if not visible) */ XWread (w, charonly, winonly) Xregister Win *w; Xint charonly, winonly; X{ X register Ch *c = w -> w_winbuf + X (w -> w_cursor.row + w -> IYO) * w -> OXE + X w -> w_cursor.col + w -> IXO; X int rv; X X if (!winonly && (c -> Mode & WBUF)) X c = w -> w_textbuf -> b_contents + X (w -> w_cursor.row + w -> IYO + w -> w_bstart.row) X * w -> w_textbuf -> b_ncols + X w -> w_cursor.row + w -> w_bstart.col + w -> IXO; X rv = charonly ? c -> Char : c -> ch_all; X w -> w_cursor.col++; X if (w -> w_cursor.col >= w -> IXE) { X w -> w_cursor.col = 0; X w -> w_cursor.row++; X if (w -> w_cursor.row >= w -> IYE) X w -> w_cursor.row = 0; X WFixCursor (w); X } X if ((w -> w_status & WCURSOR) == 0) X w -> w_status |= WDUMP; X return rv; X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 read.c /bin/echo -n ' '; /bin/ls -ld read.c fi /bin/echo 'Extracting retro.c' sed 's/^X//' <<'//go.sysin dd *' >retro.c X#include "win.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Retroactively set modes in a window line (just modes!!) */ X/* Operates in buffer at buffer cursor unless inwin is nonzero */ XWretroline (w, mode, inwin) Xregister Win *w; Xregister mode; Xint inwin; X{ X register Ch *cp, *cend; X X if (inwin) { X cp = w -> w_winbuf + X (w -> w_cursor.row + w -> IYO) * w -> OXE + w -> IXO; X cend = cp + w -> IXE; X w -> w_status |= WDUMP; X } X else { X register Buf *b = w -> w_textbuf; X X cp = b -> b_contents + b -> b_cursor.row * b -> b_ncols; X cend = cp + b -> b_ncols; X b -> b_nmodw = -1; X } X mode &= MODEMASK; X while (cp < cend) { X cp -> Mode &= ~MODEMASK; X cp++ -> Mode |= mode; X } X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 retro.c /bin/echo -n ' '; /bin/ls -ld retro.c fi /bin/echo 'Extracting scroll.c' sed 's/^X//' <<'//go.sysin dd *' >scroll.c X#include "win.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Scroll window w according to its w->w_popup */ XWscroll (w) Xregister Win *w; X{ X if (w -> w_popup == 0) {/* Means, wrap cursor to top & clr line */ X w -> w_cursor.row = 0; X w -> w_cursor.col = 0; X WFixCursor (w); X return Wclearline (w, 2);/* Clear line containing cursor */ X } X return Wrelscroll (w, w -> w_popup, 0, 0); X} X X/* Relative scroll window w by rows, cols */ X/* If cwin is set cursor sticks to window rather than buffer */ XWrelscroll (w, rows, cols, cwin) Xregister Win *w; Xint rows, cols, cwin; X{ X register Buf *b; X register Ch *cp, *ct; X X if (rows == 0 && cols == 0) X return 0; X b = w -> w_textbuf; X w -> w_bstart.row += rows; X w -> w_bstart.col += cols; X if (w -> w_bstart.row < 0) { X /* Window has moved above buffer; "create space" at top */ X cp = b -> b_contents + X (b -> b_nrows + w -> w_bstart.row) * b -> b_ncols; X ct = b -> b_contents + X b -> b_nrows * b -> b_ncols; X while (cp > b -> b_contents) X (--ct) -> ch_all = (--cp) -> ch_all; X while (ct > b -> b_contents) X (--ct) -> ch_all = ' ' | (w -> w_mode << NBPB); X w -> w_bstart.row = 0; X b -> b_nmodw = -1; X } X else if (w -> w_bstart.row + w -> OYE > b -> b_nrows) { X /* Window has moved below buffer; "create space" at bottom */ X register Ch *end; X register n = w -> w_bstart.row + w -> OYE - b -> b_nrows; X ct = b -> b_contents; X cp = b -> b_contents + n * b -> b_ncols; X end = b -> b_contents + b -> b_nrows * b -> b_ncols; X while (cp < end) X ct++ -> ch_all = cp++ -> ch_all; X while (ct < end) X ct++ -> ch_all = ' ' | (w -> w_mode << NBPB); X w -> w_bstart.row = b -> b_nrows - w -> OYE; X b -> b_nmodw = -1; X } X if (w -> w_bstart.col < 0) { X cols -= w -> w_bstart.col; X w -> w_bstart.col = 0; /* CHEAP! */ X } X if (w -> w_bstart.col + w -> OXE > b -> b_ncols) { X cols += b -> b_ncols - w -> w_bstart.col - w -> OXE; X w -> w_bstart.col = b -> b_ncols - w -> OXE; X } X if (!cwin) { /* Then make cursor stick to buffer */ X w -> w_cursor.row -= rows; X w -> w_cursor.col -= cols; X if (w -> w_cursor.row < 0) X w -> w_cursor.row = 0; X else if (w -> w_cursor.row >= w -> IYE) X w -> w_cursor.row = w -> IYE - 1; X if (w -> w_cursor.col < 0) X w -> w_cursor.col = 0; X else if (w -> w_cursor.col >= w -> IXE) X w -> w_cursor.col = w -> IXE - 1; X } X WFixCursor (w); X w -> w_status |= WDUMP; X MajorUpdate = 1; X return 0; X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 scroll.c /bin/echo -n ' '; /bin/ls -ld scroll.c fi /bin/echo 'Extracting setbuf.c' sed 's/^X//' <<'//go.sysin dd *' >setbuf.c X#include "win.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Set the amount of buffering on a window */ XWsetbuf (w, bcols, brows) XWin *w; X{ X register Buf *b = w -> w_textbuf; X register Ch *c, *cp, *ct; X register i, j; X X if (b -> b_nrows > brows) X brows = b -> b_nrows;/* Never shrink a buffer */ X if (b -> b_ncols > bcols) X bcols = b -> b_ncols; X if (b -> b_nrows == brows && b -> b_ncols == bcols) X return 0; /* Nothing to do */ X c = (Ch *) malloc (sizeof (Ch) * brows * bcols); X if (c == 0) X return -1; X X /* Copy old contents to new buffer */ X cp = b -> b_contents; X ct = c; X for (j = 0; j < b -> b_nrows; j++) { X for (i = 0; i < b -> b_ncols; i++) X ct++ -> ch_all = cp++ -> ch_all; X cp += b -> b_ncols - i; X for (; i < bcols; i++) X ct++ -> ch_all = ' '; X } X for (; j < brows; j++) X for (i = 0; i < bcols; i++) X ct++ -> ch_all = ' '; X X free (b -> b_contents); /* Discard old buffer */ X b -> b_contents = c; X b -> b_nrows = brows; X b -> b_ncols = bcols; X WFixCursor (w); X return 0; X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 setbuf.c /bin/echo -n ' '; /bin/ls -ld setbuf.c fi /bin/echo 'Extracting setframe.c' sed 's/^X//' <<'//go.sysin dd *' >setframe.c X#include "Trm.h" X#include "win.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Set frame chars */ XWsetframe (ulc, top, urc, left, right, llc, bottom, lrc) X{ X W_tt.t_frames[0] = ulc; X W_tt.t_frames[1] = top; X W_tt.t_frames[2] = urc; X W_tt.t_frames[3] = left; X W_tt.t_frames[4] = right; X W_tt.t_frames[5] = llc; X W_tt.t_frames[6] = bottom; X W_tt.t_frames[7] = lrc; X return 0; X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 setframe.c /bin/echo -n ' '; /bin/ls -ld setframe.c fi /bin/echo 'Extracting setmargins.c' sed 's/^X//' <<'//go.sysin dd *' >setmargins.c X#include "win.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Set the window's inside area (margins) */ X/* AFTER THIS ROUTINE SUCCEEDS, X ALL CHARS INSIDE COME FROM w->w_textbuf; AND X ALL CHARS OUTSIDE COME FROM w->w_winbuf */ X/* SETTING MARGINS TO ZERO TURNS OFF WBORDERED STATUS BIT */ XWsetmargins (w, inxorg, inyorg, inxext, inyext) Xregister Win *w; Xint inxorg, inyorg, inxext, inyext; X{ X register Ch *c = w -> w_winbuf; X register i, j; X int inx, iny, orow, ocol; X X if (w -> OXE < inxorg+inxext || inxorg < 0 || inxext < 1) X return -1; X if (w -> OYE < inyorg+inyext || inyorg < 0 || inyext < 1) X return -1; X X for (i = 0; i < inyorg; i++) for (j = 0; j < w -> OXE; j++) X c++ -> Mode &= MODEMASK|WINVIS; X inx = inxorg + inxext; X iny = inyorg + inyext; X for (; i < iny; i++) { X for (j = 0; j < inxorg; j++) X c++ -> Mode &= MODEMASK|WINVIS; X for (; j < inx; j++) { X c -> Mode &= MODEMASK|WINVIS; X c++ -> Mode |= WBUF; X } X for (; j < w -> OXE; j++) X c++ -> Mode &= MODEMASK|WINVIS; X } X for (; i < w -> OYE; i++) for (j = 0; j < w -> OXE; j++) X c++ -> Mode &= MODEMASK|WINVIS; X orow = w -> w_inside.yorigin + w -> w_cursor.row; X ocol = w -> w_inside.xorigin + w -> w_cursor.col; X w -> w_inside.xorigin = inxorg; X w -> w_inside.yorigin = inyorg; X w -> w_inside.xextent = inxext; X w -> w_inside.yextent = inyext; X /* Move cursor to be within (new) margins */ X w -> w_cursor.row = X orow >= w -> w_inside.yextent ? w -> w_inside.yextent - 1 : X orow < w -> w_inside.yorigin ? 0 : X orow - w -> w_inside.yorigin; X w -> w_cursor.col = X ocol >= w -> w_inside.xextent ? w -> w_inside.xextent - 1 : X ocol < w -> w_inside.xorigin ? 0 : X ocol - w -> w_inside.xorigin; X WFixCursor (w); X w -> w_status |= WDUMP; X /* Clear bordered bit if borders are gone */ X if (inxorg < 1 || inxorg + inxext == w -> OXE || X inyorg < 1 || inyorg + inyext == w -> OYE) X w -> w_status &= ~WBORDERED; X return 0; X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 setmargins.c /bin/echo -n ' '; /bin/ls -ld setmargins.c fi /bin/echo 'Extracting size.c' sed 's/^X//' <<'//go.sysin dd *' >size.c X#include "win.h" X#include "display.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Change the size of an existing window */ XWsize (w, xext, yext) Xregister Win *w; Xregister xext, yext; X{ X register Buf *b; X register Ch *c; X X if (xext < 1 || yext < 1) X return -1; X if (w -> OXO + xext > ScreenWidth || w -> OYO + yext > ScreenLength) X return -1; X b = w -> w_textbuf; X if (b -> b_ncols < xext || b -> b_nrows < yext) { X if (Wsetbuf (w, xext, yext)) X return -1; X } X if ((w -> w_status & WHIDDEN) == 0) { X WErase (w); /* Erase visible portions */ X WRemoveCoverList (w); /* Uncover everything */ X } X X /* Get new winbuf */ X c = (Ch *) malloc (sizeof (Ch) * xext * yext); X if (c == 0) { X if ((w -> w_status & WHIDDEN) == 0) X WComputeCover (w); X return -1; X } X free (w -> w_winbuf); X w -> w_winbuf = c; X w -> w_outside.xextent = xext; /* Change size */ X w -> w_outside.yextent = yext; X X /* Make inside whole thing (sigh) */ X for (c = w -> w_winbuf + xext * yext; c > w -> w_winbuf;) X (--c) -> ch_all = ' ' | (WBUF<<NBPB); X WFixCursor (w); X if ((w -> w_status & WHIDDEN) == 0) X WComputeCover (w); /* Recompute cover with new size */ X return Wsetmargins (w, 0, 0, xext, yext); X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 size.c /bin/echo -n ' '; /bin/ls -ld size.c fi /bin/echo 'Extracting suspend.c' sed 's/^X//' <<'//go.sysin dd *' >suspend.c X#include "win.h" X#include <signal.h> X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X Xint (*sigset())(); X X/* Suspend window system (called on ^Z) */ X/* NOTE: if SigMagic is not set user must make sure that SIGTSTP does what he X wants */ XWsuspend () { X int (*oldtstp) (), (*oldint) (); X static nest, restart; /* Dont want to recurse */ X if (nest) X return restart++, 0; X nest = 1; Xtop: X if (SigMagic) { /* Then save signal definitions */ X sigrelse (SIGTSTP); X sigrelse (SIGINT); /* Make sure they arent held */ X /* NOTE: if sigrelse calls Wsuspend "nest" gets us back */ X oldtstp = sigset (SIGTSTP, SIG_IGN); X oldint = sigset (SIGINT, SIG_IGN); X } X restart = 0; X Wcleanup (); /* If SigMagic, resets sigs to SIG_DFL */ X kill (0, SIGTSTP); /* SCREECHing halt */ X if (SigMagic) { X sighold (SIGTSTP); X sighold (SIGINT); /* Hold these for Winit to do its stuff, */ X sigset (SIGTSTP, oldtstp); X sigset (SIGINT, oldint);/* putting them back where they were */ X } X (void) Winit (1, 1); X if (SigMagic) { X sigrelse (SIGTSTP); X sigrelse (SIGINT); X if (restart) /* If TSTP signal occurred during Winit */ X goto top; /* Note: the oldxxx=sigset() is OK because we X have already restored the settings */ X Wrefresh (); X if (restart) /* If the Wrefresh was suspended */ X goto top; X } X return nest = 0; X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 suspend.c /bin/echo -n ' '; /bin/ls -ld suspend.c fi /bin/echo 'Extracting wcursor.c' sed 's/^X//' <<'//go.sysin dd *' >wcursor.c X#include "win.h" X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Position the window cursor, within the window */ XWWcursor (w, row, col) Xregister Win *w; Xregister row, col; X{ X w -> w_cursor.row = Min (Max (row, 0), w -> IYE - 1); X w -> w_cursor.col = Min (Max (col, 0), w -> IXE - 1); X WFixCursor (w); X if ((w -> w_status & WCURSOR) == 0) X w -> w_status |= WDUMP; X return 0; X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 wcursor.c /bin/echo -n ' '; /bin/ls -ld wcursor.c fi /bin/echo 'Extracting wexit.c' sed 's/^X//' <<'//go.sysin dd *' >wexit.c X#include <stdio.h> X X/* Copyright (c) 1983 University of Maryland Computer Science Department */ X X/* Exit after cleaning up */ XWexit (code) { X Wcleanup (); X fflush (stdout); X exit (code); X} //go.sysin dd * made=TRUE if [ $made = TRUE ]; then /bin/chmod 644 wexit.c /bin/echo -n ' '; /bin/ls -ld wexit.c fi -- UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris.umcp-cs@UDel-Relay