about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPatrick Oscity <patrick.oscity@gmail.com>2013-12-15 12:01:21 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2013-12-16 21:35:21 +0000
commit977f9ff5c8137b76fea8e93498086525af460cc5 (patch)
treee1ab695a531323b0855190b88203396a71a4518d /Src
parent71038e31db8076ff2229a5b4629536044b2367d1 (diff)
downloadzsh-977f9ff5c8137b76fea8e93498086525af460cc5.tar.gz
zsh-977f9ff5c8137b76fea8e93498086525af460cc5.tar.xz
zsh-977f9ff5c8137b76fea8e93498086525af460cc5.zip
32114: ZLE_PROMPT_INDENT allows you to move rprompt flush right
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_refresh.c26
-rw-r--r--Src/Zle/zle_tricky.c12
2 files changed, 31 insertions, 7 deletions
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 17b78ce59..debb9730d 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 = (int)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;
 	    /*
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index e30e0b1aa..25f09c459 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -1504,7 +1504,17 @@ get_comp_string(void)
 	    nnb = s + MB_METACHARLEN(s);
 	else
 	    nnb = s;
-	for (tt = s; tt < s + zlemetacs_qsub - wb;) {
+	tt = s;
+	if (lincmd)
+	{
+	    /*
+	     * Ignore '['s at the start of a command as they're not
+	     * matched by closing brackets.
+	     */
+	    while (*tt == Inbrack && tt < s + zlemetacs_qsub - wb)
+		tt++;
+	}
+	while (tt < s + zlemetacs_qsub - wb) {
 	    if (*tt == Inbrack) {
 		i++;
 		nb = nnb;