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

Re: clear to end of display

On Mar 18,  9:18am, Danny Dulai wrote:
} Subject: clear to end of display
} Every time ZLE prints the prompt, I get a ^[[K (erase display) printed out.
} It occurs on the character right before the prompt is printed. If I
} unsetopt zle, it stops printing, so ZLE is probably at fault.

[In another message]
} Its also printing out a ^[[K at the end of the prompt. i thought the %E was
} supposed to clear to end of line. I have no %E and yet its still generating
} this esc seq to clear the line.

What you should be seeing is a clear-to-end-of-display before the prompt
is printed, and a clear-to-end-of-line after it.  It's suspicious that
you get the same thing both times, so the termcap/terminfo description
of your terminal may be messed up.  If what you're actually getting is
clear-screen-and-home-cursor, termcap/terminfo is _badly_ messed up.

The %E sequence is for use in prompts that move the cursor around inside
%{...%} blocks and need to erase lines that may be above the prompt.

What's the problem with having a clear-eol after the prompt?

[Back in the first message]
} I'm wondering why this happens, and how can I turn it off. Bash does not
} exhibit this havior.

I believe this has to do with the always_last_prompt option -- the code
that prints the prompt wants to be sure that there's a clean slate below
the prompt where it can display completion listings.  However, it's a
bit too aggressive; it performs the clear-eod whenever it's "safe" to do
so (that is, whenever there's no completion listing there already that
needs to continue to be seen) and not just whenever it's necessary to do
so (which it -almost- never is when always_last_prompt is not set).

The problem is with that -almost-.  The following patch makes zle use
clear-eod less aggressively, but I'm not confident that it won't leave
garbage characters visible when some part of the completion system is
drawing on the screen.  I don't *think* there are any problems, because
the completion list code prints its own clear-eod (at least in 3.1.6+),
but only Geoff and Sven would know for certain.

It may also be that there's a better way to do this; the change below
makes prompt display slightly less efficient by causing it to emit a
clear-eol (or a string of spaces if the terminal can't clear-eol) after
each line it prints (that's the effect of cleareol = 1).  That shouldn't
make much difference if you don't have a multi-line prompt.

The "Index" line is relative to the 3.1.6 sources, but this will also
apply to Src/zle_refresh.c in 3.0.7.  Note to zsh-workers, I don't think
we should include this patch "officially" until at least Geoff has had a
chance to comment on it.

Index: Src/Zle/zle_refresh.c
@@ -333,7 +333,7 @@
 	tsetcap(TCUNDERLINEEND, 0);
         if (!clearflag) {
-            if (tccan(TCCLEAREOD))
+            if (tccan(TCCLEAREOD) && isset(ALWAYSLASTPROMPT))
                 cleareol = 1;   /* request: clear to end of line */

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

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