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

PATCH: PREBUFFER parameter



I've been talking about this one already...

This adds a special zle parameter `PREBUFFER' (there may be a better
name) that gives (read-only) access to the lines before the current
one in a multi-line input buffer. This is just a string with the whole 
stuff, separated by newlines -- it was the easiest thing to do.

Bye
 Sven

diff -u os/Zle/zle_params.c Src/Zle/zle_params.c
--- os/Zle/zle_params.c	Fri Mar 26 11:50:01 1999
+++ Src/Zle/zle_params.c	Fri Mar 26 11:57:42 1999
@@ -61,6 +61,8 @@
 	zleunsetfn, NULL },
     { "RBUFFER", PM_SCALAR,  FN(set_rbuffer), FN(get_rbuffer),
 	zleunsetfn, NULL },
+    { "PREBUFFER",  PM_SCALAR | PM_READONLY,  NULL,  FN(get_prebuffer),
+	zleunsetfn, NULL },
     { "WIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_widget),
         zleunsetfn, NULL },
     { "LASTWIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_lwidget),
@@ -208,6 +210,16 @@
 get_rbuffer(Param pm)
 {
     return metafy((char *)line + cs, ll - cs, META_HEAPDUP);
+}
+
+/**/
+static char *
+get_prebuffer(Param pm)
+{
+    if (chline)
+	return dupstrpfx(chline, hptr - chline);
+    else
+	return dupstring("");
 }
 
 /**/
diff -u od/Zsh/zle.yo Doc/Zsh/zle.yo
--- od/Zsh/zle.yo	Fri Mar 26 11:49:48 1999
+++ Doc/Zsh/zle.yo	Fri Mar 26 12:43:43 1999
@@ -139,6 +139,12 @@
 If it is assigned to, only that part of the buffer is replaced, and the
 cursor remains between the old tt($LBUFFER) and the new tt($RBUFFER).
 )
+vindex(PREBUFFER)
+item(tt(PREBUFFER) (scalar))(
+In a multi-line input at the secondary prompt, this read-only parameter
+contains the contents of the lines before the one the cursor is
+currently in.
+)
 vindex(WIDGET)
 item(tt(WIDGET) (scalar))(
 The name of the widget currently being executed.

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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