zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: Re: Weird behaviour with certain PS1-sequences
Date: Tue, 28 Sep 1999 10:54:04 +0200	[thread overview]
Message-ID: <9909280854.AA28230@ibmth.df.unipi.it> (raw)
In-Reply-To: "Dan Nelson"'s message of "Mon, 27 Sep 1999 17:06:47 DFT." <19990927170647.A5674@dan.emsphone.com>

Dan Nelson wrote:
> % zsh -f
> % PROMPT="%m %n %/ %%"
> dan dan /home/dan % TERM=dumb
> dan dan /home/dan % 
>                     ^ blanks start here and don't stop

Yes, I can see this, and what's going wrong, in the refresh code.
Unfortunately I'm not sure I understand the logic well enough to fix it,
though if Geoff doesn't get around to it I will have to try.

The spaces in the prompt match what is on the line already at that point,
i.e. nothing.  singmoveto() is called to skip over them, one by one.
(Since we're skipping only one character in this example, it would
presumably be more efficient just to output it, but that's a different
question.)  singmoveto() correctly finds out that we need to move one
character to the right, and calls tc_rightcurs() to do this.  Here, all the
easy things you can do with proper terminals fail, and it gets down to the
code currently around line 948 for dumb terminals.

This is where all hell breaks loose.  For reasons I am totally at a loss to
understand, if we are printing in the prompt, as we currently are, the code
assumes we can just write out the entire rest of the prompt, then fix the
position up after.  But, obviously, in this case fixing up after means
skipping back over all the unnecessary characters we've just printed to get
where we were.  The code correctly counts the offset we need to fix up the
position, but it's minus something because we're way past.  The remainder
of tc_rightcurs() assumes this offset (ct) is positive and tries to output
spaces to match, which puts it into a loop eternally decrementing ct, at
least until it wraps round after 4,000,000,000 or so.

The obvious simple fix is to write out only the bit of the prompt we need
to advance to the right position.  But I don't understand why it's the way
it is at the moment, so I'd better not try to rewrite it myself.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-09-28  9:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-27 19:14 Juhapekka Tolvanen
1999-09-27 19:57 ` Bart Schaefer
1999-09-27 20:03   ` Juhapekka Tolvanen
1999-09-27 22:06   ` Dan Nelson
1999-09-28  8:54     ` Peter Stephenson [this message]
1999-10-03  8:15       ` PATCH: 3.1.6: promptexpand (Re: Weird behaviour with certain PS1-sequences) Bart Schaefer
1999-10-03  9:04       ` PATCH: 3.1.6* (Was: " Geoff Wing

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=9909280854.AA28230@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.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).