about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-12-18 10:42:36 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-12-18 10:42:36 +0000
commit1ee6295909c893c55693232a12f10cd8625a7260 (patch)
tree362a318d0d61d8922d6076bcc440f762a94e4d54 /Src/Zle
parentac33044bd2a99a0dd70784e98d89992737f44e98 (diff)
downloadzsh-1ee6295909c893c55693232a12f10cd8625a7260.tar.gz
zsh-1ee6295909c893c55693232a12f10cd8625a7260.tar.xz
zsh-1ee6295909c893c55693232a12f10cd8625a7260.zip
24279: allow terminal changes after zle -I to be acquired by main shell
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/zle_main.c14
-rw-r--r--Src/Zle/zle_thingy.c22
2 files changed, 35 insertions, 1 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 2817f9249..e29b759e9 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -208,10 +208,21 @@ mod_export void
 zsetterm(void)
 {
     struct ttyinfo ti;
-
 #if defined(FIONREAD)
     int val;
+#endif
 
+    if (fetchttyinfo) {
+	/*
+	 * User requested terminal to be returned to normal use,
+	 * so remember the terminal settings if not frozen.
+	 */
+	if (!ttyfrozen)
+	    gettyinfo(&shttyinfo);
+	fetchttyinfo = 0;
+    }
+
+#if defined(FIONREAD)
     ioctl(SHTTY, FIONREAD, (char *)&val);
     if (val) {
 	/*
@@ -1113,6 +1124,7 @@ zleread(char **lp, char **rp, int flags, int context)
     insmode = unset(OVERSTRIKE);
     eofsent = 0;
     resetneeded = 0;
+    fetchttyinfo = 0;
     raw_lp = lp;
     lpromptbuf = promptexpand(lp ? *lp : NULL, 1, NULL, NULL);
     pmpt_attr = txtchange;
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 536ddcd6a..fb0dbb092 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -711,6 +711,17 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
     return ret;
 }
 
+
+/*
+ * Flag that the user has requested the terminal be trashed
+ * for whatever use.  We attempt to keep the tty settings in
+ * this mode synced with the normal (non-zle) settings unless
+ * they are frozen.
+ */
+
+/**/
+int fetchttyinfo;
+
 /**/
 static int
 bin_zle_invalidate(UNUSED(char *name), UNUSED(char **args), UNUSED(Options ops), UNUSED(char func))
@@ -721,7 +732,18 @@ bin_zle_invalidate(UNUSED(char *name), UNUSED(char **args), UNUSED(Options ops),
      * true if a completion widget is active.
      */
     if (zleactive) {
+	int wastrashed = trashedzle;
 	trashzle();
+	if (!wastrashed && (zlereadflags & ZLRF_NOSETTY)) {
+	    /*
+	     * We normally wouldn't have restored the terminal
+	     * in this case, but as it's at user request we do
+	     * so (hence the apparently illogical sense of the
+	     * second part of the test).
+	     */
+	    settyinfo(&shttyinfo);
+	}
+	fetchttyinfo = 1;
 	return 0;
     } else
 	return 1;