From 9af74259d2eb64229c25a3310b23a0c2d32c26eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Sat, 27 Aug 2022 17:07:20 +0200 Subject: [PATCH] Add debugging facilities for input events --- nncmpp.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/nncmpp.c b/nncmpp.c index b8a4dd6..5fa6d99 100644 --- a/nncmpp.c +++ b/nncmpp.c @@ -3108,9 +3108,28 @@ app_init_bindings (const char *keymap, return a; } +static char * +app_strfkey (const termo_key_t *key) +{ + // For display purposes, this is highly desirable + int flags = termo_get_flags (g.tk); + termo_set_flags (g.tk, flags | TERMO_FLAG_SPACESYMBOL); + termo_key_t fixed = *key; + termo_canonicalise (g.tk, &fixed); + termo_set_flags (g.tk, flags); + + char buf[16] = ""; + termo_strfkey_utf8 (g.tk, buf, sizeof buf, &fixed, TERMO_FORMAT_ALTISMETA); + return xstrdup (buf); +} + static bool app_process_termo_event (termo_key_t *event) { + char *formatted = app_strfkey (event); + print_debug ("%s", formatted); + free (formatted); + bool handled = false; if ((handled = event->type == TERMO_TYPE_FOCUS)) { @@ -4162,21 +4181,6 @@ help_tab_on_action (enum action action) return app_process_action (a), true; } -static void -help_tab_strfkey (const termo_key_t *key, struct strv *out) -{ - // For display purposes, this is highly desirable - int flags = termo_get_flags (g.tk); - termo_set_flags (g.tk, flags | TERMO_FLAG_SPACESYMBOL); - termo_key_t fixed = *key; - termo_canonicalise (g.tk, &fixed); - termo_set_flags (g.tk, flags); - - char buf[16]; - termo_strfkey_utf8 (g.tk, buf, sizeof buf, &fixed, TERMO_FORMAT_ALTISMETA); - strv_append (out, buf); -} - static void help_tab_assign_action (enum action action) { @@ -4198,7 +4202,7 @@ help_tab_group (struct binding *keys, size_t len, struct strv *out, struct strv ass = strv_make (); for (size_t k = 0; k < len; k++) if (keys[k].action == i) - help_tab_strfkey (&keys[k].decoded, &ass); + strv_append_owned (&ass, app_strfkey (&keys[k].decoded)); if (ass.len) { char *joined = strv_join (&ass, ", ");