zsh-workers
 help / color / mirror / code / Atom feed
From: Dan Bullok <dan.zsh@bullok.com>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: (one-liner) adjustwinsize doesn't update prompt string
Date: Mon, 8 Aug 2005 12:58:37 -0500	[thread overview]
Message-ID: <200508081258.38014.dan.zsh@bullok.com> (raw)
In-Reply-To: <200508081032.j78AWcfg008014@news01.csr.com>

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

  reply	other threads:[~2005-08-08 17:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-06 17:20 Dan Bullok
2005-08-08 10:32 ` Peter Stephenson
2005-08-08 17:58   ` Dan Bullok [this message]
2005-08-09 10:05     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200508081258.38014.dan.zsh@bullok.com \
    --to=dan.zsh@bullok.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).