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

Re: PATCH: (one-liner) adjustwinsize doesn't update prompt string



On Monday 08 August 2005 05:32, Peter Stephenson wrote:
> Dan Bullok wrote:
> > zsh 4.2.5 does not re-evaluate the prompt string when the window size
> > changes.
> > When the window size changes, it seems to me that zle should know about
> > it, and redisplay the prompt appropriately. Most of the two line prompts
> > get very screwed up on a window resize, and you have to hit enter for
> > them to behave again.
>
> I'll apply this (and to 4.3 where the code is slightly different).
>
> > There's another closely related issue that's bugging me, which I don't
> > have a fix for. When the window is resized, zsh keeps moving the prompt
> > down a line at a time. This isn't a big deal, except that it often ends
> > up causing the display to scroll up so that I can't see anything but the
> > messed up prompt bits on screen. Is it necessary to do this when the
> > display is updated? Is there a way to prevent it without messing
> > everything else up? I've looked at zrefresh for a couple of hours, but
> > I'm completely confused by it.
>
> Yes, I can see this behaviour.  I'll try to remember to look and see
> what's going on, unless Geoff has any ideas.

I kept at this, and have made some progress  I'm able to completely work 
around this problem by creating a new function in Src/Zle/zle_main.c  called 
zle_resetprompt.  This does the same thing that resetprompt does, only it can 
be called from call the zle reset-prompt from outside of zle (i.e. in ).  
Then you don't have to call trashzle, which seems to be the cause of the 
extra newlines.  Instead, you call zle_resetprompt after calling zrefresh 
(before might work, too, but I didn't try it).

This is admittedly a circuitous solution, but it's the best I could come up 
with given my limited understanding of zsh internals.  If anyone's 
interested, the patch is very small, and is attached.



>
> By the way, our mail scanning software (blackspider) decided there was a
> virus (huntsman) in your script attachment.  It's presumably wrong, but
> anyway the attachment got blocked.

Hmmm.  Everything looks okay here.  Mail was sent from a hardened Linux box 
that gets regular inspections by rkhunter and chkrootkit.  It also seems to 
have gone through the mailing list intact, because I got a copy (and it's the 
same one I sent).  I think your virus scanner's probably overcautious (which 
isn't necessarily a bad thing).

There were two attachments (patch and demo prompt).  Did you get either one?  
If you want them, or this patch doesn't get through, and you want it, let me 
know how to send it to you to circumvent your scanner.

-Dan
diff -urb zsh-4.2.5.ORIG/Src/Zle/zle.h zsh-4.2.5/Src/Zle/zle.h
--- zsh-4.2.5.ORIG/Src/Zle/zle.h	2003-01-27 08:54:52.000000000 -0600
+++ zsh-4.2.5/Src/Zle/zle.h	2005-08-06 14:17:52.000000000 -0500
@@ -28,6 +28,7 @@
  */
 
 #undef trashzle
+#undef zle_resetprompt
 #undef zleread
 #undef spaceinline
 #undef zrefresh
diff -urb zsh-4.2.5.ORIG/Src/Zle/zle_main.c zsh-4.2.5/Src/Zle/zle_main.c
--- zsh-4.2.5.ORIG/Src/Zle/zle_main.c	2005-04-01 04:35:09.000000000 -0600
+++ zsh-4.2.5/Src/Zle/zle_main.c	2005-08-06 14:17:59.000000000 -0500
@@ -1358,6 +1358,16 @@
 
 /**/
 mod_export void
+zle_resetprompt(void)
+{   reexpandprompt();
+    if (zleactive)
+        redisplay(NULL);
+}
+
+
+
+/**/
+mod_export void
 trashzle(void)
 {
     if (zleactive) {
@@ -1435,6 +1445,7 @@
 {
     /* Set up editor entry points */
     trashzleptr = trashzle;
+    zle_resetpromptptr = zle_resetprompt;
     refreshptr = zrefresh;
     spaceinlineptr = spaceinline;
     zlereadptr = zleread;
@@ -1519,6 +1530,7 @@
 
     /* editor entry points */
     trashzleptr = noop_function;
+    zle_resetpromptptr = noop_function;
     refreshptr = noop_function;
     spaceinlineptr = noop_function_int;
     zlereadptr = fallback_zleread;
diff -urb zsh-4.2.5.ORIG/Src/init.c zsh-4.2.5/Src/init.c
--- zsh-4.2.5.ORIG/Src/init.c	2005-04-01 04:20:30.000000000 -0600
+++ zsh-4.2.5/Src/init.c	2005-08-06 14:18:47.000000000 -0500
@@ -1125,6 +1125,8 @@
 /**/
 mod_export ZleVoidFn trashzleptr = noop_function;
 /**/
+mod_export ZleVoidFn zle_resetpromptptr = noop_function;
+/**/
 mod_export ZleVoidFn refreshptr = noop_function;
 /**/
 mod_export ZleVoidIntFn spaceinlineptr = noop_function_int;
@@ -1136,6 +1138,7 @@
 #else /* !LINKED_XMOD_zshQszle */
 
 mod_export ZleVoidFn trashzleptr = noop_function;
+mod_export ZleVoidFn zle_resetpromptptr = noop_function;
 mod_export ZleVoidFn refreshptr = noop_function;
 mod_export ZleVoidIntFn spaceinlineptr = noop_function_int;
 # ifdef UNLINKED_XMOD_zshQszle
diff -urb zsh-4.2.5.ORIG/Src/utils.c zsh-4.2.5/Src/utils.c
--- zsh-4.2.5.ORIG/Src/utils.c	2005-03-21 12:49:00.000000000 -0600
+++ zsh-4.2.5/Src/utils.c	2005-08-06 14:17:43.000000000 -0500
@@ -1055,6 +1055,7 @@
 #endif /* TIOCGWINSZ */
 	    resetneeded = 1;
 	zrefresh();
+        zle_resetprompt();
     }
 }
 
diff -urb zsh-4.2.5.ORIG/Src/zsh.h zsh-4.2.5/Src/zsh.h
--- zsh-4.2.5.ORIG/Src/zsh.h	2005-01-12 06:19:06.000000000 -0600
+++ zsh-4.2.5/Src/zsh.h	2005-08-06 14:20:19.000000000 -0500
@@ -28,6 +28,7 @@
  */
 
 #define trashzle()      trashzleptr()
+#define zle_resetprompt()      zle_resetpromptptr()
 #define zleread(X,Y,H,C)  zlereadptr(X,Y,H,C)
 #define spaceinline(X)  spaceinlineptr(X)
 #define zrefresh()      refreshptr()


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