about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2005-07-15 17:41:55 +0000
committerWayne Davison <wayned@users.sourceforge.net>2005-07-15 17:41:55 +0000
commit767e017e1f5e3a3fc54ee1bddc589e1c998839aa (patch)
tree7136bde45b74a63db2f4c4b145ba339ec9977d27 /Src
parentb1e0d218c5e82e25d0cd6743cb0172ae32f5d295 (diff)
downloadzsh-767e017e1f5e3a3fc54ee1bddc589e1c998839aa.tar.gz
zsh-767e017e1f5e3a3fc54ee1bddc589e1c998839aa.tar.xz
zsh-767e017e1f5e3a3fc54ee1bddc589e1c998839aa.zip
Implement the new PROMPT_SP option.
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_main.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 0f9d55226..33fbf0049 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -962,8 +962,30 @@ zleread(char **lp, char **rp, int flags, int context)
 	}
     }
     initundo();
-    if (isset(PROMPTCR))
+    if (isset(PROMPTCR)) {
+	/* The PROMPT_SP heuristic will move the prompt down to a new line
+	 * if there was any dangling output on the line (assuming the terminal
+	 * has automatic margins, but we try even if hasam isn't set). */
+	if (isset(PROMPTSP)) {
+	    if (hasxn) /* w/o this, a delayed wrap might be lost by TCRIGHT */
+		putc(' ', shout);
+	    if (tccan(TCSAVECURSOR)
+	     && tcmultout(TCRIGHT, TCMULTRIGHT, columns - 3)) {
+		putc(' ', shout);
+		putc(' ', shout);
+		tcout(TCSAVECURSOR);
+		tcout(TCBACKSPACE);
+		tcout(TCBACKSPACE);
+		if (tccan(TCCLEAREOL))
+		    tcout(TCCLEAREOL);
+		else
+		    tcmultout(TCDEL, TCMULTDEL, 1);
+		tcout(TCRESTRCURSOR);
+	    } else
+		fprintf(shout, "%*s", (int)columns - 1, "");
+	}
 	putc('\r', shout);
+    }
     if (tmout)
 	alarm(tmout);
     zleactive = 1;