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

Re: zle -R glitch



=?ISO-8859-1?Q?Johan_Sundstr=F6m?= wrote:

> Hi!
> 
> I just had a peek at the new (to me, at least) widget system, and
> impressed as I am, I found something that might need some fixing. As
> an exercise, I tried implementing a "what-line" function:
> 
> function what-line () { zle -R "Line $HISTNO" }
> zle -N what-line
> 
> ...but when I try it out (M-x what-line), I am barely able to make out the
> output before it is flashed away again. Setting up keyboard repeat rate
> and keeping M-z down for a while confirmed that the function seems to work
> otherwise, but I would have expected the function to work more like the
> what-cursor-position, that is, to stay visible on the status line.

That's how it should be. Note that the manual says that the string is
displayed in the status line which is used by widgets to display
strings *while the widget is active* (like M-x and some others do it).

However, I hadn't looked at w-c-p, otherwise I would have added an
option-interface to showmsg() immediatly.

So, the patch below adds the -M option to the zle builtin which allows 
to give a string that will be displayed below the prompt that will
stay there when the widget returns. I prefer to use a different option 
for this instead of changing -R because it makes the list-display
feature of -R easier (using only code that already exists anyway).

Bye
 Sven

diff -ru ../z.old/Doc/Zsh/mod_zle.yo Doc/Zsh/mod_zle.yo
--- ../z.old/Doc/Zsh/mod_zle.yo	Thu Jan 13 09:57:47 2000
+++ Doc/Zsh/mod_zle.yo	Thu Jan 13 10:10:55 2000
@@ -180,6 +180,7 @@
 xitem(tt(zle) tt(-N) var(widget) [ var(function) ])
 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) ...)(
 The tt(zle) builtin performs a number of different actions concerning
@@ -241,6 +242,17 @@
 prompt in the same way as completion lists are printed. If no
 var(string)s are given but the tt(-c) option is used such a list is
 cleared.
+
+Note that this option is only useful for widgets that do not exit
+immediatly after using it because the strings displayed will be erased 
+immediatly after return from the widget.
+)
+item(tt(-M) var(string))(
+As with the tt(-R) option, the var(string) will be displayed below the 
+command line. But unlike the tt(-R) option the string not be put into
+the status line but will instead be printed normally below the
+prompt. This means that the var(string) will still be displayed after
+the widget returns (until it is overwritten by subsequent commands).
 )
 item(tt(-U) var(string))(
 This puts the characters in the var(string) in the input queue of
diff -ru ../z.old/Src/Zle/zle_thingy.c Src/Zle/zle_thingy.c
--- ../z.old/Src/Zle/zle_thingy.c	Thu Jan 13 10:12:08 2000
+++ Src/Zle/zle_thingy.c	Thu Jan 13 10:04:04 2000
@@ -337,6 +337,7 @@
 	{ 'N', bin_zle_new,  1,  2 },
 	{ 'C', bin_zle_complete, 3, 3 },
 	{ 'R', bin_zle_refresh, 0, -1 },
+	{ 'M', bin_zle_mesg, 1, 1 },
 	{ 'U', bin_zle_unget, 1, 1 },
 	{ 0,   bin_zle_call, 0, -1 },
     };
@@ -426,6 +427,14 @@
     clearlist = ocl;
     statusline = s;
     statusll = sl;
+    return 0;
+}
+
+/**/
+static int
+bin_zle_mesg(char *name, char **args, char *ops, char func)
+{
+    showmsg(*args);
     return 0;
 }
 

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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