about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/zle_main.c13
-rw-r--r--Src/Zle/zle_params.c26
2 files changed, 36 insertions, 3 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;
+    }
+}