1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

Add signals "key_bind" and "key_unbind"

This commit is contained in:
Sebastien Helleu
2009-05-17 20:10:32 +02:00
parent e2497ff8bc
commit 6d0e15e0d7
5 changed files with 22 additions and 9 deletions
+1 -1
View File
@@ -1810,7 +1810,7 @@ command_key (void *data, struct t_gui_buffer *buffer,
{
if (argc >= 3)
{
if (gui_keyboard_unbind (NULL, argv[2]))
if (gui_keyboard_unbind (NULL, argv[2], 1))
{
gui_chat_printf (NULL,
_("Key \"%s\" unbound"),
+1 -1
View File
@@ -1100,7 +1100,7 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
else
{
/* unbind key if no value given */
gui_keyboard_unbind (NULL, option_name);
gui_keyboard_unbind (NULL, option_name, 1);
}
}
+1 -1
View File
@@ -1048,7 +1048,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
if (strcmp (property + 11, "*") == 0)
gui_keyboard_free_all (&buffer->keys, &buffer->last_key);
else
gui_keyboard_unbind (buffer, property + 11);
gui_keyboard_unbind (buffer, property + 11, 1);
}
else if (string_strcasecmp (property, "input") == 0)
{
+17 -5
View File
@@ -28,6 +28,7 @@
#include <ctype.h>
#include "../core/weechat.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-input.h"
#include "../core/wee-log.h"
@@ -317,18 +318,22 @@ gui_keyboard_new (struct t_gui_buffer *buffer, const char *key,
else
gui_keyboard_insert_sorted (&gui_keys, &last_gui_key, new_key);
expanded_name = gui_keyboard_get_expanded_name (new_key->key);
hook_signal_send ("key_bind",
WEECHAT_HOOK_SIGNAL_STRING, expanded_name);
if (gui_keyboard_verbose)
{
expanded_name = gui_keyboard_get_expanded_name (new_key->key);
gui_chat_printf (NULL,
_("New key binding: %s%s => %s%s"),
(expanded_name) ? expanded_name : new_key->key,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
new_key->command);
if (expanded_name)
free (expanded_name);
}
if (expanded_name)
free (expanded_name);
}
else
return NULL;
@@ -414,7 +419,7 @@ gui_keyboard_bind (struct t_gui_buffer *buffer, const char *key, const char *com
return NULL;
}
gui_keyboard_unbind (buffer, key);
gui_keyboard_unbind (buffer, key, 0);
new_key = gui_keyboard_new (buffer, key, command);
if (!new_key)
@@ -431,7 +436,8 @@ gui_keyboard_bind (struct t_gui_buffer *buffer, const char *key, const char *com
*/
int
gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key)
gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key,
int send_signal)
{
struct t_gui_key *ptr_key;
char *internal_code;
@@ -450,6 +456,12 @@ gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key)
if (internal_code)
free (internal_code);
if (send_signal)
{
hook_signal_send ("key_unbind",
WEECHAT_HOOK_SIGNAL_STRING, (char *)key);
}
return (ptr_key != NULL);
}
+2 -1
View File
@@ -61,7 +61,8 @@ extern struct t_gui_key *gui_keyboard_search (struct t_gui_buffer *buffer,
extern struct t_gui_key *gui_keyboard_bind (struct t_gui_buffer *buffer,
const char *key,
const char *command);
extern int gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key);
extern int gui_keyboard_unbind (struct t_gui_buffer *buffer, const char *key,
int send_signal);
extern int gui_keyboard_pressed (const char *key_str);
extern void gui_keyboard_free (struct t_gui_key **keys,
struct t_gui_key **last_key,