about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-13 17:00:37 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-13 17:00:37 +0000
commit1dbb0b4247592c0bd4d135693e86c3a20b823037 (patch)
treeb2cee6934b16b0465773c4a141d57e8a81dc35b0
parent336ba32a4322a9a50d597d724e33cb22658ed103 (diff)
downloadzsh-1dbb0b4247592c0bd4d135693e86c3a20b823037.tar.gz
zsh-1dbb0b4247592c0bd4d135693e86c3a20b823037.tar.xz
zsh-1dbb0b4247592c0bd4d135693e86c3a20b823037.zip
zsh-workers/10117
-rw-r--r--Doc/Zsh/mod_zle.yo7
-rw-r--r--Src/Zle/zle_params.c21
-rw-r--r--Src/Zle/zle_thingy.c26
3 files changed, 43 insertions, 11 deletions
diff --git a/Doc/Zsh/mod_zle.yo b/Doc/Zsh/mod_zle.yo
index 9e15cd6ff..6fd719488 100644
--- a/Doc/Zsh/mod_zle.yo
+++ b/Doc/Zsh/mod_zle.yo
@@ -184,7 +184,8 @@ xitem(tt(zle) tt(-C) var(widget) var(completion-widget) var(function))
 xitem(tt(zle) tt(-R) [ tt(-c) ] [ var(display-string) ] [ var(string) ... ])
 xitem(tt(zle) tt(-M) var(string))
 xitem(tt(zle) tt(-U) var(string))
-item(tt(zle) var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...)(
+xitem(tt(zle) var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...)
+item(tt(zle))(
 The tt(zle) builtin performs a number of different actions concerning
 ZLE.  Which operation it performs depends on its options:
 
@@ -289,5 +290,9 @@ tt(zle) command.  Thus if a user defined widget requires an immediate beep,
 it should call the tt(beep) widget directly.
 )
 enditem()
+
+With no options and no arguments, only the returns status will be
+set. It is zero if ZLE is currently active and widgets could be
+invoked using this builtin command and non-zero if ZLE is not active.
 )
 enditem()
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index a6dc2bc67..26059c871 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -57,6 +57,8 @@ static struct zleparam {
 	zleunsetfn, NULL },
     { "CURSOR",  PM_INTEGER, FN(set_cursor),  FN(get_cursor),
 	zleunsetfn, NULL },
+    { "MARK",  PM_INTEGER, FN(set_mark),  FN(get_mark),
+	zleunsetfn, NULL },
     { "LBUFFER", PM_SCALAR,  FN(set_lbuffer), FN(get_lbuffer),
 	zleunsetfn, NULL },
     { "RBUFFER", PM_SCALAR,  FN(set_rbuffer), FN(get_rbuffer),
@@ -173,6 +175,25 @@ get_cursor(Param pm)
 
 /**/
 static void
+set_mark(Param pm, zlong x)
+{
+    if (x < 0)
+	mark = 0;
+    else if (x > ll)
+	mark = ll;
+    else
+	mark = x;
+}
+
+/**/
+static zlong
+get_mark(Param pm)
+{
+    return mark;
+}
+
+/**/
+static void
 set_lbuffer(Param pm, char *x)
 {
     char *y;
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index 25a78c9b9..fd9fa3e7f 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -434,7 +434,13 @@ bin_zle_refresh(char *name, char **args, char *ops, char func)
 static int
 bin_zle_mesg(char *name, char **args, char *ops, char func)
 {
+    if (!zleactive) {
+	zerrnam(name, "can only be called from widget function", NULL, 0);
+	return 1;
+    }
     showmsg(*args);
+    if (sfcontext != SFC_WIDGET)
+	zrefresh();
     return 0;
 }
 
@@ -442,14 +448,14 @@ bin_zle_mesg(char *name, char **args, char *ops, char func)
 static int
 bin_zle_unget(char *name, char **args, char *ops, char func)
 {
-    char *p = *args;
+    char *b = *args, *p = b + strlen(b);
 
     if (!zleactive) {
 	zerrnam(name, "can only be called from widget function", NULL, 0);
 	return 1;
     }
-    while (*p)
-	ungetkey((int) *p++);
+    while (p > b)
+	ungetkey((int) *--p);
     return 0;
 }
 
@@ -589,18 +595,18 @@ bin_zle_call(char *name, char **args, char *ops, char func)
     int ret, saveflag = 0;
     char *wname = *args++;
 
-    if(!zleactive || incompctlfunc || incompfunc) {
-	zerrnam(name, "widgets can only be called when ZLE is active",
-	    NULL, 0);
-	return 1;
-    }
-
     if (!wname) {
-	zwarnnam(name, "wrong number of arguments", NULL, 0);
 	if (saveflag)
 	    zmod = modsave;
+	return (!zleactive || incompctlfunc || incompfunc ||
+		sfcontext != SFC_WIDGET);
+    }
+    if(!zleactive || incompctlfunc || incompfunc || sfcontext != SFC_WIDGET) {
+	zerrnam(name, "widgets can only be called when ZLE is active",
+	    NULL, 0);
 	return 1;
     }
+
     while (*args && **args == '-') {
 	char *num;
 	if (!args[0][1] || args[0][1] == '-') {