summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_main.c13
-rw-r--r--Src/Zle/zle_params.c26
-rw-r--r--Src/init.c6
-rw-r--r--Src/input.c5
-rw-r--r--Src/loop.c2
-rw-r--r--Src/zsh.h15
6 files changed, 57 insertions, 10 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index c3317175c..25d2539dc 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -58,6 +58,11 @@ mod_export int hascompmod;
 /**/
 int zlereadflags;
 
+/* ZLCON_* flags passed to zleread() */
+
+/**/
+int zlecontext;
+
 /* != 0 if we're done editing */
 
 /**/
@@ -735,7 +740,7 @@ zlecore(void)
 
 /**/
 unsigned char *
-zleread(char *lp, char *rp, int flags)
+zleread(char *lp, char *rp, int flags, int context)
 {
     unsigned char *s;
     int old_errno = errno;
@@ -787,6 +792,7 @@ zleread(char *lp, char *rp, int flags)
     free_prepostdisplay();
 
     zlereadflags = flags;
+    zlecontext = context;
     histline = curhist;
     undoing = 1;
     line = (unsigned char *)zalloc((linesz = 256) + 2);
@@ -838,7 +844,7 @@ zleread(char *lp, char *rp, int flags)
     trashzle();
     free(lpromptbuf);
     free(rpromptbuf);
-    zleactive = zlereadflags = lastlistlen = 0;
+    zleactive = zlereadflags = lastlistlen = zlecontext = 0;
     alarm(0);
 
     freeundo();
@@ -1154,7 +1160,8 @@ bin_vared(char *name, char **args, Options ops, int func)
     if (OPT_ISSET(ops,'h'))
 	hbegin(2);
     isfirstln = OPT_ISSET(ops,'e');
-    t = (char *) zleread(p1, p2, OPT_ISSET(ops,'h') ? ZLRF_HISTORY : 0);
+    t = (char *) zleread(p1, p2, OPT_ISSET(ops,'h') ? ZLRF_HISTORY : 0,
+			 ZLCON_VARED);
     if (OPT_ISSET(ops,'h'))
 	hend(NULL);
     isfirstln = ifl;
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index a9fd93450..0d7b20119 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -91,6 +91,8 @@ static struct zleparam {
 	zleunsetfn, NULL },
     { "LASTSEARCH", PM_SCALAR | PM_READONLY, NULL, FN(get_lsearch),
         zleunsetfn, NULL },
+    { "CONTEXT", PM_SCALAR | PM_READONLY, NULL, FN(get_context),
+	zleunsetfn, NULL },
     { NULL, 0, NULL, NULL, NULL, NULL }
 };
 
@@ -548,3 +550,27 @@ get_lsearch(Param pm)
     else
 	return "";
 }
+
+/**/
+static char *
+get_context(Param pm)
+{
+    switch (zlecontext) {
+    case ZLCON_LINE_CONT:
+	return "cont";
+	break;
+
+    case ZLCON_SELECT:
+	return "select";
+	break;
+
+    case ZLCON_VARED:
+	return "vared";
+	break;
+
+    case ZLCON_LINE_START:
+    default:
+	return "start";
+	break;
+    }
+}
diff --git a/Src/init.c b/Src/init.c
index b4b7e6f97..15e7f9c60 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1146,17 +1146,17 @@ mod_export ZleVoidIntFn zlesetkeymapptr = noop_function_int;
 
 /**/
 unsigned char *
-autoload_zleread(char *lp, char *rp, int ha)
+autoload_zleread(char *lp, char *rp, int ha, int con)
 {
     zlereadptr = fallback_zleread;
     if (load_module("zsh/zle"))
 	load_module("zsh/compctl");
-    return zleread(lp, rp, ha);
+    return zleread(lp, rp, ha, con);
 }
 
 /**/
 mod_export unsigned char *
-fallback_zleread(char *lp, char *rp, int ha)
+fallback_zleread(char *lp, char *rp, int ha, int con)
 {
     char *pptbuf;
     int pptlen;
diff --git a/Src/input.c b/Src/input.c
index 3867474b8..c07583781 100644
--- a/Src/input.c
+++ b/Src/input.c
@@ -223,6 +223,7 @@ static int
 inputline(void)
 {
     char *ingetcline, *ingetcpmptl = NULL, *ingetcpmptr = NULL;
+    int context = ZLCON_LINE_START;
 
     /* If reading code interactively, work out the prompts. */
     if (interact && isset(SHINSTDIN)) {
@@ -230,6 +231,7 @@ inputline(void)
 	    ingetcpmptl = prompt2;
 	    if (rprompt2)
 		ingetcpmptr = rprompt2;
+	    context = ZLCON_LINE_CONT;
 	}
 	else {
 	    ingetcpmptl = prompt;
@@ -272,7 +274,8 @@ inputline(void)
 	int flags = ZLRF_HISTORY|ZLRF_NOSETTY;
 	if (isset(IGNOREEOF))
 	    flags |= ZLRF_IGNOREEOF;
-	ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr, flags);
+	ingetcline = (char *)zleread(ingetcpmptl, ingetcpmptr, flags,
+				     context);
 	histdone |= HISTFLAG_SETTY;
     }
     if (!ingetcline) {
diff --git a/Src/loop.c b/Src/loop.c
index 4da5a50f0..5b09a76df 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -245,7 +245,7 @@ execselect(Estate state, int do_exec)
 		    int oef = errflag;
 
 		    isfirstln = 1;
-		    str = (char *)zleread(prompt3, NULL, 0);
+		    str = (char *)zleread(prompt3, NULL, 0, ZLCON_SELECT);
 		    if (errflag)
 			str = NULL;
 		    errflag = oef;
diff --git a/Src/zsh.h b/Src/zsh.h
index f60fa5f45..cf470f001 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -28,7 +28,7 @@
  */
 
 #define trashzle()      trashzleptr()
-#define zleread(X,Y,H)  zlereadptr(X,Y,H)
+#define zleread(X,Y,H,C)  zlereadptr(X,Y,H,C)
 #define spaceinline(X)  spaceinlineptr(X)
 #define zrefresh()      refreshptr()
 
@@ -1761,6 +1761,17 @@ struct heap {
 #define ZLRF_NOSETTY	0x02	/* Don't set tty before return */
 #define ZLRF_IGNOREEOF  0x04	/* Ignore an EOF from the keyboard */
 
+/***************************/
+/* Context of zleread call */
+/***************************/
+
+enum {
+    ZLCON_LINE_START,		/* Command line at PS1 */
+    ZLCON_LINE_CONT,		/* Command line at PS2 */
+    ZLCON_SELECT,		/* Select loop */
+    ZLCON_VARED			/* Vared command */
+};
+
 /****************/
 /* Entry points */
 /****************/
@@ -1773,7 +1784,7 @@ typedef int (*CompctlReadFn) _((char *, char **, Options, char *));
 
 typedef void (*ZleVoidFn) _((void));
 typedef void (*ZleVoidIntFn) _((int));
-typedef unsigned char * (*ZleReadFn) _((char *, char *, int));
+typedef unsigned char * (*ZleReadFn) _((char *, char *, int, int));
 
 /***************************************/
 /* Hooks in core.                      */