From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24871 invoked by alias); 15 Dec 2013 11:01:45 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32114 Received: (qmail 27142 invoked from network); 15 Dec 2013 11:01:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=NerNiua7cvq6a0vGj/HBpZ2Yotv6jHjs3U++2OMudmw=; b=kzAdOLt1GNZ62aGpbpiP2cx/ECQEc4qJniOJGTxZ+sdjkv9Pmo0/8DVtZoii9bKGiP ekllISLv07FJrjfQ3S09Jo3T86VArGTBwB9n1mNwzX4ro312TvvoDY43Ja6dvfDuwtm6 s17fvnhXIxQq+ZUN/n7wWKwCU/ilRbLWMo0nTmkOm6yaFSukshuroyjM7yc7s1NL4iAh zbnBubBDST2MVICSyW7G78aSXeT29Wy4fXU5k1q/XGAfhLWqAHRomcvldkX65VM4Cb9V xn0qlQz8NC+53ECdcRzuxL6cDJTrTxxGiMpL3+Va5ljHE83oIdNCA8J39x0FxJb/ZO1K h+IQ== X-Received: by 10.205.45.65 with SMTP id uj1mr3501155bkb.16.1387105285734; Sun, 15 Dec 2013 03:01:25 -0800 (PST) Content-Type: multipart/signed; boundary="Apple-Mail=_0EB7E14B-6DA4-4B34-910C-6CC48B1269B8"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 7.0 \(1822\)) Subject: Re: Bug report From: Patrick Oscity In-Reply-To: <131214110830.ZM18442@torch.brasslantern.com> Date: Sun, 15 Dec 2013 12:01:21 +0100 Cc: Bart Schaefer Message-Id: <6D5DE661-DC12-4FF7-A341-C2FBB049DA80@gmail.com> References: <9CB4226B-47EE-44FA-8F8F-01DF4CB5154D@gmail.com> <131214110830.ZM18442@torch.brasslantern.com> To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.1822) --Apple-Mail=_0EB7E14B-6DA4-4B34-910C-6CC48B1269B8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 14.12.2013, at 17:15 -0800, Bart Schaefer = 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 =3D rprompth =3D=3D 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; =20 - moveto(0, winw - 1 - rpromptw); + moveto(0, winw - 5 - rpromptw); zputs(rpromptbuf, shout); - vcs =3D winw - 1; + vcs =3D winw - 5; /* reset character attributes to that set by the main prompt */ txtchange =3D 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 =3D 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 =3D 0; - else + else { put_rpmpt =3D rprompth =3D=3D 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 =3D "ZLE_RPROMPT_INDENT"; + if (getvalue(&vbuf, &name, 1)) { + rprompt_off =3D getintvalue(&vbuf); + /* sanity to avoid horrible things happening */ + if (rprompt_off < 0) + rprompt_off =3D 0; + } + put_rpmpt =3D + (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; =20 - moveto(0, winw - 1 - rpromptw); + moveto(0, winw - rprompt_off - rpromptw); zputs(rpromptbuf, shout); - vcs =3D winw - 1; + vcs =3D winw - rprompt_off; /* reset character attributes to that set by the main prompt */ txtchange =3D pmpt_attr; /* --Apple-Mail=_0EB7E14B-6DA4-4B34-910C-6CC48B1269B8 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJSrYwCAAoJEMy7OC9fnReGkw4P/ikMkdY++TFF/nnfSIMSiQu6 MoPpCvl+aQ23udLvJ+LjLwgkJNHMCJXwymQP1budHZ8/NPKeqkOCFHWmtQszCc6j E1BXYTye/Q5VqM+H7PnMiwC5vpjYtwg8BlHjXF773S8yuGdw/TrCucx7nTzp1AJV W38VF6fjK1Q/MAjIFNH/xIUkTM6bK8+3knR+xYHTUtg4RHu87/K9XvrtDEdcoBX0 0u9zUaLg0Aj+d8EKcOn2SQjOX5j9vbE6mBPDk7Edn+kg7HwfFcHEzw/a4b7StKNL hN7BjatUVxuhoeEpHb4f5ulAFhGNDLWsMERokwcMhCS1m7pige8P/bpttWmwCXfk HrRjZ5CYZtWu0IREnGlWZ6+BWiXMZY2jJSGqmoYeWy9OI4Y6Q6a5DZn8g4Mv+zDl 8rEwMXyDl/7EU0lpyLZTHoNGrEzEC7pYGTnv3ama1GVFln1cSeIW07Kj/rA38d9O +kUvUyLO6QGh3g+/+keJ+S4uHonEWQiwOp4mFGKTOjpHMm3qyHHHvVIcx+h9FhoO cHj9B3799suO5VI8jTJezgVgpwFdr9A8QOk5DJifC4Iilo7C8tielLbMyRWPS0q5 cW4kIYLjSwCacdAq1bBdAh9xiaYTWKTRgK5gvXQNv61RnJm03s0AHmQnsimP8+10 uuwOL6jVKEFRBlWaGPfL =7XLU -----END PGP SIGNATURE----- --Apple-Mail=_0EB7E14B-6DA4-4B34-910C-6CC48B1269B8--