about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2002-01-31 15:13:26 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2002-01-31 15:13:26 +0000
commit16f1f616f9778cdf79f554d7107f0c3cf2c08654 (patch)
tree1268157d8e01753d3337614f9c785b68732ed626
parent149aafd65ee260f6071aeacbe07fa99df21ecce3 (diff)
downloadzsh-16f1f616f9778cdf79f554d7107f0c3cf2c08654.tar.gz
zsh-16f1f616f9778cdf79f554d7107f0c3cf2c08654.tar.xz
zsh-16f1f616f9778cdf79f554d7107f0c3cf2c08654.zip
16494: extract outermost words with negative arguments to %_ and add %^
-rw-r--r--ChangeLog4
-rw-r--r--Src/prompt.c53
2 files changed, 50 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index d5a506fec..f34d38134 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2002-01-31  Oliver Kiddle  <opk@zsh.org>
 
+	* Derek Peschel: 16494: Src/prompt.c: extract outermost words with
+	negative arguments to %_ prompt expansion and add %^ for a reverse
+	ordered status list
+
 	* Derek Peschel: 16493: Src/params.c: correct typos
 
 	* Derek Peschel: 16492: Src/params.c, Src/input.c, Doc/Zsh/params.yo:
diff --git a/Src/prompt.c b/Src/prompt.c
index 9b6edfcc6..06dd2e5a9 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -574,15 +574,54 @@ putpromptchar(int doprint, int endchar)
 	    case 'E':
                 tsetcap(TCCLEAREOL, 1);
 		break;
+	    case '^':
+		if (cmdsp) {
+		    if (arg >= 0) {
+			if (arg > cmdsp || arg == 0)
+			    arg = cmdsp;
+			for (t0 = cmdsp - 1; arg--; t0--) {
+			    stradd(cmdnames[cmdstack[t0]]);
+			    if (arg) {
+				addbufspc(1);
+				*bp++=' ';
+			    }
+			}
+		    } else {
+			arg = -arg;
+			if (arg > cmdsp)
+			    arg = cmdsp;
+			for (t0 = arg - 1; arg--; t0--) {
+			    stradd(cmdnames[cmdstack[t0]]);
+			    if (arg) {
+				addbufspc(1);
+				*bp++=' ';
+			    }
+			}
+		    }
+		}
+		break;
 	    case '_':
 		if (cmdsp) {
-		    if (arg > cmdsp || arg <= 0)
-			arg = cmdsp;
-		    for (t0 = cmdsp - arg; arg--; t0++) {
-			stradd(cmdnames[cmdstack[t0]]);
-			if (arg) {
-			    addbufspc(1);
-			    *bp++=' ';
+		    if (arg >= 0) {
+			if (arg > cmdsp || arg == 0)
+			    arg = cmdsp;
+			for (t0 = cmdsp - arg; arg--; t0++) {
+			    stradd(cmdnames[cmdstack[t0]]);
+			    if (arg) {
+				addbufspc(1);
+				*bp++=' ';
+			    }
+			}
+		    } else {
+			arg = -arg;
+			if (arg > cmdsp)
+			    arg = cmdsp;
+			for (t0 = 0; arg--; t0++) {
+			    stradd(cmdnames[cmdstack[t0]]);
+			    if (arg) {
+				addbufspc(1);
+				*bp++=' ';
+			    }
 			}
 		    }
 		}