summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorKjell Wooding <kjell@cvs.openbsd.org>2005-11-07 22:52:45 +0000
committerKjell Wooding <kjell@cvs.openbsd.org>2005-11-07 22:52:45 +0000
commitc26131c8d1b3cf7c3dbb2220ed34707e5ac7f451 (patch)
treed83070315b9a1b942f8d23a3d2639da88e3dc135 /usr.bin/mg
parent63cfb5fb74e681c90d76c5293b56f38a608e5155 (diff)
Allow ctrl-key patterns ("^X^C") in keybind function. Will
allow more modularization of keymaps later. Also, improved error checking suggested by cloder.
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/extend.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c
index e5a6d77c0cc..0719fbaa23c 100644
--- a/usr.bin/mg/extend.c
+++ b/usr.bin/mg/extend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: extend.c,v 1.37 2005/10/14 19:46:46 kjell Exp $ */
+/* $OpenBSD: extend.c,v 1.38 2005/11/07 22:52:44 kjell Exp $ */
/* This file is in the public domain. */
@@ -23,6 +23,8 @@
#endif /* !NO_STARTUP */
#endif /* FKEYS */
+#include <ctype.h>
+
static int remap(KEYMAP *, int, PF, KEYMAP *);
static KEYMAP *reallocmap(KEYMAP *);
static void fixmap(KEYMAP *, KEYMAP *, KEYMAP *);
@@ -431,10 +433,13 @@ dobindkey(KEYMAP *map, const char *func, const char *str)
for (i = 0; *str && i < MAXKEY; i++) {
/* XXX - convert numbers w/ strol()? */
- if (*str != '\\')
- key.k_chars[i] = *str;
- else {
+ if (*str == '^' && *(str + 1) != '\0') {
+ key.k_chars[i] = CCHR(toupper(*++str));
+ } else if (*str == '\\' && *(str + 1) != '\0') {
switch (*++str) {
+ case '^':
+ key.k_chars[i] = '^';
+ break;
case 't':
case 'T':
key.k_chars[i] = '\t';
@@ -451,8 +456,12 @@ dobindkey(KEYMAP *map, const char *func, const char *str)
case 'E':
key.k_chars[i] = CCHR('[');
break;
+ case '\\':
+ key.k_chars[i] = '\\';
+ break;
}
- }
+ } else
+ key.k_chars[i] = *str;
str++;
}
key.k_count = i;