summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-08-27 17:07:20 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-08-27 17:20:06 +0200
commit9af74259d2eb64229c25a3310b23a0c2d32c26eb (patch)
treebd45aa6a016670327877c2353ee7adf31183d540
parent9a996c8440f1470b7c1a686e4c345bfad4c0e997 (diff)
downloadnncmpp-9af74259d2eb64229c25a3310b23a0c2d32c26eb.tar.gz
nncmpp-9af74259d2eb64229c25a3310b23a0c2d32c26eb.tar.xz
nncmpp-9af74259d2eb64229c25a3310b23a0c2d32c26eb.zip
Add debugging facilities for input events
-rw-r--r--nncmpp.c36
1 files 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))
{
@@ -4163,21 +4182,6 @@ help_tab_on_action (enum action action)
}
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)
{
hard_assert (g_help_tab.lines.len > g_help_tab.actions_len);
@@ -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, ", ");