mile stone
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Wed, 10 Aug 1983 09:35:04 +0000 (01:35 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Wed, 10 Aug 1983 09:35:04 +0000 (01:35 -0800)
SCCS-vsn: usr.bin/window/main.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwchild.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwend.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwiomux.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwspawn.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwinit.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwmisc.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwopen.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwputc.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwputs.c 2.1.1.1
SCCS-vsn: usr.bin/window/ww.h 2.1.1.1
SCCS-vsn: usr.bin/window/cmd.c 2.1.1.1
SCCS-vsn: usr.bin/window/cmd1.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwtty.c 2.1.1.1
SCCS-vsn: usr.bin/window/wwwrite.c 2.1.1.1
SCCS-vsn: usr.bin/window/cmd2.c 2.1.1.1

16 files changed:
usr/src/usr.bin/window/cmd.c
usr/src/usr.bin/window/cmd1.c
usr/src/usr.bin/window/cmd2.c
usr/src/usr.bin/window/main.c
usr/src/usr.bin/window/ww.h
usr/src/usr.bin/window/wwchild.c
usr/src/usr.bin/window/wwend.c
usr/src/usr.bin/window/wwinit.c
usr/src/usr.bin/window/wwiomux.c
usr/src/usr.bin/window/wwmisc.c
usr/src/usr.bin/window/wwopen.c
usr/src/usr.bin/window/wwputc.c
usr/src/usr.bin/window/wwputs.c
usr/src/usr.bin/window/wwspawn.c
usr/src/usr.bin/window/wwtty.c
usr/src/usr.bin/window/wwwrite.c

index 560dbd5..76a9487 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd.c       2.1 83/07/30";
+static char *sccsid = "@(#)cmd.c       2.1.1.1 83/08/09";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -12,13 +12,15 @@ docmd()
        register struct ww *w;
 
        if (!terse)
        register struct ww *w;
 
        if (!terse)
-               Wunhide(cmdwin->ww_win);
+               wwadd(cmdwin, &wwhead);
+       /*
        if (selwin != 0)
                Woncursor(selwin->ww_win, 1);
        if (selwin != 0)
                Woncursor(selwin->ww_win, 1);
+       */
 top:
        while ((c = bgetc()) >= 0) {
                if (!terse)
 top:
        while ((c = bgetc()) >= 0) {
                if (!terse)
-                       wwputs("\r\n", cmdwin);
+                       (void) wwputs("\r\n", cmdwin);
                switch (c) {
                default:
                        if (c == escapec)
                switch (c) {
                default:
                        if (c == escapec)
@@ -32,18 +34,15 @@ top:
                case CTRL([):
                foo:
                        if (selwin == 0) {
                case CTRL([):
                foo:
                        if (selwin == 0) {
-                               if (terse)
-                                       Ding();
-                               else
-                                       wwputs("No window.  ", cmdwin);
+                               error("No window.");
                                continue;
                        }
                }
                switch (c) {
                case '1': case '2': case '3': case '4': case '5':
                case '6': case '7': case '8': case '9':
                                continue;
                        }
                }
                switch (c) {
                case '1': case '2': case '3': case '4': case '5':
                case '6': case '7': case '8': case '9':
-                       if ((w = wwfind(c - '0')) == 0) {
-                               Ding();
+                       if ((w = window[c - '1']) == 0) {
+                               wwbell();
                                break;
                        }
                        setselwin(w);
                                break;
                        }
                        setselwin(w);
@@ -54,81 +53,81 @@ top:
                        break;
                case 'c':
                        if ((w = getwin()) != 0)
                        break;
                case 'c':
                        if ((w = getwin()) != 0)
-                               doclose(w);
+                               c_close(w);
                        break;
                case 'C':
                        break;
                case 'C':
-                       doclose((struct ww *)0);
+                       c_close((struct ww *)0);
                        break;
                case 'Z':
                        break;
                case 'Z':
-                       if (terse)
-                               Ding();
-                       else
-                               wwputs("Command Z is now C.  ", cmdwin);
+                       error("Command Z is now C.");
                        break;
                case 'w':
                        break;
                case 'w':
-                       dowindow();
+                       c_window();
                        break;
                case 'S':
                        break;
                case 'S':
-                       doshow();
+                       c_show();
                        break;
                case 'L':
                        break;
                case 'L':
-                       dolist();
+                       c_list();
                        break;
                        break;
-               /*
-               case 'e':
-                       doescape();
+               case 's':
+                       c_stat();
                        break;
                        break;
-               case 'L':
-                       dolabel();
+               case 'M':
+                       wwdumpsmap();
                        break;
                        break;
-               case 'r':
-                       selwin->ww_refresh = 0;
+               case 'V':
+                       if ((w = getwin()) != 0)
+                               wwdumpnvis(w);
                        break;
                        break;
-               case 'R':
-                       selwin->ww_refresh = 1;
+               case 'D':
+                       if ((w = getwin()) != 0)
+                               wwdumpcov(w);
                        break;
                        break;
-               */
-               case 's':
-                       dostat();
+               case 'W':
+                       if ((w = getwin()) != 0)
+                               wwdumpwin(w);
                        break;
                case 't':
                        break;
                case 't':
-                       dotime(RUSAGE_SELF);
+                       c_time(RUSAGE_SELF);
                        break;
                case 'T':
                        break;
                case 'T':
-                       dotime(RUSAGE_CHILDREN);
+                       c_time(RUSAGE_CHILDREN);
                        break;
                case ':':
                        break;
                case ':':
-                       docolon();
+                       c_colon();
                        break;
                case 'h':
                        break;
                case 'h':
-                       Wcurleft(selwin->ww_win, 1);
+                       (void) wwwrite(selwin, "\b", 1);
                        break;
                case 'j':
                        break;
                case 'j':
-                       Wcurdown(selwin->ww_win, 1);
+                       (void) wwwrite(selwin, "\n", 1);
                        break;
                case 'k':
                        break;
                case 'k':
-                       Wcurup(selwin->ww_win, 1);
+                       (void) wwwrite(selwin, "\033A", 2);
                        break;
                case 'l':
                        break;
                case 'l':
-                       Wcurright(selwin->ww_win, 1);
+                       (void) wwwrite(selwin, "\033C", 2);
                        break;
                        break;
+               /*
                case CTRL(d):
                case CTRL(d):
-                       doscroll(1);
+                       c_scroll(1);
                        break;
                case CTRL(u):
                        break;
                case CTRL(u):
-                       doscroll(-1);
+                       c_scroll(-1);
                        break;
                case CTRL(f):
                        break;
                case CTRL(f):
-                       doscroll(2);
+                       c_scroll(2);
                        break;
                case CTRL(b):
                        break;
                case CTRL(b):
-                       doscroll(-2);
+                       c_scroll(-2);
                        break;
                        break;
+               */
                case CTRL(l):
                case CTRL(l):
-                       ScreenGarbaged = 1;
+                       wwredraw();
                        break;
                case '?':
                        break;
                case '?':
-                       dohelp();
+                       c_help();
                        break;
                case CTRL([):
                        goto out;
                        break;
                case CTRL([):
                        goto out;
@@ -136,24 +135,21 @@ top:
                        wwsuspend();
                        break;
                case 'q':
                        wwsuspend();
                        break;
                case 'q':
-                       doquit();
+                       c_quit();
                        if (quit)
                                goto out;
                        break;
                case '.':
                        if (quit)
                                goto out;
                        break;
                case '.':
-                       if (terse)
-                               Ding();
-                       else
-                               wwputs("Use q to quit.  ", cmdwin);
+                       error("Use q to quit.");
                        break;
                default:
                        if (c == escapec) {
                        break;
                default:
                        if (c == escapec) {
-                               write(selwin->ww_pty, &escapec, 1);
+                               (void) write(selwin->ww_pty, &escapec, 1);
                                goto out;
                        }
                                goto out;
                        }
-                       Ding();
                        if (!terse)
                        if (!terse)
-                               wwprintf(cmdwin, "Type ? for help.  ");
+                               wwbell();
+                       error("Type ? for help.");
                        break;
                }
        }
                        break;
                }
        }
@@ -161,19 +157,24 @@ top:
                wwsetcursor(0, 0);
        else {
                if (!terse)
                wwsetcursor(0, 0);
        else {
                if (!terse)
-                       wwputs("Command: ", cmdwin);
-               wwsetcursor(WCurRow(cmdwin->ww_win), WCurCol(cmdwin->ww_win));
+                       (void) wwputs("Command: ", cmdwin);
+               wwsetcursor(wwcurrow(cmdwin), wwcurcol(cmdwin));
        }
        while (bpeekc() < 0)
                bread();
        goto top;
 out:
        }
        while (bpeekc() < 0)
                bread();
        goto top;
 out:
-       if (!quit)
-               wwsetcurwin(selwin);
+       if (!quit) {
+               curwin = selwin;
+               if (!terse) {
+                       wwdelete(cmdwin);
+                       reframe();
+               }
+       }
+       /*
        if (selwin != 0)
                Woncursor(selwin->ww_win, 0);
        if (selwin != 0)
                Woncursor(selwin->ww_win, 0);
-       if (!terse)
-               Whide(cmdwin->ww_win);
+       */
 }
 
 struct ww *
 }
 
 struct ww *
@@ -183,46 +184,69 @@ getwin()
        struct ww *w = 0;
 
        if (!terse)
        struct ww *w = 0;
 
        if (!terse)
-               wwputs("Which window? ", cmdwin);
-       wwsetcursor(WCurRow(cmdwin->ww_win), WCurCol(cmdwin->ww_win));
+               (void) wwputs("Which window? ", cmdwin);
+       wwsetcursor(wwcurrow(cmdwin), wwcurcol(cmdwin));
        while ((c = bgetc()) < 0)
                bread();
        while ((c = bgetc()) < 0)
                bread();
-       if (c < '1' || c > '9' || (w = wwfind(c - '0')) == 0)
-               Ding();
+       if (debug && c == 'c')
+               w = cmdwin;
+       else if (debug && c == 'f')
+               w = framewin;
+       else if (c >= '1' && c < NWINDOW + '1')
+               w = window[c - '1'];
+       if (w == 0)
+               wwbell();
        if (!terse)
        if (!terse)
-               wwputs("\r\n", cmdwin);
+               (void) wwputs("\r\n", cmdwin);
        return w;
 }
 
 setselwin(w)
 register struct ww *w;
 {
        return w;
 }
 
 setselwin(w)
 register struct ww *w;
 {
-       struct ww *oldselwin = selwin;
+       register struct ww *oldselwin = selwin;
 
        if (w == oldselwin)
                return;
        if (selwin = w) {
 
        if (w == oldselwin)
                return;
        if (selwin = w) {
-               labelwin(w);
-               /* bring it to the top just below cmdwin */
-               wwsetcurwin(w);
-               wwsetcurwin(cmdwin);
+               wwdelete(w);
+               /*
+                * Stick it in front of the old selected window,
+                * or behind everbody else.
+                */
+               wwadd(w, (oldselwin ? oldselwin : &wwhead)->ww_back);
+               /*
                Woncursor(w->ww_win, 1);
                Woncursor(w->ww_win, 1);
+               */
        }
        }
+       /*
        if (oldselwin) {
        if (oldselwin) {
-               labelwin(oldselwin);
                Woncursor(oldselwin->ww_win, 0);
        }
                Woncursor(oldselwin->ww_win, 0);
        }
+       */
+       reframe();
 }
 
 labelwin(w)
 register struct ww *w;
 {
 }
 
 labelwin(w)
 register struct ww *w;
 {
-       char buf[2];
-       int mode = w == selwin ? WINVERSE : 0;
+       int mode = w == selwin ? WWM_REV : 0;
+
+       if (w->ww_id >= 0) {
+               char buf[2];
 
 
-       buf[0] = w->ww_ident + '0';
-       buf[1] = 0;
-       wwlabel(w, 1, buf, mode);
-       if (w->ww_label)
-               wwlabel(w, 3, w->ww_label, mode);
+               buf[0] = w->ww_id + '1';
+               buf[1] = 0;
+               (void) wwlabel(w, framewin, 1, buf, mode);
+       }
+       if (w->ww_label) {
+               int col;
+
+               if (w->ww_center) {
+                       col = (w->ww_w.nc - strlen(w->ww_label)) / 2;
+                       col = MAX(3, col);
+               } else
+                       col = 3;
+               (void) wwlabel(w, framewin, col, w->ww_label, mode);
+       }
 }
 }
index 490c06d..a23ea5c 100644 (file)
@@ -1,36 +1,33 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd1.c      2.1 83/07/30";
+static char *sccsid = "@(#)cmd1.c      2.1.1.1 83/08/09";
 #endif
 
 #include "defs.h"
 
 #endif
 
 #include "defs.h"
 
-struct ww *doopen();
-
-dowindow()
+c_window()
 {
        int col, row, xcol, xrow;
        int id;
 
        if ((id = findid()) < 0) {
 {
        int col, row, xcol, xrow;
        int id;
 
        if ((id = findid()) < 0) {
-               if (terse)
-                       Ding();
-               else
-                       wwputs("Too many windows.  ", cmdwin);
+               error("Too many windows.");
                return;
        }
        if (!terse)
                return;
        }
        if (!terse)
-               wwputs("Upper left corner: ", cmdwin);
+               (void) wwputs("Upper left corner: ", cmdwin);
        col = 0;
        row = 1;
        for (;;) {
                wwsetcursor(row, col);
                while (bpeekc() < 0)
                        bread();
        col = 0;
        row = 1;
        for (;;) {
                wwsetcursor(row, col);
                while (bpeekc() < 0)
                        bread();
-               switch (getpos(&row, &col, 0, 0)) {
+               switch (getpos(&row, &col, 1, 0)) {
                case -1:
                case -1:
+                       /*
                        WBoxActive = 0;
                        WBoxActive = 0;
+                       */
                        if (!terse)
                        if (!terse)
-                               wwputs("\r\nCancelled.  ", cmdwin);
+                               (void) wwputs("\r\nCancelled.  ", cmdwin);
                        return;
                case 1:
                        break;
                        return;
                case 1:
                        break;
@@ -40,20 +37,24 @@ dowindow()
                break;
        }
        if (!terse)
                break;
        }
        if (!terse)
-               wwputs("\r\nLower right corner: ", cmdwin);
-       xcol = col + 1;
-       xrow = row + 1;
+               (void) wwputs("\r\nLower right corner: ", cmdwin);
+       xcol = col;
+       xrow = row;
        for (;;) {
        for (;;) {
+               /*
                Wbox(col, row, xcol - col + 1, xrow - row + 1);
                Wbox(col, row, xcol - col + 1, xrow - row + 1);
+               */
                wwsetcursor(xrow, xcol);
                wwflush();
                while (bpeekc() < 0)
                        bread();
                wwsetcursor(xrow, xcol);
                wwflush();
                while (bpeekc() < 0)
                        bread();
-               switch (getpos(&xrow, &xcol, row + 1, col + 1)) {
+               switch (getpos(&xrow, &xcol, row, col)) {
                case -1:
                case -1:
+                       /*
                        WBoxActive = 0;
                        WBoxActive = 0;
+                       */
                        if (!terse)
                        if (!terse)
-                               wwputs("\r\nCancelled.  ", cmdwin);
+                               (void) wwputs("\r\nCancelled.  ", cmdwin);
                        return;
                case 1:
                        break;
                        return;
                case 1:
                        break;
@@ -62,33 +63,23 @@ dowindow()
                }
                break;
        }
                }
                break;
        }
+       /*
        WBoxActive = 0;
        WBoxActive = 0;
+       */
        if (!terse)
        if (!terse)
-               wwputs("\r\n", cmdwin);
-       wwsetcursor(WCurRow(cmdwin->ww_win), WCurCol(cmdwin->ww_win));
-       if (doopen(id, xrow-row+1, xcol-col+1, row, col) == 0)
-               if (terse)
-                       Ding();
-               else
-                       wwputs("Can't open window.  ", cmdwin);
+               (void) wwputs("\r\n", cmdwin);
+       wwcurtowin(cmdwin);
+       if (openwin(id, xrow-row+1, xcol-col+1, row, col) == 0)
+               error("Can't open window.");
 }
 
 findid()
 {
 }
 
 findid()
 {
-       register id;
-       char ids[10];
-       register struct ww *w;
+       register i;
 
 
-       for (id = 1; id <= NWINDOW; id++)
-               ids[id] = 0;
-       for (w = wwhead; w; w = w->ww_next) {
-               if (w->ww_ident < 1 || w->ww_ident > NWINDOW)
-                       continue;
-               ids[w->ww_ident]++;
-       }
-       for (id = 1; id <= NWINDOW && ids[id]; id++)
+       for (i = 0; i < NWINDOW && window[i] != 0; i++)
                ;
                ;
-       return id < 10 ? id : -1;
+       return i < NWINDOW ? i : -1;
 }
 
 getpos(row, col, minrow, mincol)
 }
 
 getpos(row, col, minrow, mincol)
@@ -142,32 +133,37 @@ register int *row, *col, minrow, mincol;
                        return 1;
                default:
                        if (!terse)
                        return 1;
                default:
                        if (!terse)
-                               wwputs("\r\nType [hjklHJKL] to move, return to enter position, escape to cancel.", cmdwin);
-                       Ding();
+                               (void) wwputs("\r\nType [hjklHJKL] to move, return to enter position, escape to cancel.", cmdwin);
+                       wwbell();
                }
        }
        return 0;
 }
 
 struct ww *
                }
        }
        return 0;
 }
 
 struct ww *
-doopen(id, nrow, ncol, row, col)
+openwin(id, nrow, ncol, row, col)
 int id, nrow, ncol, row, col;
 {
        register struct ww *w;
 
 int id, nrow, ncol, row, col;
 {
        register struct ww *w;
 
+       if (row <= 0)
+               return 0;
        if (id < 0 && (id = findid()) < 0)
                return 0;
        if (id < 0 && (id = findid()) < 0)
                return 0;
-       if ((w = wwopen(WW_PTY, id, nrow, ncol, row, col)) == 0)
+       if ((w = wwopen(WWO_PTY, nrow, ncol, row, col, 0)) == 0)
                return 0;
                return 0;
-       reframe();
-       if (selwin == 0)
-               setselwin(w);
-       else
-               wwsetcurwin(cmdwin);
+       w->ww_id = id;
+       window[id] = w;
+       w->ww_hasframe = 1;
+       wwadd(w, (selwin ? selwin : wwhead.ww_back));
+       setselwin(w);
+       /*
+       wwupdate();
        wwflush();
        wwflush();
+       */
        switch (wwfork(w)) {
        case -1:
        switch (wwfork(w)) {
        case -1:
-               doclose(w);
+               c_close(w);
                return 0;
        case 0:
                execl(shell, shellname, 0);
                return 0;
        case 0:
                execl(shell, shellname, 0);
@@ -181,11 +177,11 @@ reframe()
 {
        register struct ww *w;
 
 {
        register struct ww *w;
 
-       for (w = wwhead; w; w = w->ww_next) {
-               if (w == cmdwin)
-                       continue;
-               wwunframe(w);
-               wwframe(w);
-               labelwin(w);
-       }
+       wwunframe(framewin);
+       for (w = wwhead.ww_back; w != &wwhead; w = w->ww_back)
+               if (w->ww_hasframe)
+                       wwframe(w, framewin);
+       for (w = wwhead.ww_back; w != &wwhead; w = w->ww_back)
+               if (w->ww_hasframe)
+                       labelwin(w);
 }
 }
index 3f304c3..27ad32e 100644 (file)
@@ -1,94 +1,89 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd2.c      2.1 83/07/30";
+static char *sccsid = "@(#)cmd2.c      2.1.1.1 83/08/09";
 #endif
 
 #include "defs.h"
 
 #endif
 
 #include "defs.h"
 
-struct ww *getwin();
-struct ww *openwin();
-char *strtime();
+struct ww *openiwin();
 
 
-dohelp()
+c_help()
 {
        register struct ww *w;
 
 {
        register struct ww *w;
 
-       if ((w = openwin(wwnrow - 1, "Help")) == 0) {
-               if (terse)
-                       Ding();
-               else
-                       wwputs("Can't open help window.  ", cmdwin);
+       if ((w = openiwin(wwnrow - 2, "Help")) == 0) {
+               error("Can't open help window.");
                return;
        }
                return;
        }
-       wwprintf(w, "The escape character is %s, which gets you into command mode.\r\n\n",
+       (void) wwprintf(w, "The escape character is %s, which gets you into command mode.\r\n\n",
                unctrl(escapec));
                unctrl(escapec));
-       wwprintf(w, "Short commands:\r\n\n");
-       wwprintf(w, "{1-9}   Select window {1-9} and return to conversation mode.\r\n");
-       wwprintf(w, "%%{1-9}  Select window {1-9}.\r\n");
-       wwprintf(w, "c{1-9}  Close window {1-9}.\r\n");
-       wwprintf(w, "C       Close all windows.\r\n");
-       wwprintf(w, "S       Show all windows in sequence.\r\n");
-       wwprintf(w, "L       List all windows with their labels.\r\n");
-       wwprintf(w, "w       Open a new window.\r\n");
-       wwprintf(w, "[^U^D]  Scroll [up, down] half a window.\r\n");
-       wwprintf(w, "[^B^F]  Scroll [up, down] a full window.\r\n");
-       wwprintf(w, "[hjkl]  Move cursor [left, down, up, right].\r\n");
-       wwprintf(w, "escape  Exit command mode.\r\n");
-       wwprintf(w, "^L      Redraw screen.\r\n");
-       wwprintf(w, "^Z      Suspend.\r\n");
-       wwprintf(w, ".       Quit.\r\n");
+       (void) wwprintf(w, "Short commands:\r\n\n");
+       (void) wwprintf(w, "{1-9}   Select window {1-9} and return to conversation mode.\r\n");
+       (void) wwprintf(w, "%%{1-9}  Select window {1-9}.\r\n");
+       (void) wwprintf(w, "c{1-9}  Close window {1-9}.\r\n");
+       (void) wwprintf(w, "C       Close all windows.\r\n");
+       (void) wwprintf(w, "S       Show all windows in sequence.\r\n");
+       (void) wwprintf(w, "L       List all windows with their labels.\r\n");
+       (void) wwprintf(w, "w       Open a new window.\r\n");
+       (void) wwprintf(w, "[^U^D]  Scroll [up, down] half a window.\r\n");
+       (void) wwprintf(w, "[^B^F]  Scroll [up, down] a full window.\r\n");
+       (void) wwprintf(w, "[hjkl]  Move cursor [left, down, up, right].\r\n");
+       (void) wwprintf(w, "escape  Exit command mode.\r\n");
+       (void) wwprintf(w, "^L      Redraw screen.\r\n");
+       (void) wwprintf(w, "^Z      Suspend.\r\n");
+       (void) wwprintf(w, ".       Quit.\r\n");
        waitnl(w);
        waitnl(w);
-       wwprintf(w, "Long commands:\r\n\n");
-       wwprintf(w, ":terse [off]            Turn on (or off) terse mode.\r\n");
-       wwprintf(w, ":refresh {1-9} [off]    Turn on (or off) refresh after every newline\r\n");
-       wwprintf(w, "                        for window {1-9}.\r\n");
-       wwprintf(w, ":label {1-9} string     Label window {1-9}.\r\n");
-       wwprintf(w, ":escape C               Set escape character to C.\r\n");
-       wwprintf(w, ":%%{1-9}                 Select window {1-9}.\r\n");
-       wwprintf(w, ":window r c nr nc       Open a window at row r column c\r\n");
-       wwprintf(w, "                        with nr rows and nc colomns\r\n");
-       wwprintf(w, ":source filename        Execute the commands in `filename'.\r\n");
+       (void) wwprintf(w, "Long commands:\r\n\n");
+       (void) wwprintf(w, ":terse [off]            Turn on (or off) terse mode.\r\n");
+       (void) wwprintf(w, ":refresh {1-9} [off]    Turn on (or off) refresh after every newline\r\n");
+       (void) wwprintf(w, "                        for window {1-9}.\r\n");
+       (void) wwprintf(w, ":label {1-9} string     Label window {1-9}.\r\n");
+       (void) wwprintf(w, ":escape C               Set escape character to C.\r\n");
+       (void) wwprintf(w, ":%%{1-9}                 Select window {1-9}.\r\n");
+       (void) wwprintf(w, ":window r c nr nc       Open a window at row r column c\r\n");
+       (void) wwprintf(w, "                        with nr rows and nc colomns\r\n");
+       (void) wwprintf(w, ":source filename        Execute the commands in `filename'.\r\n");
        waitnl(w);
        waitnl(w);
-       closewin(w);
+       closeiwin(w);
 }
 
 }
 
-dotime(flag)
+char *strtime();
+
+c_time(flag)
 {
        register struct ww *w;
        struct rusage rusage;
        struct timeval timeval;
 {
        register struct ww *w;
        struct rusage rusage;
        struct timeval timeval;
+       struct timezone timezone;
 
 
-       if ((w = openwin(8, "Timing and Resource Usage")) == 0) {
-               if (terse)
-                       Ding();
-               else
-                       wwputs("Can't open time window.  ", cmdwin);
+       if ((w = openiwin(6, "Timing and Resource Usage")) == 0) {
+               error("Can't open time window.");
                return;
        }
 
                return;
        }
 
-       gettimeofday(&timeval, &timezone);
+       (void) gettimeofday(&timeval, &timezone);
        timeval.tv_sec -= starttime.tv_sec;
        if ((timeval.tv_usec -= starttime.tv_usec) < 0) {
                timeval.tv_sec--;
                timeval.tv_usec += 1000000;
        }
        timeval.tv_sec -= starttime.tv_sec;
        if ((timeval.tv_usec -= starttime.tv_usec) < 0) {
                timeval.tv_sec--;
                timeval.tv_usec += 1000000;
        }
-       getrusage(flag, &rusage);
+       (void) getrusage(flag, &rusage);
 
 
-       wwprintf(w, "time\t\tutime\t\tstime\t\tmaxrss\tixrss\tidrss\tisrss\r\n");
-       wwprintf(w, "%-16s", strtime(&timeval));
-       wwprintf(w, "%-16s", strtime(&rusage.ru_utime));
-       wwprintf(w, "%-16s", strtime(&rusage.ru_stime));
-       wwprintf(w, "%D\t%D\t%D\t%D\r\n",
+       (void) wwprintf(w, "time\t\tutime\t\tstime\t\tmaxrss\tixrss\tidrss\tisrss\r\n");
+       (void) wwprintf(w, "%-16s", strtime(&timeval));
+       (void) wwprintf(w, "%-16s", strtime(&rusage.ru_utime));
+       (void) wwprintf(w, "%-16s", strtime(&rusage.ru_stime));
+       (void) wwprintf(w, "%D\t%D\t%D\t%D\r\n",
                rusage.ru_maxrss, rusage.ru_ixrss,
                rusage.ru_idrss, rusage.ru_isrss);
                rusage.ru_maxrss, rusage.ru_ixrss,
                rusage.ru_idrss, rusage.ru_isrss);
-       wwprintf(w, "minflt\tmajflt\tnswap\tinblk\toublk\tmsgsnd\tmsgrcv\tnsigs\tnvcsw\tnivcsw\r\n");
-       wwprintf(w, "%D\%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\r\n",
+       (void) wwprintf(w, "minflt\tmajflt\tnswap\tinblk\toublk\tmsgsnd\tmsgrcv\tnsigs\tnvcsw\tnivcsw\r\n");
+       (void) wwprintf(w, "%D\%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\r\n",
                rusage.ru_minflt, rusage.ru_majflt, rusage.ru_nswap,
                rusage.ru_inblock, rusage.ru_oublock,
                rusage.ru_msgsnd, rusage.ru_msgrcv, rusage.ru_nsignals,
                rusage.ru_nvcsw, rusage.ru_nivcsw);
 
        waitnl(w);
                rusage.ru_minflt, rusage.ru_majflt, rusage.ru_nswap,
                rusage.ru_inblock, rusage.ru_oublock,
                rusage.ru_msgsnd, rusage.ru_msgrcv, rusage.ru_nsignals,
                rusage.ru_nvcsw, rusage.ru_nivcsw);
 
        waitnl(w);
-       closewin(w);
+       closeiwin(w);
 }
 
 char *
 }
 
 char *
@@ -100,7 +95,7 @@ register struct timeval *t;
        register char *p = buf;
 
        if (t->tv_sec > 60*60) {
        register char *p = buf;
 
        if (t->tv_sec > 60*60) {
-               sprintf(p, "%D:", t->tv_sec / (60*60));
+               (void) sprintf(p, "%D:", t->tv_sec / (60*60));
                while (*p++)
                        ;
                p--;
                while (*p++)
                        ;
                p--;
@@ -108,109 +103,120 @@ register struct timeval *t;
                fill++;
        }
        if (t->tv_sec > 60) {
                fill++;
        }
        if (t->tv_sec > 60) {
-               sprintf(p, fill ? "%02D:" : "%D:", t->tv_sec / 60);
+               (void) sprintf(p, fill ? "%02D:" : "%D:", t->tv_sec / 60);
                while (*p++)
                        ;
                p--;
                t->tv_sec %= 60;
                fill++;
        }
                while (*p++)
                        ;
                p--;
                t->tv_sec %= 60;
                fill++;
        }
-       sprintf(p, fill ? "%02D.%02d" : "%D.%02D",
+       (void) sprintf(p, fill ? "%02D.%02d" : "%D.%02D",
                t->tv_sec, t->tv_usec / 10000);
        return buf;
 }
 
                t->tv_sec, t->tv_usec / 10000);
        return buf;
 }
 
-dostat()
+c_stat()
 {
        register struct ww *w;
 
 {
        register struct ww *w;
 
-       if ((w = openwin(6, "IO Statics")) == 0) {
-               if (terse)
-                       Ding();
-               else
-                       wwputs("Can't open statistics window.  ", cmdwin);
+       if ((w = openiwin(6, "IO Statics")) == 0) {
+               error("Can't open statistics window.");
                return;
        }
                return;
        }
-       wwprintf(w, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\r\n");
-       wwprintf(w, "%d\t%d\t%d\t%d\t%d\t%d\r\n",
+       (void) wwprintf(w, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\r\n");
+       (void) wwprintf(w, "%d\t%d\t%d\t%d\t%d\t%d\r\n",
                nread, nreadz, nreade, nreadc, wwnwrite, wwnwritec);
        waitnl(w);
                nread, nreadz, nreade, nreadc, wwnwrite, wwnwritec);
        waitnl(w);
-       closewin(w);
+       closeiwin(w);
 }
 
 }
 
-dolist()
+c_list()
 {
 {
-       register struct ww *w, *w1;
-       int id;
-       char doneit = 0;
-
-       if ((w = openwin(14, "Active Windows")) == 0) {
-               if (terse)
-                       Ding();
-               else
-                       wwputs("Can't open listing window.  ", cmdwin);
+       register struct ww *w;
+       register i;
+       int n;
+
+       for (n = 0, i = 0; i < NWINDOW; i++)
+               if (window[i] != 0)
+                       n++;
+       if ((w = openiwin(MIN(n, 1) + 2, "Active Windows")) == 0) {
+               error("Can't open listing window.");
                return;
        }
                return;
        }
-       for (id = 1; id <= NWINDOW; id++) {
-               if ((w1 = wwfind(id)) == 0)
-                       continue;
-               doneit = 1;
-               wwprintf(w, "%d   %s\r\n", id, w1->ww_label);
+       if (n == 0) {
+               (void) wwputs("No windows.\r\n", w);
+       } else {
+               for (i = 0; i < NWINDOW; i++) {
+                       if (window[i] == 0)
+                               continue;
+                       (void) wwprintf(w, "%c   %s\r\n", i + '1',
+                               window[i]->ww_label ? window[i]->ww_label
+                                       : "(No label)");
+               }
        }
        }
-       if (!doneit)
-               wwprintf(w, "No windows.\r\n");
        waitnl(w);
        waitnl(w);
-       closewin(w);
+       closeiwin(w);
 }
 
 }
 
-doquit()
+c_quit()
 {
        if (terse)
 {
        if (terse)
-               Wunhide(cmdwin->ww_win);
-       wwputs("Really quit [yn]? ", cmdwin);
-       wwsetcursor(WCurRow(cmdwin->ww_win), WCurCol(cmdwin->ww_win));
+               wwadd(cmdwin, &wwhead);
+       (void) wwputs("Really quit [yn]? ", cmdwin);
+       wwcurtowin(cmdwin);
        while (bpeekc() < 0)
                bread();
        if (bgetc() == 'y') {
        while (bpeekc() < 0)
                bread();
        if (bgetc() == 'y') {
-               wwputs("Yes", cmdwin);
+               (void) wwputs("Yes", cmdwin);
                quit++;
        } else
                quit++;
        } else
-               wwputs("\r\n", cmdwin);
-       if (terse)
-               Whide(cmdwin->ww_win);
+               (void) wwputs("\r\n", cmdwin);
+       if (terse && !quit)
+               wwdelete(cmdwin);
 }
 
 }
 
+/*
+ * Open an information window.
+ */
 struct ww *
 struct ww *
-openwin(nrow, label)
+openiwin(nrow, label)
 char *label;
 {
        register struct ww *w;
 char *label;
 {
        register struct ww *w;
-       int startcol;
 
 
-       if ((w = wwopen(WW_NONE, 0, nrow, wwncol, 0, 0)) == 0)
+       if ((w = wwopen(0, nrow, wwncol, 2, 0, 0)) == 0)
                return 0;
                return 0;
-       wwframe(w);
-       if ((startcol = (wwncol - strlen(label)) / 2) <= 0)
-               startcol = 1;
-       wwlabel(w, startcol, label, WINVERSE);
-       wwsetcurwin(w);
+       /*
+       w->ww_mapnl = 1;
+       */
+       w->ww_hasframe = 1;
+       w->ww_id = -1;
+       w->ww_center = 1;
+       (void) setlabel(w, label);
+       wwadd(w, framewin);
+       reframe();
        return w;
 }
 
 waitnl(w)
 register struct ww *w;
 {
        return w;
 }
 
 waitnl(w)
 register struct ww *w;
 {
-       wwsetcurwin(w);
-       wwprintf(w, "\r\nType return to continue: ");
-       wwsetcursor(WCurRow(w->ww_win), WCurCol(w->ww_win));
+       if (w->ww_back != framewin) {
+               (void) wwputs("reframed", w);
+               wwdelete(w);
+               wwadd(w, framewin);
+               reframe();
+       }
+       (void) wwputs("\r\nType return to continue: ", w);
+       wwcurtowin(w);
        while (bgetc() < 0)
                bread();
        while (bgetc() < 0)
                bread();
-       wwputs("\033E", w);                     /* clear and home cursor */
+       (void) wwputs("\033E", w);              /* clear and home cursor */
 }
 
 }
 
-closewin(w)
-register struct ww *w;
+closeiwin(w)
+struct ww *w;
 {
 {
-       wwclose(w);
-       wwsetcurwin(cmdwin);
+       closewin(w);
+       reframe();
 }
 }
index c69814b..1325494 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)main.c      2.1 83/07/30";
+static char *sccsid = "@(#)main.c      2.1.1.1 83/08/09";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -8,17 +8,15 @@ char escapec = CTRL(p);
 
 #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
 
 
 #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
 
-/*ARGUSED*/
+/*ARGSUSED*/
 main(argc, argv)
 char **argv;
 {
        register n;
        register char *p;
        char fast = 0;
 main(argc, argv)
 char **argv;
 {
        register n;
        register char *p;
        char fast = 0;
-       int wwchild();
        int imask;
        int imask;
-       char *rindex();
-       char *getenv();
+       struct timezone timezone;
 
        if (p = rindex(*argv, '/'))
                p++;
 
        if (p = rindex(*argv, '/'))
                p++;
@@ -41,10 +39,10 @@ char **argv;
                                debug++;
                                break;
                        default:
                                debug++;
                                break;
                        default:
-                               usage();
+                               (void) usage();
                        }
                } else
                        }
                } else
-                       usage();
+                       (void) usage();
        }
        if ((shell = getenv("SHELL")) == 0)
                shell = "/bin/csh";
        }
        if ((shell = getenv("SHELL")) == 0)
                shell = "/bin/csh";
@@ -52,34 +50,47 @@ char **argv;
                shellname++;
        else
                shellname = shell;
                shellname++;
        else
                shellname = shell;
-       gettimeofday(&starttime, &timezone);
+       (void) gettimeofday(&starttime, &timezone);
        if (wwinit() < 0) {
        if (wwinit() < 0) {
-               fflush(stdout);
-               fprintf("Can't do windows on this terminal.\n");
+               (void) fflush(stdout);
+               (void) fprintf(stderr, "Can't do windows on this terminal.\n");
                exit(1);
        }
        if (debug) {
                wwnewtty.ww_tchars.t_quitc = wwoldtty.ww_tchars.t_quitc;
                exit(1);
        }
        if (debug) {
                wwnewtty.ww_tchars.t_quitc = wwoldtty.ww_tchars.t_quitc;
-               wwsettty(0, &wwnewtty);
+               (void) wwsettty(0, &wwnewtty);
        }
        }
-       if ((cmdwin = wwopen(WW_NONE, 0, 1, wwncol, 0, 0)) == 0) {
-               fflush(stdout);
-               fprintf(stderr, "Can't open command window.\r\n");
+
+       if ((cmdwin = wwopen(WWO_REVERSE, 1, wwncol, 0, 0, 0)) == 0) {
+               (void) wwflush();
+               (void) fprintf(stderr, "Can't open command window.\r\n");
+               goto bad;
+       }
+       if ((framewin = wwopen(WWO_GLASS, wwnrow, wwncol, 0, 0, 0)) == 0) {
+               (void) wwflush();
+               (void) fprintf(stderr, "Can't open frame window.\r\n");
                goto bad;
        }
                goto bad;
        }
-       if (terse)
-               Whide(cmdwin->ww_win);
-       wwsetcurwin(cmdwin);
-       for (n = 0; n < wwncol; n++)                    /* XXX */
-               Waputc(0, WINVERSE|WBUF, cmdwin->ww_win);
+       wwadd(framewin, &wwhead);
+
+       curwin = cmdwin;
+       wwupdate();
        wwflush();
        (void) signal(SIGCHLD, wwchild);
        if (!fast) {
        wwflush();
        (void) signal(SIGCHLD, wwchild);
        if (!fast) {
+               if (!terse)
+                       wwadd(cmdwin, &wwhead);
                if (doconfig() < 0)
                        dodefault();
                if (selwin != 0) {
                if (doconfig() < 0)
                        dodefault();
                if (selwin != 0) {
-                       wwsetcurwin(selwin);
+                       curwin = selwin;
+                       /*
                        Woncursor(selwin->ww_win, 0);
                        Woncursor(selwin->ww_win, 0);
+                       */
+               }
+               if (!terse) {
+                       wwdelete(cmdwin);
+                       reframe();
                }
        }
        while (!quit) {
                }
        }
        while (!quit) {
@@ -91,8 +102,8 @@ char **argv;
                 * Loop until we get some keyboard input.
                 */
                while (ibufc == 0) {
                 * Loop until we get some keyboard input.
                 */
                while (ibufc == 0) {
-                       wwsetcursor(WCurRow(curwin->ww_win),
-                               WCurCol(curwin->ww_win));
+                       wwcurtowin(curwin);
+                       wwupdate();
                        wwflush();
                        imask = 1 << 0;
                        while (wwforce(&imask) < 0)
                        wwflush();
                        imask = 1 << 0;
                        while (wwforce(&imask) < 0)
@@ -111,28 +122,31 @@ char **argv;
                        nread++;
                }
                /*
                        nread++;
                }
                /*
-                * Weird loop.  Copy the buffer to the pty stopping
-                * on the escape character in a hopefully efficient
-                * way.
+                * Weird loop.  Copy the buffer to the pty
+                * and stopping on the escape character
+                * in a hopefully efficient way.
                 * Probably a good thing to make ibufc == 1 a special
                 * case.
                 */
                for (p = ibufp, n = ibufc;;) {
                        if (--n < 0) {
                 * Probably a good thing to make ibufc == 1 a special
                 * case.
                 */
                for (p = ibufp, n = ibufc;;) {
                        if (--n < 0) {
-                               write(curwin->ww_pty, ibufp, ibufc);
+                               (void) write(curwin->ww_pty, ibufp, ibufc);
                                ibufp = ibuf;
                                ibufc = 0;
                                break;
                        } else if (*p++ == escapec) {
                                if ((n = p - ibufp) > 1)
                                ibufp = ibuf;
                                ibufc = 0;
                                break;
                        } else if (*p++ == escapec) {
                                if ((n = p - ibufp) > 1)
-                                       write(curwin->ww_pty, ibufp, n - 1);
+                                       (void) write(curwin->ww_pty,
+                                               ibufp, n - 1);
                                ibufp = p;
                                ibufc -= n;
                                ibufp = p;
                                ibufc -= n;
-                               wwsetcurwin(cmdwin);
+                               curwin = cmdwin;
                                break;
                        }
                }
        }
                                break;
                        }
                }
        }
+       wwupdate();
+       wwflush();
 bad:
        wwend();
        return 0;
 bad:
        wwend();
        return 0;
@@ -140,6 +154,6 @@ bad:
 
 usage()
 {
 
 usage()
 {
-       fprintf(stderr, "window: [-e escape] [-t]\n");
-       exit(1);
+       (void) fprintf(stderr, "window: [-e escape] [-t] [-f]\n");
+       return exit(1);                 /* for lint */
 }
 }
index be32ff0..13c3d45 100644 (file)
@@ -1,35 +1,81 @@
-/*     @(#)ww.h        2.1 83/07/30            */
+/*
+ *     @(#)ww.h        2.1.1.1 83/08/09        
+ */
 
 #include <stdio.h>
 #include <sgtty.h>
 
 #include <stdio.h>
 #include <sgtty.h>
-#include "window.h"
+#include "tt.h"
+
+#define NWW    30
 
 struct ww_dim {
 
 struct ww_dim {
-       short col;
-       short row;
-       short ncol;
-       short nrow;
+       int nr;                 /* number of rows */
+       int nc;                 /* number of columns */
+       int t, b;               /* top, bottom */
+       int l, r;               /* left, right */
+};
+
+struct ww_pos {
+       int r;                  /* row */
+       int c;                  /* column */
 };
 
 };
 
+union ww_char {
+       short c_w;              /* as a word */
+       struct {
+               char C_c;       /* the character part */
+               char C_m;       /* the mode part */
+       } c_un;
+};
+#define c_c c_un.C_c
+#define c_m c_un.C_m
+
+#define WWC_CMASK      0x00ff
+#define WWC_MMASK      0xff00
+#define WWC_MSHIFT     8
+
+       /* c_m bits */
+#define WWM_REV                0x01    /* reverse video */
+#define WWM_BLK                0x02    /* blinking */
+#define WWM_UL         0x04    /* underlined */
+#define WWM_GLS                0x10    /* window only, glass, i.e. transparent */
+#define WWM_COV                0x20    /* window only, covered */
+
 struct ww {
 struct ww {
+       struct ww *ww_forw;     /* doubly linked list, for overlapping info */
+       struct ww *ww_back;
        char ww_state;          /* state of window creation */
        char ww_state;          /* state of window creation */
-       char ww_mode;           /* mode used to open this window */
        char ww_wstate;         /* state for printing charcters */
        int ww_insert :1;       /* insert mode, for printing */
        char ww_wstate;         /* state for printing charcters */
        int ww_insert :1;       /* insert mode, for printing */
-       int ww_refresh :1;      /* force refresh after \n and others */
-       char ww_ident;          /* the window id */
-       char *ww_label;         /* the user supplied label */
-       Win *ww_win;
-       struct ww_dim ww_o;     /* outside dimemsions */
-       struct ww_dim ww_i;     /* inside dimemsions */
+       int ww_mapnl :1;        /* map \n to \r\n */
+       int ww_haspty :1;       /* has pty */
+       char ww_index;          /* the index, for wwindex[] */
+       char ww_order;          /* the overlapping order */
        struct ww_dim ww_w;     /* window dimemsions */
        struct ww_dim ww_w;     /* window dimemsions */
-       int ww_pty;             /* pty or socket pair */
-       int ww_tty;
-       int ww_pid;
-       struct ww *ww_next;
-       char ww_ttyname[11];
+       short ww_nline;         /* size of the buffer */
+       short ww_scroll;        /* where the window is relative to the buffer */
+       struct ww_pos ww_cur;   /* the cursor position, relative to ww_w */
+       char **ww_win;          /* the window */
+       union ww_char **ww_buf; /* the buffer */
+       char **ww_cov;          /* the covered-by array */
+       short *ww_nvis;         /* how many ww_buf chars are visible per row */
+       int ww_pty;             /* file descriptor of pty */
+       int ww_tty;             /* . . . tty */
+       int ww_pid;             /* pid of process, if WWS_HASPROC true */
+       char ww_ttyname[11];    /* /dev/ttyp? */
+       /* below are things for the user */
+       char ww_hasframe :1;    /* frame it */
+       char ww_center :1;      /* center the label */
+       int ww_id;              /* the user id */
+       char *ww_label;         /* the user supplied label */
 };
 
 };
 
+       /* ww_state values */
+#define WWS_INITIAL    0       /* just opened */
+#define WWS_HASPROC    1       /* forked, in parent */
+#define WWS_INCHILD    2       /* forked, in child */
+#define WWS_DEAD       3       /* child died */
+
 struct ww_tty {
        struct sgttyb ww_sgttyb;
        struct tchars ww_tchars;
 struct ww_tty {
        struct sgttyb ww_sgttyb;
        struct tchars ww_tchars;
@@ -39,34 +85,61 @@ struct ww_tty {
        int ww_pgrp;
 };
 
        int ww_pgrp;
 };
 
-       /* ww_state values */
-#define WW_INITIAL     0
-#define WW_HASPROC     1
-#define WW_INCHILD     2
-#define WW_DEAD                3
+       /* flags to wwopen() */
+#define WWO_PTY                0x01            /* want pty */
+#define WWO_REVERSE    0x02            /* make it all reverse video */
+#define WWO_GLASS      0x04            /* make it all glass */
 
 
-       /* ww_mode values */
-#define WW_PTY         0               /* has pty */
-#define WW_SOCKET      1               /* has socket pair */
-#define WW_NONE                2               /* has nothing */
+struct ww wwhead;
+struct ww *wwindex[NWW + 1];
+struct ww wwnobody;
+#define WWX_NOBODY     NWW
 
 
-#undef CTRL
-#define CTRL(c)                ('c'&0x1f)
-#define DEL            0x7f
-#define ISCTRL(c)      ((c) < ' ' || (c) >= DEL)
+struct ww_tty wwoldtty, wwnewtty, wwwintty;
+
+char *wwterm;
+char wwtermcap[1024];
+char wwkeys[512];
+int wwnrow, wwncol;            /* the screen size */
+int wwcursorrow, wwcursorcol;  /* the terminal cursor position */
+int wwdtablesize;
+char **wwsmap;                 /* the screen map */
+union ww_char **wwns;
+union ww_char **wwos;
+int wwbaud;
+int wwbaudmap[];
 
 
-extern struct ww *wwhead, *curwin;
-extern struct ww_tty wwoldtty, wwnewtty, wwwintty;
-extern int wwnwrite;
-extern int wwnwritec;
-extern int wwnrow, wwncol;             /* the screen size */
+       /* statistics */
+int wwnwrite;
+int wwnwritec;
 
 
-#define wwputchar(c)   wwputc((c), curwin)
-#define wwputstr(s)    wwputs((s), curwin)
-#define wwsetcursor(r,c) (WRCurRow = (r), WRCurCol = (c))
-#define wwflush()      Wrefresh(1)
+#define wwcurrow(w)    ((w)->ww_cur.r + (w)->ww_w.t)
+#define wwcurcol(w)    ((w)->ww_cur.c + (w)->ww_w.l)
+#define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
+#define wwcurtowin(w)  wwsetcursor(wwcurrow(w), wwcurcol(w))
+#define wwbell()       putchar(CTRL(g))
 
 struct ww *wwopen();
 struct ww *wwfind();
 int wwchild();
 
 struct ww *wwopen();
 struct ww *wwfind();
 int wwchild();
+int wwsuspend();
 char *unctrl();
 char *unctrl();
+char **wwalloc();
+
+char *malloc();
+char *calloc();
+char *getenv();
+char *tgetstr();
+char *rindex();
+char *strcpy();
+char *strcat();
+
+#undef MIN
+#undef MAX
+#define MIN(x, y)      ((x) > (y) ? (y) : (x))
+#define MAX(x, y)      ((x) > (y) ? (x) : (y))
+
+#undef CTRL
+#define CTRL(c)                ('c'&0x1f)
+#define DEL            0x7f
+#define ISCTRL(c)      ((c) < ' ' || (c) >= DEL)
index 8fddc8b..9d4b971 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwchild.c   2.1 83/07/30";
+static char *sccsid = "@(#)wwchild.c   2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -7,24 +7,25 @@ static        char *sccsid = "@(#)wwchild.c   2.1 83/07/30";
 
 wwchild()
 {
 
 wwchild()
 {
-       register struct ww *wp;
+       register struct ww **wp;
        union wait w;
        int pid;
 
        union wait w;
        int pid;
 
-       while ((pid = wait3(&w, WNOHANG|WUNTRACED, 0)) > 0) {
-               for (wp = wwhead; wp; wp = wp->ww_next) {
-                       if (wp->ww_pid == pid) {
-                               wp->ww_state = WW_DEAD;
+       while ((pid = wait3(&w, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) {
+               for (wp = wwindex; wp < &wwindex[NWW]; wp++) {
+                       if (*wp && (*wp)->ww_state == WWS_HASPROC
+                           && (*wp)->ww_pid == pid) {
+                               (*wp)->ww_state = WWS_DEAD;
                                /*
                                /*
-                               wwprintf(curwin,
+                               (void) wwprintf(curwin,
                                        "\r\n%d: Died\r\n", pid);
                                */
                                break;
                        }
                }
                /*
                                        "\r\n%d: Died\r\n", pid);
                                */
                                break;
                        }
                }
                /*
-               if (wp == 0)
-                       wwprintf(curwin, "\r\n%d: No such child\r\n", pid);
+               if (wp >= &wwindex[NWW])
+                       (void) wwprintf(curwin, "\r\n%d: No such child\r\n", pid);
                */
        }
 }
                */
        }
 }
index 99df4b8..a8f9969 100644 (file)
@@ -1,11 +1,12 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwend.c     2.1 83/07/30";
+static char *sccsid = "@(#)wwend.c     2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 
 wwend()
 {
 #endif
 
 #include "ww.h"
 
 wwend()
 {
-       Wcleanup();
-       wwsettty(0, &wwoldtty);
+       (*tt.tt_move)(tt.tt_nrow - 1, 0);
+       (*tt.tt_cleanup)();
+       (void) wwsettty(0, &wwoldtty);
 }
 }
index 1ec6ecd..82f4c07 100644 (file)
@@ -1,32 +1,17 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinit.c    2.1 83/07/30";
+static char *sccsid = "@(#)wwinit.c    2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 
 #endif
 
 #include "ww.h"
 
-struct ww_tty wwoldtty;
-struct ww_tty wwwintty;
-struct ww_tty wwnewtty = {
-       { 0, 0, -1, -1, 0 },
-       { -1, -1, -1, -1, -1, -1 },
-       { -1, -1, -1, -1, -1, -1 },
-       0, 0, 0
-};
-int _wwdtablesize;
-char _wwtermcap[1024];
-char _wwkeys[512];
-static char *kp = _wwkeys;
-int wwncol, wwnrow;
+static char *kp = wwkeys;
 
 wwinit()
 {
 
 wwinit()
 {
-       static char done = 0;
+       register i, j;
        int kn;
 
        int kn;
 
-       if (done)
-               return 0;
-       done++;
-       _wwdtablesize = getdtablesize();
+       wwdtablesize = getdtablesize();
        if (wwgettty(0, &wwoldtty) < 0)
                return -1;
        wwwintty = wwoldtty;
        if (wwgettty(0, &wwoldtty) < 0)
                return -1;
        wwwintty = wwoldtty;
@@ -41,14 +26,44 @@ wwinit()
        wwnewtty.ww_sgttyb.sg_flags &= ~(ECHO|CRMOD);
        wwnewtty.ww_lmode |= LLITOUT;
        if (wwsettty(0, &wwnewtty) < 0)
        wwnewtty.ww_sgttyb.sg_flags &= ~(ECHO|CRMOD);
        wwnewtty.ww_lmode |= LLITOUT;
        if (wwsettty(0, &wwnewtty) < 0)
-               return -1;
-       if (Winit(2, 1) != 0)
-               return -1;
-       WSetRealCursor = 1;
-       Wscreensize(&wwnrow, &wwncol);
+               goto bad;
+
+       if ((wwterm = getenv("TERM")) == 0)
+               goto bad;
+       if (tgetent(wwtermcap, wwterm) != 1)
+               goto bad;
+       wwbaud = wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed];
+
+       if (ttinit() < 0)
+               goto bad;
+       wwnrow = tt.tt_nrow;
+       wwncol = tt.tt_ncol;
+       (*tt.tt_reset)();
+       (*tt.tt_clreos)();
+
+       if ((wwsmap = wwalloc(wwnrow, wwncol, sizeof (char))) == 0)
+               goto bad;
+       for (i = 0; i < wwnrow; i++)
+               for (j = 0; j < wwncol; j++)
+                       wwsmap[i][j] = WWX_NOBODY;
+       wwos = (union ww_char **)
+               wwalloc(wwnrow, wwncol, sizeof (union ww_char));
+       if (wwos == 0)
+               goto bad;
+       for (i = 0; i < wwnrow; i++)
+               for (j = 0; j < wwncol; j++)
+                       wwos[i][j].c_w = ' ';
+       wwns = (union ww_char **)
+               wwalloc(wwnrow, wwncol, sizeof (union ww_char));
+       if (wwns == 0)
+               goto bad;
+       for (i = 0; i < wwnrow; i++)
+               for (j = 0; j < wwncol; j++)
+                       wwns[i][j].c_w = ' ';
+
+       wwindex[WWX_NOBODY] = &wwnobody;
+       wwnobody.ww_order = NWW;
 
 
-       if (tgetent(_wwtermcap, getenv("TERM")) != 1)
-               return -1;
        addcap("kb");
        addcap("ku");
        addcap("kd");
        addcap("kb");
        addcap("ku");
        addcap("kd");
@@ -59,26 +74,29 @@ wwinit()
                char cap[5];
                int i;
 
                char cap[5];
                int i;
 
-               sprintf(kp, "kn#%d:", kn);
+               (void) sprintf(kp, "kn#%d:", kn);
                for (; *kp; kp++)
                        ;
                for (i = 1; i <= kn; i++) {
                for (; *kp; kp++)
                        ;
                for (i = 1; i <= kn; i++) {
-                       sprintf(cap, "k%d", i);
+                       (void) sprintf(cap, "k%d", i);
                        addcap(cap);
                        cap[0] = 'l';
                        addcap(cap);
                }
        }
        return 0;
                        addcap(cap);
                        cap[0] = 'l';
                        addcap(cap);
                }
        }
        return 0;
+bad:
+       (void) wwsettty(0, &wwoldtty);
+       return -1;
 }
 
 }
 
+static
 addcap(cap)
 register char *cap;
 {
 addcap(cap)
 register char *cap;
 {
-       static char tbuf[512];
-       static char *tp = tbuf;
+       char tbuf[512];
+       char *tp = tbuf;
        register char *str, *p;
        register char *str, *p;
-       char *tgetstr();
 
        if ((str = tgetstr(cap, &tp)) != 0) {
                while (*kp++ = *cap++)
 
        if ((str = tgetstr(cap, &tp)) != 0) {
                while (*kp++ = *cap++)
index d073f7d..c1bd787 100644 (file)
@@ -1,31 +1,29 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwiomux.c   2.1 83/07/30";
+static char *sccsid = "@(#)wwiomux.c   2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 
 #endif
 
 #include "ww.h"
 
-extern int _wwdtablesize;
-
 wwforce(imask)
 register int *imask;
 {
 wwforce(imask)
 register int *imask;
 {
-       register struct ww *w;
+       register struct ww **w;
        char buf[512];
        register int n;
 
        char buf[512];
        register int n;
 
-       for (w = wwhead; w; w = w->ww_next)
-               if (w->ww_pty >= 0)
-                       *imask |= 1 << w->ww_pty;
-       n = select(_wwdtablesize, imask,
-               (int *)0, (int *)0, (struct timeval *)0);
+       for (w = wwindex; w < &wwindex[NWW]; w++)
+               if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0)
+                       *imask |= 1 << (*w)->ww_pty;
+       n = select(wwdtablesize, imask, (int *)0, (int *)0,
+               (struct timeval *)0);
        if (n <= 0)
                return -1;
        if (n <= 0)
                return -1;
-       for (w = wwhead; w; w = w->ww_next) {
-               if (*imask & 1<<w->ww_pty) {
-                       n = read(w->ww_pty, buf, sizeof buf);
+       for (w = wwindex; w < &wwindex[NWW]; w++)
+               if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0
+                   && *imask & 1 << (*w)->ww_pty) {
+                       n = read((*w)->ww_pty, buf, sizeof buf);
                        if (n > 0)
                        if (n > 0)
-                               wwwrite(w, buf, n);
+                               (void) wwwrite((*w), buf, n);
                }
                }
-       }
        return 0;
 }
        return 0;
 }
index 3b33ca9..0b60fb1 100644 (file)
@@ -1,40 +1,9 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwmisc.c    2.1 83/07/30";
+static char *sccsid = "@(#)wwmisc.c    2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 
 #endif
 
 #include "ww.h"
 
-struct ww *wwhead = 0;
-struct ww *curwin = 0;
-
-wwsetcurwin(wp)
-register struct ww *wp;
-{
-       curwin = wp;
-       Wfront(wp->ww_win);
-}
-
-wwhaschildren()
-{
-       register struct ww *wp;
-
-       for (wp = wwhead; wp; wp = wp->ww_next)
-               if (wp->ww_state == WW_HASPROC)
-                       return 1;
-       return 0;
-}
-
-struct ww *
-wwfind(id)
-register id;
-{
-       register struct ww *w;
-
-       for (w = wwhead; w && w->ww_ident != id; w = w->ww_next)
-               ;
-       return w;
-}
-
 char *
 unctrl(c)
 register char c;
 char *
 unctrl(c)
 register char c;
index f466252..5fdd3ea 100644 (file)
@@ -1,92 +1,95 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwopen.c    2.1 83/07/30";
+static char *sccsid = "@(#)wwopen.c    2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
-#include <sys/types.h>
-#include <sys/stat.h>
 
 struct ww *
 
 struct ww *
-wwopen(mode, id, nrow, ncol, row, col)
+wwopen(flags, nrow, ncol, row, col, nline)
 {
        register struct ww *w = 0;
 {
        register struct ww *w = 0;
+       register i, j;
+       char m;
+       short nvis;
 
 
-       w = (struct ww *)calloc(sizeof (struct ww), 1);
+       for (i = 0; i < NWW && wwindex[i] != 0; i++)
+               ;
+       if (i >= NWW)
+               return 0;
+       wwindex[i] = w = (struct ww *)calloc(sizeof (struct ww), 1);
        if (w == 0)
                goto bad;
        if (w == 0)
                goto bad;
-       w->ww_pty = w->ww_tty = -1;
-       switch (mode) {
-       case WW_PTY:
+       w->ww_index = i;
+       w->ww_pty = w->ww_tty = -1;     /* closing by mistake is still safe */
+       if (flags & WWO_PTY) {
+               w->ww_haspty = 1;
                if (wwgetpty(w) < 0)
                        goto bad;
                if (wwsettty(w->ww_pty, &wwwintty) < 0)
                        goto bad;
                if (wwgetpty(w) < 0)
                        goto bad;
                if (wwsettty(w->ww_pty, &wwwintty) < 0)
                        goto bad;
-               break;
-       case WW_SOCKET:
-               break;
-       case WW_NONE:
-               break;
-       default:
-               goto bad;
        }
        }
-       if ((w->ww_win = Wopen(id, col, row, ncol, nrow, ncol, 48)) == 0)
+
+       if ((w->ww_w.l = col) < 0)
+               goto bad;
+       if ((w->ww_w.r = col + ncol) > wwncol)
+               goto bad;
+       if ((w->ww_w.t = row) < 0)
+               goto bad;
+       if ((w->ww_w.b = row + nrow) > wwnrow)
+               goto bad;
+       w->ww_w.nc = ncol;
+       w->ww_w.nr = nrow;
+       w->ww_nline = MAX(nline, w->ww_w.nr);
+
+       w->ww_win = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char));
+       if (w->ww_win == 0)
+               goto bad;
+       m = 0;
+       if (flags & WWO_GLASS)
+               m |= WWM_GLS;
+       if (flags & WWO_REVERSE)
+               m |= WWM_REV;
+       for (i = 0; i < w->ww_w.nr; i++)
+               for (j = 0; j < w->ww_w.nc; j++)
+                       w->ww_win[i][j] = m;
+       
+       w->ww_cov = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char));
+       if (w->ww_cov == 0)
+               goto bad;
+       for (i = 0; i < w->ww_w.nr; i++)
+               for (j = 0; j < w->ww_w.nc; j++)
+                       w->ww_cov[i][j] = WWX_NOBODY;
+       
+       w->ww_buf = (union ww_char **)
+               wwalloc(w->ww_nline, w->ww_w.nc, sizeof (union ww_char));
+       if (w->ww_buf == 0)
+               goto bad;
+       for (i = 0; i < w->ww_nline; i++)
+               for (j = 0; j < w->ww_w.nc; j++)
+                       w->ww_buf[i][j].c_w = ' ';
+
+       w->ww_nvis = (short *)malloc((unsigned) w->ww_w.nr * sizeof (short));
+       if (w->ww_nvis == 0)
                goto bad;
                goto bad;
-       Woncursor(w->ww_win, 0);                /* don't show cursor */
-       w->ww_mode = mode;
-       w->ww_ident = id;
-       w->ww_w.col = w->ww_i.col = w->ww_o.col = col;
-       w->ww_w.row = w->ww_i.row = w->ww_o.row = row;
-       w->ww_w.ncol = w->ww_i.ncol = w->ww_o.ncol = ncol;
-       w->ww_w.nrow = w->ww_i.nrow = w->ww_o.nrow = nrow;
-       w->ww_next = wwhead;
-       w->ww_state = WW_INITIAL;
-       wwhead = w;
+       nvis = m ? 0 : w->ww_w.nc;
+       for (i = 0; i < w->ww_w.nr; i++)
+               w->ww_nvis[i] = nvis;
+
+       w->ww_state = WWS_INITIAL;
        return w;
 bad:
        if (w != 0) {
        return w;
 bad:
        if (w != 0) {
-               close(w->ww_tty);
-               close(w->ww_pty);
+               if (w->ww_win != 0)
+                       wwfree(w->ww_win, nrow);
+               if (w->ww_cov != 0)
+                       wwfree(w->ww_cov, nrow);
+               if (w->ww_buf != 0)
+                       wwfree((char **)w->ww_buf, w->ww_nline);
+               if (w->ww_nvis != 0)
+                       free((char *)w->ww_nvis);
+               (void) close(w->ww_tty);
+               (void) close(w->ww_pty);
                cfree((char *)w);
        }
        return 0;
 }
                cfree((char *)w);
        }
        return 0;
 }
-
-wwgetpty(w)
-       register struct ww *w;
-{
-       register char c;
-       register char *line;
-       register int i;
-#define PTY "/dev/ptyXX"
-
-       for (c = 'p'; c <= 's'; c++) {
-               struct stat stb;
-
-               line = PTY;
-               line[sizeof PTY - 6] = 'p';
-               line[sizeof PTY - 3] = c;
-               line[sizeof PTY - 2] = '0';
-               if (stat(line, &stb) < 0)
-                       break;
-               for (i = 0; i < 16; i++) {
-                       line[sizeof PTY - 6] = 'p';
-                       line[sizeof PTY - 2] = "0123456789abcdef"[i];
-                       w->ww_pty = open(line, 2);
-                       if (w->ww_pty >= 0) {
-                               line[sizeof PTY - 6] = 't';
-                               w->ww_tty = open(line, 2);
-                               if (w->ww_tty >= 0)
-                                       goto good;
-                               close(w->ww_pty);
-                       }
-               }
-       }
-       return -1;
-good:
-       strcpy(w->ww_ttyname, line);
-       return 0;
-bad:
-       close(w->ww_pty);
-       close(w->ww_tty);
-       return -1;
-}
index da39cba..09b6787 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwputc.c    2.1 83/07/30";
+static char *sccsid = "@(#)wwputc.c    2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
index df59212..3b1ace6 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwputs.c    2.1 83/07/30";
+static char *sccsid = "@(#)wwputs.c    2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -12,5 +12,5 @@ struct ww *w;
 
        while (*p++)
                ;
 
        while (*p++)
                ;
-       wwwrite(w, s, p - s - 1);
+       return wwwrite(w, s, p - s - 1);
 }
 }
index 896e703..6b1bbb0 100644 (file)
@@ -1,12 +1,9 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwspawn.c   2.1 83/07/30";
+static char *sccsid = "@(#)wwspawn.c   2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 
 #endif
 
 #include "ww.h"
 
-extern int _wwdtablesize;
-extern char _wwtermcap[];
-
 wwfork(wp)
 register struct ww *wp;
 {
 wwfork(wp)
 register struct ww *wp;
 {
@@ -14,12 +11,12 @@ register struct ww *wp;
        case -1:
                return -1;
        case 0:
        case -1:
                return -1;
        case 0:
-               wp->ww_state = WW_INCHILD;
+               wp->ww_state = WWS_INCHILD;
                wwenviron(wp);
                return 0;
        default:
                wwenviron(wp);
                return 0;
        default:
-               wp->ww_state = WW_HASPROC;
-               close(wp->ww_tty);
+               wp->ww_state = WWS_HASPROC;
+               (void) close(wp->ww_tty);
                wp->ww_tty = -1;
                return wp->ww_pid;
        }
                wp->ww_tty = -1;
                return wp->ww_pid;
        }
@@ -34,7 +31,6 @@ register struct ww *wp;
 static char *env[100];
 static char buf[1024];
 extern char **environ;
 static char *env[100];
 static char buf[1024];
 extern char **environ;
-extern char _wwkeys[];
 
 wwenviron(wp)
 register struct ww *wp;
 
 wwenviron(wp)
 register struct ww *wp;
@@ -43,16 +39,16 @@ register struct ww *wp;
        register char **p, **q;
        char **termcap = 0;
 
        register char **p, **q;
        char **termcap = 0;
 
-       dup2(wp->ww_tty, 0);
-       dup2(wp->ww_tty, 1);
-       dup2(wp->ww_tty, 2);
-       for (i = _wwdtablesize - 1; i > 2; i--)
-               close(i);
+       (void) dup2(wp->ww_tty, 0);
+       (void) dup2(wp->ww_tty, 1);
+       (void) dup2(wp->ww_tty, 2);
+       for (i = wwdtablesize - 1; i > 2; i--)
+               (void) close(i);
 
        i = open("/dev/tty");
 
        i = open("/dev/tty");
-       ioctl(i, TIOCNOTTY, 0);
-       close(i);
-       open(wp->ww_ttyname, 0);
+       (void) ioctl(i, (int)TIOCNOTTY, (char *)0);
+       (void) close(i);
+       (void) open(wp->ww_ttyname, 0);
 
        for (p = environ, q = env; *p; p++, q++) {
                if (strncmp(*p, "TERM=", 5) == 0)
 
        for (p = environ, q = env; *p; p++, q++) {
                if (strncmp(*p, "TERM=", 5) == 0)
@@ -65,7 +61,7 @@ register struct ww *wp;
        if (termcap == 0)
                termcap = q++;
        *q = 0;
        if (termcap == 0)
                termcap = q++;
        *q = 0;
-       *termcap = sprintf(buf, TERMCAP, wp->ww_i.ncol, wp->ww_i.nrow);
-       strcat(buf, _wwkeys);
+       *termcap = sprintf(buf, TERMCAP, wp->ww_w.nc, wp->ww_w.nr);
+       (void) strcat(buf, wwkeys);
        environ = env;
 }
        environ = env;
 }
index 05e0623..4b617a8 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwtty.c     2.1 83/07/30";
+static char *sccsid = "@(#)wwtty.c     2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -7,17 +7,17 @@ static        char *sccsid = "@(#)wwtty.c     2.1 83/07/30";
 wwgettty(d, t)
 register struct ww_tty *t;
 {
 wwgettty(d, t)
 register struct ww_tty *t;
 {
-       if (ioctl(d, TIOCGETP, &t->ww_sgttyb) < 0)
+       if (ioctl(d, TIOCGETP, (char *)&t->ww_sgttyb) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCGETC, &t->ww_tchars) < 0)
+       if (ioctl(d, TIOCGETC, (char *)&t->ww_tchars) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCGLTC, &t->ww_ltchars) < 0)
+       if (ioctl(d, TIOCGLTC, (char *)&t->ww_ltchars) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCLGET, &t->ww_lmode) < 0)
+       if (ioctl(d, TIOCLGET, (char *)&t->ww_lmode) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCGETD, &t->ww_ldisc) < 0)
+       if (ioctl(d, TIOCGETD, (char *)&t->ww_ldisc) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCGPGRP, &t->ww_pgrp) < 0)
+       if (ioctl(d, TIOCGPGRP, (char *)&t->ww_pgrp) < 0)
                return -1;
        return 0;
 }
                return -1;
        return 0;
 }
@@ -25,17 +25,17 @@ register struct ww_tty *t;
 wwsettty(d, t)
 register struct ww_tty *t;
 {
 wwsettty(d, t)
 register struct ww_tty *t;
 {
-       if (ioctl(d, TIOCSETP, &t->ww_sgttyb) < 0)
+       if (ioctl(d, TIOCSETP, (char *)&t->ww_sgttyb) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCSETC, &t->ww_tchars) < 0)
+       if (ioctl(d, TIOCSETC, (char *)&t->ww_tchars) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCSLTC, &t->ww_ltchars) < 0)
+       if (ioctl(d, TIOCSLTC, (char *)&t->ww_ltchars) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCLSET, &t->ww_lmode) < 0)
+       if (ioctl(d, TIOCLSET, (char *)&t->ww_lmode) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCSETD, &t->ww_ldisc) < 0)
+       if (ioctl(d, TIOCSETD, (char *)&t->ww_ldisc) < 0)
                return -1;
                return -1;
-       if (ioctl(d, TIOCSPGRP, &t->ww_pgrp) < 0)
+       if (ioctl(d, TIOCSPGRP, (char *)&t->ww_pgrp) < 0)
                return -1;
        return 0;
 }
                return -1;
        return 0;
 }
index db4d2c9..f931939 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwwrite.c   2.1 83/07/30";
+static char *sccsid = "@(#)wwwrite.c   2.1.1.1 83/08/09";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -13,32 +13,60 @@ register char *p;
 register n;
 {
        register char c;
 register n;
 {
        register char c;
+       int oldn = n;
 
 
-       if (w == 0 || w->ww_win == 0)
+       if (w == 0)
                return -1;
        wwnwrite++;
        wwnwritec += n;
                return -1;
        wwnwrite++;
        wwnwritec += n;
-       while (n-- > 0) {
+       while (--n >= 0) {
                c = *p++ & 0x7f;
                switch (w->ww_wstate) {
                case 0:
                        if (c >= ' ' && c < 0x7f) {
                c = *p++ & 0x7f;
                switch (w->ww_wstate) {
                case 0:
                        if (c >= ' ' && c < 0x7f) {
+                               register i, j, cc;
+
                                if (w->ww_insert)
                                if (w->ww_insert)
-                                       Winschars(w->ww_win, 1);
-                               Wputc(c, w->ww_win);
+                                       wwinschar(w, 1);
+                               cc = w->ww_buf[w->ww_scroll + w->ww_cur.r]
+                                       [w->ww_cur.c].c_w = c;
+                               i = wwcurrow(w);
+                               j = wwcurcol(w);
+                               if (wwsmap[i][j] == w->ww_index) {
+                                       cc = wwns[i][j].c_w = cc
+                                               ^ w->ww_win[w->ww_cur.r]
+                                               [w->ww_cur.c] << WWC_MSHIFT;
+                               }
+               right:
+                               if (++w->ww_cur.c >= w->ww_w.nc) {
+                                       w->ww_cur.c = 0;
+                                       goto lf;
+                               }
                                break;
                        }
                        switch (c) {
                        case '\n':
                                break;
                        }
                        switch (c) {
                        case '\n':
-                               Wputc(c, w->ww_win);
-                               if (w->ww_refresh)
-                                       Wrefresh(1);
+                               if (w->ww_mapnl)
+                                       w->ww_cur.c = 0;
+               lf:
+                               if (++w->ww_cur.r >= w->ww_w.nr) {
+                                       w->ww_cur.r = w->ww_w.nr - 1;
+                                       wwdelline(w, 0);
+                               }
                                break;
                        case '\t':
                                break;
                        case '\t':
+                               w->ww_cur.c |= 7;
+                               goto right;
+                               break;
                        case '\b':
                        case '\b':
+                               if (--w->ww_cur.c < 0)
+                                       w->ww_cur.c = 0;
+                               break;
                        case '\r':
                        case '\r':
+                               w->ww_cur.c = 0;
+                               break;
                        case CTRL(g):
                        case CTRL(g):
-                               Wputc(c, w->ww_win);
+                               wwbell();
                                break;
                        case CTRL([):
                                w->ww_wstate = 1;
                                break;
                        case CTRL([):
                                w->ww_wstate = 1;
@@ -52,41 +80,35 @@ register n;
                                w->ww_insert = 1;
                                break;
                        case 'A':
                                w->ww_insert = 1;
                                break;
                        case 'A':
-                               Wcurup(w->ww_win, 1);
+                               if (--w->ww_cur.r < 0)
+                                       w->ww_cur.r = 0;
                                break;
                        case 'B':
                                break;
                        case 'B':
-                               Wcurdown(w->ww_win, 1);
-                               break;
+                               goto lf;
                        case 'C':
                        case 'C':
-                               Wcurright(w->ww_win, 1);
-                               break;
+                               goto right;
                        case 'E':
                        case 'E':
-                               WWcursor(w->ww_win, 0, 0);
-                               Wclear(w->ww_win, 2);
-                               /* always refresh */
-                               Wrefresh(1);
+                               w->ww_cur.c = w->ww_cur.r = 0;
+                               wwclreos(w);
                                break;
                        case 'H':
                                break;
                        case 'H':
-                               WWcursor(w->ww_win, 0, 0);
+                               w->ww_cur.c = w->ww_cur.r = 0;
                                break;
                        case 'J':
                                break;
                        case 'J':
-                               Wclear(w->ww_win, 0);
+                               wwclreos(w);
                                break;
                        case 'K':
                                break;
                        case 'K':
-                               Wclearline(w->ww_win, 0);
+                               wwclreol(w, w->ww_scroll + w->ww_cur.r,
+                                       w->ww_cur.c, 0);
                                break;
                        case 'L':
                                break;
                        case 'L':
-                               Winslines(w->ww_win, 1);
-                               if (w->ww_refresh)
-                                       Wrefresh(1);
+                               wwinsline(w);
                                break;
                        case 'M':
                                break;
                        case 'M':
-                               Wdellines(w->ww_win, 1);
-                               if (w->ww_refresh)
-                                       Wrefresh(1);
+                               wwdelline(w, w->ww_scroll + w->ww_cur.r);
                                break;
                        case 'N':
                                break;
                        case 'N':
-                               Wdelchars(w->ww_win, 1);
+                               wwdelchar(w);
                                break;
                        case 'O':
                                w->ww_insert = 0;
                                break;
                        case 'O':
                                w->ww_insert = 0;
@@ -97,15 +119,14 @@ register n;
                        }
                        break;
                case 2:
                        }
                        break;
                case 2:
-                       WWcursor(w->ww_win, (c - ' ') % w->ww_i.nrow,
-                               w->ww_win->w_cursor.col);
+                       w->ww_cur.r = (c - ' ') % w->ww_w.nr;
                        w->ww_wstate++;
                        break;
                case 3:
                        w->ww_wstate++;
                        break;
                case 3:
-                       WWcursor(w->ww_win, w->ww_win->w_cursor.row,
-                               (c - ' ') % w->ww_i.ncol);
+                       w->ww_cur.c = (c - ' ') % w->ww_w.nc;
                        w->ww_wstate = 0;
                        break;
                }
        }
                        w->ww_wstate = 0;
                        break;
                }
        }
+       return oldn - n;
 }
 }