zsh-workers
 help / color / mirror / code / Atom feed
From: Wayne Davison <wayned@users.sourceforge.net>
To: zsh-workers@zsh.org
Subject: Re: Mac OS X Prompt Bug
Date: Wed, 24 Nov 2010 11:04:33 -0800	[thread overview]
Message-ID: <AANLkTi=i3GyrJLKVCRAp0BstOMMf3n0AXUs5PrTnmxQo@mail.gmail.com> (raw)
In-Reply-To: <20101124160832.GA5062@prunille.vinc17.org>

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

On Wed, Nov 24, 2010 at 8:08 AM, Vincent Lefevre <vincent@vinc17.net> wrote:

> Couldn't the mark be printed exactly at the same time of the prompt?
>

That wouldn't be desirable, because it can allow other output to muck things
up.  The PROMPT_SP needs to happen as soon after the command exits as
possible to ensure that its output-idiom has the largest chance of just
affecting incomplete output from the program (e.g. we actually want to cover
up type-ahead that shows up just prior to the prompt).

One thing that could be done to improve the PROMPT_SP heuristic is to output
a extra space (assuming the width (w) is 1) and another CR after the
trailing CR that is currently output.  That would ensure that newlines
wouldn't show a superfluous percent when no dangling output was present.
 So, how about this?

--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1292,9 +1292,7 @@ preprompt(void)
        countprompt(str, &w, 0, -1);
        opts[PROMPTPERCENT] = percents;
        zputs(str, shout);
-       for (w = (int)columns - w - !hasxn; w > 0; w--)
-           putc(' ', shout);
-       putc('\r', shout);
+       fprintf(shout, "%*s\r%*s\r", (int)columns - w - !hasxn, "", w, "");
        free(str);
     }


I'm not sure if that works well for the case where hasxn isn't set, though.
 We may want to create a separate fprintf() for that case which leaves the
no-hasxn case alone:

--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1292,9 +1292,10 @@ preprompt(void)
        countprompt(str, &w, 0, -1);
        opts[PROMPTPERCENT] = percents;
        zputs(str, shout);
-       for (w = (int)columns - w - !hasxn; w > 0; w--)
-           putc(' ', shout);
-       putc('\r', shout);
+       if (hasxn)
+           fprintf(shout, "%*s\r%*s\r", (int)columns - w, "", w, "");
+       else
+           fprintf(shout, "%*s\r", (int)columns - w - 1, "");
        free(str);
     }


..wayne..

  parent reply	other threads:[~2010-11-24 19:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-24 13:58 Sorin Ionescu
2010-11-24 15:24 ` Peter Stephenson
2010-11-24 16:08   ` Vincent Lefevre
2010-11-24 16:53     ` Peter Stephenson
2010-11-24 19:04     ` Wayne Davison [this message]
2010-11-25 10:38       ` Peter Stephenson
2010-11-24 15:30 ` Vincent Lefevre
2010-11-24 16:59   ` Sorin Ionescu
2010-11-24 17:49     ` Benjamin R. Haskell
2010-11-24 21:14       ` Sorin Ionescu
2010-11-24 23:49         ` Bart Schaefer

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='AANLkTi=i3GyrJLKVCRAp0BstOMMf3n0AXUs5PrTnmxQo@mail.gmail.com' \
    --to=wayned@users.sourceforge.net \
    --cc=zsh-workers@zsh.org \
    /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).