summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/mg/def.h3
-rw-r--r--usr.bin/mg/funmap.c4
-rw-r--r--usr.bin/mg/match.c27
3 files changed, 28 insertions, 6 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index 427523e6f77..d03146b22e8 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.159 2019/06/22 15:38:15 lum Exp $ */
+/* $OpenBSD: def.h,v 1.160 2019/06/26 16:42:30 lum Exp $ */
/* This file is in the public domain. */
@@ -642,6 +642,7 @@ void ttykeymapinit(void);
void ttykeymaptidy(void);
/* match.c X */
+int ask_showmatch(int, int);
int showmatch(int, int);
/* version.c X */
diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c
index a4c49858614..9eabfebca6d 100644
--- a/usr.bin/mg/funmap.c
+++ b/usr.bin/mg/funmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: funmap.c,v 1.55 2018/12/13 14:59:16 lum Exp $ */
+/* $OpenBSD: funmap.c,v 1.56 2019/06/26 16:42:30 lum Exp $ */
/* This file is in the public domain */
@@ -39,7 +39,7 @@ static struct funmap functnames[] = {
{backword, "backward-word",},
{gotobob, "beginning-of-buffer",},
{gotobol, "beginning-of-line",},
- {showmatch, "blink-and-insert",},
+ {ask_showmatch, "blink-and-insert",},
{bsmap, "bsmap-mode",},
{NULL, "c-x 4 prefix",},
{NULL, "c-x prefix",},
diff --git a/usr.bin/mg/match.c b/usr.bin/mg/match.c
index e73a291bafb..d7b7047631a 100644
--- a/usr.bin/mg/match.c
+++ b/usr.bin/mg/match.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: match.c,v 1.19 2015/06/03 23:40:01 bcallah Exp $ */
+/* $OpenBSD: match.c,v 1.20 2019/06/26 16:42:30 lum Exp $ */
/* This file is in the public domain. */
@@ -35,9 +35,30 @@ static struct balance {
{ '\0', '\0' }
};
+
+/*
+ * Self-insert character, then show matching character.
+ * Bound to "blink-and-insert".
+ */
+int
+ask_showmatch(int f, int n)
+{
+ char *c, cbuf[2];
+
+ if ((c = eread("Insert a character: ", cbuf, sizeof(cbuf),
+ EFNEW)) == NULL || (c[0] == '\0'))
+ return (ABORT);
+
+ key.k_chars[0] = *c;
+ key.k_chars[1] = '\0';
+ key.k_count = 1;
+
+ return (showmatch(FFRAND, 1));
+}
+
+
/*
- * Hack to show matching paren. Self-insert character, then show matching
- * character, if any. Bound to "blink-and-insert".
+ * Hack to show matching paren. Bound to balance stucture chars ),],}.
*/
int
showmatch(int f, int n)