zsh-workers
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: Incorrect cursor position when ZLE_RPROMPT_INDENT=0 (with a fix)
Date: Thu, 23 May 2019 07:48:33 +0200	[thread overview]
Message-ID: <CAN=4vMqP+5KeCBa3cAZB8shtnc5YBvP2OrWVZ6yPC0tz_oGqMw@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMpeG8sA3ReySo+8D3GP8=AT1gzNDgNHRZ8gDgVqy4OLNA@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 585 bytes --]

Is there anything else I need to do to move this forward? The patch works
on all terminals I and others have tried (11 in total; some with multiple
versions and/or configurations). The code no longer
special-cases ZLE_RPROMPT_INDENT=0, which is nice. There is branch
for ZLE_RPROMPT_INDENT=0 but it's just an optimization to avoid an
unnecessary zputc(&zr_cr) call when it's known to have no effect. So I
think the logic is simpler now.

I've attached the patch to the email. You can also find it at
https://github.com/zsh-users/zsh/compare/master...romkatv:rprompt-indent.

Roman.

>

[-- Attachment #1.2: Type: text/html, Size: 941 bytes --]

[-- Attachment #2: rprompt-indent.patch --]
[-- Type: text/x-patch, Size: 1376 bytes --]

diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 1f293845f..85e55e0d4 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1678,7 +1678,12 @@ zrefresh(void)
 
 	    moveto(0, winw - rprompt_off - rpromptw);
 	    zputs(rpromptbuf, shout);
-	    vcs = winw - rprompt_off;
+	    if (rprompt_off) {
+		vcs = winw - rprompt_off;
+	    } else {
+		zputc(&zr_cr);
+		vcs = 0;
+	    }
 	/* reset character attributes to that set by the main prompt */
 	    txtchange = pmpt_attr;
 	    /*
@@ -2159,25 +2164,20 @@ moveto(int ln, int cl)
     const REFRESH_ELEMENT *rep;
 
     if (vcs == winw) {
-	if (rprompt_indent == 0 && tccan(TCLEFT)) {
-	  tc_leftcurs(1);
-	  vcs--;
-	} else {
-	    vln++, vcs = 0;
-	    if (!hasam) {
-		zputc(&zr_cr);
-		zputc(&zr_nl);
-	    } else {
-		if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr)
-		    rep = nbuf[vln];
-		else
-		    rep = &zr_sp;
-		zputc(rep);
-		zputc(&zr_cr);
-		if ((vln < olnct) && obuf[vln] && obuf[vln]->chr)
-		    *obuf[vln] = *rep;
-	    }
-	}
+    vln++, vcs = 0;
+    if (!hasam) {
+	zputc(&zr_cr);
+	zputc(&zr_nl);
+    } else {
+	if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr)
+	    rep = nbuf[vln];
+	else
+	    rep = &zr_sp;
+	zputc(rep);
+	zputc(&zr_cr);
+	if ((vln < olnct) && obuf[vln] && obuf[vln]->chr)
+	    *obuf[vln] = *rep;
+    }
     }
 
     if (ln == vln && cl == vcs)

  reply	other threads:[~2019-05-23  5:49 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-19 15:38 Roman Perepelitsa
2019-05-19 15:41 ` Roman Perepelitsa
2019-05-19 17:04 ` Bart Schaefer
2019-05-19 17:34   ` Roman Perepelitsa
2019-05-19 18:09     ` Roman Perepelitsa
2019-05-19 18:51       ` Roman Perepelitsa
2019-05-19 20:12         ` Bart Schaefer
2019-05-19 21:07           ` Roman Perepelitsa
2019-05-20  8:21             ` Yannic Schröder
2019-05-20  8:36               ` Roman Perepelitsa
2019-05-20 10:21                 ` Charles Blake
2019-05-20 10:46                   ` Roman Perepelitsa
2019-05-20 11:06                     ` Daniel Shahaf
2019-05-20 11:07                     ` Charles Blake
2019-05-20 11:11                       ` Peter Stephenson
2019-05-20 11:32                       ` Roman Perepelitsa
2019-05-20 12:41                     ` Charles Blake
2019-05-20 13:16                       ` Roman Perepelitsa
     [not found]                         ` <CAKiz1a-nOkAe42JoxFRgMJ+LXZ3fgMxqgwNZOW+2Y45oqzu8hA@mail.gmail.com>
2019-05-20 13:55                           ` Roman Perepelitsa
2019-05-23  5:48                             ` Roman Perepelitsa [this message]
2019-05-23 21:36                               ` Daniel Shahaf
2019-05-23 22:52                                 ` Roman Perepelitsa
2019-05-24 12:18                                   ` Daniel Shahaf
2019-05-27 15:36                                     ` Roman Perepelitsa
2019-05-27 21:51                                       ` Peter Stephenson
2019-05-28  8:44                                         ` Peter Stephenson
2019-05-28  8:46                                           ` Roman Perepelitsa
2019-05-28 14:26                                         ` 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='CAN=4vMqP+5KeCBa3cAZB8shtnc5YBvP2OrWVZ6yPC0tz_oGqMw@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.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).