aboutsummaryrefslogtreecommitdiff
path: root/termkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'termkey.c')
-rw-r--r--termkey.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/termkey.c b/termkey.c
index 1d2ae4d..273318c 100644
--- a/termkey.c
+++ b/termkey.c
@@ -863,6 +863,18 @@ size_t termkey_snprint_key(termkey_t *tk, char *buffer, size_t len, termkey_key
int longmod = format & TERMKEY_FORMAT_LONGMOD;
+ if(format & TERMKEY_FORMAT_CARETCTRL) {
+ if(key->type == TERMKEY_TYPE_UNICODE &&
+ key->modifiers == TERMKEY_KEYMOD_CTRL &&
+ key->code.number >= '@' &&
+ key->code.number <= '_') {
+ l = snprintf(buffer + pos, len - pos, "^");
+ if(l <= 0) return pos;
+ pos += l;
+ goto do_codepoint;
+ }
+ }
+
if(key->modifiers & TERMKEY_KEYMOD_CTRL) {
l = snprintf(buffer + pos, len - pos, longmod ? "Ctrl-" : "C-");
if(l <= 0) return pos;
@@ -870,7 +882,10 @@ size_t termkey_snprint_key(termkey_t *tk, char *buffer, size_t len, termkey_key
}
if(key->modifiers & TERMKEY_KEYMOD_ALT) {
- l = snprintf(buffer + pos, len - pos, longmod ? "Alt-" : "A-");
+ int altismeta = format & TERMKEY_FORMAT_ALTISMETA;
+
+ l = snprintf(buffer + pos, len - pos, longmod ? ( altismeta ? "Meta-" : "Alt-" )
+ : ( altismeta ? "M-" : "A-" ));
if(l <= 0) return pos;
pos += l;
}
@@ -881,6 +896,8 @@ size_t termkey_snprint_key(termkey_t *tk, char *buffer, size_t len, termkey_key
pos += l;
}
+do_codepoint:
+
switch(key->type) {
case TERMKEY_TYPE_UNICODE:
l = snprintf(buffer + pos, len - pos, "%s", key->utf8);