summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-08-09 14:56:15 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-08-09 14:56:15 +0200
commitfe9aee25a5de346e01e7992aba373870eb6f0b4f (patch)
tree4fc37ff83a3e2100681de030d4727203440f9ce1 /src/gui
parent40c5eb207da9d40133eec57b499c4f9b56c4ac37 (diff)
downloadweechat-fe9aee25a5de346e01e7992aba373870eb6f0b4f.zip
core: allow send of hsignal instead of command for keys in context "mouse"
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui-key.c74
1 files changed, 46 insertions, 28 deletions
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index 32a7879d4..6e70d072a 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -739,10 +739,13 @@ gui_key_focus_command (const char *key, int context,
struct t_gui_focus_info *focus_info2)
{
struct t_gui_key *ptr_key;
- int i, errors, matching, area_type;
+ int i, errors, matching, area_type, debug;
char *pos, *command, **commands, *area_name;
struct t_hashtable *hashtable;
+ debug = ((gui_cursor_debug && (context == GUI_KEY_CONTEXT_CURSOR))
+ || (gui_mouse_debug && (context == GUI_KEY_CONTEXT_MOUSE)));
+
for (ptr_key = gui_keys[context]; ptr_key;
ptr_key = ptr_key->next_key)
{
@@ -771,49 +774,64 @@ gui_key_focus_command (const char *key, int context,
hashtable = hook_focus_get_data (focus_info1,
focus_info2,
key);
- if (gui_cursor_debug || gui_mouse_debug)
+ if (debug)
{
gui_chat_printf (NULL, "Hashtable focus: %s",
hashtable_get_string (hashtable,
"keys_values_sorted"));
}
- command = string_replace_with_hashtable (ptr_key->command,
- hashtable,
- &errors);
- if (command)
+ if (string_strncasecmp (ptr_key->command, "hsignal:", 8) == 0)
{
- if (errors == 0)
+ if (ptr_key->command[8])
{
- if (gui_cursor_debug || gui_mouse_debug)
- {
- gui_chat_printf (NULL,
- "Command executed: %s (%s)",
- command, ptr_key->command);
- }
- if ((context == GUI_KEY_CONTEXT_CURSOR) && gui_cursor_debug)
+ if (debug)
{
- gui_input_delete_line (gui_current_window->buffer);
+ gui_chat_printf (NULL, "Sending hsignal \"%s\"",
+ ptr_key->command + 8);
}
- commands = string_split_command (command, ';');
- if (commands)
+ hook_hsignal_send (ptr_key->command + 8, hashtable);
+ }
+ }
+ else
+ {
+ command = string_replace_with_hashtable (ptr_key->command,
+ hashtable,
+ &errors);
+ if (command)
+ {
+ if (errors == 0)
{
- for (i = 0; commands[i]; i++)
+ if (debug)
{
- input_data (gui_current_window->buffer, commands[i]);
+ gui_chat_printf (NULL,
+ "Executing command: %s (%s)",
+ command, ptr_key->command);
+ }
+ if ((context == GUI_KEY_CONTEXT_CURSOR) && gui_cursor_debug)
+ {
+ gui_input_delete_line (gui_current_window->buffer);
+ }
+ commands = string_split_command (command, ';');
+ if (commands)
+ {
+ for (i = 0; commands[i]; i++)
+ {
+ input_data (gui_current_window->buffer, commands[i]);
+ }
+ string_free_split_command (commands);
}
- string_free_split_command (commands);
}
- }
- else
- {
- if (gui_cursor_debug || gui_mouse_debug)
+ else
{
- gui_chat_printf (NULL,
- "Command NOT executed (%s)",
- ptr_key->command);
+ if (debug)
+ {
+ gui_chat_printf (NULL,
+ "Command NOT executed (%s)",
+ ptr_key->command);
+ }
}
+ free (command);
}
- free (command);
}
if (hashtable)
hashtable_free (hashtable);