diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui-keyboard.c | 35 | ||||
-rw-r--r-- | src/gui/gui-keyboard.h | 2 | ||||
-rw-r--r-- | src/plugins/plugin-api.c | 19 |
3 files changed, 56 insertions, 0 deletions
diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index a8c9bbd29..27d60105c 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -28,6 +28,7 @@ #include <ctype.h> #include "../core/weechat.h" +#include "../core/wee-infolist.h" #include "../core/wee-input.h" #include "../core/wee-log.h" #include "../core/wee-string.h" @@ -702,6 +703,40 @@ gui_keyboard_end () } /* + * gui_keyboard_add_to_infolist: add a key in an infolist + * return 1 if ok, 0 if error + */ + +int +gui_keyboard_add_to_infolist (struct t_infolist *infolist, + struct t_gui_key *key) +{ + struct t_infolist_item *ptr_item; + char *expanded_key; + + if (!infolist || !key) + return 0; + + ptr_item = infolist_new_item (infolist); + if (!ptr_item) + return 0; + + if (!infolist_new_var_string (ptr_item, "key_internal", key->key)) + return 0; + expanded_key = gui_keyboard_get_expanded_name (key->key); + if (expanded_key) + { + if (!infolist_new_var_string (ptr_item, "key", expanded_key)) + return 0; + free (expanded_key); + } + if (!infolist_new_var_string (ptr_item, "command", key->command)) + return 0; + + return 1; +} + +/* * gui_keyboard_print_log: print key infos in log (usually for crash dump) */ diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h index 5aea4b427..73dda8d00 100644 --- a/src/gui/gui-keyboard.h +++ b/src/gui/gui-keyboard.h @@ -74,6 +74,8 @@ extern int gui_keyboard_get_paste_lines (); extern void gui_keyboard_paste_accept (); extern void gui_keyboard_paste_cancel (); extern void gui_keyboard_end (); +extern int gui_keyboard_add_to_infolist (struct t_infolist *infolist, + struct t_gui_key *key); extern void gui_keyboard_print_log (struct t_gui_buffer *buffer); /* keyboard functions (GUI dependent) */ diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index fb4483b26..a9028e356 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -316,6 +316,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, struct t_gui_filter *ptr_filter; struct t_gui_window *ptr_window; struct t_gui_hotlist *ptr_hotlist; + struct t_gui_key *ptr_key; struct t_weechat_plugin *ptr_plugin; char buffer_full_name[1024]; @@ -574,6 +575,22 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name, return ptr_infolist; } } + else if (string_strcasecmp (infolist_name, "key") == 0) + { + ptr_infolist = infolist_new (); + if (ptr_infolist) + { + for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) + { + if (!gui_keyboard_add_to_infolist (ptr_infolist, ptr_key)) + { + infolist_free (ptr_infolist); + return NULL; + } + } + return ptr_infolist; + } + } else if (string_strcasecmp (infolist_name, "nicklist") == 0) { /* invalid buffer pointer ? */ @@ -883,6 +900,8 @@ plugin_api_init () &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "hotlist", N_("list of buffers in hotlist"), &plugin_api_infolist_get_internal, NULL); + hook_infolist (NULL, "key", N_("list of key bindings"), + &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"), &plugin_api_infolist_get_internal, NULL); hook_infolist (NULL, "option", N_("list of options"), |