aboutsummaryrefslogtreecommitdiff
path: root/termkey.c
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2013-08-26 00:56:07 +0100
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2013-08-26 00:56:07 +0100
commit24abb0c59e78c2b7a660ca05f5afb6c514555ca5 (patch)
tree3a7a88cf6fc334b659d7af89e664599e854578c3 /termkey.c
parent89ac8b058cb7bb8f7bc47a4a42fa5642abc84dae (diff)
downloadtermo-24abb0c59e78c2b7a660ca05f5afb6c514555ca5.tar.gz
termo-24abb0c59e78c2b7a660ca05f5afb6c514555ca5.tar.xz
termo-24abb0c59e78c2b7a660ca05f5afb6c514555ca5.zip
Added TERMKEY_FORMAT_SPACEMOD
Diffstat (limited to 'termkey.c')
-rw-r--r--termkey.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/termkey.c b/termkey.c
index 5813b9e..a45dc56 100644
--- a/termkey.c
+++ b/termkey.c
@@ -1191,6 +1191,8 @@ size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, T
int wrapbracket = (format & TERMKEY_FORMAT_WRAPBRACKET) &&
(key->type != TERMKEY_TYPE_UNICODE || key->modifiers != 0);
+ char sep = (format & TERMKEY_FORMAT_SPACEMOD) ? ' ' : '-';
+
if(format & TERMKEY_FORMAT_CARETCTRL &&
key->type == TERMKEY_TYPE_UNICODE &&
key->modifiers == TERMKEY_KEYMOD_CTRL) {
@@ -1219,19 +1221,19 @@ size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, T
}
if(key->modifiers & TERMKEY_KEYMOD_ALT) {
- l = snprintf(buffer + pos, len - pos, "%s-", mods->alt);
+ l = snprintf(buffer + pos, len - pos, "%s%c", mods->alt, sep);
if(l <= 0) return pos;
pos += l;
}
if(key->modifiers & TERMKEY_KEYMOD_CTRL) {
- l = snprintf(buffer + pos, len - pos, "%s-", mods->ctrl);
+ l = snprintf(buffer + pos, len - pos, "%s%c", mods->ctrl, sep);
if(l <= 0) return pos;
pos += l;
}
if(key->modifiers & TERMKEY_KEYMOD_SHIFT) {
- l = snprintf(buffer + pos, len - pos, "%s-", mods->shift);
+ l = snprintf(buffer + pos, len - pos, "%s%c", mods->shift, sep);
if(l <= 0) return pos;
pos += l;
}
@@ -1320,10 +1322,10 @@ const char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermK
return (char *)str;
}
- const char *hyphen;
+ const char *sep_at;
- while((hyphen = strchr(str, '-'))) {
- size_t n = hyphen - str;
+ while((sep_at = strchr(str, (format & TERMKEY_FORMAT_SPACEMOD) ? ' ' : '-'))) {
+ size_t n = sep_at - str;
if(n == strlen(mods->alt) && strncmp(mods->alt, str, n) == 0)
key->modifiers |= TERMKEY_KEYMOD_ALT;
@@ -1335,7 +1337,7 @@ const char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermK
else
break;
- str = hyphen + 1;
+ str = sep_at + 1;
}
size_t nbytes;