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

Re: Mac OS X Prompt Bug



On Wed, Nov 24, 2010 at 8:08 AM, Vincent Lefevre <vincent@xxxxxxxxxx> 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..


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