BSD 4_3 release
[unix-history] / usr / src / ucb / ex / ex_v.c
index 5111e90..bf1e335 100644 (file)
@@ -1,5 +1,13 @@
-/* Copyright (c) 1981 Regents of the University of California */
-static char *sccsid = "@(#)ex_v.c      7.2     9/3/81";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char *sccsid = "@(#)ex_v.c      7.8 (Berkeley) 6/7/85";
+#endif not lint
+
 #include "ex.h"
 #include "ex_re.h"
 #include "ex_tty.h"
 #include "ex.h"
 #include "ex_re.h"
 #include "ex_tty.h"
@@ -47,6 +55,9 @@ static char *sccsid = "@(#)ex_v.c     7.2     9/3/81";
  *             absolute motions, contextual displays, line depth determination
  */
 
  *             absolute motions, contextual displays, line depth determination
  */
 
+jmp_buf venv;
+int    winch();
+
 /*
  * Enter open mode
  */
 /*
  * Enter open mode
  */
@@ -60,7 +71,15 @@ oop()
        char atube[TUBESIZE + LBSIZE];
 #endif
        ttymode f;      /* mjm: was register */
        char atube[TUBESIZE + LBSIZE];
 #endif
        ttymode f;      /* mjm: was register */
+       int resize;
 
 
+       if (resize = setjmp(venv)) {
+               setsize();
+               initev = (char *)0;
+               inopen = 0;
+               addr1 = addr2 = dot;
+       }
+       (void)signal(SIGWINCH, winch);
        ovbeg();
        if (peekchar() == '/') {
                ignore(compile(getchar(), 1));
        ovbeg();
        if (peekchar() == '/') {
                ignore(compile(getchar(), 1));
@@ -117,6 +136,7 @@ oop()
                vclean();
        Command = "open";
        ovend(f);
                vclean();
        Command = "open";
        ovend(f);
+       (void)signal(SIGWINCH, SIG_DFL);
 }
 
 ovbeg()
 }
 
 ovbeg()
@@ -162,6 +182,7 @@ vop()
        char atube[TUBESIZE + LBSIZE];
 #endif
        ttymode f;      /* mjm: was register */
        char atube[TUBESIZE + LBSIZE];
 #endif
        ttymode f;      /* mjm: was register */
+       int resize;
 
        if (!CA && UP == NOSTR) {
                if (initev) {
 
        if (!CA && UP == NOSTR) {
                if (initev) {
@@ -188,6 +209,13 @@ toopen:
                        goto toopen;
                error("Visual requires scrolling");
        }
                        goto toopen;
                error("Visual requires scrolling");
        }
+       if (resize = setjmp(venv)) {
+               setsize();
+               initev = (char *)0;
+               inopen = 0;
+               addr1 = addr2 = dot;
+       }
+       (void)signal(SIGWINCH, winch);
        ovbeg();
        bastate = VISUAL;
        c = 0;
        ovbeg();
        bastate = VISUAL;
        c = 0;
@@ -210,6 +238,7 @@ toopen:
        vmain();
        Command = "visual";
        ovend(f);
        vmain();
        Command = "visual";
        ovend(f);
+       (void)signal(SIGWINCH, SIG_DFL);
 }
 
 /*
 }
 
 /*
@@ -359,12 +388,18 @@ vok(atube)
 #ifdef CBREAK
 vintr()
 {
 #ifdef CBREAK
 vintr()
 {
+       extern jmp_buf readbuf;
+       extern int doingread;
 
        signal(SIGINT, vintr);
        if (vcatch)
                onintr();
        ungetkey(ATTN);
        draino();
 
        signal(SIGINT, vintr);
        if (vcatch)
                onintr();
        ungetkey(ATTN);
        draino();
+       if (doingread) {
+               doingread = 0;
+               longjmp(readbuf, 1);
+       }
 }
 #endif
 
 }
 #endif
 
@@ -387,3 +422,10 @@ vsetsiz(size)
        basWTOP = b;
        basWLINES = WBOT - b + 1;
 }
        basWTOP = b;
        basWLINES = WBOT - b + 1;
 }
+
+winch()
+{
+       vsave();
+       setty(normf);
+       longjmp(venv, 1);
+}