about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-02-15 23:59:05 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-02-15 23:59:05 +0000
commit7da98c51246f245cde16cddb9b418afcfb3b3574 (patch)
treef51933a73efe9bce68907df66827f23f413569bc
parentac0756270c583430fa036403ac4a726716e1c967 (diff)
downloadzsh-7da98c51246f245cde16cddb9b418afcfb3b3574.tar.gz
zsh-7da98c51246f245cde16cddb9b418afcfb3b3574.tar.xz
zsh-7da98c51246f245cde16cddb9b418afcfb3b3574.zip
24556: %G in prompt for glitch characters
-rw-r--r--ChangeLog3
-rw-r--r--Doc/Zsh/prompt.yo12
-rw-r--r--Src/prompt.c10
3 files changed, 25 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 11b29abde..347743fe5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-02-15  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 24556: Doc/Zsh/prompt.yo, Src/prompt.c: %G inside %{...%}
+	can be used to count width of "glitch" characters.
+
 	* 24554: Src/Zle/complist.c: push an extra heap for
 	complistmatches() to stop accumulating it; always treat
 	mcolors as a global instead of just sometimes.
diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo
index 456a0bc0e..66e2b9015 100644
--- a/Doc/Zsh/prompt.yo
+++ b/Doc/Zsh/prompt.yo
@@ -188,6 +188,18 @@ Include a string as a literal escape sequence.
 The string within the braces should not change the cursor
 position.  Brace pairs can nest.
 )
+item(tt(%G))(
+Within a tt(%{)...tt(%}) sequence, include a `glitch': that is, assume
+that a single character width will be output.  This is useful when
+outputting characters that otherwise cannot be correctly handled by the
+shell, such as the alternate character set on some terminals.
+The characters in question can be included within a tt(%{)...tt(%})
+sequence together with the appropriate number of tt(%G) sequences to
+indicate the correct width.  An integer between the `tt(%)' and `tt(G)'
+indicates a character width other than one.  Hence tt(%{)var(seq)tt(%2G%})
+outputs var(seq) and assumes it takes up the width of two standard
+characters.
+)
 enditem()
 
 sect(Conditional Substrings in Prompts)
diff --git a/Src/prompt.c b/Src/prompt.c
index 68a55a3fd..54baf47ed 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -473,6 +473,16 @@ putpromptchar(int doprint, int endchar)
 		    *bp++ = Inpar;
 		}
 		break;
+	    case 'G':
+		if (arg > 0) {
+		    addbufspc(arg);
+		    while (arg--)
+			*bp++ = Nularg;
+		} else {
+		    addbufspc(1);
+		    *bp++ = Nularg;
+		}
+		break;
 	    case /*{*/ '}':
 		if (trunccount && trunccount >= dontcount)
 		    return *fm;