zsh-workers
 help / color / mirror / code / Atom feed
* PATCH:  (one-liner) adjustwinsize doesn't update prompt string
@ 2005-08-06 17:20 Dan Bullok
  2005-08-08 10:32 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Bullok @ 2005-08-06 17:20 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 866 bytes --]

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.

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. 
-Dan

[-- Attachment #2: zsh-4.2.5-zrefresh.diff --]
[-- Type: text/x-diff, Size: 344 bytes --]

diff -ur 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 07:43:46.000000000 -0500
@@ -1054,7 +1054,7 @@
 	winchanged =
 #endif /* TIOCGWINSZ */
 	    resetneeded = 1;
-	zrefresh();
+	trashzle();
     }
 }
 
Only in zsh-4.2.5/Src: utils.c~

[-- Attachment #3: prompt_stretchy_setup --]
[-- Type: application/x-shellscript, Size: 1036 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: (one-liner) adjustwinsize doesn't update prompt string
  2005-08-06 17:20 PATCH: (one-liner) adjustwinsize doesn't update prompt string Dan Bullok
@ 2005-08-08 10:32 ` Peter Stephenson
  2005-08-08 17:58   ` Dan Bullok
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2005-08-08 10:32 UTC (permalink / raw)
  To: zsh-workers

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.

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.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: (one-liner) adjustwinsize doesn't update prompt string
  2005-08-08 10:32 ` Peter Stephenson
@ 2005-08-08 17:58   ` Dan Bullok
  2005-08-09 10:05     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Bullok @ 2005-08-08 17:58 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2622 bytes --]

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

[-- Attachment #2: zsh-4.2.5-zle_resetprompt.diff --]
[-- Type: text/x-diff, Size: 2707 bytes --]

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()

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: (one-liner) adjustwinsize doesn't update prompt string
  2005-08-08 17:58   ` Dan Bullok
@ 2005-08-09 10:05     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2005-08-09 10:05 UTC (permalink / raw)
  To: zsh-workers

Dan Bullok wrote:
> 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).

Seems to work, so I checked this on both branches (code is a little
different on main).  I'm not convinced we need both the zrefresh()
before and the redisplay() after the prompt expansion (even though the
logic depends on zleactive), but it's small enough that I haven't played
around with it.

> > 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).

Yes, I think so, too.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-08-09 10:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-06 17:20 PATCH: (one-liner) adjustwinsize doesn't update prompt string Dan Bullok
2005-08-08 10:32 ` Peter Stephenson
2005-08-08 17:58   ` Dan Bullok
2005-08-09 10:05     ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).