interrupt driven input
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sun, 4 Mar 1984 14:47:55 +0000 (06:47 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sun, 4 Mar 1984 14:47:55 +0000 (06:47 -0800)
SCCS-vsn: usr.bin/window/main.c 3.15
SCCS-vsn: usr.bin/window/wwend.c 3.4
SCCS-vsn: usr.bin/window/wwinit.c 3.15
SCCS-vsn: usr.bin/window/wwputc.c 3.2
SCCS-vsn: usr.bin/window/wwputs.c 3.2
SCCS-vsn: usr.bin/window/ww.h 3.26
SCCS-vsn: usr.bin/window/cmd.c 3.21
SCCS-vsn: usr.bin/window/cmd1.c 3.21
SCCS-vsn: usr.bin/window/wwtty.c 3.6
SCCS-vsn: usr.bin/window/wwwrite.c 3.18
SCCS-vsn: usr.bin/window/wwgets.c 3.4
SCCS-vsn: usr.bin/window/cmd2.c 3.23
SCCS-vsn: usr.bin/window/defs.h 3.9
SCCS-vsn: usr.bin/window/wwprintf.c 3.2
SCCS-vsn: usr.bin/window/cmd3.c 3.10
SCCS-vsn: usr.bin/window/cmd4.c 3.8
SCCS-vsn: usr.bin/window/cmd5.c 3.10
SCCS-vsn: usr.bin/window/startup.c 3.9
SCCS-vsn: usr.bin/window/error.c 3.7
SCCS-vsn: usr.bin/window/:ww 1.8
SCCS-vsn: usr.bin/window/cmd6.c 3.8
SCCS-vsn: usr.bin/window/ttinit.c 3.8
SCCS-vsn: usr.bin/window/tt.h 3.10
SCCS-vsn: usr.bin/window/tth19.c 3.12
SCCS-vsn: usr.bin/window/wwdata.c 3.9
SCCS-vsn: usr.bin/window/wwflush.c 3.5
SCCS-vsn: usr.bin/window/wwupdate.c 3.12
SCCS-vsn: usr.bin/window/tttermcap.c 3.3
SCCS-vsn: usr.bin/window/ttgeneric.c 3.22
SCCS-vsn: usr.bin/window/mloop.c 3.3
SCCS-vsn: usr.bin/window/wwiomux.c 3.8
SCCS-vsn: usr.bin/window/context.h 3.4
SCCS-vsn: usr.bin/window/win.c 3.3

32 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/cmd3.c
usr/src/usr.bin/window/cmd4.c
usr/src/usr.bin/window/cmd5.c
usr/src/usr.bin/window/cmd6.c
usr/src/usr.bin/window/context.h
usr/src/usr.bin/window/defs.h
usr/src/usr.bin/window/error.c
usr/src/usr.bin/window/main.c
usr/src/usr.bin/window/mloop.c
usr/src/usr.bin/window/startup.c
usr/src/usr.bin/window/tt.h
usr/src/usr.bin/window/ttgeneric.c
usr/src/usr.bin/window/tth19.c
usr/src/usr.bin/window/ttinit.c
usr/src/usr.bin/window/tttermcap.c
usr/src/usr.bin/window/win.c
usr/src/usr.bin/window/ww.h
usr/src/usr.bin/window/wwdata.c
usr/src/usr.bin/window/wwend.c
usr/src/usr.bin/window/wwflush.c
usr/src/usr.bin/window/wwgets.c
usr/src/usr.bin/window/wwinit.c
usr/src/usr.bin/window/wwiomux.c
usr/src/usr.bin/window/wwprintf.c
usr/src/usr.bin/window/wwputc.c
usr/src/usr.bin/window/wwputs.c
usr/src/usr.bin/window/wwtty.c
usr/src/usr.bin/window/wwupdate.c
usr/src/usr.bin/window/wwwrite.c

index be1fe37..5bd1b60 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd.c       3.20 84/01/16";
+static char *sccsid = "@(#)cmd.c       3.21 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -16,7 +16,7 @@ docmd()
        for (;;) {
                while ((c = wwgetc()) >= 0) {
                        if (!terse)
        for (;;) {
                while ((c = wwgetc()) >= 0) {
                        if (!terse)
-                               (void) wwputs("\r\n", cmdwin);
+                               wwputs("\r\n", cmdwin);
                        switch (c) {
                        default:
                                if (c == escapec)
                        switch (c) {
                        default:
                                if (c == escapec)
@@ -47,7 +47,7 @@ docmd()
                                }
                                setselwin(w);
                                if (checkproc(selwin) >= 0)
                                }
                                setselwin(w);
                                if (checkproc(selwin) >= 0)
-                                       incmd = 0;
+                                        wwcurwin = selwin;
                                break;
                        case '%':
                                if ((w = getwin()) != 0)
                                break;
                        case '%':
                                if ((w = getwin()) != 0)
@@ -57,7 +57,7 @@ docmd()
                                if (lastselwin != 0) {
                                        setselwin(lastselwin);
                                        if (checkproc(selwin) >= 0)
                                if (lastselwin != 0) {
                                        setselwin(lastselwin);
                                        if (checkproc(selwin) >= 0)
-                                               incmd = 0;
+                                               wwcurwin = selwin;
                                } else
                                        error("No previous window.");
                                break;
                                } else
                                        error("No previous window.");
                                break;
@@ -138,7 +138,7 @@ docmd()
                                break;
                        case CTRL([):
                                if (checkproc(selwin) >= 0)
                                break;
                        case CTRL([):
                                if (checkproc(selwin) >= 0)
-                                       incmd = 0;
+                                       wwcurwin = selwin;
                                break;
                        case CTRL(z):
                                wwsuspend();
                                break;
                        case CTRL(z):
                                wwsuspend();
@@ -169,21 +169,21 @@ docmd()
                                        if (checkproc(selwin) >= 0) {
                                                (void) write(selwin->ww_pty,
                                                        &escapec, 1);
                                        if (checkproc(selwin) >= 0) {
                                                (void) write(selwin->ww_pty,
                                                        &escapec, 1);
-                                               incmd = 0;
+                                               wwcurwin = selwin;
                                        }
                                } else {
                                        if (!terse)
                                        }
                                } else {
                                        if (!terse)
-                                               wwbell();
+                                               wwputc(CTRL(g), cmdwin);
                                        error("Type ? for help.");
                                }
                        }
                }
                                        error("Type ? for help.");
                                }
                        }
                }
-               if (!incmd || quit)
+               if (wwcurwin != 0 || quit)
                        break;
                if (terse)
                        wwsetcursor(0, 0);
                else {
                        break;
                if (terse)
                        wwsetcursor(0, 0);
                else {
-                       (void) wwputs("Command: ", cmdwin);
+                       wwputs("Command: ", cmdwin);
                        wwcurtowin(cmdwin);
                }
                while (wwpeekc() < 0)
                        wwcurtowin(cmdwin);
                }
                while (wwpeekc() < 0)
@@ -205,7 +205,7 @@ getwin()
        struct ww *w = 0;
 
        if (!terse)
        struct ww *w = 0;
 
        if (!terse)
-               (void) wwputs("Which window? ", cmdwin);
+               wwputs("Which window? ", cmdwin);
        wwcurtowin(cmdwin);
        while ((c = wwgetc()) < 0)
                wwiomux();
        wwcurtowin(cmdwin);
        while ((c = wwgetc()) < 0)
                wwiomux();
@@ -218,9 +218,9 @@ getwin()
        else if (c >= '1' && c < NWINDOW + '1')
                w = window[c - '1'];
        if (w == 0)
        else if (c >= '1' && c < NWINDOW + '1')
                w = window[c - '1'];
        if (w == 0)
-               wwbell();
+               wwputc(CTRL(g), cmdwin);
        if (!terse)
        if (!terse)
-               (void) wwputs("\r\n", cmdwin);
+               wwputs("\r\n", cmdwin);
        return w;
 }
 
        return w;
 }
 
index 2e22b06..2772d34 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd1.c      3.20 84/01/16";
+static char *sccsid = "@(#)cmd1.c      3.21 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -12,7 +12,7 @@ c_window()
        if ((id = findid()) < 0)
                return;
        if (!terse)
        if ((id = findid()) < 0)
                return;
        if (!terse)
-               (void) wwputs("Upper left corner: ", cmdwin);
+               wwputs("Upper left corner: ", cmdwin);
        col = 0;
        row = 1;
        wwadd(boxwin, framewin->ww_back);
        col = 0;
        row = 1;
        wwadd(boxwin, framewin->ww_back);
@@ -38,7 +38,7 @@ c_window()
                break;
        }
        if (!terse)
                break;
        }
        if (!terse)
-               (void) wwputs("\r\nLower right corner: ", cmdwin);
+               wwputs("\r\nLower right corner: ", cmdwin);
        xcol = col;
        xrow = row;
        for (;;) {
        xcol = col;
        xrow = row;
        for (;;) {
@@ -66,7 +66,7 @@ c_window()
        }
        wwdelete(boxwin);
        if (!terse)
        }
        wwdelete(boxwin);
        if (!terse)
-               (void) wwputs("\r\n", cmdwin);
+               wwputs("\r\n", cmdwin);
        wwcurtowin(cmdwin);
        (void) openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline,
                (char *) 0);
        wwcurtowin(cmdwin);
        (void) openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline,
                (char *) 0);
@@ -122,14 +122,14 @@ int maxrow, maxcol;
                        break;
                case CTRL([):
                        if (!terse)
                        break;
                case CTRL([):
                        if (!terse)
-                               (void) wwputs("\r\nCancelled.  ", cmdwin);
+                               wwputs("\r\nCancelled.  ", cmdwin);
                        return 3;
                case '\r':
                        return 2;
                default:
                        if (!terse)
                        return 3;
                case '\r':
                        return 2;
                default:
                        if (!terse)
-                               (void) wwputs("\r\nType [hjklHJKL] to move, return to enter position, escape to cancel.", cmdwin);
-                       wwbell();
+                               wwputs("\r\nType [hjklHJKL] to move, return to enter position, escape to cancel.", cmdwin);
+                       wwputc(CTRL(g), cmdwin);
                }
        }
        return oldrow != *row || oldcol != *col;
                }
        }
        return oldrow != *row || oldcol != *col;
index d1ea784..05c3644 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd2.c      3.22 84/01/16";
+static char *sccsid = "@(#)cmd2.c      3.23 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -54,7 +54,7 @@ c_help()
                error("Can't open help window: %s.", wwerror());
                return;
        }
                error("Can't open help window: %s.", wwerror());
                return;
        }
-       (void) wwprintf(w, "The escape character is %s, which gets you into command mode.\n\n",
+       wwprintf(w, "The escape character is %s, which gets you into command mode.\n\n",
                unctrl(escapec));
        if (help_print(w, "Short commands", help_shortcmd) >= 0)
                (void) help_print(w, "Long commands", help_longcmd);
                unctrl(escapec));
        if (help_print(w, "Short commands", help_shortcmd) >= 0)
                (void) help_print(w, "Long commands", help_longcmd);
@@ -66,15 +66,15 @@ register struct ww *w;
 char *name;
 register char **list;
 {
 char *name;
 register char **list;
 {
-       (void) wwprintf(w, "%s:\n\n", name);
+       wwprintf(w, "%s:\n\n", name);
        while (*list)
                switch (more(w, 0)) {
                case 0:
        while (*list)
                switch (more(w, 0)) {
                case 0:
-                       (void) wwputs(*list++, w);
-                       (void) wwputc('\n', w);
+                       wwputs(*list++, w);
+                       wwputc('\n', w);
                        break;
                case 1:
                        break;
                case 1:
-                       (void) wwprintf(w, "%s: (continued)\n\n", name);
+                       wwprintf(w, "%s: (continued)\n\n", name);
                        break;
                case 2:
                        return -1;
                        break;
                case 2:
                        return -1;
@@ -90,14 +90,13 @@ 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 = openiwin(6, "Timing and Resource Usage")) == 0) {
                error("Can't open time window: %s.", wwerror());
                return;
        }
 
 
        if ((w = openiwin(6, "Timing and Resource Usage")) == 0) {
                error("Can't open time window: %s.", wwerror());
                return;
        }
 
-       (void) gettimeofday(&timeval, &timezone);
+       (void) gettimeofday(&timeval, (struct timezone *)0);
        timeval.tv_sec -= starttime.tv_sec;
        if ((timeval.tv_usec -= starttime.tv_usec) < 0) {
                timeval.tv_sec--;
        timeval.tv_sec -= starttime.tv_sec;
        if ((timeval.tv_usec -= starttime.tv_usec) < 0) {
                timeval.tv_sec--;
@@ -105,15 +104,15 @@ c_time(flag)
        }
        (void) getrusage(flag, &rusage);
 
        }
        (void) getrusage(flag, &rusage);
 
-       (void) wwprintf(w, "time\t\tutime\t\tstime\t\tmaxrss\tixrss\tidrss\tisrss\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\n",
+       wwprintf(w, "time\t\tutime\t\tstime\t\tmaxrss\tixrss\tidrss\tisrss\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\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);
-       (void) wwprintf(w, "minflt\tmajflt\tnswap\tinblk\toublk\tmsgsnd\tmsgrcv\tnsigs\tnvcsw\tnivcsw\n");
-       (void) wwprintf(w, "%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\n",
+       wwprintf(w, "minflt\tmajflt\tnswap\tinblk\toublk\tmsgsnd\tmsgrcv\tnsigs\tnvcsw\tnivcsw\n");
+       wwprintf(w, "%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\t%D\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_minflt, rusage.ru_majflt, rusage.ru_nswap,
                rusage.ru_inblock, rusage.ru_oublock,
                rusage.ru_msgsnd, rusage.ru_msgrcv, rusage.ru_nsignals,
@@ -157,22 +156,29 @@ c_stat()
 {
        register struct ww *w;
 
 {
        register struct ww *w;
 
-       if ((w = openiwin(8, "IO Statistics")) == 0) {
+       if ((w = openiwin(14, "IO Statistics")) == 0) {
                error("Can't open statistics window: %s.", wwerror());
                return;
        }
                error("Can't open statistics window: %s.", wwerror());
                return;
        }
-       (void) wwprintf(w, "nwrite\tnwritec\tnupdate\tnupdlin\tnupdmis\tnmajlin\tnmajmis\n");
-       (void) wwprintf(w, "%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
-               wwnwrite, wwnwritec,
+       wwprintf(w, "ttflush\twrite\terror\tzero\tchar\n");
+       wwprintf(w, "%d\t%d\t%d\t%d\t%d\n",
+               wwnflush, wwnwr, wwnwre, wwnwrz, wwnwrc);
+       wwprintf(w, "wwwrite\tattmpt\tchar\n");
+       wwprintf(w, "%d\t%d\t%d\n",
+               wwnwwr, wwnwwra, wwnwwrc);
+       wwprintf(w, "wwupdat\tline\tmiss\tmajor\tmiss\n");
+       wwprintf(w, "%d\t%d\t%d\t%d\t%d\n",
                wwnupdate, wwnupdline, wwnupdmiss, wwnmajline, wwnmajmiss);
                wwnupdate, wwnupdline, wwnupdmiss, wwnmajline, wwnmajmiss);
-       (void) wwprintf(w, "nsel\tnselz\tnsele\tnread\tnreadz\tnreade\tnreadc\n");
-       (void) wwprintf(w, "%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
-               wwnselect, wwnselectz, wwnselecte,
-               wwnread, wwnreadz, wwnreade, wwnreadc);
-       (void) wwprintf(w, "nwread\tnwreadz\tnwreade\tnwreadd\tnwreadc\tnwreadp\n");
-       (void) wwprintf(w, "%d\t%d\t%d\t%d\t%d\t%d\n",
-               wwnwread, wwnwreadz, wwnwreade,
-               wwnwreadd, wwnwreadc, wwnwreadp);
+       wwprintf(w, "select\terror\tzero\n");
+       wwprintf(w, "%d\t%d\t%d\n",
+               wwnselect, wwnselecte, wwnselectz);
+       wwprintf(w, "read\terror\tzero\tchar\n");
+       wwprintf(w, "%d\t%d\t%d\t%d\n",
+               wwnread, wwnreade, wwnreadz, wwnreadc);
+       wwprintf(w, "ptyread\terror\tzero\tcontrol\tdata\tchar\n");
+       wwprintf(w, "%d\t%d\t%d\t%d\t%d\t%d\n",
+               wwnwread, wwnwreade, wwnwreadz,
+               wwnwreadp, wwnwreadd, wwnwreadc);
        waitnl(w);
        closeiwin(w);
 }
        waitnl(w);
        closeiwin(w);
 }
@@ -197,7 +203,7 @@ c_list()
        for (i = 0; i < NWINDOW; i++) {
                if ((wp = window[i]) == 0)
                        continue;
        for (i = 0; i < NWINDOW; i++) {
                if ((wp = window[i]) == 0)
                        continue;
-               (void) wwprintf(w, "%c %c %-13s %-.*s\n",
+               wwprintf(w, "%c %c %-13s %-.*s\n",
                        wp == selwin ? '*' : ' ',
                        i + '1',
                        wp->ww_state == WWS_HASPROC ? "" : "(No process)",
                        wp == selwin ? '*' : ' ',
                        i + '1',
                        wp->ww_state == WWS_HASPROC ? "" : "(No process)",
@@ -212,15 +218,15 @@ c_quit()
 {
        if (terse)
                wwadd(cmdwin, &wwhead);
 {
        if (terse)
                wwadd(cmdwin, &wwhead);
-       (void) wwputs("Really quit [yn]? ", cmdwin);
+       wwputs("Really quit [yn]? ", cmdwin);
        wwcurtowin(cmdwin);
        while (wwpeekc() < 0)
                wwiomux();
        if (wwgetc() == 'y') {
        wwcurtowin(cmdwin);
        while (wwpeekc() < 0)
                wwiomux();
        if (wwgetc() == 'y') {
-               (void) wwputs("Yes", cmdwin);
+               wwputs("Yes", cmdwin);
                quit++;
        } else
                quit++;
        } else
-               (void) wwputs("\r\n", cmdwin);
+               wwputs("\r\n", cmdwin);
        if (terse && !quit)
                wwdelete(cmdwin);
 }
        if (terse && !quit)
                wwdelete(cmdwin);
 }
index 9b00c42..6aa80d5 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd3.c      3.9 84/01/13";
+static char *sccsid = "@(#)cmd3.c      3.10 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -27,16 +27,16 @@ register struct var *r;
 {
        if (more(w, 0) == 2)
                return -1;
 {
        if (more(w, 0) == 2)
                return -1;
-       (void) wwprintf(w, "%16s\t", r->r_name);
+       wwprintf(w, "%16s\t", r->r_name);
        switch (r->r_val.v_type) {
        case V_STR:
        switch (r->r_val.v_type) {
        case V_STR:
-               (void) wwprintf(w, "%s\n", r->r_val.v_str);
+               wwprintf(w, "%s\n", r->r_val.v_str);
                break;
        case V_NUM:
                break;
        case V_NUM:
-               (void) wwprintf(w, "%d\n", r->r_val.v_num);
+               wwprintf(w, "%d\n", r->r_val.v_num);
                break;
        case V_ERR:
                break;
        case V_ERR:
-               (void) wwprintf(w, "ERROR\n");
+               wwprintf(w, "ERROR\n");
                break;
        }
        return 0;
                break;
        }
        return 0;
index fe84f29..cbea99c 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd4.c      3.7 84/01/16";
+static char *sccsid = "@(#)cmd4.c      3.8 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -32,9 +32,9 @@ c_show()
                                wwiomux();
                                continue;
                        default:
                                wwiomux();
                                continue;
                        default:
-                               wwbell();
+                               wwputc(CTRL(g), cmdwin);
                                if (!terse) {
                                if (!terse) {
-                                       (void) wwputs("\rType return to continue, escape to select.", cmdwin);
+                                       wwputs("\rType return to continue, escape to select.", cmdwin);
                                        wwdelete(cmdwin);
                                        wwadd(cmdwin, &wwhead);
                                }
                                        wwdelete(cmdwin);
                                        wwadd(cmdwin, &wwhead);
                                }
@@ -50,7 +50,7 @@ out:
                if (!terse) {
                        wwdelete(cmdwin);
                        wwadd(cmdwin, &wwhead);
                if (!terse) {
                        wwdelete(cmdwin);
                        wwadd(cmdwin, &wwhead);
-                       (void) wwputs("\r\n", cmdwin);
+                       wwputs("\r\n", cmdwin);
                }
        }
 }
                }
        }
 }
@@ -61,9 +61,9 @@ c_colon()
 
        if (terse)
                wwadd(cmdwin, &wwhead);
 
        if (terse)
                wwadd(cmdwin, &wwhead);
-       (void) wwputc(':', cmdwin);
+       wwputc(':', cmdwin);
        wwgets(buf, wwncol - 3, cmdwin);
        wwgets(buf, wwncol - 3, cmdwin);
-       (void) wwputs("\r\n", cmdwin);
+       wwputs("\r\n", cmdwin);
        if (terse)
                wwdelete(cmdwin);
        else
        if (terse)
                wwdelete(cmdwin);
        else
index 40a49e9..2169b93 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd5.c      3.9 84/01/16";
+static char *sccsid = "@(#)cmd5.c      3.10 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -45,7 +45,7 @@ register struct ww *w;
        }
        wwdelete(boxwin);
        if (!terse)
        }
        wwdelete(boxwin);
        if (!terse)
-               (void) wwputs("\r\n", cmdwin);
+               wwputs("\r\n", cmdwin);
        wwcurtowin(cmdwin);
        movewin(w, row, col);
 }
        wwcurtowin(cmdwin);
        movewin(w, row, col);
 }
index d6a933a..970ea0b 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd6.c      3.7 84/01/16";
+static char *sccsid = "@(#)cmd6.c      3.8 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -14,12 +14,12 @@ c_debug()
        register struct ww *w;
 
        if (!terse)
        register struct ww *w;
 
        if (!terse)
-               (void) wwputs("[m(smap) n(ns) o(os) s(string) v(nvis) w(win)]? ", cmdwin);
+               wwputs("[m(smap) n(ns) o(os) s(string) v(nvis) w(win)]? ", cmdwin);
        wwcurtowin(cmdwin);
        while (wwpeekc() < 0)
                wwiomux();
        if (!terse)
        wwcurtowin(cmdwin);
        while (wwpeekc() < 0)
                wwiomux();
        if (!terse)
-               (void) wwputs("\r\n", cmdwin);
+               wwputs("\r\n", cmdwin);
        switch (wwgetc()) {
        case 'm':
                wwdumpsmap();
        switch (wwgetc()) {
        case 'm':
                wwdumpsmap();
@@ -42,7 +42,7 @@ c_debug()
                        wwdumpwin(w);
                break;
        default:
                        wwdumpwin(w);
                break;
        default:
-               wwbell();
+               wwputc(CTRL(g), cmdwin);
        }
 }
 
        }
 }
 
@@ -59,7 +59,7 @@ debug_str()
        for (s = str_head.s_forw; s != &str_head; s = s->s_forw) {
                if (more(w, 0) == 2)
                        goto out;
        for (s = str_head.s_forw; s != &str_head; s = s->s_forw) {
                if (more(w, 0) == 2)
                        goto out;
-               (void) wwprintf(w, "(0x%x)\t\"%s\"\n", s->s_data, s->s_data);
+               wwprintf(w, "(0x%x)\t\"%s\"\n", s->s_data, s->s_data);
        }
        waitnl(w);
 out:
        }
        waitnl(w);
 out:
index acd8473..b62df5b 100644 (file)
@@ -1,7 +1,9 @@
 /*
 /*
- *     @(#)context.h   3.3 84/01/13
+ *     @(#)context.h   3.4 84/03/03
  */
 
  */
 
+#include <stdio.h>
+
 struct context {
        struct context *x_link;         /* nested contexts */
        char x_type;                    /* tag for union */
 struct context {
        struct context *x_link;         /* nested contexts */
        char x_type;                    /* tag for union */
index 3358dca..b849ce8 100644 (file)
@@ -1,9 +1,8 @@
 /*
 /*
- *     @(#)defs.h      3.8 84/01/16    
+ *     @(#)defs.h      3.9 84/03/03    
  */
 
 #include "ww.h"
  */
 
 #include "ww.h"
-#include <signal.h>
 #ifndef O_4_1A
 #include <sys/time.h>
 #include <sys/resource.h>
 #ifndef O_4_1A
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -24,15 +23,13 @@ struct ww *boxwin;          /* the window for the box */
 
 char *shell;                   /* the shell program */
 char *shellname;               /* the shell program name (for argv[0]) */
 
 char *shell;                   /* the shell program */
 char *shellname;               /* the shell program name (for argv[0]) */
-
-int nbufline;                  /* number of lines in the buffer */
+int nbufline;                  /* default buffer size for new windows */
+char escapec;                  /* the escape character */
 
        /* flags */
 
        /* flags */
-char quit;
-char terse;
-char debug;
-char incmd;                    /* in command mode */
-char escapec;                  /* escape character */
+char quit;                     /* quit command issued */
+char terse;                    /* terse mode */
+char debug;                    /* debug mode */
 
 struct ww *getwin();
 struct ww *openwin();
 
 struct ww *getwin();
 struct ww *openwin();
index bebaf03..4e27dc6 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)error.c     3.6 84/01/13";
+static char *sccsid = "@(#)error.c     3.7 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -16,10 +16,10 @@ char *fmt;
 
        if (cx.x_type != X_FILE) {
                if (terse)
 
        if (cx.x_type != X_FILE) {
                if (terse)
-                       wwbell();
+                       wwputc(CTRL(g), cmdwin);
                else {
                else {
-                       (void) wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h);
-                       (void) wwputs("  ", cmdwin);
+                       wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h);
+                       wwputs("  ", cmdwin);
                }
                return;
        }
                }
                return;
        }
@@ -30,7 +30,7 @@ char *fmt;
 
                (void) sprintf(buf, "Errors from %s", cx.x_filename);
                if ((w = cx.x_errwin = openiwin(ERRLINES, buf)) == 0) {
 
                (void) sprintf(buf, "Errors from %s", cx.x_filename);
                if ((w = cx.x_errwin = openiwin(ERRLINES, buf)) == 0) {
-                       (void) wwputs("Can't open error window.  ", cmdwin);
+                       wwputs("Can't open error window.  ", cmdwin);
                        cx.x_noerr = 1;
                        return;
                }
                        cx.x_noerr = 1;
                        return;
                }
@@ -39,9 +39,9 @@ char *fmt;
                cx.x_noerr = 1;
                return;
        }
                cx.x_noerr = 1;
                return;
        }
-       (void) wwprintf(w, "line %d: ", cx.x_lineno);
-       (void) wwprintf(w, fmt, a, b, c, d, e, f, g, h);
-       (void) wwputc('\n', w);
+       wwprintf(w, "line %d: ", cx.x_lineno);
+       wwprintf(w, fmt, a, b, c, d, e, f, g, h);
+       wwputc('\n', w);
 }
 
 err_end()
 }
 
 err_end()
index 4d0b16f..9690ba5 100644 (file)
@@ -1,11 +1,13 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)main.c      3.14 83/12/06";
+static char *sccsid = "@(#)main.c      3.15 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
+#include <sys/signal.h>
+#include <stdio.h>
 
 
-char escapec = CTRL(p);
 int nbufline = 48;                     /* compatible */
 int nbufline = 48;                     /* compatible */
+char escapec = CTRL(p);        
 
 #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
 
 
 #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
 
@@ -17,9 +19,6 @@ char **argv;
        char fflag = 0;
        char dflag = 0;
        char xflag = 0;
        char fflag = 0;
        char dflag = 0;
        char xflag = 0;
-#ifndef O_4_1A
-       struct timezone timezone;
-#endif
 
        if (p = rindex(*argv, '/'))
                p++;
 
        if (p = rindex(*argv, '/'))
                p++;
@@ -60,10 +59,9 @@ char **argv;
        else
                shellname = shell;
 #ifndef O_4_1A
        else
                shellname = shell;
 #ifndef O_4_1A
-       (void) gettimeofday(&starttime, &timezone);
+       (void) gettimeofday(&starttime, (struct timezone *)0);
 #endif
        if (wwinit() < 0) {
 #endif
        if (wwinit() < 0) {
-               (void) fflush(stdout);
                (void) fprintf(stderr, "%s.\n", wwerror());
                exit(1);
        }
                (void) fprintf(stderr, "%s.\n", wwerror());
                exit(1);
        }
@@ -81,6 +79,7 @@ char **argv;
                (void) fprintf(stderr, "%s.\r\n", wwerror());
                goto bad;
        }
                (void) fprintf(stderr, "%s.\r\n", wwerror());
                goto bad;
        }
+       cmdwin->ww_nointr = 1;
        if ((framewin = wwopen(WWO_GLASS|WWO_FRAME, wwnrow, wwncol, 0, 0, 0))
            == 0) {
                (void) wwflush();
        if ((framewin = wwopen(WWO_GLASS|WWO_FRAME, wwnrow, wwncol, 0, 0, 0))
            == 0) {
                (void) wwflush();
@@ -99,14 +98,14 @@ char **argv;
        (void) signal(SIGCHLD, wwchild);
        setvars();
        if (fflag)
        (void) signal(SIGCHLD, wwchild);
        setvars();
        if (fflag)
-               incmd = 1;
+               wwcurwin = 0;
        else {
                if (!terse)
                        wwadd(cmdwin, &wwhead);
                if (dflag || doconfig() < 0)
                        dodefault();
                if (selwin != 0) {
        else {
                if (!terse)
                        wwadd(cmdwin, &wwhead);
                if (dflag || doconfig() < 0)
                        dodefault();
                if (selwin != 0) {
-                       incmd = 0;
+                       wwcurwin = selwin;
                        wwcursor(selwin, 0);
                }
                if (!terse) {
                        wwcursor(selwin, 0);
                }
                if (!terse) {
index 8a7864d..61b1a98 100644 (file)
@@ -1,49 +1,37 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)mloop.c     3.2 84/01/16";
+static char *sccsid = "@(#)mloop.c     3.3 84/03/03";
 #endif
 
 #include "defs.h"
 
 mloop()
 {
 #endif
 
 #include "defs.h"
 
 mloop()
 {
-       register n;
-       register char *p;
-       int imask;
-
        while (!quit) {
        while (!quit) {
-               if (!incmd && selwin->ww_state != WWS_HASPROC) {
-                       incmd = 1;
-                       error("Process died.");
-               }
-               if (incmd) {
+               if (wwcurwin == 0) {
                        docmd();
                        docmd();
-                       continue;
-               }
-               while (wwibc == 0) {
-                       wwcurtowin(selwin);
+               } else if (wwcurwin->ww_state != WWS_HASPROC) {
+                       wwcurwin = 0;
+                       if (wwpeekc() == escapec)
+                               (void) wwgetc();
+                       error("Process died.");
+               } else {
+                       register char *p;
+                       register n;
+
                        wwiomux();
                        wwiomux();
-               }
-               /*
-                * 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 wwibc == 1 a special
-                * case.
-                */
-               for (p = wwibp, n = wwibc;;) {
-                       if (--n < 0) {
-                               (void) write(selwin->ww_pty, wwibp, wwibc);
-                               wwibc = 0;
-                               break;
-                       }
-                       if (*p++ == escapec) {
-                               if ((n = p - wwibp) > 1)
-                                       (void) write(selwin->ww_pty,
-                                               wwibp, n - 1);
-                               wwibp = p;
-                               wwibc -= n;
-                               incmd = 1;
-                               break;
+                       if (wwibp < wwibq) {
+                               for (p = wwibp; p < wwibq && *p != escapec;
+                                    p++)
+                                       ;
+                               if ((n = p - wwibp) > 0) {
+                                       (void) write(wwcurwin->ww_pty,
+                                               wwibp, n);
+                                       wwibp = p;
+                               }
+                               if (wwpeekc() == escapec) {
+                                       wwcurwin = 0;
+                                       (void) wwgetc();
+                               }
                        }
                }
        }
                        }
                }
        }
index c966b4d..08706b0 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)startup.c   3.8 84/01/11";
+static char *sccsid = "@(#)startup.c   3.9 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -30,11 +30,11 @@ dodefault()
        if (openwin(-1, r + 2, 0, wwnrow - r - 2, wwncol, nbufline, (char *) 0)
            == 0)
                goto bad;
        if (openwin(-1, r + 2, 0, wwnrow - r - 2, wwncol, nbufline, (char *) 0)
            == 0)
                goto bad;
-       (void) wwprintf(w, "Escape character is %s.\r\n", unctrl(escapec));
+       wwprintf(w, "Escape character is %s.\r\n", unctrl(escapec));
        setselwin(w);
        return;
 bad:
        setselwin(w);
        return;
 bad:
-       (void) wwputs("Can't open default windows.  ", cmdwin);
+       wwputs("Can't open default windows.  ", cmdwin);
 }
 
 setvars()
 }
 
 setvars()
index 742a432..9a68f9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *     @(#)tt.h        3.9 83/12/17
+ *     @(#)tt.h        3.10 84/03/03
  */
 
 /*
  */
 
 /*
@@ -54,13 +54,24 @@ struct tt_tab tt_tab[];
 
 /*
  * Clean interface to termcap routines.
 
 /*
  * Clean interface to termcap routines.
+ * Too may t's.
  */
 char tt_strings[1024];         /* string buffer */
 char *tt_strp;                 /* pointer for it */
 
  */
 char tt_strings[1024];         /* string buffer */
 char *tt_strp;                 /* pointer for it */
 
-int tt_pc();                   /* just putchar() */
-int tt_sc();                   /* *tt_strp++ = c */
-char *tt_xgetstr();            /* tgetstr() and expand delays */
+#define tttgetstr(s)   tgetstr((s), &tt_strp)
+char *ttxgetstr();             /* tgetstr() and expand delays */
 
 
-#define tt_tgetstr(s)  tgetstr((s), &tt_strp)
-#define tt_tputs(s, n) tputs((s), (n), tt_pc)
+int tttputc();
+#define tttputs(s, n)  tputs((s), (n), tttputc)
+
+/*
+ * Buffered output without stdio.
+ * These variables have different meanings from the ww_ob* variabels.
+ * But I'm too lazy to think up different names.
+ */
+char tt_ob[512];
+char *tt_obp;
+char *tt_obe;
+#define ttputc(c)      (tt_obp < tt_obe ? *tt_obp++ = (c) \
+                               : (ttflush(), *tt_obp++ = (c)))
index 85150cc..c3063d3 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttgeneric.c 3.21 84/03/02";
+static char *sccsid = "@(#)ttgeneric.c 3.22 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -54,8 +54,7 @@ int gen_LI;
 int gen_UG;
 int gen_SG;
 
 int gen_UG;
 int gen_SG;
 
-#define pc(c) putchar('c')
-#define ps(s) fputs((s), stdout)
+#define ps(s) ttputs(s)
 
 gen_setinsert(new)
 char new;
 
 gen_setinsert(new)
 char new;
@@ -107,7 +106,7 @@ gen_insline()
        if (tt.tt_modes)                        /* for concept 100 */
                gen_setmodes(0);
        if (gen_AL)
        if (tt.tt_modes)                        /* for concept 100 */
                gen_setmodes(0);
        if (gen_AL)
-               tt_tputs(gen_AL, gen_LI - tt.tt_row);
+               tttputs(gen_AL, gen_LI - tt.tt_row);
 }
 
 gen_delline()
 }
 
 gen_delline()
@@ -115,7 +114,7 @@ gen_delline()
        if (tt.tt_modes)                        /* for concept 100 */
                gen_setmodes(0);
        if (gen_DL)
        if (tt.tt_modes)                        /* for concept 100 */
                gen_setmodes(0);
        if (gen_DL)
-               tt_tputs(gen_DL, gen_LI - tt.tt_row);
+               tttputs(gen_DL, gen_LI - tt.tt_row);
 }
 
 gen_putc(c)
 }
 
 gen_putc(c)
@@ -127,12 +126,12 @@ register char c;
                gen_setmodes(tt.tt_nmodes);
        if (tt.tt_insert) {
                if (gen_IC)
                gen_setmodes(tt.tt_nmodes);
        if (tt.tt_insert) {
                if (gen_IC)
-                       tt_tputs(gen_IC, gen_CO - tt.tt_col);
-               putchar(c);
+                       tttputs(gen_IC, gen_CO - tt.tt_col);
+               ttputc(c);
                if (gen_IP)
                if (gen_IP)
-                       tt_tputs(gen_IP, gen_CO - tt.tt_col);
+                       tttputs(gen_IP, gen_CO - tt.tt_col);
        } else
        } else
-               putchar(c);
+               ttputc(c);
        if (++tt.tt_col == gen_CO)
                if (gen_AM)
                        tt.tt_col = 0, tt.tt_row++;
        if (++tt.tt_col == gen_CO)
                if (gen_AM)
                        tt.tt_col = 0, tt.tt_row++;
@@ -151,16 +150,16 @@ register n;
        if (tt.tt_insert) {
                while (--n >= 0) {
                        if (gen_IC)
        if (tt.tt_insert) {
                while (--n >= 0) {
                        if (gen_IC)
-                               tt_tputs(gen_IC, gen_CO - tt.tt_col);
-                       putchar(*p++);
+                               tttputs(gen_IC, gen_CO - tt.tt_col);
+                       ttputc(*p++);
                        if (gen_IP)
                        if (gen_IP)
-                               tt_tputs(gen_IP, gen_CO - tt.tt_col);
+                               tttputs(gen_IP, gen_CO - tt.tt_col);
                        tt.tt_col++;
                }
        } else {
                tt.tt_col += n;
                while (--n >= 0)
                        tt.tt_col++;
                }
        } else {
                tt.tt_col += n;
                while (--n >= 0)
-                       putchar(*p++);
+                       ttputc(*p++);
        }
        if (tt.tt_col == gen_CO)
                if (gen_AM)
        }
        if (tt.tt_col == gen_CO)
                if (gen_AM)
@@ -244,7 +243,7 @@ gen_clreol()
        if (tt.tt_modes)                        /* for concept 100 */
                gen_setmodes(0);
        if (gen_CE)
        if (tt.tt_modes)                        /* for concept 100 */
                gen_setmodes(0);
        if (gen_CE)
-               tt_tputs(gen_CE, gen_CO - tt.tt_col);
+               tttputs(gen_CE, gen_CO - tt.tt_col);
 }
 
 gen_clreos()
 }
 
 gen_clreos()
@@ -252,7 +251,7 @@ gen_clreos()
        if (tt.tt_modes)                        /* for concept 100 */
                gen_setmodes(0);
        if (gen_CD)
        if (tt.tt_modes)                        /* for concept 100 */
                gen_setmodes(0);
        if (gen_CD)
-               tt_tputs(gen_CD, gen_LI - tt.tt_row);
+               tttputs(gen_CD, gen_LI - tt.tt_row);
 }
 
 gen_clear()
 }
 
 gen_clear()
@@ -266,38 +265,38 @@ gen_clear()
 gen_delchar()
 {
        if (gen_DC)
 gen_delchar()
 {
        if (gen_DC)
-               tt_tputs(gen_DC, gen_CO - tt.tt_col);
+               tttputs(gen_DC, gen_CO - tt.tt_col);
 }
 
 tt_generic()
 {
 }
 
 tt_generic()
 {
-       gen_CM = tt_xgetstr("cm");              /* may not work */
-       gen_IM = tt_xgetstr("im");
-       gen_IC = tt_tgetstr("ic");
-       gen_IP = tt_tgetstr("ip");
-       gen_EI = tt_xgetstr("ei");
-       gen_DC = tt_tgetstr("dc");
-       gen_AL = tt_tgetstr("al");
-       gen_DL = tt_tgetstr("dl");
-       gen_CE = tt_tgetstr("ce");
-       gen_CD = tt_tgetstr("cd");
-       gen_CL = tt_xgetstr("cl");
-       gen_VS = tt_xgetstr("vs");
-       gen_VE = tt_xgetstr("ve");
-       gen_TI = tt_xgetstr("ti");
-       gen_TE = tt_xgetstr("te");
-       gen_SO = tt_xgetstr("so");
-       gen_SE = tt_xgetstr("se");
-       gen_US = tt_xgetstr("us");
-       gen_UE = tt_xgetstr("ue");
-       gen_UP = tt_xgetstr("up");
-       gen_PC = tt_tgetstr("pc");
-       gen_BC = tt_xgetstr("bc");
-       gen_ND = tt_xgetstr("nd");
-       gen_HO = tt_xgetstr("ho");
-       gen_NL = tt_xgetstr("nl");
-       gen_AS = tt_xgetstr("as");
-       gen_AE = tt_xgetstr("ae");
+       gen_CM = ttxgetstr("cm");               /* may not work */
+       gen_IM = ttxgetstr("im");
+       gen_IC = tttgetstr("ic");
+       gen_IP = tttgetstr("ip");
+       gen_EI = ttxgetstr("ei");
+       gen_DC = tttgetstr("dc");
+       gen_AL = tttgetstr("al");
+       gen_DL = tttgetstr("dl");
+       gen_CE = tttgetstr("ce");
+       gen_CD = tttgetstr("cd");
+       gen_CL = ttxgetstr("cl");
+       gen_VS = ttxgetstr("vs");
+       gen_VE = ttxgetstr("ve");
+       gen_TI = ttxgetstr("ti");
+       gen_TE = ttxgetstr("te");
+       gen_SO = ttxgetstr("so");
+       gen_SE = ttxgetstr("se");
+       gen_US = ttxgetstr("us");
+       gen_UE = ttxgetstr("ue");
+       gen_UP = ttxgetstr("up");
+       gen_PC = tttgetstr("pc");
+       gen_BC = ttxgetstr("bc");
+       gen_ND = ttxgetstr("nd");
+       gen_HO = ttxgetstr("ho");
+       gen_NL = ttxgetstr("nl");
+       gen_AS = ttxgetstr("as");
+       gen_AE = ttxgetstr("ae");
        gen_MI = tgetflag("mi");
        gen_MS = tgetflag("ms");
        gen_AM = tgetflag("am");
        gen_MI = tgetflag("mi");
        gen_MS = tgetflag("ms");
        gen_AM = tgetflag("am");
index 9d2c703..e11e321 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)tth19.c     3.11 83/12/17";
+static char *sccsid = "@(#)tth19.c     3.12 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -33,7 +33,7 @@ extern char *gen_VE;
 
 int h19_msp10c;
 
 
 int h19_msp10c;
 
-#define pc(c)  putchar('c')
+#define pc(c)  ttputc('c')
 #define esc()  pc(\033)
 #define PAD(ms10) { \
        register i; \
 #define esc()  pc(\033)
 #define PAD(ms10) { \
        register i; \
@@ -89,7 +89,7 @@ register char c;
                h19_setmodes(tt.tt_nmodes);
        if (tt.tt_ninsert != tt.tt_insert)
                h19_setinsert(tt.tt_ninsert);
                h19_setmodes(tt.tt_nmodes);
        if (tt.tt_ninsert != tt.tt_insert)
                h19_setinsert(tt.tt_ninsert);
-       putchar(c);
+       ttputc(c);
        if (tt.tt_insert)
                ICPAD();
        if (++tt.tt_col == NCOL)
        if (tt.tt_insert)
                ICPAD();
        if (++tt.tt_col == NCOL)
@@ -106,14 +106,14 @@ register n;
                h19_setinsert(tt.tt_ninsert);
        if (tt.tt_insert) {
                while (--n >= 0) {
                h19_setinsert(tt.tt_ninsert);
        if (tt.tt_insert) {
                while (--n >= 0) {
-                       putchar(*p++);
+                       ttputc(*p++);
                        ICPAD();
                        tt.tt_col++;
                }
        } else {
                tt.tt_col += n;
                while (--n >= 0)
                        ICPAD();
                        tt.tt_col++;
                }
        } else {
                tt.tt_col += n;
                while (--n >= 0)
-                       putchar(*p++);
+                       ttputc(*p++);
        }
        if (tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
        }
        if (tt.tt_col == NCOL)
                tt.tt_col = NCOL - 1;
@@ -151,8 +151,8 @@ register char row, col;
        }
        esc();
        pc(Y);
        }
        esc();
        pc(Y);
-       putchar(' ' + row);
-       putchar(' ' + col);
+       ttputc(' ' + row);
+       ttputc(' ' + col);
 out:
        tt.tt_col = col;
        tt.tt_row = row;
 out:
        tt.tt_col = col;
        tt.tt_row = row;
@@ -161,7 +161,7 @@ out:
 h19_init()
 {
        if (gen_VS)
 h19_init()
 {
        if (gen_VS)
-               fputs(gen_VS, stdout);
+               ttputs(gen_VS);
        esc();
        pc(w);
        esc();
        esc();
        pc(w);
        esc();
@@ -176,7 +176,7 @@ h19_end()
        h19_setmodes(0);
        h19_setinsert(0);
        if (gen_VE)
        h19_setmodes(0);
        h19_setinsert(0);
        if (gen_VE)
-               fputs(gen_VE, stdout);
+               ttputs(gen_VE);
        esc();
        pc(v);
 }
        esc();
        pc(v);
 }
@@ -210,8 +210,8 @@ tt_h19()
        float cpms = (float) wwbaud / 10000;    /* char per ms */
 
        h19_msp10c = 10 / cpms;                 /* ms per 10 char */
        float cpms = (float) wwbaud / 10000;    /* char per ms */
 
        h19_msp10c = 10 / cpms;                 /* ms per 10 char */
-       gen_VS = tt_xgetstr("vs");
-       gen_VE = tt_xgetstr("ve");
+       gen_VS = ttxgetstr("vs");
+       gen_VE = ttxgetstr("ve");
 
        tt.tt_init = h19_init;
        tt.tt_end = h19_end;
 
        tt.tt_init = h19_init;
        tt.tt_end = h19_end;
index 5bc3d8a..c08e01e 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ttinit.c    3.7 83/12/17";
+static char *sccsid = "@(#)ttinit.c    3.8 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -11,6 +11,12 @@ ttinit()
        register char *p, *q;
        register char *t;
 
        register char *p, *q;
        register char *t;
 
+       /*
+        * Set output buffer size to about 1 second of output time.
+        */
+       tt_obp = tt_ob;
+       tt_obe = tt_ob + MIN(wwbaud/10, sizeof tt_ob);
+
        /*
         * Use the standard name of the terminal (i.e. the second
         * name in termcap).
        /*
         * Use the standard name of the terminal (i.e. the second
         * name in termcap).
index 6fb6382..5c9df27 100644 (file)
@@ -1,24 +1,23 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)tttermcap.c 3.2 83/12/17";
+static char *sccsid = "@(#)tttermcap.c 3.3 84/03/03";
 #endif
 
 #endif
 
-#include "ww.h"
 #include "tt.h"
 
 char *tgetstr();
 
 #include "tt.h"
 
 char *tgetstr();
 
-tt_pc(c)
+tttputc(c)
 {
 {
-       putchar(c);
+       ttputc(c);
 }
 
 }
 
-tt_sc(c)
+ttxputc(c)
 {
        *tt_strp++ = c;
 }
 
 char *
 {
        *tt_strp++ = c;
 }
 
 char *
-tt_xgetstr(str)
+ttxgetstr(str)
 char *str;
 {
        char buf[100];
 char *str;
 {
        char buf[100];
@@ -28,7 +27,7 @@ char *str;
        if (str == 0)
                return 0;
        str = tt_strp;
        if (str == 0)
                return 0;
        str = tt_strp;
-       tputs(buf, 1, tt_sc);
-       tt_sc(0);
+       tputs(buf, 1, ttxputc);
+       ttxputc(0);
        return str;
 }
        return str;
 }
index 45b9703..89c73d3 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)win.c       3.2 84/01/16";
+static char *sccsid = "@(#)win.c       3.3 84/03/03";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -93,11 +93,13 @@ char *label;
                return 0;
        w->ww_mapnl = 1;
        w->ww_hasframe = 1;
                return 0;
        w->ww_mapnl = 1;
        w->ww_hasframe = 1;
+       w->ww_nointr = 1;
        w->ww_id = -1;
        w->ww_center = 1;
        (void) setlabel(w, label);
        wwadd(w, framewin);
        reframe();
        w->ww_id = -1;
        w->ww_center = 1;
        (void) setlabel(w, label);
        wwadd(w, framewin);
        reframe();
+       wwupdate();
        return w;
 }
 
        return w;
 }
 
@@ -117,16 +119,16 @@ struct ww *w;
        (void) waitnl1(w, "[Type any key to continue]");
 }
 
        (void) waitnl1(w, "[Type any key to continue]");
 }
 
-more(w, alway)
+more(w, always)
 register struct ww *w;
 register struct ww *w;
-char alway;
+char always;
 {
        int c;
 
 {
        int c;
 
-       if (!alway && w->ww_cur.r < w->ww_w.b - 2)
+       if (!always && w->ww_cur.r < w->ww_w.b - 2)
                return 0;
        c = waitnl1(w, "[Type escape to abort, any other key to continue]");
                return 0;
        c = waitnl1(w, "[Type escape to abort, any other key to continue]");
-       (void) wwputs("\033E", w);
+       wwputs("\033E", w);
        return c == CTRL([) ? 2 : 1;
 }
 
        return c == CTRL([) ? 2 : 1;
 }
 
@@ -135,7 +137,7 @@ register struct ww *w;
 char *prompt;
 {
        front(w, 0);
 char *prompt;
 {
        front(w, 0);
-       (void) wwprintf(w, "\033Y%c%c\033p%s\033q ",
+       wwprintf(w, "\033Y%c%c\033p%s\033q ",
                w->ww_w.nr - 1 + ' ', ' ', prompt);     /* print on last line */
        wwcurtowin(w);
        while (wwpeekc() < 0)
                w->ww_w.nr - 1 + ' ', ' ', prompt);     /* print on last line */
        wwcurtowin(w);
        while (wwpeekc() < 0)
index 84fcfd4..dc02cad 100644 (file)
@@ -1,9 +1,9 @@
 /*
 /*
- *     @(#)ww.h        3.25 84/01/16   
+ *     @(#)ww.h        3.26 84/03/03   
  */
 
  */
 
-#include <stdio.h>
 #include <sgtty.h>
 #include <sgtty.h>
+#include <setjmp.h>
 
 #define NWW    30              /* maximum number of windows */
 
 
 #define NWW    30              /* maximum number of windows */
 
@@ -32,6 +32,7 @@ struct ww {
        char ww_mapnl :1;       /* map \n to \r\n */
        char ww_hascursor :1;   /* has fake cursor */
        char ww_hasframe :1;    /* frame it */
        char ww_mapnl :1;       /* map \n to \r\n */
        char ww_hascursor :1;   /* has fake cursor */
        char ww_hasframe :1;    /* frame it */
+       char ww_nointr : 1;     /* wwwrite() not interruptable */
        char ww_index;          /* the index, for wwindex[] */
        char ww_order;          /* the overlapping order */
 
        char ww_index;          /* the index, for wwindex[] */
        char ww_order;          /* the overlapping order */
 
@@ -47,7 +48,7 @@ struct ww {
        char **ww_fmap;         /* map for frame and box windows */
        short *ww_nvis;         /* how many ww_buf chars are visible per row */
 
        char **ww_fmap;         /* map for frame and box windows */
        short *ww_nvis;         /* how many ww_buf chars are visible per row */
 
-               /* things for the window process */
+               /* things for the window process and io */
        int ww_pty;             /* file descriptor of pty */
        int ww_pid;             /* pid of process, if WWS_HASPROC true */
        char ww_ttyname[11];    /* "/dev/ttyp?" */
        int ww_pty;             /* file descriptor of pty */
        int ww_pid;             /* pid of process, if WWS_HASPROC true */
        char ww_ttyname[11];    /* "/dev/ttyp?" */
@@ -55,10 +56,10 @@ struct ww {
        char *ww_obe;           /* end of ww_ob */
        char *ww_obp;           /* current position in ww_ob */
        int ww_obc;             /* character count */
        char *ww_obe;           /* end of ww_ob */
        char *ww_obp;           /* current position in ww_ob */
        int ww_obc;             /* character count */
-       char ww_stopped;        /* flow control */
+       char ww_stopped;        /* output stopped */
 
                /* things for the user, they really don't belong here */
 
                /* things for the user, they really don't belong here */
-       char ww_center :1;      /* center the label */
+       char ww_center;         /* center the label */
        int ww_id;              /* the user window id */
        char *ww_label;         /* the user supplied label */
        struct ww_pos ww_altpos;/* alternate position */
        int ww_id;              /* the user window id */
        char *ww_label;         /* the user supplied label */
        struct ww_pos ww_altpos;/* alternate position */
@@ -71,6 +72,7 @@ struct ww_tty {
        struct ltchars ww_ltchars;
        int ww_lmode;
        int ww_ldisc;
        struct ltchars ww_ltchars;
        int ww_lmode;
        int ww_ldisc;
+       int ww_fflags;
 };
 
 union ww_char {
 };
 
 union ww_char {
@@ -166,7 +168,8 @@ int wwcursorrow, wwcursorcol;       /* where we want the cursor to be */
 int wwerrno;                   /* error number */
 
        /* statistics */
 int wwerrno;                   /* error number */
 
        /* statistics */
-int wwnwrite, wwnwritec;
+int wwnflush, wwnwr, wwnwre, wwnwrz, wwnwrc;
+int wwnwwr, wwnwwra, wwnwwrc;
 int wwnupdate, wwnupdline, wwnupdmiss, wwnmajline, wwnmajmiss;
 int wwnread, wwnreade, wwnreadz, wwnreadc;
 int wwnwread, wwnwreade, wwnwreadz, wwnwreadd, wwnwreadc, wwnwreadp;
 int wwnupdate, wwnupdline, wwnupdmiss, wwnmajline, wwnmajmiss;
 int wwnread, wwnreade, wwnreadz, wwnreadc;
 int wwnwread, wwnwreade, wwnwreadz, wwnwreadd, wwnwreadc, wwnwreadp;
@@ -175,19 +178,24 @@ int wwnselect, wwnselecte, wwnselectz;
        /* quicky macros */
 #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
 #define wwcurtowin(w)  wwsetcursor((w)->ww_cur.r, (w)->ww_cur.c)
        /* quicky macros */
 #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c))
 #define wwcurtowin(w)  wwsetcursor((w)->ww_cur.r, (w)->ww_cur.c)
-#define wwbell()       putchar(CTRL(g))
 #define wwunbox(w)     wwunframe(w)
 #define wwclreol(w,r,c)        wwclreol1((w), (r), (c), 0)
 #define wwredrawwin(w) wwredrawwin1((w), (w)->ww_i.t, (w)->ww_i.b, 0)
 #define wwunbox(w)     wwunframe(w)
 #define wwclreol(w,r,c)        wwclreol1((w), (r), (c), 0)
 #define wwredrawwin(w) wwredrawwin1((w), (w)->ww_i.t, (w)->ww_i.b, 0)
+#define wwupdate()     wwupdate1(0, wwnrow);
 
        /* things for handling input */
 
        /* things for handling input */
+int wwrint();          /* interrupt handler */
+struct ww *wwcurwin;   /* window to copy input into */
+char wwsetjmp;         /* want a longjmp() from wwrint() */
+jmp_buf wwjmpbuf;      /* jmpbuf for above */
 char *wwib;            /* input (keyboard) buffer */
 char *wwibe;           /* wwib + sizeof buffer */
 char *wwib;            /* input (keyboard) buffer */
 char *wwibe;           /* wwib + sizeof buffer */
-char *wwibp;           /* current position in buffer */
-int wwibc;             /* character count */
-#define wwgetc()       (wwibc ? wwibc--, *wwibp++&0x7f : -1)
-#define wwpeekc()      (wwibc ? *wwibp&0x7f : -1)
-#define wwungetc(c)    (wwibp > wwib ? wwibc++, *--wwibp = (c) : -1)
+char *wwibp;           /* current read position in buffer */
+char *wwibq;           /* current write position in buffer */
+#define wwgetc()       (wwibp < wwibq ? *wwibp++ & 0x7f : -1)
+#define wwpeekc()      (wwibp < wwibq ? *wwibp & 0x7f : -1)
+#define wwungetc(c)    (wwibp > wwib ? *--wwibp = (c) : -1)
+#define wwinterrupt()  (wwibp < wwibq)
 
        /* the window virtual terminal */
 #define WWT_TERM       "TERM=window"
 
        /* the window virtual terminal */
 #define WWT_TERM       "TERM=window"
@@ -217,6 +225,7 @@ char *tgetstr();
 char *rindex();
 char *strcpy();
 char *strcat();
 char *rindex();
 char *strcpy();
 char *strcat();
+char *sprintf();
 
 #undef MIN
 #undef MAX
 
 #undef MIN
 #undef MAX
@@ -226,7 +235,7 @@ char *strcat();
 #undef CTRL
 #define CTRL(c)                ('c'&0x1f)
 #define DEL            0x7f
 #undef CTRL
 #define CTRL(c)                ('c'&0x1f)
 #define DEL            0x7f
-#define ISCTRL(c)      ((c) < ' ' || (c) >= DEL)
+#define ISCTRL(c)      ((c) < ' ' & (c) != '\t' || (c) >= DEL)
 
 #if defined(O_4_1A)||defined(O_4_1C)
 int (*sigset)();
 
 #if defined(O_4_1A)||defined(O_4_1C)
 int (*sigset)();
index 2f6d764..345a967 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwdata.c    3.8 83/12/17";
+static char *sccsid = "@(#)wwdata.c    3.9 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -13,7 +13,7 @@ struct ww_tty wwnewtty = {
        { 0, 0, -1, -1, 0 },
        { -1, -1, -1, -1, -1, -1 },
        { -1, -1, -1, -1, -1, -1 },
        { 0, 0, -1, -1, 0 },
        { -1, -1, -1, -1, -1, -1 },
        { -1, -1, -1, -1, -1, -1 },
-       0, 0
+       0, 0, 0
 };
 
 int tt_h19();
 };
 
 int tt_h19();
index ab68903..0574672 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwend.c     3.3 83/08/15";
+static char *sccsid = "@(#)wwend.c     3.4 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -9,6 +9,6 @@ wwend()
 {
        (*tt.tt_move)(tt.tt_nrow - 1, 0);
        (*tt.tt_end)();
 {
        (*tt.tt_move)(tt.tt_nrow - 1, 0);
        (*tt.tt_end)();
-       (void) fflush(stdout);
+       ttflush();
        (void) wwsettty(0, &wwoldtty);
 }
        (void) wwsettty(0, &wwoldtty);
 }
index 2c1a83a..f2e84fe 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwflush.c   3.4 83/09/14";
+static char *sccsid = "@(#)wwflush.c   3.5 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -12,5 +12,5 @@ wwflush()
                (*tt.tt_move)(0, 0);
        else
                (*tt.tt_move)(wwcursorrow, wwcursorcol);
                (*tt.tt_move)(0, 0);
        else
                (*tt.tt_move)(wwcursorrow, wwcursorcol);
-       (void) fflush(stdout);
+       ttflush();
 }
 }
index d7ada1a..b5b00be 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwgets.c    3.3 84/01/16";
+static char *sccsid = "@(#)wwgets.c    3.4 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -20,7 +20,7 @@ register struct ww *w;
                        if (p > buf)
                                rub(*--p, w);
                        else
                        if (p > buf)
                                rub(*--p, w);
                        else
-                               wwbell();
+                               wwputc(CTRL(g), w);
                } else if (c == wwoldtty.ww_sgttyb.sg_kill) {
                        while (p > buf)
                                rub(*--p, w);
                } else if (c == wwoldtty.ww_sgttyb.sg_kill) {
                        while (p > buf)
                                rub(*--p, w);
@@ -34,9 +34,9 @@ register struct ww *w;
                        break;
                } else {
                        if (p >= buf + n - 1)
                        break;
                } else {
                        if (p >= buf + n - 1)
-                               wwbell();
+                               wwputc(CTRL(g), w);
                        else
                        else
-                               (void) wwputs(unctrl(*p++ = c), w);
+                               wwputs(unctrl(*p++ = c), w);
                }
        }
        *p = 0;
                }
        }
        *p = 0;
@@ -49,5 +49,5 @@ struct ww *w;
        register i;
 
        for (i = strlen(unctrl(c)); --i >= 0;)
        register i;
 
        for (i = strlen(unctrl(c)); --i >= 0;)
-               (void) wwputs("\b \b", w);
+               wwputs("\b \b", w);
 }
 }
index 8543cb0..28526a4 100644 (file)
@@ -1,25 +1,30 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwinit.c    3.14 84/01/16";
+static char *sccsid = "@(#)wwinit.c    3.15 84/03/03";
 #endif
 
 #include "ww.h"
 #include "tt.h"
 #endif
 
 #include "ww.h"
 #include "tt.h"
+#include <sys/signal.h>
+#include <fcntl.h>
 
 static char *kp = wwkeys;
 
 static char *kp = wwkeys;
-extern char _sobuf[];
 
 wwinit()
 {
        register i, j;
        int kn;
 
 
 wwinit()
 {
        register i, j;
        int kn;
 
-       setbuf(stdout, _sobuf);
 #ifndef O_4_1A
        wwdtablesize = getdtablesize();
 #else
 #include <sys/param.h>
        wwdtablesize = NOFILE;
 #endif
 #ifndef O_4_1A
        wwdtablesize = getdtablesize();
 #else
 #include <sys/param.h>
        wwdtablesize = NOFILE;
 #endif
+
+       if (signal(SIGIO, wwrint) == BADSIG)
+               return -1;
+       (void) sighold(SIGIO);
+
        if (wwgettty(0, &wwoldtty) < 0)
                return -1;
        wwwintty = wwoldtty;
        if (wwgettty(0, &wwoldtty) < 0)
                return -1;
        wwwintty = wwoldtty;
@@ -32,6 +37,7 @@ wwinit()
        wwnewtty.ww_sgttyb.sg_flags |= CBREAK;
        wwnewtty.ww_sgttyb.sg_flags &= ~(ECHO|CRMOD);
        wwnewtty.ww_lmode |= LLITOUT;
        wwnewtty.ww_sgttyb.sg_flags |= CBREAK;
        wwnewtty.ww_sgttyb.sg_flags &= ~(ECHO|CRMOD);
        wwnewtty.ww_lmode |= LLITOUT;
+       wwnewtty.ww_fflags |= FASYNC;
        if (wwsettty(0, &wwnewtty) < 0)
                goto bad;
 
        if (wwsettty(0, &wwnewtty) < 0)
                goto bad;
 
@@ -61,8 +67,7 @@ wwinit()
        if ((wwib = malloc((unsigned) 512)) == 0)
                goto bad;
        wwibe = wwib + 512;
        if ((wwib = malloc((unsigned) 512)) == 0)
                goto bad;
        wwibe = wwib + 512;
-       wwibp = wwib;
-       wwibc = 0;
+       wwibq = wwibp = wwib;
 
        if ((wwsmap = wwalloc(0, 0, wwnrow, wwncol, sizeof (char))) == 0)
                goto bad;
 
        if ((wwsmap = wwalloc(0, 0, wwnrow, wwncol, sizeof (char))) == 0)
                goto bad;
@@ -116,6 +121,7 @@ wwinit()
                        addcap(cap);
                }
        }
                        addcap(cap);
                }
        }
+       (void) sigrelse(SIGIO);
        return 0;
 bad:
        /*
        return 0;
 bad:
        /*
@@ -123,6 +129,8 @@ bad:
         * to exit when wwinit fails anyway.
         */
        (void) wwsettty(0, &wwoldtty);
         * to exit when wwinit fails anyway.
         */
        (void) wwsettty(0, &wwoldtty);
+       (void) signal(SIGIO, SIG_DFL);
+       (void) sigrelse(SIGIO);
        return -1;
 }
 
        return -1;
 }
 
index f4959b4..9a83051 100644 (file)
@@ -1,61 +1,69 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwiomux.c   3.7 84/01/16";
+static char *sccsid = "@(#)wwiomux.c   3.8 84/03/03";
 #endif
 
 #include "ww.h"
 #include <sys/time.h>
 
 /*
 #endif
 
 #include "ww.h"
 #include <sys/time.h>
 
 /*
- * Multiple window IO handler.
+ * Multiple window output handler.
+ * The idea is to copy window outputs to the terminal, via the
+ * display package.  We try to give the top most window highest
+ * priority.  The only return condition is when there is keyboard
+ * input, which is serviced asynchronously by wwrint().
+ * When there's nothing to do, we sleep in a select().
+ * This can be done better with interrupt driven io.  But that's
+ * not supported on ptys, yet.
+ * The history of this routine is interesting.
  */
 wwiomux()
 {
        register struct ww *w;
        int imask;
  */
 wwiomux()
 {
        register struct ww *w;
        int imask;
-       char dont_block;
-       register char *p;
        register n;
        register n;
+       register char *p;
        char c;
        static struct timeval tv = { 0, 0 };
        char c;
        static struct timeval tv = { 0, 0 };
+       char noblock;
 
 loop:
 
 loop:
-       imask = 1;
-       dont_block = 0;
+       if (wwinterrupt())
+               return;
+
+       imask = 0;
+       noblock = 0;
        for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) {
                if (w->ww_pty < 0)
                        continue;
        for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) {
                if (w->ww_pty < 0)
                        continue;
-               if (w->ww_obp + w->ww_obc < w->ww_obe)
-                       imask |= 1 << w->ww_pty;
-               if (w->ww_obc != 0 && !w->ww_stopped)
-                       dont_block = 1;
+               imask |= 1 << w->ww_pty;
+               if (w->ww_obc > 0 && !w->ww_stopped)
+                       noblock = 1;
        }
        }
-       if (!dont_block) {
+
+       if (!noblock) {
+               if (wwcurwin != 0)
+                       wwcurtowin(wwcurwin);
                wwupdate();
                wwflush();
                wwupdate();
                wwflush();
+               if (setjmp(wwjmpbuf))
+                       return;
+               wwsetjmp = 1;
+               if (wwinterrupt()) {
+                       wwsetjmp = 0;
+                       return;
+               }
        }
        wwnselect++;
        n = select(wwdtablesize, &imask, (int *)0, (int *)0,
        }
        wwnselect++;
        n = select(wwdtablesize, &imask, (int *)0, (int *)0,
-               dont_block ? &tv : (struct timeval *)0);
+               noblock ? &tv : (struct timeval *)0);
+       wwsetjmp = 0;
+
        if (n < 0)
                wwnselecte++;
        if (n < 0)
                wwnselecte++;
-       else if (imask & 1) {
-               if (wwibc == 0)
-                       p = wwibp = wwib;
-               else
-                       p = wwibp + wwibc;
-               n = wwibe - p;
-               wwnread++;
-               if ((n = read(0, p, n)) > 0) {
-                       wwibc += n;
-                       wwnreadc += n;
-               } else if (n == 0)
-                       wwnreadz++;
-               else
-                       wwnreade++;
-       } else if (imask != 0 || dont_block) {
+       else if (n == 0)
+               wwnselectz++;
+       else {
                char first_time = 1;
                char first_time = 1;
-               if (n == 0)
-                       wwnselectz++;
                for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) {
                        if (w->ww_pty < 0)
                                continue;
                for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) {
                        if (w->ww_pty < 0)
                                continue;
@@ -76,9 +84,10 @@ loop:
                                } else if (n == 0) {
                                        wwnwreadz++;
                                } else if (*p == TIOCPKT_DATA) {
                                } else if (n == 0) {
                                        wwnwreadz++;
                                } else if (*p == TIOCPKT_DATA) {
+                                       n--;
                                        wwnwreadd++;
                                        wwnwreadd++;
-                                       wwnwreadc += n - 1;
-                                       w->ww_obc += n - 1;
+                                       wwnwreadc += n;
+                                       w->ww_obc += n;
                                } else {
                                        wwnwreadp++;
                                        if (*p & TIOCPKT_STOP)
                                } else {
                                        wwnwreadp++;
                                        if (*p & TIOCPKT_STOP)
@@ -86,22 +95,24 @@ loop:
                                        if (*p & TIOCPKT_START)
                                                w->ww_stopped = 0;
                                        if (*p & TIOCPKT_FLUSHWRITE) {
                                        if (*p & TIOCPKT_START)
                                                w->ww_stopped = 0;
                                        if (*p & TIOCPKT_FLUSHWRITE) {
+                                               w->ww_stopped = 0;
                                                w->ww_obp = w->ww_ob;
                                                w->ww_obc = 0;
                                                w->ww_obp = w->ww_ob;
                                                w->ww_obc = 0;
-                                               w->ww_stopped = 0;
                                        }
                                }
                                *p = c;
                        }
                        if (first_time && w->ww_obc != 0 && !w->ww_stopped) {
                                first_time = 0;
                                        }
                                }
                                *p = c;
                        }
                        if (first_time && w->ww_obc != 0 && !w->ww_stopped) {
                                first_time = 0;
-                               /* XXX */
-                               n = wwwrite(w, w->ww_obp, MIN(w->ww_obc, 50));
+                               n = wwwrite(w, w->ww_obp, w->ww_obc);
                                if (w->ww_obc -= n)
                                        w->ww_obp += n;
                                else
                                        w->ww_obp = w->ww_ob;
                                if (w->ww_obc -= n)
                                        w->ww_obp += n;
                                else
                                        w->ww_obp = w->ww_ob;
+                               if (wwinterrupt())
+                                       return;
                        }
                }
        }
                        }
                }
        }
+       goto loop;
 }
 }
index 0541dde..11ca407 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwprintf.c  3.1 83/08/11";
+static char *sccsid = "@(#)wwprintf.c  3.2 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -9,6 +9,7 @@ wwprintf(w, fmt, args)
 struct ww *w;
 char *fmt;
 {
 struct ww *w;
 char *fmt;
 {
+#include <stdio.h>
        struct _iobuf _wwbuf;
        static char buf[1024];
 
        struct _iobuf _wwbuf;
        static char buf[1024];
 
@@ -22,5 +23,5 @@ char *fmt;
        _wwbuf._cnt = sizeof buf;
        _wwbuf._file = -1;                      /* safe */
        _doprnt(fmt, &args, &_wwbuf);
        _wwbuf._cnt = sizeof buf;
        _wwbuf._file = -1;                      /* safe */
        _doprnt(fmt, &args, &_wwbuf);
-       return wwwrite(w, buf, _wwbuf._ptr - buf);
+       (void) wwwrite(w, buf, _wwbuf._ptr - buf);
 }
 }
index 53ee295..3d1d78d 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwputc.c    3.1 83/08/11";
+static char *sccsid = "@(#)wwputc.c    3.2 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -8,5 +8,5 @@ wwputc(c, w)
 char c;
 struct ww *w;
 {
 char c;
 struct ww *w;
 {
-       return wwwrite(w, &c, sizeof c);
+       (void) wwwrite(w, &c, sizeof c);
 }
 }
index 2ab7868..48dfe3f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwputs.c    3.1 83/08/11";
+static char *sccsid = "@(#)wwputs.c    3.2 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
@@ -12,5 +12,5 @@ struct ww *w;
 
        while (*p++)
                ;
 
        while (*p++)
                ;
-       return wwwrite(w, s, p - s - 1);
+       (void) wwwrite(w, s, p - s - 1);
 }
 }
index 7e5aff6..d51e848 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwtty.c     3.5 83/12/17";
+static char *sccsid = "@(#)wwtty.c     3.6 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
+#include <fcntl.h>
 
 wwgettty(d, t)
 register struct ww_tty *t;
 
 wwgettty(d, t)
 register struct ww_tty *t;
@@ -17,6 +18,8 @@ register struct ww_tty *t;
                goto bad;
        if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0)
                goto bad;
                goto bad;
        if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0)
                goto bad;
+       if ((t->ww_fflags = fcntl(d, F_GETFL, 0)) < 0)
+               goto bad;
        return 0;
 bad:
        wwerrno = WWE_SYS;
        return 0;
 bad:
        wwerrno = WWE_SYS;
@@ -36,6 +39,8 @@ register struct ww_tty *t;
                goto bad;
        if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0)
                goto bad;
                goto bad;
        if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0)
                goto bad;
+       if (fcntl(d, F_SETFL, t->ww_fflags) < 0)
+               goto bad;
        return 0;
 bad:
        wwerrno = WWE_SYS;
        return 0;
 bad:
        wwerrno = WWE_SYS;
index f2ef793..1f06e32 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwupdate.c  3.11 84/01/06";
+static char *sccsid = "@(#)wwupdate.c  3.12 84/03/03";
 #endif
 
 #include "ww.h"
 #include "tt.h"
 
 #endif
 
 #include "ww.h"
 #include "tt.h"
 
-wwupdate()
+wwupdate1(top, bot)
 {
        int i;
        register j;
 {
        int i;
        register j;
@@ -14,7 +14,8 @@ wwupdate()
        char didit;
 
        wwnupdate++;
        char didit;
 
        wwnupdate++;
-       for (i = 0, touched = wwtouched; i < wwnrow; i++, touched++) {
+       for (i = top, touched = &wwtouched[i]; i < bot && !wwinterrupt();
+            i++, touched++) {
                if (!*touched)
                        continue;
                if (*touched & WWU_MAJOR && tt.tt_clreol != 0) {
                if (!*touched)
                        continue;
                if (*touched & WWU_MAJOR && tt.tt_clreol != 0) {
index 5ba13d6..d8d8fba 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)wwwrite.c   3.17 84/01/16";
+static char *sccsid = "@(#)wwwrite.c   3.18 84/03/03";
 #endif
 
 #include "ww.h"
 #endif
 
 #include "ww.h"
+#include "tt.h"
 
 wwwrite(w, p, n)
 register struct ww *w;
 
 wwwrite(w, p, n)
 register struct ww *w;
@@ -10,66 +11,75 @@ register char *p;
 int n;
 {
        char hascursor;
 int n;
 {
        char hascursor;
-       int saven = n;
+       char *savep = p;
+       char *q = p + n;
 
 
-       wwnwrite++;
-       wwnwritec += n;
        if (hascursor = w->ww_hascursor)
                wwcursor(w, 0);
        if (hascursor = w->ww_hascursor)
                wwcursor(w, 0);
-       while (n > 0) {
+       while (p < q && !w->ww_stopped && (!wwinterrupt() || w->ww_nointr)) {
                if (w->ww_wstate == 0 && !ISCTRL(*p)) {
                        register i;
                        register union ww_char *bp;
                if (w->ww_wstate == 0 && !ISCTRL(*p)) {
                        register i;
                        register union ww_char *bp;
-                       union ww_char *bq;
                        int col, col1;
 
                        if (w->ww_insert) {     /* this is very slow */
                        int col, col1;
 
                        if (w->ww_insert) {     /* this is very slow */
-                               n--;
+                               if (*p == '\t') {
+                                       p++;
+                                       w->ww_cur.c += 8 -
+                                               (w->ww_cur.c - w->ww_w.l & 7);
+                                       goto chklf;
+                               }
                                wwinschar(w, w->ww_cur.r, w->ww_cur.c,
                                        *p++ | w->ww_modes << WWC_MSHIFT);
                                goto right;
                        }
 
                                wwinschar(w, w->ww_cur.r, w->ww_cur.c,
                                        *p++ | w->ww_modes << WWC_MSHIFT);
                                goto right;
                        }
 
-                       bp = bq = &w->ww_buf[w->ww_cur.r][w->ww_cur.c];
-                       if ((i = w->ww_b.r - w->ww_cur.c) > n)
-                               i = n;
-                       while (--i >= 0 && !ISCTRL(*p))
-                               bp++->c_w = *p++ | w->ww_modes << WWC_MSHIFT;
+                       bp = &w->ww_buf[w->ww_cur.r][w->ww_cur.c];
+                       i = w->ww_cur.c;
+                       while (i < w->ww_w.r && p < q && !ISCTRL(*p))
+                               if (*p == '\t') {
+                                       register tmp = 8 - (i - w->ww_w.l & 7);
+                                       p++;
+                                       i += tmp;
+                                       bp += tmp;
+                               } else {
+                                       bp++->c_w = *p++
+                                               | w->ww_modes << WWC_MSHIFT;
+                                       i++;
+                               }
 
 
-                       i = bp - bq;
-                       n -= i;
                        col = MAX(w->ww_cur.c, w->ww_i.l);
                        col = MAX(w->ww_cur.c, w->ww_i.l);
-                       w->ww_cur.c += i;
-                       col1 = MIN(w->ww_cur.c, w->ww_i.r);
-
+                       col1 = MIN(i, w->ww_i.r);
+                       w->ww_cur.c = i;
                        if (w->ww_cur.r >= w->ww_i.t && w->ww_cur.r < w->ww_i.b)
                        {
                                register union ww_char *ns = wwns[w->ww_cur.r];
                                register char *smap = &wwsmap[w->ww_cur.r][col];
                                register char *win = w->ww_win[w->ww_cur.r];
                        if (w->ww_cur.r >= w->ww_i.t && w->ww_cur.r < w->ww_i.b)
                        {
                                register union ww_char *ns = wwns[w->ww_cur.r];
                                register char *smap = &wwsmap[w->ww_cur.r][col];
                                register char *win = w->ww_win[w->ww_cur.r];
-                               char touched = wwtouched[w->ww_cur.r];
+                               int nchanged = 0;
 
                                bp = w->ww_buf[w->ww_cur.r];
                                for (i = col; i < col1; i++)
                                        if (*smap++ == w->ww_index) {
 
                                bp = w->ww_buf[w->ww_cur.r];
                                for (i = col; i < col1; i++)
                                        if (*smap++ == w->ww_index) {
-                                               touched |= WWU_TOUCHED;
+                                               nchanged++;
                                                ns[i].c_w = bp[i].c_w
                                                        ^ win[i] << WWC_MSHIFT;
                                        }
                                                ns[i].c_w = bp[i].c_w
                                                        ^ win[i] << WWC_MSHIFT;
                                        }
-                               wwtouched[w->ww_cur.r] = touched;
-                       }
-                       if (w->ww_cur.c >= w->ww_w.r) {
-                               w->ww_cur.c = w->ww_w.l;
-                               goto lf;
+                               if (nchanged > 0) {
+                                       wwtouched[w->ww_cur.r] |= WWU_TOUCHED;
+                                       wwupdate1(w->ww_cur.r, w->ww_cur.r + 1);
+                               }
                        }
                        }
-                       continue;
-               }
-               n--;
-               switch (w->ww_wstate) {
+                       
+               chklf:
+                       if (w->ww_cur.c >= w->ww_w.r)
+                               goto crlf;
+               } else switch (w->ww_wstate) {
                case 0:
                        switch (*p++) {
                        case '\n':
                                if (w->ww_mapnl)
                case 0:
                        switch (*p++) {
                        case '\n':
                                if (w->ww_mapnl)
+               crlf:
                                        w->ww_cur.c = w->ww_w.l;
                lf:
                                if (++w->ww_cur.r >= w->ww_w.b) {
                                        w->ww_cur.c = w->ww_w.l;
                lf:
                                if (++w->ww_cur.r >= w->ww_w.b) {
@@ -84,14 +94,6 @@ int n;
                                                wwdelline(w, w->ww_b.t);
                                }
                                break;
                                                wwdelline(w, w->ww_b.t);
                                }
                                break;
-                       case '\t':
-                               w->ww_cur.c +=
-                                       8 - (w->ww_cur.c - w->ww_w.l & 7);
-                               if (w->ww_cur.c >= w->ww_w.r) {
-                                       w->ww_cur.c = w->ww_w.l;
-                                       goto lf;
-                               }
-                               break;
                        case '\b':
                                if (--w->ww_cur.c < w->ww_w.l) {
                                        w->ww_cur.c = w->ww_w.r - 1;
                        case '\b':
                                if (--w->ww_cur.c < w->ww_w.l) {
                                        w->ww_cur.c = w->ww_w.r - 1;
@@ -102,7 +104,7 @@ int n;
                                w->ww_cur.c = w->ww_w.l;
                                break;
                        case CTRL(g):
                                w->ww_cur.c = w->ww_w.l;
                                break;
                        case CTRL(g):
-                               wwbell();
+                               ttputc(CTRL(g));
                                break;
                        case CTRL([):
                                w->ww_wstate = 1;
                                break;
                        case CTRL([):
                                w->ww_wstate = 1;
@@ -133,11 +135,8 @@ int n;
                                goto lf;
                        case 'C':
                right:
                                goto lf;
                        case 'C':
                right:
-                               if (++w->ww_cur.c >= w->ww_w.r) {
-                                       w->ww_cur.c = w->ww_w.l;
-                                       goto lf;
-                               }
-                               break;
+                               w->ww_cur.c++;
+                               goto chklf;
                        case 'E':
                                w->ww_buf -= w->ww_w.t - w->ww_b.t;
                                w->ww_b.t = w->ww_w.t;
                        case 'E':
                                w->ww_buf -= w->ww_w.t - w->ww_b.t;
                                w->ww_b.t = w->ww_w.t;
@@ -205,5 +204,9 @@ int n;
        }
        if (hascursor)
                wwcursor(w, 1);
        }
        if (hascursor)
                wwcursor(w, 1);
-       return saven;
+       wwnwwr++;
+       wwnwwra += n;
+       n = p - savep;
+       wwnwwrc += n;
+       return n;
 }
 }