summary refs log tree commit diff
path: root/Src/Zle
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 /Src/Zle
parentbf214787228dc097a268ee4207d87bf3bf09d2b3 (diff)
downloadzsh-3c13204e5574c48887e0b3f7caf3837773a7d29c.tar.gz
zsh-3c13204e5574c48887e0b3f7caf3837773a7d29c.tar.xz
zsh-3c13204e5574c48887e0b3f7caf3837773a7d29c.zip
7650: new reset-prompt zle widget
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/iwidgets.list1
-rw-r--r--Src/Zle/zle_main.c16
2 files changed, 17 insertions, 0 deletions
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)
 {