zsh-workers
 help / color / mirror / code / Atom feed
From: Patrick Oscity <patrick.oscity@gmail.com>
To: zsh-workers@zsh.org
Cc: Bart Schaefer <schaefer@brasslantern.com>
Subject: Re: Bug report
Date: Sun, 15 Dec 2013 12:01:21 +0100	[thread overview]
Message-ID: <6D5DE661-DC12-4FF7-A341-C2FBB049DA80@gmail.com> (raw)
In-Reply-To: <131214110830.ZM18442@torch.brasslantern.com>

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

On 14.12.2013, at 17:15 -0800, Bart Schaefer <schaefer@brasslantern.com> wrote:

> It appears that if you want to make this offset different from 1, you
> are going to have to change countprompt() to include the offset in the
> width of the prompt rather than just fiddle with math in the output code.

Maybe I was too enthusiastic ;-) I continued experimenting with my original patch and hard coded an offset of 5 instead of removing it, just to see what happens:

diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 17b78ce..f136178 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1576,7 +1576,7 @@ zrefresh(void)
 	else
 	    put_rpmpt = rprompth == 1 && rpromptbuf[0] &&
 		!strchr(rpromptbuf, '\t') &&
-		(int)ZR_strlen(nbuf[0]) + rpromptw < winw - 1;
+		(int)ZR_strlen(nbuf[0]) + rpromptw < winw - 5;
     } else {
 /* insert >.... on first line if there is more text before start of screen */
 	ZR_memset(nbuf[0], zr_sp, lpromptw);
@@ -1631,9 +1631,9 @@ zrefresh(void)
 	if (put_rpmpt && !iln && !oput_rpmpt) {
 	    int attrchange;
 
-	    moveto(0, winw - 1 - rpromptw);
+	    moveto(0, winw - 5 - rpromptw);
 	    zputs(rpromptbuf, shout);
-	    vcs = winw - 1;
+	    vcs = winw - 5;
 	/* reset character attributes to that set by the main prompt */
 	    txtchange = pmpt_attr;
 	    /*

This did not result in the problem you described. It worked just as expected, not misplacing the cursor at all, so I figured that the problem had to be introduced by Peter's patch. I came up with the following fix, which also sets the vcs variable according to rprompt_off, instead of subtracting the fixed value 1 (last change in the diff). This fixed the issue for me with arbitrary values for ZLE_RPROMPT_INDENT.

diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index b7b7750..2039fa1 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1531,4 +1531,17 @@ See the completion system documentation in
 ifzman(zmanref(zshcompsys))\
 ifnzman(noderef(Completion System)).
 )
+vindex(ZLE_RPROMPT_INDENT)
+item(tt(ZLE_RPROMPT_INDENT))(
+If set, used to give the indentation between the right hand side of
+the right prompt in the line editor as given by tt(RPS1) or tt(RPROMPT)
+and the right hand side of the screen.  If not set, the value 1 is used.
+
+Typically this will be used to set the value to 0 so that the prompt
+appears flush with the right hand side of the screen.  This is not the
+default as many terminals do not handle this correctly, in particular
+when the prompt appears at the extreme bottom right of the screen.
+Recent virtual terminals are more likely to handle this case correctly.
+Some experimentation is necessary.
+)
 enditem()
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 17b78ce..83cbd0b 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -976,7 +976,8 @@ zrefresh(void)
     int tmppos;			/* t - tmpline				     */
     int tmpalloced;		/* flag to free tmpline when finished	     */
     int remetafy;		/* flag that zle line is metafied	     */
-    int txtchange;		/* attributes set after prompts */
+    int txtchange;		/* attributes set after prompts              */
+    int rprompt_off = 1;	/* Offset of rprompt from right of screen    */
     struct rparams rpms;
 #ifdef MULTIBYTE_SUPPORT
     int width;			/* width of wide character		     */
@@ -1573,10 +1574,23 @@ zrefresh(void)
     if (!more_start) {
 	if (trashedzle && opts[TRANSIENTRPROMPT])
 	    put_rpmpt = 0;
-	else
+	else {
 	    put_rpmpt = rprompth == 1 && rpromptbuf[0] &&
-		!strchr(rpromptbuf, '\t') &&
-		(int)ZR_strlen(nbuf[0]) + rpromptw < winw - 1;
+		!strchr(rpromptbuf, '\t');
+	    if (put_rpmpt)
+	    {
+		struct value vbuf;
+		char *name = "ZLE_RPROMPT_INDENT";
+		if (getvalue(&vbuf, &name, 1)) {
+		    rprompt_off = getintvalue(&vbuf);
+		    /* sanity to avoid horrible things happening */
+		    if (rprompt_off < 0)
+			rprompt_off = 0;
+		}
+		put_rpmpt =
+		    (int)ZR_strlen(nbuf[0]) + rpromptw < winw - rprompt_off;
+	    }
+	}
     } else {
 /* insert >.... on first line if there is more text before start of screen */
 	ZR_memset(nbuf[0], zr_sp, lpromptw);
@@ -1631,9 +1645,9 @@ zrefresh(void)
 	if (put_rpmpt && !iln && !oput_rpmpt) {
 	    int attrchange;
 
-	    moveto(0, winw - 1 - rpromptw);
+	    moveto(0, winw - rprompt_off - rpromptw);
 	    zputs(rpromptbuf, shout);
-	    vcs = winw - 1;
+	    vcs = winw - rprompt_off;
 	/* reset character attributes to that set by the main prompt */
 	    txtchange = pmpt_attr;
 	    /*

[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 842 bytes --]

  parent reply	other threads:[~2013-12-15 11:01 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-14 18:44 Patrick Oscity
2013-12-14 19:08 ` Bart Schaefer
2013-12-14 20:43   ` Peter Stephenson
2013-12-15  1:15     ` Bart Schaefer
2013-12-15 13:30       ` Peter Stephenson
2013-12-15 17:10         ` Bart Schaefer
2013-12-15  1:08   ` Patrick Oscity
2013-12-15 11:01   ` Patrick Oscity [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-03-01  9:43 BUG REPORT ZheNing Hu
2021-03-01 15:27 ` Daniel Shahaf
2021-03-01 17:32 ` Bart Schaefer
2021-03-05  7:51   ` ZheNing Hu
2019-09-19 11:16 Bug report Vladimir Deyter
2019-09-19 14:53 ` Mikael Magnusson
2019-09-19 15:57   ` Daniel Shahaf
2014-12-26 16:53 mvxxc
2014-12-27  2:35 ` Bart Schaefer
2014-09-17  0:26 bug report Mica Chimera
2014-09-17  1:08 ` Frank Terbeck
2014-06-05 17:05 robin terrep-drangiug
2014-06-05 20:48 ` Bart Schaefer
2013-12-17 10:59 Bug report Patrick Oscity
2013-12-17 11:27 ` Peter Stephenson
2013-12-17 17:11 ` Bart Schaefer
2013-12-17 17:56   ` Bart Schaefer
2013-08-04 12:16 Bug Report Yuusuke Yoshimoto
2013-08-04 17:58 ` Peter Stephenson
1996-05-22  0:07 Bug report Felix von Leitner
1996-05-15  7:48 Martin Birgmeier
1996-05-10  8:30 Martin Birgmeier
1995-08-24 11:23 Bug Report Carsten Friedrich

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=6D5DE661-DC12-4FF7-A341-C2FBB049DA80@gmail.com \
    --to=patrick.oscity@gmail.com \
    --cc=schaefer@brasslantern.com \
    --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).