about summary refs log tree commit diff
path: root/Src/Zle/zle_params.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-07-01 16:50:41 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-07-01 16:50:41 +0000
commit1a1b108b341885da0a70d550384c9ec32a627615 (patch)
treefd8ad7f31204540e6d99bac4ef66a9e1914f2798 /Src/Zle/zle_params.c
parent964f819070c1d506bfcd45e25704ae23c8f09ed4 (diff)
downloadzsh-1a1b108b341885da0a70d550384c9ec32a627615.tar.gz
zsh-1a1b108b341885da0a70d550384c9ec32a627615.tar.xz
zsh-1a1b108b341885da0a70d550384c9ec32a627615.zip
17390: new zle parameters $PREDISPLAY, $POSTDISPLAY
Diffstat (limited to 'Src/Zle/zle_params.c')
-rw-r--r--Src/Zle/zle_params.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index e2bbdd20b..ef8a98139 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -85,6 +85,10 @@ static struct zleparam {
 	unset_cutbuffer, NULL },
     { "killring", PM_ARRAY, FN(set_killring), FN(get_killring),
 	unset_killring, NULL },
+    { "PREDISPLAY", PM_SCALAR, FN(set_predisplay), FN(get_predisplay),
+	zleunsetfn, NULL },
+    { "POSTDISPLAY", PM_SCALAR, FN(set_postdisplay), FN(get_postdisplay),
+	zleunsetfn, NULL },
     { NULL, 0, NULL, NULL, NULL, NULL }
 };
 
@@ -462,3 +466,53 @@ unset_killring(Param pm, int exp)
 	stdunsetfn(pm, exp);
     }
 }
+
+static void
+set_prepost(unsigned char **textvar, int *lenvar, char *x)
+{
+    if (*lenvar) {
+	zfree(*textvar, *lenvar);
+	*textvar = NULL;
+	*lenvar = 0;
+    }
+    if (x) {
+	unmetafy(x, lenvar);
+	*textvar = (unsigned char *)zalloc(*lenvar);
+	memcpy((char *)*textvar, x, *lenvar);
+	free(x);
+    }
+}
+
+static char *
+get_prepost(unsigned char *text, int len)
+{
+    return metafy((char *)text, len, META_HEAPDUP);
+}
+
+/**/
+static void
+set_predisplay(Param pm, char *x)
+{
+    set_prepost(&predisplay, &predisplaylen, x);
+}
+
+/**/
+static char *
+get_predisplay(Param pm)
+{
+    return get_prepost(predisplay, predisplaylen);
+}
+
+/**/
+static void
+set_postdisplay(Param pm, char *x)
+{
+    set_prepost(&postdisplay, &postdisplaylen, x);
+}
+
+/**/
+static char *
+get_postdisplay(Param pm)
+{
+    return get_prepost(postdisplay, postdisplaylen);
+}