zsh-workers
 help / color / mirror / code / Atom feed
* Simulating ZLE_RPROMPT_INDENT=0
@ 2013-12-18  6:43 Bart Schaefer
  2013-12-18  9:27 ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2013-12-18  6:43 UTC (permalink / raw)
  To: zsh-workers

I wrote:
> Src/Zle/zle_refresh.c:moveto() knows that the last character that was
> output for the right-prompt was in the rightmost column.  What it does
> not know is whether that left the cursor AT the rightmost column, or
> whether it wrapped around to the next line.

For terminals like xterm where the line doesn't wrap until the *next*
character is output, one can do something like this:

zmodload zsh/terminfo
RPS1="${RPS1%?}%{${(M)RPS1%?}${terminfo[cub1]}%}"

What this does is:

- Tell ZLE that $RPS1 is one character shorter than it really is, by
  putting the last character inside %{ %}

- Include a "move back one" sequence after that last character; when
  this is output, the terminal will silently swallow it without moving
  the cursor.

Thus there's a way to create the ZLE_RPROMPT_INDENT=0 behavior in almost
any version of zsh, if your terminal works in the "right" way.

I believe we concluded some years ago that it's not possible to reliably
tell from termcap/terminfo descriptions whether this sort of trick will
work, which is why moveto() is written the way it is.  However, as we
have now made ZLE_RPROMPT_INDENT the user's responsibility, we could
simply assume that if ZLE_RPROMPT_INDENT=0, then printing the cub1
sequence will do the right thing.  (An extra check could be that the
cub1 sequence is not backspace or del.)

To do this would require that rprompt_off be available in moveto(), which
likely means it needs to become global like vln and vcs.  It's rather
inefficient anyway to be looking up the value of ZLE_RPROMPT_INDENT every
time zrefresh() is called; it ought to be handled like LINES/COLUMNS.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-12-20  7:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-18  6:43 Simulating ZLE_RPROMPT_INDENT=0 Bart Schaefer
2013-12-18  9:27 ` Peter Stephenson
2013-12-18 17:26   ` Bart Schaefer
2013-12-18 17:38     ` Peter Stephenson
2013-12-18 18:43       ` Bart Schaefer
2013-12-18 19:37         ` Peter Stephenson
2013-12-19  7:33           ` Bart Schaefer
2013-12-19  8:04             ` Bart Schaefer
2013-12-19 20:36             ` Peter Stephenson
2013-12-20  7:28               ` IPDEF5U [was Re: Simulating ZLE_RPROMPT_INDENT=0] Bart Schaefer

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).