From 89137552a73ef64e9f05ae1a5cb83a0fea474abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 8 Jul 2023 13:26:44 +0200 Subject: [PATCH] core: display focus hashtable for debug even if no key is matching --- ChangeLog.adoc | 1 + src/gui/gui-key.c | 56 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 094a3b46c..6fdaa833b 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -30,6 +30,7 @@ Bug fixes:: * core: add key ctrl-backspace in /help key (issue #1975) * core: keep keys ctrl-H and ctrl-? (in lower case) if they were manually bound to custom commands in a previous version * core: fix cursor position after `/plugin list -i` or `/plugin list -il` + * core: display focus hashtable for debug even if no key is matching * fset: remove extra spaces between min and max values when second format is used * irc: fix display of country code in message 344 received as whois geo info (issue #1736) * script: fix cursor position after `/script list -i` or `/script list -il` diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 1744f21d9..2085c5fe5 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -2002,6 +2002,31 @@ gui_key_focus_matching (struct t_gui_key *key, return match[0] && match[1]; } +/* + * Displays focus hashtable (for debug). + */ + +void +gui_key_focus_display_hashtable (struct t_hashtable *hashtable) +{ + struct t_weelist *list_keys; + struct t_weelist_item *ptr_item; + + gui_chat_printf (NULL, _("Hashtable focus:")); + list_keys = hashtable_get_list_keys (hashtable); + if (list_keys) + { + for (ptr_item = list_keys->items; ptr_item; + ptr_item = ptr_item->next_item) + { + gui_chat_printf (NULL, " %s: \"%s\"", + ptr_item->data, + hashtable_get (hashtable, ptr_item->data)); + } + weelist_free (list_keys); + } +} + /* * Runs command according to focus. * @@ -2020,8 +2045,6 @@ gui_key_focus_command (const char *key, int context, char *command, **commands; const char *str_buffer; struct t_hashtable *hashtable; - struct t_weelist *list_keys; - struct t_weelist_item *ptr_item; struct t_gui_buffer *ptr_buffer; debug = 0; @@ -2088,24 +2111,10 @@ gui_key_focus_command (const char *key, int context, gui_input_delete_line (gui_current_window->buffer); } - if (debug > 1) - { - gui_chat_printf (NULL, _("Hashtable focus:")); - list_keys = hashtable_get_list_keys (hashtable); - if (list_keys) - { - for (ptr_item = list_keys->items; ptr_item; - ptr_item = ptr_item->next_item) - { - gui_chat_printf (NULL, " %s: \"%s\"", - ptr_item->data, - hashtable_get (hashtable, ptr_item->data)); - } - weelist_free (list_keys); - } - } if (debug) { + if (debug > 1) + gui_key_focus_display_hashtable (hashtable); gui_chat_printf (NULL, _("Command for key: \"%s\""), ptr_key->command); } @@ -2156,6 +2165,17 @@ gui_key_focus_command (const char *key, int context, return 1; } + if (debug > 1) + { + hashtable = hook_focus_get_data (hashtable_focus[0], + hashtable_focus[1]); + if (hashtable) + { + gui_key_focus_display_hashtable (hashtable); + hashtable_free (hashtable); + } + } + return 0; }