Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: zleread flags



I did this while thinking about the problem with history in vared, but
since I haven't got any further with that, I may as well post it.  It
simply makes the use of the flags passed to zle simpler and easier to
extend.  I hope I've reconstructed it correctly, since I applied some
patches in the meanwhile.  It'll be in the next development version,
anyway.

Index: Src/zsh.h
===================================================================
--- Src/zsh.h	2000/01/04 22:04:35	1.4
+++ Src/zsh.h	2000/01/04 22:05:19
@@ -1653,8 +1653,8 @@
 /* Flags to third argument of zle */
 /**********************************/
 
-#define ZLRF_HISTORY	0x01
-#define ZLRF_NOSETTY	0x02
+#define ZLRF_HISTORY	0x01	/* OK to access the history list */
+#define ZLRF_NOSETTY	0x02	/* Don't set tty before return */
 
 /****************/
 /* Entry points */
Index: Src/Zle/zle_main.c
===================================================================
--- Src/Zle/zle_main.c	1999/12/21 15:18:28	1.3
+++ Src/Zle/zle_main.c	2000/01/04 22:09:11
@@ -46,6 +46,11 @@
 /**/
 mod_export int hascompmod;
 
+/* ZLRF_* flags passed to zleread() */
+
+/**/
+int zlereadflags;
+
 /* != 0 if we're done editing */
 
 /**/
@@ -447,8 +452,6 @@
     return ret;
 }
 
-static int no_restore_tty;
-
 /* Read a line.  It is returned metafied. */
 
 /**/
@@ -505,8 +508,8 @@
     pmpt_attr = txtchange;
     rpromptbuf = promptexpand(rp, 1, NULL, NULL);
     rpmpt_attr = txtchange;
-    histallowed = (flags & ZLRF_HISTORY);
     PERMALLOC {
+	zlereadflags = flags;
 	histline = curhist;
 #ifdef HAVE_SELECT
 	FD_ZERO(&foofd);
@@ -540,8 +543,6 @@
 	if (tmout)
 	    alarm(tmout);
 	zleactive = 1;
-	if (flags & ZLRF_NOSETTY)
-	  no_restore_tty = 1;
 	resetneeded = 1;
 	errflag = retflag = 0;
 	lastcol = -1;
@@ -592,7 +593,7 @@
 	trashzle();
 	free(lpromptbuf);
 	free(rpromptbuf);
-	zleactive = no_restore_tty = 0;
+	zleactive = zlereadflags = 0;
 	alarm(0);
     } LASTALLOC;
     freeundo();
@@ -974,7 +975,7 @@
 	    fprintf(shout, "%s", postedit);
 	fflush(shout);
 	resetneeded = 1;
-	if (!no_restore_tty)
+	if (!(zlereadflags & ZLRF_NOSETTY))
 	  settyinfo(&shttyinfo);
     }
     if (errflag)
Index: Src/Zle/zle_hist.c
===================================================================
--- Src/Zle/zle_hist.c	1999/11/28 17:42:29	1.1
+++ Src/Zle/zle_hist.c	2000/01/04 22:04:35	1.2
@@ -30,12 +30,6 @@
 #include "zle.mdh"
 #include "zle_hist.pro"
 
-/* Are references to earlier history lines permitted?  == 0 if       *
- * editing or reading a standalone line, such as in vared or select. */
-
-/**/
-int histallowed;
-
 /* Column position of vi ideal cursor.  -1 if it is unknown -- most *
  * movements and changes do this.                                   */
 
@@ -126,7 +120,7 @@
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed)
+	if (virangeflag || !(zlereadflags & ZLRF_HISTORY))
 	    return 1;
 	zmult = n;
 	ret = uphistory(args);
@@ -156,7 +150,7 @@
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed)
+	if (virangeflag || !(zlereadflags & ZLRF_HISTORY))
 	    return 1;
 	zmult = n;
 	ret = historysearchbackward(args);
@@ -210,7 +204,7 @@
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed)
+	if (virangeflag || !(zlereadflags & ZLRF_HISTORY))
 	    return 1;
 	zmult = n;
 	ret = downhistory(args);
@@ -240,7 +234,7 @@
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed)
+	if (virangeflag || !(zlereadflags & ZLRF_HISTORY))
 	    return 1;
 	zmult = n;
 	ret = historysearchforward(args);

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>



Messages sorted by: Reverse Date, Date, Thread, Author