about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-07-01 14:55:54 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-07-01 14:55:54 +0000
commit3c13204e5574c48887e0b3f7caf3837773a7d29c (patch)
tree8a41ed2e51039076dedcd7b0f5d282cc2b93c1e7
parentbf214787228dc097a268ee4207d87bf3bf09d2b3 (diff)
downloadzsh-3c13204e5574c48887e0b3f7caf3837773a7d29c.tar.gz
zsh-3c13204e5574c48887e0b3f7caf3837773a7d29c.tar.xz
zsh-3c13204e5574c48887e0b3f7caf3837773a7d29c.zip
7650: new reset-prompt zle widget
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/zle.yo9
-rw-r--r--Src/Zle/iwidgets.list1
-rw-r--r--Src/Zle/zle_main.c16
4 files changed, 31 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c6ffe191e..b665d1ae5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-07-01  Peter Stephenson  <pws@csr.com>
+
+	* 7650: Doc/Zsh/zle.yo, Src/Zle/iwidgets.list, Src/Zle/zle_main.c:
+	new zle widget prompt-reset redisplays screen with prompt updated.
+
 2004-06-30  Peter Stephenson  <pws@csr.com>
 
 	* 20118: Doc/Zsh/builtins.yo, Src/Builtins/rlimits.c:
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index caabc9aaf..94d7a7677 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1737,6 +1737,15 @@ tindex(redisplay)
 item(tt(redisplay) (unbound) (^R) (^R))(
 Redisplays the edit buffer.
 )
+tindex(reset-prompt)
+item(tt(reset-prompt) (unbound) (unbound) (unbound))(
+Force the prompts on both the left and right of the screen to be
+re-expanded, then redisplay the edit buffer.  Note that this
+does not reflect changes to the prompt variables themselves, only changes
+in the expansion of the values (for example, changes in time or
+directory, or changes to the value of variables referred to by the
+prompt).
+)
 tindex(send-break)
 item(tt(send-break) (^G ESC-^G) (unbound) (unbound))(
 Abort the current editor function, e.g. tt(execute-named-command), or the
diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list
index 36d0cf396..bf8b7c0ce 100644
--- a/Src/Zle/iwidgets.list
+++ b/Src/Zle/iwidgets.list
@@ -88,6 +88,7 @@
 "recursive-edit", recursiveedit, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "redisplay", redisplay, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "redo", redo, ZLE_KEEPSUFFIX
+"reset-prompt", resetprompt, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "reverse-menu-complete", reversemenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_ISCOMP
 "run-help", processcmd, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "self-insert", selfinsert, ZLE_MENUCMP | ZLE_KEEPSUFFIX
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 0cfb8d9f6..6f66aa104 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -150,6 +150,8 @@ int kungetct;
 /**/
 mod_export char *zlenoargs[1] = { NULL };
 
+static char *raw_lp, *raw_rp;
+
 #ifdef FIONREAD
 static int delayzsetterm;
 #endif
@@ -785,8 +787,10 @@ zleread(char *lp, char *rp, int flags, int context)
     insmode = unset(OVERSTRIKE);
     eofsent = 0;
     resetneeded = 0;
+    raw_lp = lp;
     lpromptbuf = promptexpand(lp, 1, NULL, NULL);
     pmpt_attr = txtchange;
+    raw_rp = rp;
     rpromptbuf = promptexpand(rp, 1, NULL, NULL);
     rpmpt_attr = txtchange;
     free_prepostdisplay();
@@ -1307,6 +1311,18 @@ recursiveedit(UNUSED(char **args))
 }
 
 /**/
+int
+resetprompt(UNUSED(char **args))
+{
+    free(lpromptbuf);
+    lpromptbuf = promptexpand(raw_lp, 1, NULL, NULL);
+    free(rpromptbuf);
+    rpromptbuf = promptexpand(raw_rp, 1, NULL, NULL);
+
+    return redisplay(NULL);
+}
+
+/**/
 mod_export void
 trashzle(void)
 {