1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 17:53:13 +02:00

core: return info about line/word for chat area in focus hashtable, add keys m/q/Q to quote line in cursor mode, sort mouse keys by priority

This commit is contained in:
Sebastien Helleu
2011-08-14 11:30:08 +02:00
parent fb4c1ed1e9
commit 1cb7c6a6c5
41 changed files with 1202 additions and 521 deletions
+21 -6
View File
@@ -1215,6 +1215,7 @@ COMMAND_CALLBACK(debug)
{
struct t_config_option *ptr_option;
struct t_weechat_plugin *ptr_plugin;
int debug;
/* make C compiler happy */
(void) data;
@@ -1264,7 +1265,14 @@ COMMAND_CALLBACK(debug)
}
else if (string_strcasecmp (argv[1], "cursor") == 0)
{
gui_cursor_debug_toggle ();
if (gui_cursor_debug)
gui_cursor_debug_set (0);
else
{
debug = ((argc > 2)
&& (string_strcasecmp (argv[2], "verbose") == 0)) ? 2 : 1;
gui_cursor_debug_set (debug);
}
}
else if (string_strcasecmp (argv[1], "hdata") == 0)
{
@@ -1283,7 +1291,14 @@ COMMAND_CALLBACK(debug)
}
else if (string_strcasecmp (argv[1], "mouse") == 0)
{
gui_mouse_debug_toggle ();
if (gui_mouse_debug)
gui_mouse_debug_set (0);
else
{
debug = ((argc > 2)
&& (string_strcasecmp (argv[2], "verbose") == 0)) ? 2 : 1;
gui_mouse_debug_set (debug);
}
}
else if (string_strcasecmp (argv[1], "tags") == 0)
{
@@ -5425,8 +5440,8 @@ command_init ()
N_("list"
" || set <plugin> <level>"
" || dump [<plugin>]"
" || buffer|color|cursor|infolists|memory|mouse|tags|"
"term|windows"
" || buffer|color|infolists|memory|tags|term|windows"
" || mouse|cursor [verbose]"
" || hdata [free]"),
N_(" list: list plugins with debug levels\n"
" set: set debug level for plugin\n"
@@ -5451,11 +5466,11 @@ command_init ()
" || dump %(plugins_names)|core"
" || buffer"
" || color"
" || cursor"
" || cursor verbose"
" || hdata free"
" || infolists"
" || memory"
" || mouse"
" || mouse verbose"
" || tags"
" || term"
" || windows",
+51 -42
View File
@@ -2840,26 +2840,34 @@ hook_focus_hashtable_map2_cb (void *data, struct t_hashtable *hashtable,
/*
* hook_focus_get_data: get data for focus on (x,y) on screen
* focus_info2 is not NULL only for a mouse gesture (it's
* for point where mouse button is released)
* hashtable_focus2 is not NULL only for a mouse gesture
* (it's for point where mouse button has been released)
*/
struct t_hashtable *
hook_focus_get_data (struct t_gui_focus_info *focus_info1,
struct t_gui_focus_info *focus_info2,
const char *key)
hook_focus_get_data (struct t_hashtable *hashtable_focus1,
struct t_hashtable *hashtable_focus2)
{
struct t_hook *ptr_hook, *next_hook;
struct t_hashtable *hash_info1, *hash_info2, *hash_info_ret;
const char *keys;
struct t_hashtable *hashtable1, *hashtable2, *hashtable_ret;
const char *focus1_chat, *focus1_bar_item_name, *keys;
char **list_keys, *new_key;
int num_keys, i, length;
int num_keys, i, length, focus1_is_chat;
if (!hashtable_focus1)
return NULL;
focus1_chat = hashtable_get (hashtable_focus1, "_chat");
focus1_is_chat = (focus1_chat && (strcmp (focus1_chat, "1") == 0));
focus1_bar_item_name = hashtable_get (hashtable_focus1, "_bar_item_name");
hashtable1 = hashtable_dup (hashtable_focus1);
if (!hashtable1)
return NULL;
hashtable2 = (hashtable_focus2) ? hashtable_dup (hashtable_focus2) : NULL;
hook_exec_start ();
hash_info1 = gui_focus_to_hashtable (focus_info1, key);
hash_info2 = (focus_info2) ? gui_focus_to_hashtable (focus_info2, key) : NULL;
ptr_hook = weechat_hooks[HOOK_TYPE_FOCUS];
while (ptr_hook)
{
@@ -2867,50 +2875,50 @@ hook_focus_get_data (struct t_gui_focus_info *focus_info1,
if (!ptr_hook->deleted
&& !ptr_hook->running
&& ((focus_info1->chat
&& ((focus1_is_chat
&& (strcmp (HOOK_FOCUS(ptr_hook, area), "chat") == 0))
|| (focus_info1->bar_item
&& (strcmp (HOOK_FOCUS(ptr_hook, area), focus_info1->bar_item) == 0))))
|| (focus1_bar_item_name && focus1_bar_item_name[0]
&& (strcmp (HOOK_FOCUS(ptr_hook, area), focus1_bar_item_name) == 0))))
{
/* run callback for focus_info1 */
/* run callback for focus #1 */
ptr_hook->running = 1;
hash_info_ret = (HOOK_FOCUS(ptr_hook, callback))
(ptr_hook->callback_data, hash_info1);
hashtable_ret = (HOOK_FOCUS(ptr_hook, callback))
(ptr_hook->callback_data, hashtable1);
ptr_hook->running = 0;
if (hash_info_ret)
if (hashtable_ret)
{
if (hash_info_ret != hash_info1)
if (hashtable_ret != hashtable1)
{
/*
* add keys of hash_info_ret into hash_info and destroy
* hash_info_ret
* add keys of hashtable_ret into hashtable1
* and destroy it
*/
hashtable_map (hash_info_ret,
hashtable_map (hashtable_ret,
&hook_focus_hashtable_map_cb,
hash_info1);
hashtable_free (hash_info_ret);
hashtable1);
hashtable_free (hashtable_ret);
}
}
/* run callback for focus_info2 */
if (hash_info2)
/* run callback for focus #2 */
if (hashtable2)
{
ptr_hook->running = 1;
hash_info_ret = (HOOK_FOCUS(ptr_hook, callback))
(ptr_hook->callback_data, hash_info2);
hashtable_ret = (HOOK_FOCUS(ptr_hook, callback))
(ptr_hook->callback_data, hashtable2);
ptr_hook->running = 0;
if (hash_info_ret)
if (hashtable_ret)
{
if (hash_info_ret != hash_info2)
if (hashtable_ret != hashtable2)
{
/*
* add keys of hash_info_ret into hash_info and destroy
* hash_info_ret
* add keys of hashtable_ret into hashtable2
* and destroy it
*/
hashtable_map (hash_info_ret,
hashtable_map (hashtable_ret,
&hook_focus_hashtable_map_cb,
hash_info2);
hashtable_free (hash_info_ret);
hashtable2);
hashtable_free (hashtable_ret);
}
}
}
@@ -2919,14 +2927,14 @@ hook_focus_get_data (struct t_gui_focus_info *focus_info1,
ptr_hook = next_hook;
}
if (hash_info2)
if (hashtable2)
{
hashtable_map (hash_info2, &hook_focus_hashtable_map2_cb, hash_info1);
hashtable_free (hash_info2);
hashtable_map (hashtable2, &hook_focus_hashtable_map2_cb, hashtable1);
hashtable_free (hashtable2);
}
else
{
keys = hashtable_get_string (hash_info1, "keys");
keys = hashtable_get_string (hashtable1, "keys");
if (keys)
{
list_keys = string_split (keys, ",", 0, 0, &num_keys);
@@ -2939,8 +2947,9 @@ hook_focus_get_data (struct t_gui_focus_info *focus_info1,
if (new_key)
{
snprintf (new_key, length, "%s2", list_keys[i]);
hashtable_set (hash_info1, new_key,
hashtable_get (hash_info1, list_keys[i]));
hashtable_set (hashtable1, new_key,
hashtable_get (hashtable1,
list_keys[i]));
free (new_key);
}
}
@@ -2951,7 +2960,7 @@ hook_focus_get_data (struct t_gui_focus_info *focus_info1,
hook_exec_end ();
return hash_info1;
return hashtable1;
}
/*
+2 -4
View File
@@ -28,7 +28,6 @@ struct t_gui_bar;
struct t_gui_buffer;
struct t_gui_line;
struct t_gui_completion;
struct t_gui_focus_info;
struct t_gui_window;
struct t_weelist;
struct t_hashtable;
@@ -541,9 +540,8 @@ extern struct t_hook *hook_focus (struct t_weechat_plugin *plugin,
const char *area,
t_hook_callback_focus *callback,
void *callback_data);
extern struct t_hashtable *hook_focus_get_data (struct t_gui_focus_info *focus_info1,
struct t_gui_focus_info *focus_info2,
const char *key);
extern struct t_hashtable *hook_focus_get_data (struct t_hashtable *hashtable_focus1,
struct t_hashtable *hashtable_focus2);
extern void unhook (struct t_hook *hook);
extern void unhook_all_plugin (struct t_weechat_plugin *plugin);
extern void unhook_all ();