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

Re: Bug report



On Sat, 14 Dec 2013 11:08:30 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Given the number of other prompt-specific setopts we have at this point,
> we could potentially add another one to control this, but I think the
> default behavior should remain as it is.

Or avoid version clutter by adding an optional variable giving the
indent.  The clutter is less because if the variable isn't set it
doesn't appear anywhere except the documentation.

Seems to work: I've sanity checked for negative values and the worst I
can see happening with large numbers is the prompt doesn't appear.

diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 9d951bb..37c79b2 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1547,4 +1547,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..2863e39 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,7 +1645,7 @@ 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;
 	/* reset character attributes to that set by the main prompt */



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