diff options
author | Mark Lumsden <lum@cvs.openbsd.org> | 2019-07-03 18:11:08 +0000 |
---|---|---|
committer | Mark Lumsden <lum@cvs.openbsd.org> | 2019-07-03 18:11:08 +0000 |
commit | f063ac3cbe721eb92512c87b11f9434bf6385d68 (patch) | |
tree | 334d7241c1c95bd4f04531a1125464b378f9ff92 | |
parent | a90effbf4d01e073bf35840c42fcc0757524843c (diff) |
selfinsert() can't be called directly from a startup file or by
'eval-current-buffer' since it is by design, meant to be called interactively
as characters are typed in a buffer. ask_selfinsert() allows selfinsert() to
be used by excline(). Having ask_selfinsert() helps with regression testing.
No manual page entry since use case is a bit obscure. See 'insert' command.
-rw-r--r-- | usr.bin/mg/def.h | 3 | ||||
-rw-r--r-- | usr.bin/mg/funmap.c | 3 | ||||
-rw-r--r-- | usr.bin/mg/kbd.c | 25 |
3 files changed, 28 insertions, 3 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h index fab4bde10ad..1a571d9b1ca 100644 --- a/usr.bin/mg/def.h +++ b/usr.bin/mg/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.161 2019/07/02 16:25:39 lum Exp $ */ +/* $OpenBSD: def.h,v 1.162 2019/07/03 18:11:07 lum Exp $ */ /* This file is in the public domain. */ @@ -490,6 +490,7 @@ int rescan(int, int); int universal_argument(int, int); int digit_argument(int, int); int negative_argument(int, int); +int ask_selfinsert(int, int); int selfinsert(int, int); int quote(int, int); diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c index cb555dfee9a..0d0c026d546 100644 --- a/usr.bin/mg/funmap.c +++ b/usr.bin/mg/funmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: funmap.c,v 1.57 2019/07/02 16:25:39 lum Exp $ */ +/* $OpenBSD: funmap.c,v 1.58 2019/07/03 18:11:07 lum Exp $ */ /* This file is in the public domain */ @@ -179,6 +179,7 @@ static struct funmap functnames[] = { {searchagain, "search-again",}, {backsearch, "search-backward",}, {forwsearch, "search-forward",}, + {ask_selfinsert, "self-insert-char",}, {selfinsert, "self-insert-command",}, {sentencespace, "sentence-end-double-space",}, #ifdef REGEX diff --git a/usr.bin/mg/kbd.c b/usr.bin/mg/kbd.c index cc3e93b7649..06d6c9fcf48 100644 --- a/usr.bin/mg/kbd.c +++ b/usr.bin/mg/kbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd.c,v 1.32 2019/06/26 16:54:29 lum Exp $ */ +/* $OpenBSD: kbd.c,v 1.33 2019/07/03 18:11:07 lum Exp $ */ /* This file is in the public domain. */ @@ -390,6 +390,29 @@ selfinsert(int f, int n) } /* + * selfinsert() can't be called directly from a startup file or by + * 'eval-current-buffer' since it is by design, meant to be called interactively + * as characters are typed in a buffer. ask_selfinsert() allows selfinsert() to + * be used by excline(). Having ask_selfinsert() helps with regression testing. + * No manual page entry since use case is a bit obscure. See 'insert' command. + */ +int +ask_selfinsert(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 (selfinsert(FFRAND, 1)); +} + +/* * This could be implemented as a keymap with everything defined as self-insert. */ int |