mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
core: remove unneeded whitespace
This commit is contained in:
+1
-1
@@ -97,7 +97,7 @@ ENDIF(ENABLE_GCRYPT)
|
||||
# Check for GnuTLS
|
||||
IF(ENABLE_GNUTLS)
|
||||
FIND_PACKAGE(GnuTLS)
|
||||
|
||||
|
||||
IF(GNUTLS_FOUND)
|
||||
STRING(REGEX REPLACE "/[^/]*$" "" GNUTLS_LIBRARY_PATH "${GNUTLS_LIBRARY}")
|
||||
ADD_DEFINITIONS(-DHAVE_GNUTLS)
|
||||
|
||||
@@ -80,14 +80,14 @@ weechat_backtrace_addr2line (int number, void *address, const char *symbol)
|
||||
char cmd_line[1024];
|
||||
char line[1024], *ptr_line, *pos;
|
||||
char function_name[1024];
|
||||
|
||||
|
||||
rc = dladdr (address, &info);
|
||||
if ((rc == 0) || !info.dli_fname || !info.dli_fname[0])
|
||||
{
|
||||
weechat_backtrace_printf ("%03d %s", number, symbol);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
addr = address;
|
||||
if (info.dli_fbase >= (const void *) 0x40000000)
|
||||
addr = (void *)((unsigned long)((const char *) addr) -
|
||||
@@ -166,7 +166,7 @@ weechat_backtrace ()
|
||||
#ifdef HAVE_BACKTRACE
|
||||
trace_size = backtrace (trace, BACKTRACE_MAX);
|
||||
symbols = backtrace_symbols (trace, trace_size);
|
||||
|
||||
|
||||
for (i = 0; i < trace_size; i++)
|
||||
{
|
||||
weechat_backtrace_addr2line (i + 1, trace[i], symbols[i]);
|
||||
@@ -175,6 +175,6 @@ weechat_backtrace ()
|
||||
weechat_backtrace_printf (" No backtrace info (no debug info available "
|
||||
"or no backtrace possible on your system).");
|
||||
#endif
|
||||
|
||||
|
||||
weechat_backtrace_printf ("======= End of backtrace =======");
|
||||
}
|
||||
|
||||
+313
-313
File diff suppressed because it is too large
Load Diff
+94
-94
@@ -65,18 +65,18 @@ completion_list_add_bars_names_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
gui_completion_list_add (completion, ptr_bar->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -91,18 +91,18 @@ completion_list_add_bars_options_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
|
||||
{
|
||||
gui_completion_list_add (completion, gui_bar_option_string[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -117,19 +117,19 @@ completion_list_add_buffers_names_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
gui_completion_list_add (completion, ptr_buffer->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -145,12 +145,12 @@ completion_list_add_buffers_numbers_cb (void *data,
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
char str_number[32];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ completion_list_add_buffers_numbers_cb (void *data,
|
||||
gui_completion_list_add (completion, str_number,
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -175,12 +175,12 @@ completion_list_add_buffers_plugins_names_cb (void *data,
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
char name[512];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -190,7 +190,7 @@ completion_list_add_buffers_plugins_names_cb (void *data,
|
||||
gui_completion_list_add (completion, name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -206,19 +206,19 @@ completion_list_add_buffer_properties_set_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (i = 0; gui_buffer_properties_set[i]; i++)
|
||||
{
|
||||
gui_completion_list_add (completion,
|
||||
gui_buffer_properties_set[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -234,12 +234,12 @@ completion_list_add_buffer_properties_get_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (i = 0; gui_buffer_properties_get_integer[i]; i++)
|
||||
{
|
||||
gui_completion_list_add (completion,
|
||||
@@ -258,7 +258,7 @@ completion_list_add_buffer_properties_get_cb (void *data,
|
||||
gui_buffer_properties_get_pointer[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -274,19 +274,19 @@ completion_list_add_windows_numbers_cb (void *data,
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
char str_number[32];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
snprintf (str_number, sizeof (str_number), "%d", ptr_win->number);
|
||||
gui_completion_list_add (completion, str_number,
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ completion_list_map_add_palette_color_cb (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
(void) value;
|
||||
|
||||
|
||||
gui_completion_list_add ((struct t_gui_completion *)data,
|
||||
(char *)key,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
@@ -322,11 +322,11 @@ completion_list_add_palette_colors_cb (void *data,
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
hashtable_map (gui_color_hash_palette_color,
|
||||
&completion_list_map_add_palette_color_cb,
|
||||
completion);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -341,19 +341,19 @@ completion_list_add_config_files_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_config_file *ptr_config_file;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_config_file = config_files; ptr_config_file;
|
||||
ptr_config_file = ptr_config_file->next_config)
|
||||
{
|
||||
gui_completion_list_add (completion, ptr_config_file->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -375,19 +375,19 @@ completion_list_add_filename_cb (void *data,
|
||||
struct dirent *entry;
|
||||
struct stat statbuf;
|
||||
char home[3] = { '~', DIR_SEPARATOR_CHAR, '\0' };
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
buf_len = PATH_MAX;
|
||||
buf = malloc (buf_len);
|
||||
if (!buf)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
completion->add_space = 0;
|
||||
|
||||
|
||||
if ((strncmp (completion->base_word, home, 2) == 0) && getenv("HOME"))
|
||||
{
|
||||
real_prefix = strdup (getenv("HOME"));
|
||||
@@ -407,7 +407,7 @@ completion_list_add_filename_cb (void *data,
|
||||
prefix = strdup (DIR_SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
snprintf (buf, buf_len, "%s", completion->base_word + strlen (prefix));
|
||||
p = strrchr (buf, DIR_SEPARATOR_CHAR);
|
||||
if (p)
|
||||
@@ -422,7 +422,7 @@ completion_list_add_filename_cb (void *data,
|
||||
path_d = strdup ("");
|
||||
path_b = strdup (buf);
|
||||
}
|
||||
|
||||
|
||||
sprintf (buf, "%s%s%s", real_prefix, DIR_SEPARATOR, path_d);
|
||||
d_name = strdup (buf);
|
||||
dp = opendir (d_name);
|
||||
@@ -434,12 +434,12 @@ completion_list_add_filename_cb (void *data,
|
||||
{
|
||||
if (strcmp (entry->d_name, ".") == 0 || strcmp (entry->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
|
||||
snprintf (buf, buf_len, "%s%s%s",
|
||||
d_name, DIR_SEPARATOR, entry->d_name);
|
||||
if (stat (buf, &statbuf) == -1)
|
||||
continue;
|
||||
|
||||
|
||||
snprintf (buf, buf_len, "%s%s%s%s%s%s",
|
||||
prefix,
|
||||
((strcmp(prefix, "") == 0)
|
||||
@@ -448,21 +448,21 @@ completion_list_add_filename_cb (void *data,
|
||||
strcmp(path_d, "") == 0 ? "" : DIR_SEPARATOR,
|
||||
entry->d_name,
|
||||
S_ISDIR(statbuf.st_mode) ? DIR_SEPARATOR : "");
|
||||
|
||||
|
||||
gui_completion_list_add (completion, buf,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
}
|
||||
closedir (dp);
|
||||
}
|
||||
|
||||
|
||||
free (d_name);
|
||||
free (prefix);
|
||||
free (real_prefix);
|
||||
free (path_d);
|
||||
free (path_b);
|
||||
free (buf);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -477,19 +477,19 @@ completion_list_add_filters_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_gui_filter *ptr_filter;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_filter = gui_filters; ptr_filter;
|
||||
ptr_filter = ptr_filter->next_filter)
|
||||
{
|
||||
gui_completion_list_add (completion, ptr_filter->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -504,12 +504,12 @@ completion_list_add_commands_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_hook *ptr_hook;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook;
|
||||
ptr_hook = ptr_hook->next_hook)
|
||||
{
|
||||
@@ -520,7 +520,7 @@ completion_list_add_commands_cb (void *data,
|
||||
HOOK_COMMAND(ptr_hook, command),
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -535,12 +535,12 @@ completion_list_add_infos_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_hook *ptr_hook;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_hook = weechat_hooks[HOOK_TYPE_INFO]; ptr_hook;
|
||||
ptr_hook = ptr_hook->next_hook)
|
||||
{
|
||||
@@ -551,7 +551,7 @@ completion_list_add_infos_cb (void *data,
|
||||
HOOK_INFO(ptr_hook, info_name),
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -566,12 +566,12 @@ completion_list_add_infolists_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_hook *ptr_hook;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_hook = weechat_hooks[HOOK_TYPE_INFOLIST]; ptr_hook;
|
||||
ptr_hook = ptr_hook->next_hook)
|
||||
{
|
||||
@@ -582,7 +582,7 @@ completion_list_add_infolists_cb (void *data,
|
||||
HOOK_INFOLIST(ptr_hook, infolist_name),
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -599,12 +599,12 @@ completion_list_add_nicks_cb (void *data,
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
struct t_gui_nick *ptr_nick;
|
||||
int count_before;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
count_before = weelist_size (completion->completion_list);
|
||||
hook_completion_exec (completion->buffer->plugin,
|
||||
"nick",
|
||||
@@ -630,7 +630,7 @@ completion_list_add_nicks_cb (void *data,
|
||||
&ptr_group, &ptr_nick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -650,12 +650,12 @@ completion_list_add_config_options_cb (void *data,
|
||||
struct t_config_option *ptr_option;
|
||||
int length;
|
||||
char *option_full_name;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_config = config_files; ptr_config;
|
||||
ptr_config = ptr_config->next_config)
|
||||
{
|
||||
@@ -682,7 +682,7 @@ completion_list_add_config_options_cb (void *data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -697,19 +697,19 @@ completion_list_add_plugins_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
{
|
||||
gui_completion_list_add (completion, ptr_plugin->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -728,12 +728,12 @@ completion_list_add_plugins_commands_cb (void *data,
|
||||
char *pos_space, *plugin_name;
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
struct t_hook *ptr_hook;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (completion->args)
|
||||
{
|
||||
pos_space = strchr (completion->args, ' ');
|
||||
@@ -742,7 +742,7 @@ completion_list_add_plugins_commands_cb (void *data,
|
||||
pos_space - completion->args);
|
||||
else
|
||||
plugin_name = strdup (completion->args);
|
||||
|
||||
|
||||
if (plugin_name)
|
||||
{
|
||||
ptr_plugin = NULL;
|
||||
@@ -772,7 +772,7 @@ completion_list_add_plugins_commands_cb (void *data,
|
||||
free (plugin_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -788,7 +788,7 @@ completion_list_map_add_color_alias_cb (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
(void) value;
|
||||
|
||||
|
||||
gui_completion_list_add ((struct t_gui_completion *)data,
|
||||
(char *)key,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
@@ -813,12 +813,12 @@ completion_list_add_config_option_values_cb (void *data,
|
||||
struct t_config_section *ptr_section, *section_found;
|
||||
struct t_config_option *option_found;
|
||||
struct t_gui_color_palette *color_palette;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (completion->args)
|
||||
{
|
||||
pos_space = strchr (completion->args, ' ');
|
||||
@@ -827,16 +827,16 @@ completion_list_add_config_option_values_cb (void *data,
|
||||
pos_space - completion->args);
|
||||
else
|
||||
option_full_name = strdup (completion->args);
|
||||
|
||||
|
||||
if (option_full_name)
|
||||
{
|
||||
file = NULL;
|
||||
section = NULL;
|
||||
pos_option = NULL;
|
||||
|
||||
|
||||
pos_section = strchr (option_full_name, '.');
|
||||
pos_option = (pos_section) ? strchr (pos_section + 1, '.') : NULL;
|
||||
|
||||
|
||||
if (pos_section && pos_option)
|
||||
{
|
||||
file = string_strndup (option_full_name,
|
||||
@@ -1043,7 +1043,7 @@ completion_list_add_config_option_values_cb (void *data,
|
||||
free (section);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1059,12 +1059,12 @@ completion_list_add_weechat_commands_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_hook *ptr_hook;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook;
|
||||
ptr_hook = ptr_hook->next_hook)
|
||||
{
|
||||
@@ -1078,7 +1078,7 @@ completion_list_add_weechat_commands_cb (void *data,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1093,19 +1093,19 @@ completion_list_add_proxies_names_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_proxy *ptr_proxy;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_proxy = weechat_proxies; ptr_proxy;
|
||||
ptr_proxy = ptr_proxy->next_proxy)
|
||||
{
|
||||
gui_completion_list_add (completion, ptr_proxy->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1120,18 +1120,18 @@ completion_list_add_proxies_options_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (i = 0; i < PROXY_NUM_OPTIONS; i++)
|
||||
{
|
||||
gui_completion_list_add (completion, proxy_option_string[i],
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1146,18 +1146,18 @@ completion_list_add_keys_contexts_cb (void *data,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
|
||||
{
|
||||
gui_completion_list_add (completion, gui_key_context_string[i],
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1174,7 +1174,7 @@ completion_list_add_keys_codes_cb (void *data,
|
||||
int i;
|
||||
struct t_gui_key *ptr_key;
|
||||
char *expanded_name;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
@@ -1192,7 +1192,7 @@ completion_list_add_keys_codes_cb (void *data,
|
||||
free (expanded_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1211,7 +1211,7 @@ completion_list_add_keys_codes_for_reset_cb (void *data,
|
||||
int i;
|
||||
struct t_gui_key *ptr_key, *ptr_default_key;
|
||||
char *expanded_name;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
@@ -1234,7 +1234,7 @@ completion_list_add_keys_codes_for_reset_cb (void *data,
|
||||
free (expanded_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* keys deleted */
|
||||
for (ptr_default_key = gui_default_keys[i]; ptr_default_key;
|
||||
ptr_default_key = ptr_default_key->next_key)
|
||||
@@ -1251,7 +1251,7 @@ completion_list_add_keys_codes_for_reset_cb (void *data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1268,15 +1268,15 @@ completion_list_add_cursor_areas_cb (void *data,
|
||||
{
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
/* add "chat" for chat area */
|
||||
gui_completion_list_add (completion, "chat", 0, WEECHAT_LIST_POS_SORT);
|
||||
|
||||
|
||||
/* add bar windows (of current window) */
|
||||
for (ptr_bar_win = gui_current_window->bar_windows; ptr_bar_win;
|
||||
ptr_bar_win = ptr_bar_win->next_bar_window)
|
||||
@@ -1292,7 +1292,7 @@ completion_list_add_cursor_areas_cb (void *data,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
+164
-164
File diff suppressed because it is too large
Load Diff
+145
-145
@@ -252,7 +252,7 @@ config_change_save_config_on_exit (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (!CONFIG_BOOLEAN(config_look_save_config_on_exit))
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
@@ -272,7 +272,7 @@ config_change_title (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
|
||||
}
|
||||
@@ -287,7 +287,7 @@ config_change_buffers (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ config_change_buffer_content (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (gui_ok)
|
||||
gui_current_window->refresh_needed = 1;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ config_change_buffer_notify_default (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
gui_buffer_notify_set_all ();
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ config_change_buffer_time_format (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
gui_chat_time_length = gui_chat_get_time_length ();
|
||||
gui_chat_change_time_format ();
|
||||
if (gui_ok)
|
||||
@@ -347,7 +347,7 @@ config_change_eat_newline_glitch (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (gui_ok)
|
||||
{
|
||||
if (CONFIG_BOOLEAN(config_look_eat_newline_glitch))
|
||||
@@ -367,14 +367,14 @@ config_change_highlight_regex (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (config_highlight_regex)
|
||||
{
|
||||
regfree (config_highlight_regex);
|
||||
free (config_highlight_regex);
|
||||
config_highlight_regex = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG_STRING(config_look_highlight_regex)
|
||||
&& CONFIG_STRING(config_look_highlight_regex)[0])
|
||||
{
|
||||
@@ -402,14 +402,14 @@ config_change_highlight_tags (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (config_highlight_tags)
|
||||
{
|
||||
string_free_split (config_highlight_tags);
|
||||
config_highlight_tags = NULL;
|
||||
}
|
||||
config_num_highlight_tags = 0;
|
||||
|
||||
|
||||
if (CONFIG_STRING(config_look_highlight_tags)
|
||||
&& CONFIG_STRING(config_look_highlight_tags)[0])
|
||||
{
|
||||
@@ -428,7 +428,7 @@ config_change_hotlist (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
gui_hotlist_resort ();
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ config_change_read_marker (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ config_change_prefix (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
gui_chat_prefix_build ();
|
||||
}
|
||||
|
||||
@@ -468,11 +468,11 @@ void
|
||||
config_change_prefix_align_min (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -494,7 +494,7 @@ config_change_color (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (gui_ok)
|
||||
{
|
||||
gui_color_init_weechat ();
|
||||
@@ -512,7 +512,7 @@ config_change_nick_colors (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
gui_color_buffer_display ();
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ config_change_network_gnutls_ca_file (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (network_init_ok)
|
||||
network_set_gnutls_ca_file ();
|
||||
}
|
||||
@@ -546,15 +546,15 @@ config_day_change_timer_cb (void *data, int remaining_calls)
|
||||
int new_mday;
|
||||
char text_time[256], *text_time2;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
gettimeofday (&tv_time, NULL);
|
||||
local_time = localtime (&tv_time.tv_sec);
|
||||
new_mday = local_time->tm_mday;
|
||||
|
||||
|
||||
if ((config_day_change_old_day >= 0)
|
||||
&& (new_mday != config_day_change_old_day))
|
||||
{
|
||||
@@ -580,14 +580,14 @@ config_day_change_timer_cb (void *data, int remaining_calls)
|
||||
free (text_time2);
|
||||
gui_add_hotlist = 1;
|
||||
}
|
||||
|
||||
|
||||
/* send signal "day_changed" */
|
||||
strftime (text_time, sizeof (text_time), "%Y-%m-%d", local_time);
|
||||
hook_signal_send ("day_changed", WEECHAT_HOOK_SIGNAL_STRING, text_time);
|
||||
}
|
||||
|
||||
|
||||
config_day_change_old_day = new_mday;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -600,11 +600,11 @@ void
|
||||
config_weechat_init_after_read ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
gui_buffer_notify_set_all ();
|
||||
|
||||
|
||||
proxy_use_temp_proxies ();
|
||||
|
||||
|
||||
gui_bar_use_temp_bars ();
|
||||
if (gui_bars)
|
||||
{
|
||||
@@ -619,7 +619,7 @@ config_weechat_init_after_read ()
|
||||
/* no bar defined => create default bars */
|
||||
gui_bar_create_default ();
|
||||
}
|
||||
|
||||
|
||||
/* if no key was found config file, then we use default bindings */
|
||||
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
|
||||
{
|
||||
@@ -640,38 +640,38 @@ int
|
||||
config_weechat_reload_cb (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
int i, rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
/* remove all keys */
|
||||
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
|
||||
{
|
||||
gui_key_free_all (&gui_keys[i], &last_gui_key[i],
|
||||
&gui_keys_count[i]);
|
||||
}
|
||||
|
||||
|
||||
/* remove all proxies */
|
||||
proxy_free_all ();
|
||||
|
||||
|
||||
/* remove all bars */
|
||||
gui_bar_free_all ();
|
||||
|
||||
|
||||
/* remove layout */
|
||||
gui_layout_buffer_reset (&gui_layout_buffers, &last_gui_layout_buffer);
|
||||
gui_layout_window_reset (&gui_layout_windows);
|
||||
|
||||
|
||||
/* remove all notify levels */
|
||||
config_file_section_free_options (weechat_config_section_notify);
|
||||
|
||||
|
||||
/* remove all filters */
|
||||
gui_filter_free_all ();
|
||||
|
||||
|
||||
rc = config_file_reload (config_file);
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_READ_OK)
|
||||
config_weechat_init_after_read ();
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -697,11 +697,11 @@ config_weechat_debug_set_all ()
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
|
||||
|
||||
/* set debug for core */
|
||||
ptr_option = config_weechat_debug_get (PLUGIN_CORE);
|
||||
weechat_debug_core = (ptr_option) ? CONFIG_INTEGER(ptr_option) : 0;
|
||||
|
||||
|
||||
/* set debug for plugins */
|
||||
for (ptr_plugin = weechat_plugins; ptr_plugin;
|
||||
ptr_plugin = ptr_plugin->next_plugin)
|
||||
@@ -722,7 +722,7 @@ config_weechat_debug_change_cb (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
config_weechat_debug_set_all ();
|
||||
}
|
||||
|
||||
@@ -739,12 +739,12 @@ config_weechat_debug_create_option_cb (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = config_file_search_option (config_file, section,
|
||||
@@ -777,10 +777,10 @@ config_weechat_debug_create_option_cb (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* set debug level for "core" and all plugins */
|
||||
config_weechat_debug_set_all ();
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -798,11 +798,11 @@ config_weechat_debug_delete_option_cb (void *data,
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
config_file_option_free (option);
|
||||
|
||||
|
||||
config_weechat_debug_set_all ();
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -830,11 +830,11 @@ config_weechat_palette_change_cb (void *data,
|
||||
{
|
||||
char *error;
|
||||
int number;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
error = NULL;
|
||||
number = (int)strtol (option->name, &error, 10);
|
||||
if (error && !error[0])
|
||||
@@ -857,10 +857,10 @@ config_weechat_palette_create_option_cb (void *data,
|
||||
struct t_config_option *ptr_option;
|
||||
char *error;
|
||||
int rc, number;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
error = NULL;
|
||||
@@ -908,7 +908,7 @@ config_weechat_palette_create_option_cb (void *data,
|
||||
_("%sError: palette option must be numeric"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -924,19 +924,19 @@ config_weechat_palette_delete_option_cb (void *data,
|
||||
{
|
||||
char *error;
|
||||
int number;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
error = NULL;
|
||||
number = (int)strtol (option->name, &error, 10);
|
||||
if (error && !error[0])
|
||||
gui_color_palette_remove (number);
|
||||
|
||||
|
||||
config_file_option_free (option);
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -952,12 +952,12 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
|
||||
char *pos_option, *proxy_name;
|
||||
struct t_proxy *ptr_temp_proxy;
|
||||
int index_option;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
pos_option = strchr (option_name, '.');
|
||||
@@ -982,7 +982,7 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
|
||||
/* add new temp proxy at end of queue */
|
||||
ptr_temp_proxy->prev_proxy = last_weechat_temp_proxy;
|
||||
ptr_temp_proxy->next_proxy = NULL;
|
||||
|
||||
|
||||
if (!weechat_temp_proxies)
|
||||
weechat_temp_proxies = ptr_temp_proxy;
|
||||
else
|
||||
@@ -990,7 +990,7 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
|
||||
last_weechat_temp_proxy = ptr_temp_proxy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ptr_temp_proxy)
|
||||
{
|
||||
index_option = proxy_search_option (pos_option);
|
||||
@@ -1000,12 +1000,12 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
|
||||
value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free (proxy_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
|
||||
@@ -1021,12 +1021,12 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
|
||||
char *pos_option, *bar_name;
|
||||
struct t_gui_bar *ptr_temp_bar;
|
||||
int index_option;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
pos_option = strchr (option_name, '.');
|
||||
@@ -1051,7 +1051,7 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
|
||||
/* add new temp bar at end of queue */
|
||||
ptr_temp_bar->prev_bar = last_gui_temp_bar;
|
||||
ptr_temp_bar->next_bar = NULL;
|
||||
|
||||
|
||||
if (!gui_temp_bars)
|
||||
gui_temp_bars = ptr_temp_bar;
|
||||
else
|
||||
@@ -1059,7 +1059,7 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
|
||||
last_gui_temp_bar = ptr_temp_bar;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ptr_temp_bar)
|
||||
{
|
||||
index_option = gui_bar_search_option (pos_option);
|
||||
@@ -1069,12 +1069,12 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
|
||||
value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free (bar_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
|
||||
@@ -1091,12 +1091,12 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
|
||||
char **argv, *error1, *error2, *error3, *error4;
|
||||
long number1, number2, number3, number4;
|
||||
struct t_gui_layout_window *parent;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
if (option_name && value && value[0])
|
||||
{
|
||||
if (string_strcasecmp (option_name, "buffer") == 0)
|
||||
@@ -1153,7 +1153,7 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
|
||||
@@ -1176,21 +1176,21 @@ config_weechat_layout_write_tree (struct t_config_file *config_file,
|
||||
(layout_window->buffer_name) ?
|
||||
layout_window->buffer_name : "-"))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
if (layout_window->child1)
|
||||
{
|
||||
if (config_weechat_layout_write_tree (config_file,
|
||||
layout_window->child1) != WEECHAT_CONFIG_WRITE_OK)
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (layout_window->child2)
|
||||
{
|
||||
if (config_weechat_layout_write_tree (config_file,
|
||||
layout_window->child2) != WEECHAT_CONFIG_WRITE_OK)
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1203,13 +1203,13 @@ config_weechat_layout_write_cb (void *data, struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
{
|
||||
struct t_gui_layout_buffer *ptr_layout_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!config_file_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (ptr_layout_buffer = gui_layout_buffers; ptr_layout_buffer;
|
||||
ptr_layout_buffer = ptr_layout_buffer->next_layout)
|
||||
{
|
||||
@@ -1219,14 +1219,14 @@ config_weechat_layout_write_cb (void *data, struct t_config_file *config_file,
|
||||
ptr_layout_buffer->number))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (gui_layout_windows)
|
||||
{
|
||||
if (config_weechat_layout_write_tree (config_file,
|
||||
gui_layout_windows) != WEECHAT_CONFIG_WRITE_OK)
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1240,7 +1240,7 @@ config_weechat_notify_change_cb (void *data, struct t_config_option *option)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
gui_buffer_notify_set_all ();
|
||||
}
|
||||
|
||||
@@ -1258,12 +1258,12 @@ config_weechat_notify_create_option_cb (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = config_file_search_option (config_file, section,
|
||||
@@ -1296,10 +1296,10 @@ config_weechat_notify_create_option_cb (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
gui_buffer_notify_set_all ();
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1318,11 +1318,11 @@ config_weechat_notify_delete_option_cb (void *data,
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
config_file_option_free (option);
|
||||
|
||||
|
||||
gui_buffer_notify_set_all ();
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -1339,10 +1339,10 @@ config_weechat_notify_set (struct t_gui_buffer *buffer, const char *notify)
|
||||
const char *plugin_name;
|
||||
char *option_name;
|
||||
int i, value, length;
|
||||
|
||||
|
||||
if (!buffer || !notify)
|
||||
return 0;
|
||||
|
||||
|
||||
value = -1;
|
||||
for (i = 0; i < GUI_BUFFER_NUM_NOTIFY; i++)
|
||||
{
|
||||
@@ -1354,14 +1354,14 @@ config_weechat_notify_set (struct t_gui_buffer *buffer, const char *notify)
|
||||
}
|
||||
if ((value < 0) && (strcmp (notify, "reset") != 0))
|
||||
return 0;
|
||||
|
||||
|
||||
plugin_name = gui_buffer_get_plugin_name (buffer);
|
||||
length = strlen (plugin_name) + 1 + strlen (buffer->name) + 1;
|
||||
option_name = malloc (length);
|
||||
if (option_name)
|
||||
{
|
||||
snprintf (option_name, length, "%s.%s", plugin_name, buffer->name);
|
||||
|
||||
|
||||
/* create/update option */
|
||||
config_weechat_notify_create_option_cb (NULL,
|
||||
weechat_config_file,
|
||||
@@ -1371,7 +1371,7 @@ config_weechat_notify_set (struct t_gui_buffer *buffer, const char *notify)
|
||||
NULL : gui_buffer_notify_string[value]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1387,12 +1387,12 @@ config_weechat_filter_read_cb (void *data,
|
||||
{
|
||||
char **argv, **argv_eol;
|
||||
int argc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
if (option_name && value && value[0])
|
||||
{
|
||||
argv = string_split (value, ";", 0, 0, &argc);
|
||||
@@ -1407,7 +1407,7 @@ config_weechat_filter_read_cb (void *data,
|
||||
if (argv_eol)
|
||||
string_free_split (argv_eol);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
|
||||
@@ -1420,13 +1420,13 @@ config_weechat_filter_write_cb (void *data, struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
{
|
||||
struct t_gui_filter *ptr_filter;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!config_file_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (ptr_filter = gui_filters; ptr_filter;
|
||||
ptr_filter = ptr_filter->next_filter)
|
||||
{
|
||||
@@ -1439,7 +1439,7 @@ config_weechat_filter_write_cb (void *data, struct t_config_file *config_file,
|
||||
ptr_filter->regex))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1454,11 +1454,11 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
int context;
|
||||
char *pos;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
context = GUI_KEY_CONTEXT_DEFAULT;
|
||||
@@ -1469,7 +1469,7 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
|
||||
if (context < 0)
|
||||
context = GUI_KEY_CONTEXT_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
if (value && value[0])
|
||||
{
|
||||
/* bind key (overwrite any binding with same key) */
|
||||
@@ -1481,7 +1481,7 @@ config_weechat_key_read_cb (void *data, struct t_config_file *config_file,
|
||||
gui_key_unbind (NULL, context, option_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
|
||||
@@ -1496,10 +1496,10 @@ config_weechat_key_write_cb (void *data, struct t_config_file *config_file,
|
||||
struct t_gui_key *ptr_key;
|
||||
char *pos, *expanded_name;
|
||||
int rc, context;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!config_file_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
@@ -1526,7 +1526,7 @@ config_weechat_key_write_cb (void *data, struct t_config_file *config_file,
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1541,12 +1541,12 @@ config_weechat_init_options ()
|
||||
struct t_config_section *ptr_section;
|
||||
int i;
|
||||
char section_name[128];
|
||||
|
||||
|
||||
weechat_config_file = config_file_new (NULL, WEECHAT_CONFIG_NAME,
|
||||
&config_weechat_reload_cb, NULL);
|
||||
if (!weechat_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* debug */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "debug",
|
||||
1, 1,
|
||||
@@ -1559,9 +1559,9 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_config_section_debug = ptr_section;
|
||||
|
||||
|
||||
/* startup */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "startup",
|
||||
0, 0,
|
||||
@@ -1572,7 +1572,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
config_startup_command_after_plugins = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"command_after_plugins", "string",
|
||||
@@ -1593,7 +1593,7 @@ config_weechat_init_options ()
|
||||
"display_version", "boolean",
|
||||
N_("display WeeChat version at startup"),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* look */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "look",
|
||||
0, 0,
|
||||
@@ -1604,7 +1604,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
config_look_align_end_of_lines = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"align_end_of_lines", "integer",
|
||||
@@ -2051,7 +2051,7 @@ config_weechat_init_options ()
|
||||
N_("time format for dates converted to strings and displayed in "
|
||||
"messages"),
|
||||
NULL, 0, 0, "%a, %d %b %Y %T", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* palette */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "palette",
|
||||
1, 1,
|
||||
@@ -2064,7 +2064,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* colors */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "color",
|
||||
0, 0,
|
||||
@@ -2075,9 +2075,9 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_config_section_color = ptr_section;
|
||||
|
||||
|
||||
/* general color settings */
|
||||
config_color_separator = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
@@ -2414,7 +2414,7 @@ config_weechat_init_options ()
|
||||
N_("text color for offline nicknames"),
|
||||
NULL, -1, 0, "blue", NULL, 0,
|
||||
NULL, NULL, &config_change_color, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* completion */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "completion",
|
||||
0, 0,
|
||||
@@ -2425,7 +2425,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
config_completion_default_template = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"default_template", "string",
|
||||
@@ -2482,7 +2482,7 @@ config_weechat_init_options ()
|
||||
"partial_completion_count", "boolean",
|
||||
N_("display count for each partial completion in bar item"),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* history */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "history",
|
||||
0, 0,
|
||||
@@ -2493,7 +2493,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
config_history_max_lines = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"max_lines", "integer",
|
||||
@@ -2517,7 +2517,7 @@ config_weechat_init_options ()
|
||||
N_("maximum number of commands to display by default in "
|
||||
"history listing (0 = unlimited)"),
|
||||
NULL, 0, INT_MAX, "5", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* proxies */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "proxy",
|
||||
0, 0,
|
||||
@@ -2529,7 +2529,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_config_section_proxy = ptr_section;
|
||||
|
||||
/* network */
|
||||
@@ -2542,7 +2542,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
config_network_gnutls_ca_file = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"gnutls_ca_file", "string",
|
||||
@@ -2555,7 +2555,7 @@ config_weechat_init_options ()
|
||||
"gnutls_handshake_timeout", "integer",
|
||||
N_("timeout (in seconds) for gnutls handshake"),
|
||||
NULL, 1, INT_MAX, "30", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* plugin */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "plugin",
|
||||
0, 0,
|
||||
@@ -2566,7 +2566,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
config_plugin_autoload = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"autoload", "string",
|
||||
@@ -2605,7 +2605,7 @@ config_weechat_init_options ()
|
||||
"save_config_on_unload", "boolean",
|
||||
N_("save configuration files when unloading plugins"),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* bars */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "bar",
|
||||
0, 0,
|
||||
@@ -2617,9 +2617,9 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_config_section_bar = ptr_section;
|
||||
|
||||
|
||||
/* layout */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "layout",
|
||||
0, 0,
|
||||
@@ -2631,7 +2631,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* notify */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "notify",
|
||||
1, 1,
|
||||
@@ -2645,9 +2645,9 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_config_section_notify = ptr_section;
|
||||
|
||||
|
||||
/* filters */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "filter",
|
||||
0, 0,
|
||||
@@ -2660,7 +2660,7 @@ config_weechat_init_options ()
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* keys */
|
||||
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
|
||||
{
|
||||
@@ -2680,7 +2680,7 @@ config_weechat_init_options ()
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2695,15 +2695,15 @@ config_weechat_init ()
|
||||
int rc;
|
||||
struct timeval tv_time;
|
||||
struct tm *local_time;
|
||||
|
||||
|
||||
rc = config_weechat_init_options ();
|
||||
|
||||
|
||||
if (!rc)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("FATAL: error initializing configuration options"));
|
||||
}
|
||||
|
||||
|
||||
if (!config_day_change_timer)
|
||||
{
|
||||
/* create timer to check if day has changed */
|
||||
@@ -2721,7 +2721,7 @@ config_weechat_init ()
|
||||
config_change_highlight_regex (NULL, NULL);
|
||||
if (!config_highlight_tags)
|
||||
config_change_highlight_tags (NULL, NULL);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -2737,18 +2737,18 @@ int
|
||||
config_weechat_read ()
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
rc = config_file_read (weechat_config_file);
|
||||
if (rc == WEECHAT_CONFIG_READ_OK)
|
||||
config_weechat_init_after_read ();
|
||||
|
||||
|
||||
if (rc != WEECHAT_CONFIG_READ_OK)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sError reading configuration"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
+37
-37
@@ -69,14 +69,14 @@ debug_dump (int crash)
|
||||
/* prevent reentrance */
|
||||
if (debug_dump_active)
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
|
||||
if (crash)
|
||||
{
|
||||
debug_dump_active = 1;
|
||||
log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)...");
|
||||
weechat_log_use_time = 0;
|
||||
}
|
||||
|
||||
|
||||
log_printf ("");
|
||||
if (crash)
|
||||
{
|
||||
@@ -97,19 +97,19 @@ debug_dump (int crash)
|
||||
gui_bar_print_log ();
|
||||
gui_bar_item_print_log ();
|
||||
gui_hotlist_print_log ();
|
||||
|
||||
|
||||
hdata_print_log ();
|
||||
|
||||
|
||||
infolist_print_log ();
|
||||
|
||||
|
||||
hook_print_log ();
|
||||
|
||||
|
||||
config_file_print_log ();
|
||||
|
||||
|
||||
proxy_print_log ();
|
||||
|
||||
|
||||
plugin_print_log ();
|
||||
|
||||
|
||||
log_printf ("");
|
||||
log_printf ("****** End of WeeChat dump ******");
|
||||
log_printf ("");
|
||||
@@ -127,10 +127,10 @@ debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data || (string_strcasecmp ((char *)signal_data, "core") == 0))
|
||||
debug_dump (0);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ debug_sigsegv ()
|
||||
debug_dump (1);
|
||||
unhook_all ();
|
||||
gui_main_end (0);
|
||||
|
||||
|
||||
string_iconv_fprintf (stderr, "\n");
|
||||
string_iconv_fprintf (stderr, "*** Very bad! WeeChat is crashing (SIGSEGV received)\n");
|
||||
if (!log_crash_rename ())
|
||||
@@ -160,9 +160,9 @@ debug_sigsegv ()
|
||||
string_iconv_fprintf (stderr, "*** 2. Otherwise send backtrace (below) and weechat.log\n");
|
||||
string_iconv_fprintf (stderr, "*** (be careful, private info may be in this file since\n");
|
||||
string_iconv_fprintf (stderr, "*** part of chats are displayed, so remove lines if needed)\n\n");
|
||||
|
||||
|
||||
weechat_backtrace ();
|
||||
|
||||
|
||||
/* shutdown with error code */
|
||||
weechat_shutdown (EXIT_FAILURE, 1);
|
||||
}
|
||||
@@ -179,9 +179,9 @@ debug_buffer_cb (void *data, const char *signal, const char *type_data,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
gui_buffer_dump_hexa ((struct t_gui_buffer *)signal_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ void
|
||||
debug_windows_tree_display (struct t_gui_window_tree *tree, int indent)
|
||||
{
|
||||
char format[128];
|
||||
|
||||
|
||||
if (tree)
|
||||
{
|
||||
if (tree->window)
|
||||
@@ -229,7 +229,7 @@ debug_windows_tree_display (struct t_gui_window_tree *tree, int indent)
|
||||
tree->split_horizontal,
|
||||
tree->child1, tree->child2);
|
||||
}
|
||||
|
||||
|
||||
if (tree->child1)
|
||||
debug_windows_tree_display (tree->child1, indent + 1);
|
||||
if (tree->child2)
|
||||
@@ -262,9 +262,9 @@ debug_windows_cb (void *data, const char *signal, const char *type_data,
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
debug_windows_tree ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -277,9 +277,9 @@ debug_memory ()
|
||||
{
|
||||
#ifdef HAVE_MALLINFO
|
||||
struct mallinfo info;
|
||||
|
||||
|
||||
info = mallinfo ();
|
||||
|
||||
|
||||
gui_chat_printf (NULL, "");
|
||||
gui_chat_printf (NULL, _("Memory usage (see \"man mallinfo\" for help):"));
|
||||
gui_chat_printf (NULL, " arena :%10d", info.arena);
|
||||
@@ -310,12 +310,12 @@ debug_hdata_hash_var_map_cb (void *data,
|
||||
{
|
||||
struct t_weelist *list;
|
||||
char str_offset[16];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
list = (struct t_weelist *)data;
|
||||
|
||||
|
||||
snprintf (str_offset, sizeof (str_offset),
|
||||
"%12d", (*((int *)value)) & 0xFFFF);
|
||||
weelist_add (list, str_offset, WEECHAT_LIST_POS_SORT, (void *)key);
|
||||
@@ -333,7 +333,7 @@ debug_hdata_hash_list_map_cb (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
gui_chat_printf (NULL,
|
||||
" list: %s -> 0x%lx",
|
||||
(char *)key,
|
||||
@@ -352,13 +352,13 @@ debug_hdata_map_cb (void *data, struct t_hashtable *hashtable,
|
||||
struct t_weelist *list;
|
||||
struct t_weelist_item *ptr_item;
|
||||
void *ptr_value;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
ptr_hdata = (struct t_hdata *)value;
|
||||
|
||||
|
||||
gui_chat_printf (NULL,
|
||||
" hdata 0x%lx: \"%s\", %d vars, %d lists:",
|
||||
ptr_hdata, (const char *)key,
|
||||
@@ -366,11 +366,11 @@ debug_hdata_map_cb (void *data, struct t_hashtable *hashtable,
|
||||
"items_count"),
|
||||
hashtable_get_integer (ptr_hdata->hash_list,
|
||||
"items_count"));
|
||||
|
||||
|
||||
/* display lists */
|
||||
hashtable_map (ptr_hdata->hash_list,
|
||||
&debug_hdata_hash_list_map_cb, NULL);
|
||||
|
||||
|
||||
/* display vars */
|
||||
list = weelist_new ();
|
||||
hashtable_map (ptr_hdata->hash_var,
|
||||
@@ -399,12 +399,12 @@ void
|
||||
debug_hdata ()
|
||||
{
|
||||
int count;
|
||||
|
||||
|
||||
count = hashtable_get_integer (weechat_hdata, "items_count");
|
||||
|
||||
|
||||
gui_chat_printf (NULL, "");
|
||||
gui_chat_printf (NULL, "%d hdata in memory", count);
|
||||
|
||||
|
||||
if (count > 0)
|
||||
hashtable_map (weechat_hdata, &debug_hdata_map_cb, NULL);
|
||||
}
|
||||
@@ -421,21 +421,21 @@ debug_infolists ()
|
||||
struct t_infolist_var *ptr_var;
|
||||
int i, count, count_items, count_vars, size_structs, size_data;
|
||||
int total_items, total_vars, total_size;
|
||||
|
||||
|
||||
count = 0;
|
||||
for (ptr_infolist = weechat_infolists; ptr_infolist;
|
||||
ptr_infolist = ptr_infolist->next_infolist)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
gui_chat_printf (NULL, "");
|
||||
gui_chat_printf (NULL, "%d infolists in memory (%s)", count,
|
||||
(count == 0) ?
|
||||
"this is ok!" :
|
||||
"WARNING: this is probably a memory leak in WeeChat or "
|
||||
"plugins/scripts!");
|
||||
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
i = 0;
|
||||
|
||||
+72
-72
@@ -52,16 +52,16 @@ int
|
||||
hashtable_get_type (const char *type)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!type)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < HASHTABLE_NUM_TYPES; i++)
|
||||
{
|
||||
if (string_strcasecmp (hashtable_type_string[i], type) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* type not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ hashtable_hash_key_string_cb (struct t_hashtable *hashtable, const void *key)
|
||||
{
|
||||
const char *ptr_key;
|
||||
unsigned long hash;
|
||||
|
||||
|
||||
/* variant of djb2 hash */
|
||||
hash = 5381;
|
||||
for (ptr_key = (const char *)key; ptr_key[0]; ptr_key++)
|
||||
@@ -95,7 +95,7 @@ hashtable_keycmp_string_cb (struct t_hashtable *hashtable,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
return strcmp ((const char *)key1, (const char *)key2);
|
||||
}
|
||||
|
||||
@@ -111,17 +111,17 @@ hashtable_new (int size,
|
||||
{
|
||||
struct t_hashtable *new_hashtable;
|
||||
int i, type_keys_int, type_values_int;
|
||||
|
||||
|
||||
type_keys_int = hashtable_get_type (type_keys);
|
||||
if (type_keys_int < 0)
|
||||
return NULL;
|
||||
type_values_int = hashtable_get_type (type_values);
|
||||
if (type_values_int < 0)
|
||||
return NULL;
|
||||
|
||||
|
||||
if ((type_keys_int != HASHTABLE_STRING) && (!callback_hash_key || !callback_keycmp))
|
||||
return NULL;
|
||||
|
||||
|
||||
new_hashtable = malloc (sizeof (*new_hashtable));
|
||||
if (new_hashtable)
|
||||
{
|
||||
@@ -140,17 +140,17 @@ hashtable_new (int size,
|
||||
new_hashtable->htable[i] = NULL;
|
||||
}
|
||||
new_hashtable->items_count = 0;
|
||||
|
||||
|
||||
if ((type_keys_int == HASHTABLE_STRING) && !callback_hash_key)
|
||||
new_hashtable->callback_hash_key = &hashtable_hash_key_string_cb;
|
||||
else
|
||||
new_hashtable->callback_hash_key = callback_hash_key;
|
||||
|
||||
|
||||
if ((type_keys_int == HASHTABLE_STRING) && !callback_keycmp)
|
||||
new_hashtable->callback_keycmp = &hashtable_keycmp_string_cb;
|
||||
else
|
||||
new_hashtable->callback_keycmp = callback_keycmp;
|
||||
|
||||
|
||||
new_hashtable->callback_free_value = NULL;
|
||||
}
|
||||
return new_hashtable;
|
||||
@@ -281,14 +281,14 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
|
||||
{
|
||||
unsigned int hash;
|
||||
struct t_hashtable_item *ptr_item, *pos_item, *new_item;
|
||||
|
||||
|
||||
if (!hashtable || !key
|
||||
|| ((hashtable->type_keys == HASHTABLE_BUFFER) && (key_size <= 0))
|
||||
|| ((hashtable->type_values == HASHTABLE_BUFFER) && (value_size <= 0)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* search position for item in hash table */
|
||||
hash = hashtable->callback_hash_key (hashtable, key);
|
||||
pos_item = NULL;
|
||||
@@ -299,7 +299,7 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
|
||||
{
|
||||
pos_item = ptr_item;
|
||||
}
|
||||
|
||||
|
||||
/* replace value if item is already in hash table */
|
||||
if (ptr_item && (hashtable->callback_keycmp (hashtable, key, ptr_item->key) == 0))
|
||||
{
|
||||
@@ -309,12 +309,12 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
|
||||
&ptr_item->value, &ptr_item->value_size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* create new item */
|
||||
new_item = malloc (sizeof (*new_item));
|
||||
if (!new_item)
|
||||
return 0;
|
||||
|
||||
|
||||
/* set key and value */
|
||||
hashtable_alloc_type (hashtable->type_keys,
|
||||
key, key_size,
|
||||
@@ -322,7 +322,7 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
|
||||
hashtable_alloc_type (hashtable->type_values,
|
||||
value, value_size,
|
||||
&new_item->value, &new_item->value_size);
|
||||
|
||||
|
||||
/* add item */
|
||||
if (pos_item)
|
||||
{
|
||||
@@ -342,9 +342,9 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
|
||||
(hashtable->htable[hash])->prev_item = new_item;
|
||||
hashtable->htable[hash] = new_item;
|
||||
}
|
||||
|
||||
|
||||
hashtable->items_count++;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -374,10 +374,10 @@ hashtable_get_item (struct t_hashtable *hashtable, const void *key,
|
||||
{
|
||||
unsigned int key_hash;
|
||||
struct t_hashtable_item *ptr_item;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
key_hash = hashtable->callback_hash_key (hashtable, key);
|
||||
if (hash)
|
||||
*hash = key_hash;
|
||||
@@ -386,13 +386,13 @@ hashtable_get_item (struct t_hashtable *hashtable, const void *key,
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
if (ptr_item
|
||||
&& (hashtable->callback_keycmp (hashtable, key, ptr_item->key) == 0))
|
||||
{
|
||||
return ptr_item;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -406,9 +406,9 @@ void *
|
||||
hashtable_get (struct t_hashtable *hashtable, const void *key)
|
||||
{
|
||||
struct t_hashtable_item *ptr_item;
|
||||
|
||||
|
||||
ptr_item = hashtable_get_item (hashtable, key, NULL);
|
||||
|
||||
|
||||
return (ptr_item) ? ptr_item->value : NULL;
|
||||
}
|
||||
|
||||
@@ -433,22 +433,22 @@ hashtable_map (struct t_hashtable *hashtable,
|
||||
{
|
||||
int i;
|
||||
struct t_hashtable_item *ptr_item, *ptr_next_item;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return;
|
||||
|
||||
|
||||
for (i = 0; i < hashtable->size; i++)
|
||||
{
|
||||
ptr_item = hashtable->htable[i];
|
||||
while (ptr_item)
|
||||
{
|
||||
ptr_next_item = ptr_item->next_item;
|
||||
|
||||
|
||||
(void) (callback_map) (callback_map_data,
|
||||
hashtable,
|
||||
ptr_item->key,
|
||||
ptr_item->value);
|
||||
|
||||
|
||||
ptr_item = ptr_next_item;
|
||||
}
|
||||
}
|
||||
@@ -465,10 +465,10 @@ hashtable_duplicate_map_cb (void *data,
|
||||
const void *key, const void *value)
|
||||
{
|
||||
struct t_hashtable *hashtable2;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
hashtable2 = (struct t_hashtable *)data;
|
||||
if (hashtable2)
|
||||
hashtable_set (hashtable2, key, value);
|
||||
@@ -482,7 +482,7 @@ struct t_hashtable *
|
||||
hashtable_dup (struct t_hashtable *hashtable)
|
||||
{
|
||||
struct t_hashtable *new_hashtable;
|
||||
|
||||
|
||||
new_hashtable = hashtable_new (hashtable->size,
|
||||
hashtable_type_string[hashtable->type_keys],
|
||||
hashtable_type_string[hashtable->type_values],
|
||||
@@ -495,7 +495,7 @@ hashtable_dup (struct t_hashtable *hashtable)
|
||||
&hashtable_duplicate_map_cb,
|
||||
new_hashtable);
|
||||
}
|
||||
|
||||
|
||||
return new_hashtable;
|
||||
}
|
||||
|
||||
@@ -511,13 +511,13 @@ hashtable_get_list_keys_map_cb (void *data,
|
||||
{
|
||||
struct t_weelist *list;
|
||||
char str_key[128];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
(void) value;
|
||||
|
||||
|
||||
list = (struct t_weelist *)data;
|
||||
|
||||
|
||||
switch (hashtable->type_keys)
|
||||
{
|
||||
case HASHTABLE_INTEGER:
|
||||
@@ -550,7 +550,7 @@ struct t_weelist *
|
||||
hashtable_get_list_keys (struct t_hashtable *hashtable)
|
||||
{
|
||||
struct t_weelist *weelist;
|
||||
|
||||
|
||||
weelist = weelist_new ();
|
||||
if (weelist)
|
||||
hashtable_map (hashtable, &hashtable_get_list_keys_map_cb, weelist);
|
||||
@@ -571,7 +571,7 @@ hashtable_get_integer (struct t_hashtable *hashtable, const char *property)
|
||||
else if (string_strcasecmp (property, "items_count") == 0)
|
||||
return hashtable->items_count;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -586,12 +586,12 @@ hashtable_compute_length_keys_cb (void *data,
|
||||
{
|
||||
char str_value[128];
|
||||
int *length;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) value;
|
||||
|
||||
|
||||
length = (int *)data;
|
||||
|
||||
|
||||
switch (hashtable->type_keys)
|
||||
{
|
||||
case HASHTABLE_INTEGER:
|
||||
@@ -626,10 +626,10 @@ hashtable_compute_length_values_cb (void *data,
|
||||
{
|
||||
char str_value[128];
|
||||
int *length;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) key;
|
||||
|
||||
|
||||
length = (int *)data;
|
||||
|
||||
if (value)
|
||||
@@ -686,15 +686,15 @@ hashtable_build_string_keys_cb (void *data,
|
||||
{
|
||||
char str_value[128];
|
||||
char *str;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) value;
|
||||
|
||||
|
||||
str = (char *)data;
|
||||
|
||||
|
||||
if (str[0])
|
||||
strcat (str, ",");
|
||||
|
||||
|
||||
switch (hashtable->type_keys)
|
||||
{
|
||||
case HASHTABLE_INTEGER:
|
||||
@@ -729,12 +729,12 @@ hashtable_build_string_values_cb (void *data,
|
||||
{
|
||||
char str_value[128];
|
||||
char *str;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) key;
|
||||
|
||||
|
||||
str = (char *)data;
|
||||
|
||||
|
||||
if (str[0])
|
||||
strcat (str, ",");
|
||||
|
||||
@@ -779,12 +779,12 @@ hashtable_build_string_keys_values_cb (void *data,
|
||||
{
|
||||
char str_value[128];
|
||||
char *str;
|
||||
|
||||
|
||||
str = (char *)data;
|
||||
|
||||
|
||||
if (str[0])
|
||||
strcat (str, ",");
|
||||
|
||||
|
||||
switch (hashtable->type_keys)
|
||||
{
|
||||
case HASHTABLE_INTEGER:
|
||||
@@ -806,7 +806,7 @@ hashtable_build_string_keys_values_cb (void *data,
|
||||
case HASHTABLE_NUM_TYPES:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
strcat (str, ":");
|
||||
|
||||
if (value)
|
||||
@@ -854,13 +854,13 @@ hashtable_get_keys_values (struct t_hashtable *hashtable,
|
||||
int length;
|
||||
struct t_weelist *list_keys;
|
||||
struct t_weelist_item *ptr_item;
|
||||
|
||||
|
||||
if (hashtable->keys_values)
|
||||
{
|
||||
free (hashtable->keys_values);
|
||||
hashtable->keys_values = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* first compute length of string */
|
||||
length = 0;
|
||||
hashtable_map (hashtable,
|
||||
@@ -870,7 +870,7 @@ hashtable_get_keys_values (struct t_hashtable *hashtable,
|
||||
&length);
|
||||
if (length == 0)
|
||||
return hashtable->keys_values;
|
||||
|
||||
|
||||
/* build string */
|
||||
hashtable->keys_values = malloc (length + 1);
|
||||
if (!hashtable->keys_values)
|
||||
@@ -911,7 +911,7 @@ hashtable_get_keys_values (struct t_hashtable *hashtable,
|
||||
&hashtable_build_string_values_cb),
|
||||
hashtable->keys_values);
|
||||
}
|
||||
|
||||
|
||||
return hashtable->keys_values;
|
||||
}
|
||||
|
||||
@@ -939,7 +939,7 @@ hashtable_get_string (struct t_hashtable *hashtable, const char *property)
|
||||
else if (string_strcasecmp (property, "keys_values_sorted") == 0)
|
||||
return hashtable_get_keys_values (hashtable, 1, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -971,11 +971,11 @@ hashtable_add_to_infolist (struct t_hashtable *hashtable,
|
||||
int i, item_number;
|
||||
struct t_hashtable_item *ptr_item;
|
||||
char option_name[128];
|
||||
|
||||
|
||||
if (!hashtable || (hashtable->type_keys != HASHTABLE_STRING)
|
||||
|| !infolist_item || !prefix)
|
||||
return 0;
|
||||
|
||||
|
||||
item_number = 0;
|
||||
for (i = 0; i < hashtable->size; i++)
|
||||
{
|
||||
@@ -1037,11 +1037,11 @@ hashtable_remove_item (struct t_hashtable *hashtable,
|
||||
{
|
||||
if (!hashtable || !item)
|
||||
return;
|
||||
|
||||
|
||||
/* free key and value */
|
||||
hashtable_free_value (hashtable, item);
|
||||
hashtable_free_key (hashtable, item);
|
||||
|
||||
|
||||
/* remove item from list */
|
||||
if (item->prev_item)
|
||||
(item->prev_item)->next_item = item->next_item;
|
||||
@@ -1049,9 +1049,9 @@ hashtable_remove_item (struct t_hashtable *hashtable,
|
||||
(item->next_item)->prev_item = item->prev_item;
|
||||
if (hashtable->htable[hash] == item)
|
||||
hashtable->htable[hash] = item->next_item;
|
||||
|
||||
|
||||
free (item);
|
||||
|
||||
|
||||
hashtable->items_count--;
|
||||
}
|
||||
|
||||
@@ -1064,10 +1064,10 @@ hashtable_remove (struct t_hashtable *hashtable, const void *key)
|
||||
{
|
||||
struct t_hashtable_item *ptr_item;
|
||||
unsigned int hash;
|
||||
|
||||
|
||||
if (!hashtable || !key)
|
||||
return;
|
||||
|
||||
|
||||
ptr_item = hashtable_get_item (hashtable, key, &hash);
|
||||
if (ptr_item)
|
||||
hashtable_remove_item (hashtable, ptr_item, hash);
|
||||
@@ -1081,10 +1081,10 @@ void
|
||||
hashtable_remove_all (struct t_hashtable *hashtable)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return;
|
||||
|
||||
|
||||
for (i = 0; i < hashtable->size; i++)
|
||||
{
|
||||
while (hashtable->htable[i])
|
||||
@@ -1103,7 +1103,7 @@ hashtable_free (struct t_hashtable *hashtable)
|
||||
{
|
||||
if (!hashtable)
|
||||
return;
|
||||
|
||||
|
||||
hashtable_remove_all (hashtable);
|
||||
free (hashtable->htable);
|
||||
if (hashtable->keys_values)
|
||||
@@ -1120,7 +1120,7 @@ hashtable_print_log (struct t_hashtable *hashtable, const char *name)
|
||||
{
|
||||
struct t_hashtable_item *ptr_item;
|
||||
int i;
|
||||
|
||||
|
||||
log_printf ("");
|
||||
log_printf ("[hashtable %s (addr:0x%lx)]", name, hashtable);
|
||||
log_printf (" size . . . . . . . . . : %d", hashtable->size);
|
||||
@@ -1134,7 +1134,7 @@ hashtable_print_log (struct t_hashtable *hashtable, const char *name)
|
||||
hashtable_type_string[hashtable->type_values]);
|
||||
log_printf (" callback_hash_key. . . : 0x%lx", hashtable->callback_hash_key);
|
||||
log_printf (" callback_keycmp. . . . : 0x%lx", hashtable->callback_keycmp);
|
||||
|
||||
|
||||
for (i = 0; i < hashtable->size; i++)
|
||||
{
|
||||
log_printf (" htable[%06d] . . . . : 0x%lx", i, hashtable->htable[i]);
|
||||
|
||||
@@ -91,16 +91,16 @@ struct t_hashtable
|
||||
struct t_hashtable_item **htable; /* table to map hashes with linked */
|
||||
/* lists */
|
||||
int items_count; /* number of items in hashtable */
|
||||
|
||||
|
||||
/* type for keys and values */
|
||||
enum t_hashtable_type type_keys; /* type for keys: int/str/pointer */
|
||||
enum t_hashtable_type type_values; /* type for values: int/str/pointer */
|
||||
|
||||
|
||||
/* callbacks */
|
||||
t_hashtable_hash_key *callback_hash_key; /* hash key to int value */
|
||||
t_hashtable_keycmp *callback_keycmp; /* compare two keys */
|
||||
t_hashtable_free_value *callback_free_value; /* callback to free value */
|
||||
|
||||
|
||||
/* keys/values as string */
|
||||
char *keys_values; /* keys/values as string (NULL if */
|
||||
/* never asked) */
|
||||
|
||||
+39
-39
@@ -51,10 +51,10 @@ hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name,
|
||||
const char *var_prev, const char *var_next)
|
||||
{
|
||||
struct t_hdata *new_hdata;
|
||||
|
||||
|
||||
if (!hdata_name || !hdata_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
new_hdata = malloc (sizeof (*new_hdata));
|
||||
if (new_hdata)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name,
|
||||
NULL);
|
||||
hashtable_set (weechat_hdata, hdata_name, new_hdata);
|
||||
}
|
||||
|
||||
|
||||
return new_hdata;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ hdata_new_var (struct t_hdata *hdata, const char *name, int offset, int type,
|
||||
const char *hdata_name)
|
||||
{
|
||||
int value;
|
||||
|
||||
|
||||
if (hdata && name)
|
||||
{
|
||||
value = (type << 16) | (offset & 0xFFFF);
|
||||
@@ -120,14 +120,14 @@ int
|
||||
hdata_get_var_offset (struct t_hdata *hdata, const char *name)
|
||||
{
|
||||
int *ptr_value;
|
||||
|
||||
|
||||
if (hdata && name)
|
||||
{
|
||||
ptr_value = hashtable_get (hdata->hash_var, name);
|
||||
if (ptr_value)
|
||||
return (*ptr_value) & 0xFFFF;
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -139,14 +139,14 @@ int
|
||||
hdata_get_var_type (struct t_hdata *hdata, const char *name)
|
||||
{
|
||||
int *ptr_value;
|
||||
|
||||
|
||||
if (hdata && name)
|
||||
{
|
||||
ptr_value = hashtable_get (hdata->hash_var, name);
|
||||
if (ptr_value)
|
||||
return (*ptr_value) >> 16;
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -158,14 +158,14 @@ const char *
|
||||
hdata_get_var_type_string (struct t_hdata *hdata, const char *name)
|
||||
{
|
||||
int *ptr_value;
|
||||
|
||||
|
||||
if (hdata && name)
|
||||
{
|
||||
ptr_value = hashtable_get (hdata->hash_var, name);
|
||||
if (ptr_value)
|
||||
return hdata_type_string[(*ptr_value) >> 16];
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ hdata_get_var_hdata (struct t_hdata *hdata, const char *name)
|
||||
{
|
||||
if (hdata && name)
|
||||
return (const char *)hashtable_get (hdata->hash_var_hdata, name);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -191,14 +191,14 @@ void *
|
||||
hdata_get_var (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
{
|
||||
int offset;
|
||||
|
||||
|
||||
if (hdata && pointer)
|
||||
{
|
||||
offset = hdata_get_var_offset (hdata, name);
|
||||
if (offset >= 0)
|
||||
return pointer + offset;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ hdata_get_var_at_offset (struct t_hdata *hdata, void *pointer, int offset)
|
||||
{
|
||||
if (hdata && pointer)
|
||||
return pointer + offset;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -224,14 +224,14 @@ void *
|
||||
hdata_get_list (struct t_hdata *hdata, const char *name)
|
||||
{
|
||||
void *ptr_value;
|
||||
|
||||
|
||||
if (hdata && name)
|
||||
{
|
||||
ptr_value = hashtable_get (hdata->hash_list, name);
|
||||
if (ptr_value)
|
||||
return *((void **)ptr_value);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -244,12 +244,12 @@ hdata_move (struct t_hdata *hdata, void *pointer, int count)
|
||||
{
|
||||
char *ptr_var;
|
||||
int i, abs_count;
|
||||
|
||||
|
||||
if (hdata && pointer && (count != 0))
|
||||
{
|
||||
ptr_var = (count < 0) ? hdata->var_prev : hdata->var_next;
|
||||
abs_count = abs(count);
|
||||
|
||||
|
||||
for (i = 0; i < abs_count; i++)
|
||||
{
|
||||
pointer = hdata_pointer (hdata, pointer, ptr_var);
|
||||
@@ -257,7 +257,7 @@ hdata_move (struct t_hdata *hdata, void *pointer, int count)
|
||||
return pointer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -269,14 +269,14 @@ int
|
||||
hdata_integer (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
{
|
||||
int offset;
|
||||
|
||||
|
||||
if (hdata && pointer)
|
||||
{
|
||||
offset = hdata_get_var_offset (hdata, name);
|
||||
if (offset >= 0)
|
||||
return *((int *)(pointer + offset));
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -288,14 +288,14 @@ long
|
||||
hdata_long (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
{
|
||||
int offset;
|
||||
|
||||
|
||||
if (hdata && pointer)
|
||||
{
|
||||
offset = hdata_get_var_offset (hdata, name);
|
||||
if (offset >= 0)
|
||||
return *((long *)(pointer + offset));
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -307,14 +307,14 @@ const char *
|
||||
hdata_string (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
{
|
||||
int offset;
|
||||
|
||||
|
||||
if (hdata && pointer)
|
||||
{
|
||||
offset = hdata_get_var_offset (hdata, name);
|
||||
if (offset >= 0)
|
||||
return *((char **)(pointer + offset));
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -326,14 +326,14 @@ void *
|
||||
hdata_pointer (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
{
|
||||
int offset;
|
||||
|
||||
|
||||
if (hdata && pointer)
|
||||
{
|
||||
offset = hdata_get_var_offset (hdata, name);
|
||||
if (offset >= 0)
|
||||
return *((void **)(pointer + offset));
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -345,14 +345,14 @@ time_t
|
||||
hdata_time (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
{
|
||||
int offset;
|
||||
|
||||
|
||||
if (hdata && pointer)
|
||||
{
|
||||
offset = hdata_get_var_offset (hdata, name);
|
||||
if (offset >= 0)
|
||||
return *((time_t *)(pointer + offset));
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ hdata_get_string (struct t_hdata *hdata, const char *property)
|
||||
else if (string_strcasecmp (property, "list_keys_values") == 0)
|
||||
return hashtable_get_string (hdata->hash_list, "keys_values");
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ hdata_free (struct t_hdata *hdata)
|
||||
hashtable_free (hdata->hash_var_hdata);
|
||||
if (hdata->hash_list)
|
||||
hashtable_free (hdata->hash_list);
|
||||
|
||||
|
||||
free (hdata);
|
||||
}
|
||||
|
||||
@@ -422,9 +422,9 @@ hdata_free_all_plugin_map_cb (void *data, struct t_hashtable *hashtable,
|
||||
const void *key, const void *value)
|
||||
{
|
||||
struct t_hdata *ptr_hdata;
|
||||
|
||||
|
||||
ptr_hdata = (struct t_hdata *)value;
|
||||
|
||||
|
||||
if (ptr_hdata->plugin == (struct t_weechat_plugin *)data)
|
||||
{
|
||||
hdata_free (ptr_hdata);
|
||||
@@ -451,12 +451,12 @@ hdata_free_all_map_cb (void *data, struct t_hashtable *hashtable,
|
||||
const void *key, const void *value)
|
||||
{
|
||||
struct t_hdata *ptr_hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_hdata = (struct t_hdata *)value;
|
||||
|
||||
|
||||
hdata_free (ptr_hdata);
|
||||
hashtable_remove (hashtable, key);
|
||||
}
|
||||
@@ -480,13 +480,13 @@ hdata_print_log_map_cb (void *data, struct t_hashtable *hashtable,
|
||||
const void *key, const void *value)
|
||||
{
|
||||
struct t_hdata *ptr_hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
ptr_hdata = (struct t_hdata *)value;
|
||||
|
||||
|
||||
log_printf ("");
|
||||
log_printf ("[hdata (addr:0x%lx, name:'%s')]", ptr_hdata, (const char *)key);
|
||||
log_printf (" plugin . . . . . . . . : 0x%lx", ptr_hdata->plugin);
|
||||
|
||||
+331
-331
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -108,7 +108,7 @@ struct t_hook
|
||||
int running; /* 1 if hook is currently running */
|
||||
int priority; /* priority (to sort hooks) */
|
||||
void *callback_data; /* data sent to callback */
|
||||
|
||||
|
||||
/* hook data (depends on hook type) */
|
||||
void *hook_data; /* hook specific data */
|
||||
struct t_hook *prev_hook; /* link to previous hook */
|
||||
@@ -128,17 +128,17 @@ struct t_hook_command
|
||||
char *args; /* (for /help) command arguments */
|
||||
char *args_description; /* (for /help) args long description*/
|
||||
char *completion; /* template for completion */
|
||||
|
||||
|
||||
/* templates */
|
||||
int cplt_num_templates; /* number of templates for compl. */
|
||||
char **cplt_templates; /* completion templates */
|
||||
char **cplt_templates_static; /* static part of template (at */
|
||||
/* beginning */
|
||||
|
||||
|
||||
/* arguments for each template */
|
||||
int *cplt_template_num_args; /* number of arguments for template */
|
||||
char ***cplt_template_args; /* arguments for each template */
|
||||
|
||||
|
||||
/* concatenation of arg N for each template */
|
||||
int cplt_template_num_args_concat; /* number of concatened arguments */
|
||||
char **cplt_template_args_concat; /* concatened arguments */
|
||||
|
||||
+65
-65
@@ -54,7 +54,7 @@ infolist_new (struct t_weechat_plugin *plugin)
|
||||
new_infolist->items = NULL;
|
||||
new_infolist->last_item = NULL;
|
||||
new_infolist->ptr_item = NULL;
|
||||
|
||||
|
||||
new_infolist->prev_infolist = last_weechat_infolist;
|
||||
new_infolist->next_infolist = NULL;
|
||||
if (weechat_infolists)
|
||||
@@ -63,7 +63,7 @@ infolist_new (struct t_weechat_plugin *plugin)
|
||||
weechat_infolists = new_infolist;
|
||||
last_weechat_infolist = new_infolist;
|
||||
}
|
||||
|
||||
|
||||
return new_infolist;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ infolist_new_item (struct t_infolist *infolist)
|
||||
new_item->vars = NULL;
|
||||
new_item->last_var = NULL;
|
||||
new_item->fields = NULL;
|
||||
|
||||
|
||||
new_item->prev_item = infolist->last_item;
|
||||
new_item->next_item = NULL;
|
||||
if (infolist->items)
|
||||
@@ -91,7 +91,7 @@ infolist_new_item (struct t_infolist *infolist)
|
||||
infolist->items = new_item;
|
||||
infolist->last_item = new_item;
|
||||
}
|
||||
|
||||
|
||||
return new_item;
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ infolist_new_var_integer (struct t_infolist_item *item,
|
||||
const char *name, int value)
|
||||
{
|
||||
struct t_infolist_var *new_var;
|
||||
|
||||
|
||||
if (!item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
@@ -116,7 +116,7 @@ infolist_new_var_integer (struct t_infolist_item *item,
|
||||
new_var->value = malloc (sizeof (int));
|
||||
if (new_var->value)
|
||||
*((int *)new_var->value) = value;
|
||||
|
||||
|
||||
new_var->prev_var = item->last_var;
|
||||
new_var->next_var = NULL;
|
||||
if (item->vars)
|
||||
@@ -125,7 +125,7 @@ infolist_new_var_integer (struct t_infolist_item *item,
|
||||
item->vars = new_var;
|
||||
item->last_var = new_var;
|
||||
}
|
||||
|
||||
|
||||
return new_var;
|
||||
}
|
||||
|
||||
@@ -138,17 +138,17 @@ infolist_new_var_string (struct t_infolist_item *item,
|
||||
const char *name, const char *value)
|
||||
{
|
||||
struct t_infolist_var *new_var;
|
||||
|
||||
|
||||
if (!item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
new_var->name = strdup (name);
|
||||
new_var->type = INFOLIST_STRING;
|
||||
new_var->value = (value) ? strdup (value) : NULL;
|
||||
|
||||
|
||||
new_var->prev_var = item->last_var;
|
||||
new_var->next_var = NULL;
|
||||
if (item->vars)
|
||||
@@ -157,7 +157,7 @@ infolist_new_var_string (struct t_infolist_item *item,
|
||||
item->vars = new_var;
|
||||
item->last_var = new_var;
|
||||
}
|
||||
|
||||
|
||||
return new_var;
|
||||
}
|
||||
|
||||
@@ -170,17 +170,17 @@ infolist_new_var_pointer (struct t_infolist_item *item,
|
||||
const char *name, void *pointer)
|
||||
{
|
||||
struct t_infolist_var *new_var;
|
||||
|
||||
|
||||
if (!item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
new_var->name = strdup (name);
|
||||
new_var->type = INFOLIST_POINTER;
|
||||
new_var->value = pointer;
|
||||
|
||||
|
||||
new_var->prev_var = item->last_var;
|
||||
new_var->next_var = NULL;
|
||||
if (item->vars)
|
||||
@@ -189,7 +189,7 @@ infolist_new_var_pointer (struct t_infolist_item *item,
|
||||
item->vars = new_var;
|
||||
item->last_var = new_var;
|
||||
}
|
||||
|
||||
|
||||
return new_var;
|
||||
}
|
||||
|
||||
@@ -202,10 +202,10 @@ infolist_new_var_buffer (struct t_infolist_item *item,
|
||||
const char *name, void *pointer, int size)
|
||||
{
|
||||
struct t_infolist_var *new_var;
|
||||
|
||||
|
||||
if (!item || !name || !name[0] || (size <= 0))
|
||||
return NULL;
|
||||
|
||||
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ infolist_new_var_buffer (struct t_infolist_item *item,
|
||||
if (new_var->value)
|
||||
memcpy (new_var->value, pointer, size);
|
||||
new_var->size = size;
|
||||
|
||||
|
||||
new_var->prev_var = item->last_var;
|
||||
new_var->next_var = NULL;
|
||||
if (item->vars)
|
||||
@@ -224,7 +224,7 @@ infolist_new_var_buffer (struct t_infolist_item *item,
|
||||
item->vars = new_var;
|
||||
item->last_var = new_var;
|
||||
}
|
||||
|
||||
|
||||
return new_var;
|
||||
}
|
||||
|
||||
@@ -237,10 +237,10 @@ infolist_new_var_time (struct t_infolist_item *item,
|
||||
const char *name, time_t time)
|
||||
{
|
||||
struct t_infolist_var *new_var;
|
||||
|
||||
|
||||
if (!item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
new_var = malloc (sizeof (*new_var));
|
||||
if (new_var)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ infolist_new_var_time (struct t_infolist_item *item,
|
||||
new_var->value = malloc (sizeof (time_t));
|
||||
if (new_var->value)
|
||||
*((time_t *)new_var->value) = time;
|
||||
|
||||
|
||||
new_var->prev_var = item->last_var;
|
||||
new_var->next_var = NULL;
|
||||
if (item->vars)
|
||||
@@ -258,7 +258,7 @@ infolist_new_var_time (struct t_infolist_item *item,
|
||||
item->vars = new_var;
|
||||
item->last_var = new_var;
|
||||
}
|
||||
|
||||
|
||||
return new_var;
|
||||
}
|
||||
|
||||
@@ -272,14 +272,14 @@ int
|
||||
infolist_valid (struct t_infolist *infolist)
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
|
||||
|
||||
for (ptr_infolist = weechat_infolists; ptr_infolist;
|
||||
ptr_infolist = ptr_infolist->next_infolist)
|
||||
{
|
||||
if (ptr_infolist == infolist)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* list not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -339,25 +339,25 @@ infolist_fields (struct t_infolist *infolist)
|
||||
{
|
||||
struct t_infolist_var *ptr_var;
|
||||
int length;
|
||||
|
||||
|
||||
if (!infolist || !infolist->ptr_item)
|
||||
return NULL;
|
||||
|
||||
/* list of fields already asked ? if yes, just return string */
|
||||
if (infolist->ptr_item->fields)
|
||||
return infolist->ptr_item->fields;
|
||||
|
||||
|
||||
length = 0;
|
||||
for (ptr_var = infolist->ptr_item->vars;
|
||||
ptr_var; ptr_var = ptr_var->next_var)
|
||||
{
|
||||
length += strlen (ptr_var->name) + 3;
|
||||
}
|
||||
|
||||
|
||||
infolist->ptr_item->fields = malloc (length + 1);
|
||||
if (!infolist->ptr_item->fields)
|
||||
return NULL;
|
||||
|
||||
|
||||
infolist->ptr_item->fields[0] = '\0';
|
||||
for (ptr_var = infolist->ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
@@ -384,7 +384,7 @@ infolist_fields (struct t_infolist *infolist)
|
||||
if (ptr_var->next_var)
|
||||
strcat (infolist->ptr_item->fields, ",");
|
||||
}
|
||||
|
||||
|
||||
return infolist->ptr_item->fields;
|
||||
}
|
||||
|
||||
@@ -396,10 +396,10 @@ int
|
||||
infolist_integer (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
struct t_infolist_var *ptr_var;
|
||||
|
||||
|
||||
if (!infolist || !infolist->ptr_item || !var || !var[0])
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_var = infolist->ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
{
|
||||
@@ -411,7 +411,7 @@ infolist_integer (struct t_infolist *infolist, const char *var)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* variable not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -424,10 +424,10 @@ const char *
|
||||
infolist_string (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
struct t_infolist_var *ptr_var;
|
||||
|
||||
|
||||
if (!infolist || !infolist->ptr_item || !var || !var[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_var = infolist->ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
{
|
||||
@@ -439,7 +439,7 @@ infolist_string (struct t_infolist *infolist, const char *var)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* variable not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -452,10 +452,10 @@ void *
|
||||
infolist_pointer (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
struct t_infolist_var *ptr_var;
|
||||
|
||||
|
||||
if (!infolist || !infolist->ptr_item || !var || !var[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_var = infolist->ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
{
|
||||
@@ -467,7 +467,7 @@ infolist_pointer (struct t_infolist *infolist, const char *var)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* variable not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -482,10 +482,10 @@ infolist_buffer (struct t_infolist *infolist, const char *var,
|
||||
int *size)
|
||||
{
|
||||
struct t_infolist_var *ptr_var;
|
||||
|
||||
|
||||
if (!infolist || !infolist->ptr_item || !var || !var[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_var = infolist->ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
{
|
||||
@@ -500,7 +500,7 @@ infolist_buffer (struct t_infolist *infolist, const char *var,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* variable not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -513,10 +513,10 @@ time_t
|
||||
infolist_time (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
struct t_infolist_var *ptr_var;
|
||||
|
||||
|
||||
if (!infolist || !infolist->ptr_item || !var || !var[0])
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_var = infolist->ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
{
|
||||
@@ -528,7 +528,7 @@ infolist_time (struct t_infolist *infolist, const char *var)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* variable not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -542,7 +542,7 @@ infolist_var_free (struct t_infolist_item *item,
|
||||
struct t_infolist_var *var)
|
||||
{
|
||||
struct t_infolist_var *new_vars;
|
||||
|
||||
|
||||
/* remove var */
|
||||
if (item->last_var == var)
|
||||
item->last_var = var->prev_var;
|
||||
@@ -553,10 +553,10 @@ infolist_var_free (struct t_infolist_item *item,
|
||||
}
|
||||
else
|
||||
new_vars = var->next_var;
|
||||
|
||||
|
||||
if (var->next_var)
|
||||
(var->next_var)->prev_var = var->prev_var;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (var->name)
|
||||
free (var->name);
|
||||
@@ -568,9 +568,9 @@ infolist_var_free (struct t_infolist_item *item,
|
||||
{
|
||||
free (var->value);
|
||||
}
|
||||
|
||||
|
||||
free (var);
|
||||
|
||||
|
||||
item->vars = new_vars;
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ infolist_item_free (struct t_infolist *infolist,
|
||||
struct t_infolist_item *item)
|
||||
{
|
||||
struct t_infolist_item *new_items;
|
||||
|
||||
|
||||
/* remove var */
|
||||
if (infolist->last_item == item)
|
||||
infolist->last_item = item->prev_item;
|
||||
@@ -594,10 +594,10 @@ infolist_item_free (struct t_infolist *infolist,
|
||||
}
|
||||
else
|
||||
new_items = item->next_item;
|
||||
|
||||
|
||||
if (item->next_item)
|
||||
(item->next_item)->prev_item = item->prev_item;
|
||||
|
||||
|
||||
/* free data */
|
||||
while (item->vars)
|
||||
{
|
||||
@@ -605,9 +605,9 @@ infolist_item_free (struct t_infolist *infolist,
|
||||
}
|
||||
if (item->fields)
|
||||
free (item->fields);
|
||||
|
||||
|
||||
free (item);
|
||||
|
||||
|
||||
infolist->items = new_items;
|
||||
}
|
||||
|
||||
@@ -619,7 +619,7 @@ void
|
||||
infolist_free (struct t_infolist *infolist)
|
||||
{
|
||||
struct t_infolist *new_weechat_infolists;
|
||||
|
||||
|
||||
/* remove list */
|
||||
if (last_weechat_infolist == infolist)
|
||||
last_weechat_infolist = infolist->prev_infolist;
|
||||
@@ -630,18 +630,18 @@ infolist_free (struct t_infolist *infolist)
|
||||
}
|
||||
else
|
||||
new_weechat_infolists = infolist->next_infolist;
|
||||
|
||||
|
||||
if (infolist->next_infolist)
|
||||
(infolist->next_infolist)->prev_infolist = infolist->prev_infolist;
|
||||
|
||||
|
||||
/* free data */
|
||||
while (infolist->items)
|
||||
{
|
||||
infolist_item_free (infolist, infolist->items);
|
||||
}
|
||||
|
||||
|
||||
free (infolist);
|
||||
|
||||
|
||||
weechat_infolists = new_weechat_infolists;
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ void
|
||||
infolist_free_all_plugin (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_infolist *ptr_infolist, *next_infolist;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolists;
|
||||
while (ptr_infolist)
|
||||
{
|
||||
@@ -674,7 +674,7 @@ infolist_print_log ()
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_infolist_item *ptr_item;
|
||||
struct t_infolist_var *ptr_var;
|
||||
|
||||
|
||||
for (ptr_infolist = weechat_infolists; ptr_infolist;
|
||||
ptr_infolist = ptr_infolist->next_infolist)
|
||||
{
|
||||
@@ -686,7 +686,7 @@ infolist_print_log ()
|
||||
log_printf (" ptr_item . . . . . . . : 0x%lx", ptr_infolist->ptr_item);
|
||||
log_printf (" prev_infolist. . . . . : 0x%lx", ptr_infolist->prev_infolist);
|
||||
log_printf (" next_infolist. . . . . : 0x%lx", ptr_infolist->next_infolist);
|
||||
|
||||
|
||||
for (ptr_item = ptr_infolist->items; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
@@ -696,7 +696,7 @@ infolist_print_log ()
|
||||
log_printf (" last_var . . . . . . . : 0x%lx", ptr_item->last_var);
|
||||
log_printf (" prev_item. . . . . . . : 0x%lx", ptr_item->prev_item);
|
||||
log_printf (" next_item. . . . . . . : 0x%lx", ptr_item->next_item);
|
||||
|
||||
|
||||
for (ptr_var = ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
{
|
||||
|
||||
+11
-11
@@ -71,17 +71,17 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
{
|
||||
int rc;
|
||||
char *command, *pos, *ptr_args;
|
||||
|
||||
|
||||
if ((!string) || (!string[0]))
|
||||
return;
|
||||
|
||||
|
||||
command = strdup (string);
|
||||
if (!command)
|
||||
return ;
|
||||
|
||||
|
||||
/* look for end of command */
|
||||
ptr_args = NULL;
|
||||
|
||||
|
||||
pos = &command[strlen (command) - 1];
|
||||
if (pos[0] == ' ')
|
||||
{
|
||||
@@ -89,9 +89,9 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
pos--;
|
||||
pos[1] = '\0';
|
||||
}
|
||||
|
||||
|
||||
rc = hook_command_exec (buffer, any_plugin, plugin, command);
|
||||
|
||||
|
||||
pos = strchr (command, ' ');
|
||||
if (pos)
|
||||
{
|
||||
@@ -103,7 +103,7 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
if (!ptr_args[0])
|
||||
ptr_args = NULL;
|
||||
}
|
||||
|
||||
|
||||
switch (rc)
|
||||
{
|
||||
case 0: /* command hooked, KO */
|
||||
@@ -161,10 +161,10 @@ input_data (struct t_gui_buffer *buffer, const char *data)
|
||||
char *pos, *buf;
|
||||
const char *ptr_data, *ptr_data_for_buffer;
|
||||
int length, char_size;
|
||||
|
||||
|
||||
if (!buffer || !data || !data[0] || (data[0] == '\r') || (data[0] == '\n'))
|
||||
return;
|
||||
|
||||
|
||||
/* use new data (returned by plugin) */
|
||||
ptr_data = data;
|
||||
while (ptr_data && ptr_data[0])
|
||||
@@ -172,7 +172,7 @@ input_data (struct t_gui_buffer *buffer, const char *data)
|
||||
pos = strchr (ptr_data, '\n');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
|
||||
|
||||
ptr_data_for_buffer = string_input_for_buffer (ptr_data);
|
||||
if (ptr_data_for_buffer)
|
||||
{
|
||||
@@ -202,7 +202,7 @@ input_data (struct t_gui_buffer *buffer, const char *data)
|
||||
/* input string is a command */
|
||||
input_exec_command (buffer, 1, buffer->plugin, ptr_data);
|
||||
}
|
||||
|
||||
|
||||
if (pos)
|
||||
{
|
||||
pos[0] = '\n';
|
||||
|
||||
+24
-24
@@ -64,7 +64,7 @@ weelist_find_pos (struct t_weelist *weelist, const char *data)
|
||||
|
||||
if (!weelist || !data)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_item = weelist->items; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
|
||||
|
||||
if (!weelist || !item)
|
||||
return;
|
||||
|
||||
|
||||
if (weelist->items)
|
||||
{
|
||||
/* remove element if already in list */
|
||||
@@ -106,7 +106,7 @@ weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item,
|
||||
pos_item = NULL;
|
||||
else
|
||||
pos_item = weelist_find_pos (weelist, item->data);
|
||||
|
||||
|
||||
if (pos_item)
|
||||
{
|
||||
/* insert data into the list (before position found) */
|
||||
@@ -145,10 +145,10 @@ weelist_add (struct t_weelist *weelist, const char *data, const char *where,
|
||||
void *user_data)
|
||||
{
|
||||
struct t_weelist_item *new_item;
|
||||
|
||||
|
||||
if (!weelist || !data || !data[0] || !where || !where[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
new_item = malloc (sizeof (*new_item));
|
||||
if (new_item)
|
||||
{
|
||||
@@ -171,7 +171,7 @@ weelist_search (struct t_weelist *weelist, const char *data)
|
||||
|
||||
if (!weelist || !data)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_item = weelist->items; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
@@ -192,7 +192,7 @@ weelist_search_pos (struct t_weelist *weelist, const char *data)
|
||||
{
|
||||
struct t_weelist_item *ptr_item;
|
||||
int i;
|
||||
|
||||
|
||||
if (!weelist || !data)
|
||||
return -1;
|
||||
|
||||
@@ -219,7 +219,7 @@ weelist_casesearch (struct t_weelist *weelist, const char *data)
|
||||
|
||||
if (!weelist || !data)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_item = weelist->items; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
@@ -240,10 +240,10 @@ weelist_casesearch_pos (struct t_weelist *weelist, const char *data)
|
||||
{
|
||||
struct t_weelist_item *ptr_item;
|
||||
int i;
|
||||
|
||||
|
||||
if (!weelist || !data)
|
||||
return -1;
|
||||
|
||||
|
||||
for (ptr_item = weelist->items; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
@@ -267,7 +267,7 @@ weelist_get (struct t_weelist *weelist, int position)
|
||||
|
||||
if (!weelist)
|
||||
return NULL;
|
||||
|
||||
|
||||
i = 0;
|
||||
ptr_item = weelist->items;
|
||||
while (ptr_item)
|
||||
@@ -305,7 +305,7 @@ weelist_next (struct t_weelist_item *item)
|
||||
{
|
||||
if (item)
|
||||
return item->next_item;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ weelist_prev (struct t_weelist_item *item)
|
||||
{
|
||||
if (item)
|
||||
return item->prev_item;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ weelist_string (struct t_weelist_item *item)
|
||||
{
|
||||
if (item)
|
||||
return item->data;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ weelist_size (struct t_weelist *weelist)
|
||||
{
|
||||
if (weelist)
|
||||
return weelist->size;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -356,10 +356,10 @@ void
|
||||
weelist_remove (struct t_weelist *weelist, struct t_weelist_item *item)
|
||||
{
|
||||
struct t_weelist_item *new_items;
|
||||
|
||||
|
||||
if (!weelist || !item)
|
||||
return;
|
||||
|
||||
|
||||
/* remove item from list */
|
||||
if (weelist->last_item == item)
|
||||
weelist->last_item = item->prev_item;
|
||||
@@ -370,16 +370,16 @@ weelist_remove (struct t_weelist *weelist, struct t_weelist_item *item)
|
||||
}
|
||||
else
|
||||
new_items = item->next_item;
|
||||
|
||||
|
||||
if (item->next_item)
|
||||
(item->next_item)->prev_item = item->prev_item;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (item->data)
|
||||
free (item->data);
|
||||
free (item);
|
||||
weelist->items = new_items;
|
||||
|
||||
|
||||
weelist->size--;
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ weelist_remove_all (struct t_weelist *weelist)
|
||||
{
|
||||
if (!weelist)
|
||||
return;
|
||||
|
||||
|
||||
while (weelist->items)
|
||||
{
|
||||
weelist_remove (weelist, weelist->items);
|
||||
@@ -408,7 +408,7 @@ weelist_free (struct t_weelist *weelist)
|
||||
{
|
||||
if (!weelist)
|
||||
return;
|
||||
|
||||
|
||||
weelist_remove_all (weelist);
|
||||
free (weelist);
|
||||
}
|
||||
@@ -421,9 +421,9 @@ void
|
||||
weelist_print_log (struct t_weelist *weelist, const char *name)
|
||||
{
|
||||
struct t_weelist_item *ptr_item;
|
||||
|
||||
|
||||
log_printf ("[weelist %s (addr:0x%lx)]", name, weelist);
|
||||
|
||||
|
||||
for (ptr_item = weelist->items; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
|
||||
+9
-9
@@ -74,7 +74,7 @@ log_open (const char *filename, const char *mode)
|
||||
snprintf (weechat_log_filename, filename_length,
|
||||
"%s/%s", weechat_home, WEECHAT_LOG_NAME);
|
||||
}
|
||||
|
||||
|
||||
weechat_log_file = fopen (weechat_log_filename, mode);
|
||||
if (!weechat_log_file)
|
||||
{
|
||||
@@ -129,10 +129,10 @@ log_printf (const char *message, ...)
|
||||
char *ptr_buffer;
|
||||
static time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
|
||||
|
||||
if (!weechat_log_file)
|
||||
return;
|
||||
|
||||
|
||||
weechat_va_format (message);
|
||||
if (vbuffer)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ log_printf (const char *message, ...)
|
||||
ptr_buffer[0] = '.';
|
||||
ptr_buffer++;
|
||||
}
|
||||
|
||||
|
||||
if (!weechat_log_use_time)
|
||||
string_iconv_fprintf (weechat_log_file, "%s\n", vbuffer);
|
||||
else
|
||||
@@ -163,9 +163,9 @@ log_printf (const char *message, ...)
|
||||
else
|
||||
string_iconv_fprintf (weechat_log_file, "%s\n", vbuffer);
|
||||
}
|
||||
|
||||
|
||||
fflush (weechat_log_file);
|
||||
|
||||
|
||||
free (vbuffer);
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ log_printf_hexa (const char *spaces, const char *string)
|
||||
{
|
||||
int msg_pos, hexa_pos, ascii_pos;
|
||||
char hexa[(16 * 3) + 1], ascii[(16 * 2) + 1];
|
||||
|
||||
|
||||
msg_pos = 0;
|
||||
hexa_pos = 0;
|
||||
ascii_pos = 0;
|
||||
@@ -243,13 +243,13 @@ log_crash_rename ()
|
||||
|
||||
if (!weechat_log_filename)
|
||||
return 0;
|
||||
|
||||
|
||||
old_name = strdup (weechat_log_filename);
|
||||
if (!old_name)
|
||||
return 0;
|
||||
|
||||
log_close ();
|
||||
|
||||
|
||||
length = strlen (weechat_home) + 128;
|
||||
new_name = malloc (length);
|
||||
if (new_name)
|
||||
|
||||
+77
-77
@@ -71,7 +71,7 @@ network_set_gnutls_ca_file ()
|
||||
{
|
||||
#ifdef HAVE_GNUTLS
|
||||
char *ca_path, *ca_path2;
|
||||
|
||||
|
||||
ca_path = string_expand_home (CONFIG_STRING(config_network_gnutls_ca_file));
|
||||
if (ca_path)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ network_init ()
|
||||
#ifdef HAVE_GNUTLS
|
||||
gnutls_global_init ();
|
||||
gnutls_certificate_allocate_credentials (&gnutls_xcred);
|
||||
|
||||
|
||||
network_set_gnutls_ca_file ();
|
||||
#if LIBGNUTLS_VERSION_NUMBER >= 0x02090a
|
||||
/* for gnutls >= 2.9.10 */
|
||||
@@ -152,7 +152,7 @@ network_pass_httpproxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
{
|
||||
char buffer[256], authbuf[128], authbuf_base64[512];
|
||||
int n, m;
|
||||
|
||||
|
||||
if (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])
|
||||
&& CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])[0])
|
||||
{
|
||||
@@ -172,20 +172,20 @@ network_pass_httpproxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
n = snprintf (buffer, sizeof (buffer),
|
||||
"CONNECT %s:%d HTTP/1.0\r\n\r\n", address, port);
|
||||
}
|
||||
|
||||
|
||||
m = send (sock, buffer, n, 0);
|
||||
if (n != m)
|
||||
return 0;
|
||||
|
||||
|
||||
n = recv (sock, buffer, sizeof (buffer), 0);
|
||||
|
||||
|
||||
/* success result must be like: "HTTP/1.0 200 OK" */
|
||||
if (n < 12)
|
||||
return 0;
|
||||
|
||||
|
||||
if (memcmp (buffer, "HTTP/", 5) || memcmp (buffer + 9, "200", 3))
|
||||
return 0;
|
||||
|
||||
|
||||
/* connection ok */
|
||||
return 1;
|
||||
}
|
||||
@@ -202,34 +202,34 @@ network_resolve (const char *hostname, char *ip, int *version)
|
||||
{
|
||||
char ipbuffer[NI_MAXHOST];
|
||||
struct addrinfo *res;
|
||||
|
||||
|
||||
if (version != NULL)
|
||||
*version = 0;
|
||||
|
||||
|
||||
res = NULL;
|
||||
|
||||
|
||||
if (getaddrinfo (hostname, NULL, NULL, &res) != 0)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!res)
|
||||
return 0;
|
||||
|
||||
|
||||
if (getnameinfo (res->ai_addr, res->ai_addrlen, ipbuffer, sizeof(ipbuffer),
|
||||
NULL, 0, NI_NUMERICHOST) != 0)
|
||||
{
|
||||
freeaddrinfo (res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ((res->ai_family == AF_INET) && (version != NULL))
|
||||
*version = 4;
|
||||
if ((res->ai_family == AF_INET6) && (version != NULL))
|
||||
*version = 6;
|
||||
|
||||
|
||||
strcpy (ip, ipbuffer);
|
||||
|
||||
|
||||
freeaddrinfo (res);
|
||||
|
||||
|
||||
/* resolution ok */
|
||||
return 1;
|
||||
}
|
||||
@@ -246,11 +246,11 @@ network_pass_socks4proxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
int port)
|
||||
{
|
||||
/* socks4 protocol is explained here: http://en.wikipedia.org/wiki/SOCKS */
|
||||
|
||||
|
||||
struct t_network_socks4 socks4;
|
||||
unsigned char buffer[24];
|
||||
char ip_addr[NI_MAXHOST];
|
||||
|
||||
|
||||
socks4.version = 4;
|
||||
socks4.method = 1;
|
||||
socks4.port = htons (port);
|
||||
@@ -258,14 +258,14 @@ network_pass_socks4proxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
socks4.address = inet_addr (ip_addr);
|
||||
strncpy (socks4.user, CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]),
|
||||
sizeof (socks4.user) - 1);
|
||||
|
||||
|
||||
send (sock, (char *) &socks4, 8 + strlen (socks4.user) + 1, 0);
|
||||
recv (sock, buffer, sizeof (buffer), 0);
|
||||
|
||||
|
||||
/* connection ok */
|
||||
if ((buffer[0] == 0) && (buffer[1] == 90))
|
||||
return 1;
|
||||
|
||||
|
||||
/* connection failed */
|
||||
return 0;
|
||||
}
|
||||
@@ -285,26 +285,26 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
* socks5 protocol is explained in RFC 1928
|
||||
* socks5 authentication with username/pass is explained in RFC 1929
|
||||
*/
|
||||
|
||||
|
||||
struct t_network_socks5 socks5;
|
||||
unsigned char buffer[288];
|
||||
int username_len, password_len, addr_len, addr_buffer_len;
|
||||
unsigned char *addr_buffer;
|
||||
|
||||
|
||||
socks5.version = 5;
|
||||
socks5.nmethods = 1;
|
||||
|
||||
|
||||
if (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])
|
||||
&& CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])[0])
|
||||
socks5.method = 2; /* with authentication */
|
||||
else
|
||||
socks5.method = 0; /* without authentication */
|
||||
|
||||
|
||||
send (sock, (char *) &socks5, sizeof(socks5), 0);
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 0;
|
||||
|
||||
|
||||
if (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])
|
||||
&& CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])[0])
|
||||
{
|
||||
@@ -314,14 +314,14 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
* - socks version (buffer[0]) = 5 => socks5
|
||||
* - socks method (buffer[1]) = 2 => authentication
|
||||
*/
|
||||
|
||||
|
||||
if (buffer[0] != 5 || buffer[1] != 2)
|
||||
return 0;
|
||||
|
||||
|
||||
/* authentication as in RFC 1929 */
|
||||
username_len = strlen (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]));
|
||||
password_len = strlen (CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]));
|
||||
|
||||
|
||||
/* make username/password buffer */
|
||||
buffer[0] = 1;
|
||||
buffer[1] = (unsigned char) username_len;
|
||||
@@ -329,13 +329,13 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
buffer[2 + username_len] = (unsigned char) password_len;
|
||||
memcpy (buffer + 3 + username_len,
|
||||
CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]), password_len);
|
||||
|
||||
|
||||
send (sock, buffer, 3 + username_len + password_len, 0);
|
||||
|
||||
|
||||
/* server socks5 must respond with 2 bytes */
|
||||
if (recv (sock, buffer, 2, 0) != 2)
|
||||
return 0;
|
||||
|
||||
|
||||
/* buffer[1] = auth state, must be 0 for success */
|
||||
if (buffer[1] != 0)
|
||||
return 0;
|
||||
@@ -351,7 +351,7 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
if (!((buffer[0] == 5) && (buffer[1] == 0)))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* authentication successful then giving address/port to connect */
|
||||
addr_len = strlen(address);
|
||||
addr_buffer_len = 4 + 1 + addr_len + 2;
|
||||
@@ -365,17 +365,17 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
addr_buffer[4] = (unsigned char) addr_len;
|
||||
memcpy (addr_buffer + 5, address, addr_len); /* server address */
|
||||
*((unsigned short *) (addr_buffer + 5 + addr_len)) = htons (port); /* server port */
|
||||
|
||||
|
||||
send (sock, addr_buffer, addr_buffer_len, 0);
|
||||
free (addr_buffer);
|
||||
|
||||
|
||||
/* dialog with proxy server */
|
||||
if (recv (sock, buffer, 4, 0) != 4)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!((buffer[0] == 5) && (buffer[1] == 0)))
|
||||
return 0;
|
||||
|
||||
|
||||
/* buffer[3] = address type */
|
||||
switch (buffer[3])
|
||||
{
|
||||
@@ -413,7 +413,7 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address,
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* connection ok */
|
||||
return 1;
|
||||
}
|
||||
@@ -429,9 +429,9 @@ network_pass_proxy (const char *proxy, int sock, const char *address, int port)
|
||||
{
|
||||
int rc;
|
||||
struct t_proxy *ptr_proxy;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
ptr_proxy = proxy_search (proxy);
|
||||
if (ptr_proxy)
|
||||
{
|
||||
@@ -466,7 +466,7 @@ network_connect_to (const char *proxy, int sock,
|
||||
struct hostent *hostent;
|
||||
char *ip4;
|
||||
int ret;
|
||||
|
||||
|
||||
ptr_proxy = NULL;
|
||||
if (proxy && proxy[0])
|
||||
{
|
||||
@@ -474,13 +474,13 @@ network_connect_to (const char *proxy, int sock,
|
||||
if (!ptr_proxy)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (ptr_proxy)
|
||||
{
|
||||
memset (&addr, 0, sizeof (addr));
|
||||
addr.sin_addr.s_addr = htonl (address);
|
||||
ip4 = inet_ntoa(addr.sin_addr);
|
||||
|
||||
|
||||
memset (&addr, 0, sizeof (addr));
|
||||
addr.sin_port = htons (CONFIG_INTEGER(ptr_proxy->options[PROXY_OPTION_PORT]));
|
||||
addr.sin_family = AF_INET;
|
||||
@@ -520,12 +520,12 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
char ipv4_address[INET_ADDRSTRLEN + 1], ipv6_address[INET6_ADDRSTRLEN + 1];
|
||||
char status_ok_without_address[1 + 5 + 1];
|
||||
int rc, length, num_written;
|
||||
|
||||
|
||||
res = NULL;
|
||||
res_local = NULL;
|
||||
|
||||
|
||||
status_str[1] = '\0';
|
||||
|
||||
|
||||
ptr_proxy = NULL;
|
||||
if (HOOK_CONNECT(hook_connect, proxy)
|
||||
&& HOOK_CONNECT(hook_connect, proxy)[0])
|
||||
@@ -541,7 +541,7 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ptr_proxy)
|
||||
{
|
||||
/* get info about peer */
|
||||
@@ -578,12 +578,12 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
freeaddrinfo (res);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(ptr_proxy->options[PROXY_OPTION_IPV6]))
|
||||
((struct sockaddr_in6 *)(res->ai_addr))->sin6_port = htons (CONFIG_INTEGER(ptr_proxy->options[PROXY_OPTION_PORT]));
|
||||
else
|
||||
((struct sockaddr_in *)(res->ai_addr))->sin_port = htons (CONFIG_INTEGER(ptr_proxy->options[PROXY_OPTION_PORT]));
|
||||
|
||||
|
||||
/* connect to peer */
|
||||
if (connect (HOOK_CONNECT(hook_connect, sock),
|
||||
res->ai_addr, res->ai_addrlen) != 0)
|
||||
@@ -596,7 +596,7 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
freeaddrinfo (res);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!network_pass_proxy (HOOK_CONNECT(hook_connect, proxy),
|
||||
HOOK_CONNECT(hook_connect, sock),
|
||||
HOOK_CONNECT(hook_connect, address),
|
||||
@@ -652,7 +652,7 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* get info about peer */
|
||||
memset (&hints, 0, sizeof(hints));
|
||||
hints.ai_family = (HOOK_CONNECT(hook_connect, ipv6)) ? AF_INET6 : AF_INET;
|
||||
@@ -672,9 +672,9 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
freeaddrinfo (res_local);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
status_str[0] = '0' + WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND;
|
||||
|
||||
|
||||
/* try all IP addresses found, stop when connection is ok */
|
||||
for (ptr_res = res; ptr_res; ptr_res = ptr_res->ai_next)
|
||||
{
|
||||
@@ -682,7 +682,7 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
if ((HOOK_CONNECT(hook_connect, ipv6) && (ptr_res->ai_family != AF_INET6))
|
||||
|| ((!HOOK_CONNECT(hook_connect, ipv6) && (ptr_res->ai_family != AF_INET))))
|
||||
continue;
|
||||
|
||||
|
||||
/* connect to peer */
|
||||
if (HOOK_CONNECT(hook_connect, ipv6))
|
||||
((struct sockaddr_in6 *)(ptr_res->ai_addr))->sin6_port =
|
||||
@@ -690,7 +690,7 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
else
|
||||
((struct sockaddr_in *)(ptr_res->ai_addr))->sin_port =
|
||||
htons (HOOK_CONNECT(hook_connect, port));
|
||||
|
||||
|
||||
if (connect (HOOK_CONNECT(hook_connect, sock),
|
||||
ptr_res->ai_addr, ptr_res->ai_addrlen) == 0)
|
||||
{
|
||||
@@ -701,7 +701,7 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
status_str[0] = '0' + WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (status_str[0] == '0' + WEECHAT_HOOK_CONNECT_OK)
|
||||
{
|
||||
status_ok_with_address = NULL;
|
||||
@@ -736,7 +736,7 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
status_str, (int)strlen (ptr_address), ptr_address);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (status_ok_with_address)
|
||||
{
|
||||
num_written = write (HOOK_CONNECT(hook_connect, child_write),
|
||||
@@ -759,7 +759,7 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
status_str, 1);
|
||||
(void) num_written;
|
||||
}
|
||||
|
||||
|
||||
if (res)
|
||||
freeaddrinfo (res);
|
||||
if (res_local)
|
||||
@@ -778,14 +778,14 @@ network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
|
||||
{
|
||||
struct t_hook *hook_connect;
|
||||
int rc, direction, flags;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) fd;
|
||||
|
||||
|
||||
hook_connect = (struct t_hook *)arg_hook_connect;
|
||||
|
||||
|
||||
rc = gnutls_handshake (*HOOK_CONNECT(hook_connect, gnutls_sess));
|
||||
|
||||
|
||||
if ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED))
|
||||
{
|
||||
direction = gnutls_record_get_direction (*HOOK_CONNECT(hook_connect, gnutls_sess));
|
||||
@@ -837,7 +837,7 @@ network_connect_gnutls_handshake_fd_cb (void *arg_hook_connect, int fd)
|
||||
HOOK_CONNECT(hook_connect, handshake_ip_address));
|
||||
unhook (hook_connect);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
#endif
|
||||
@@ -852,14 +852,14 @@ network_connect_gnutls_handshake_timer_cb (void *arg_hook_connect,
|
||||
int remaining_calls)
|
||||
{
|
||||
struct t_hook *hook_connect;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
hook_connect = (struct t_hook *)arg_hook_connect;
|
||||
|
||||
|
||||
HOOK_CONNECT(hook_connect, handshake_hook_timer) = NULL;
|
||||
|
||||
|
||||
(void) (HOOK_CONNECT(hook_connect, callback))
|
||||
(hook_connect->callback_data,
|
||||
WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR,
|
||||
@@ -867,7 +867,7 @@ network_connect_gnutls_handshake_timer_cb (void *arg_hook_connect,
|
||||
gnutls_strerror (GNUTLS_E_EXPIRED),
|
||||
HOOK_CONNECT(hook_connect, handshake_ip_address));
|
||||
unhook (hook_connect);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
#endif
|
||||
@@ -889,11 +889,11 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd)
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) fd;
|
||||
|
||||
|
||||
hook_connect = (struct t_hook *)arg_hook_connect;
|
||||
|
||||
|
||||
ip_address = NULL;
|
||||
|
||||
|
||||
num_read = read (HOOK_CONNECT(hook_connect, child_read),
|
||||
buffer, sizeof (buffer));
|
||||
if (num_read > 0)
|
||||
@@ -1011,10 +1011,10 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd)
|
||||
(hook_connect->callback_data, buffer[0] - '0', 0, NULL, ip_address);
|
||||
unhook (hook_connect);
|
||||
}
|
||||
|
||||
|
||||
if (ip_address)
|
||||
free (ip_address);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1031,7 +1031,7 @@ network_connect_with_fork (struct t_hook *hook_connect)
|
||||
const char *pos_error;
|
||||
#endif
|
||||
pid_t pid;
|
||||
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
/* initialize GnuTLS if SSL asked */
|
||||
if (HOOK_CONNECT(hook_connect, gnutls_sess))
|
||||
@@ -1064,7 +1064,7 @@ network_connect_with_fork (struct t_hook *hook_connect)
|
||||
(gnutls_transport_ptr) ((unsigned long) HOOK_CONNECT(hook_connect, sock)));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* create pipe for child process */
|
||||
if (pipe (child_pipe) < 0)
|
||||
{
|
||||
@@ -1077,7 +1077,7 @@ network_connect_with_fork (struct t_hook *hook_connect)
|
||||
}
|
||||
HOOK_CONNECT(hook_connect, child_read) = child_pipe[0];
|
||||
HOOK_CONNECT(hook_connect, child_write) = child_pipe[1];
|
||||
|
||||
|
||||
switch (pid = fork ())
|
||||
{
|
||||
/* fork failed */
|
||||
|
||||
+44
-44
@@ -59,16 +59,16 @@ int
|
||||
proxy_search_option (const char *option_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!option_name)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < PROXY_NUM_OPTIONS; i++)
|
||||
{
|
||||
if (string_strcasecmp (proxy_option_string[i], option_name) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* proxy option not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -82,16 +82,16 @@ int
|
||||
proxy_search_type (const char *type)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!type)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < PROXY_NUM_TYPES; i++)
|
||||
{
|
||||
if (string_strcasecmp (proxy_type_string[i], type) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* type not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -104,17 +104,17 @@ struct t_proxy *
|
||||
proxy_search (const char *name)
|
||||
{
|
||||
struct t_proxy *ptr_proxy;
|
||||
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_proxy = weechat_proxies; ptr_proxy;
|
||||
ptr_proxy = ptr_proxy->next_proxy)
|
||||
{
|
||||
if (strcmp (ptr_proxy->name, name) == 0)
|
||||
return ptr_proxy;
|
||||
}
|
||||
|
||||
|
||||
/* proxy not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -129,9 +129,9 @@ proxy_search_with_option_name (const char *option_name)
|
||||
{
|
||||
char *proxy_name, *pos_option;
|
||||
struct t_proxy *ptr_proxy;
|
||||
|
||||
|
||||
ptr_proxy = NULL;
|
||||
|
||||
|
||||
pos_option = strchr (option_name, '.');
|
||||
if (pos_option)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ proxy_search_with_option_name (const char *option_name)
|
||||
free (proxy_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ptr_proxy;
|
||||
}
|
||||
|
||||
@@ -160,10 +160,10 @@ proxy_set_name (struct t_proxy *proxy, const char *name)
|
||||
{
|
||||
int length;
|
||||
char *option_name;
|
||||
|
||||
|
||||
if (!name || !name[0])
|
||||
return;
|
||||
|
||||
|
||||
length = strlen (name) + 64;
|
||||
option_name = malloc (length);
|
||||
if (option_name)
|
||||
@@ -180,11 +180,11 @@ proxy_set_name (struct t_proxy *proxy, const char *name)
|
||||
config_file_option_rename (proxy->options[PROXY_OPTION_USERNAME], option_name);
|
||||
snprintf (option_name, length, "%s.password", name);
|
||||
config_file_option_rename (proxy->options[PROXY_OPTION_PASSWORD], option_name);
|
||||
|
||||
|
||||
if (proxy->name)
|
||||
free (proxy->name);
|
||||
proxy->name = strdup (name);
|
||||
|
||||
|
||||
free (option_name);
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ proxy_set (struct t_proxy *proxy, const char *property, const char *value)
|
||||
{
|
||||
if (!proxy || !property || !value)
|
||||
return 0;
|
||||
|
||||
|
||||
if (string_strcasecmp (property, "name") == 0)
|
||||
{
|
||||
proxy_set_name (proxy, value);
|
||||
@@ -235,7 +235,7 @@ proxy_set (struct t_proxy *proxy, const char *property, const char *value)
|
||||
config_file_option_set (proxy->options[PROXY_OPTION_PASSWORD], value, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -250,9 +250,9 @@ proxy_create_option (const char *proxy_name, int index_option,
|
||||
struct t_config_option *ptr_option;
|
||||
int length;
|
||||
char *option_name;
|
||||
|
||||
|
||||
ptr_option = NULL;
|
||||
|
||||
|
||||
length = strlen (proxy_name) + 1 +
|
||||
strlen (proxy_option_string[index_option]) + 1;
|
||||
option_name = malloc (length);
|
||||
@@ -260,7 +260,7 @@ proxy_create_option (const char *proxy_name, int index_option,
|
||||
{
|
||||
snprintf (option_name, length, "%s.%s",
|
||||
proxy_name, proxy_option_string[index_option]);
|
||||
|
||||
|
||||
switch (index_option)
|
||||
{
|
||||
case PROXY_OPTION_TYPE:
|
||||
@@ -316,7 +316,7 @@ proxy_create_option (const char *proxy_name, int index_option,
|
||||
}
|
||||
free (option_name);
|
||||
}
|
||||
|
||||
|
||||
return ptr_option;
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ proxy_create_option_temp (struct t_proxy *temp_proxy, int index_option,
|
||||
const char *value)
|
||||
{
|
||||
struct t_config_option *new_option;
|
||||
|
||||
|
||||
new_option = proxy_create_option (temp_proxy->name,
|
||||
index_option,
|
||||
value);
|
||||
@@ -347,7 +347,7 @@ proxy_alloc (const char *name)
|
||||
{
|
||||
struct t_proxy *new_proxy;
|
||||
int i;
|
||||
|
||||
|
||||
new_proxy = malloc (sizeof (*new_proxy));
|
||||
if (new_proxy)
|
||||
{
|
||||
@@ -359,7 +359,7 @@ proxy_alloc (const char *name)
|
||||
new_proxy->prev_proxy = NULL;
|
||||
new_proxy->next_proxy = NULL;
|
||||
}
|
||||
|
||||
|
||||
return new_proxy;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ proxy_new_with_options (const char *name,
|
||||
struct t_config_option *password)
|
||||
{
|
||||
struct t_proxy *new_proxy;
|
||||
|
||||
|
||||
/* create proxy */
|
||||
new_proxy = proxy_alloc (name);
|
||||
if (new_proxy)
|
||||
@@ -388,7 +388,7 @@ proxy_new_with_options (const char *name,
|
||||
new_proxy->options[PROXY_OPTION_PORT] = port;
|
||||
new_proxy->options[PROXY_OPTION_USERNAME] = username;
|
||||
new_proxy->options[PROXY_OPTION_PASSWORD] = password;
|
||||
|
||||
|
||||
/* add proxy to proxies list */
|
||||
new_proxy->prev_proxy = last_weechat_proxy;
|
||||
if (weechat_proxies)
|
||||
@@ -398,7 +398,7 @@ proxy_new_with_options (const char *name,
|
||||
last_weechat_proxy = new_proxy;
|
||||
new_proxy->next_proxy = NULL;
|
||||
}
|
||||
|
||||
|
||||
return new_proxy;
|
||||
}
|
||||
|
||||
@@ -414,18 +414,18 @@ proxy_new (const char *name, const char *type, const char *ipv6,
|
||||
struct t_config_option *option_type, *option_ipv6, *option_address;
|
||||
struct t_config_option *option_port, *option_username, *option_password;
|
||||
struct t_proxy *new_proxy;
|
||||
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
/* it's not possible to create 2 proxies with same name */
|
||||
if (proxy_search (name))
|
||||
return NULL;
|
||||
|
||||
|
||||
/* look for type */
|
||||
if (proxy_search_type (type) < 0)
|
||||
return NULL;
|
||||
|
||||
|
||||
option_type = proxy_create_option (name, PROXY_OPTION_TYPE,
|
||||
type);
|
||||
option_ipv6 = proxy_create_option (name, PROXY_OPTION_IPV6,
|
||||
@@ -438,7 +438,7 @@ proxy_new (const char *name, const char *type, const char *ipv6,
|
||||
(username) ? username : "");
|
||||
option_password = proxy_create_option (name, PROXY_OPTION_PASSWORD,
|
||||
(password) ? password : "");
|
||||
|
||||
|
||||
new_proxy = proxy_new_with_options (name, option_type, option_ipv6,
|
||||
option_address, option_port,
|
||||
option_username, option_password);
|
||||
@@ -457,7 +457,7 @@ proxy_new (const char *name, const char *type, const char *ipv6,
|
||||
if (option_password)
|
||||
config_file_option_free (option_password);
|
||||
}
|
||||
|
||||
|
||||
return new_proxy;
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ proxy_use_temp_proxies ()
|
||||
{
|
||||
struct t_proxy *ptr_temp_proxy, *next_temp_proxy;
|
||||
int i, num_options_ok;
|
||||
|
||||
|
||||
for (ptr_temp_proxy = weechat_temp_proxies; ptr_temp_proxy;
|
||||
ptr_temp_proxy = ptr_temp_proxy->next_proxy)
|
||||
{
|
||||
@@ -486,7 +486,7 @@ proxy_use_temp_proxies ()
|
||||
if (ptr_temp_proxy->options[i])
|
||||
num_options_ok++;
|
||||
}
|
||||
|
||||
|
||||
if (num_options_ok == PROXY_NUM_OPTIONS)
|
||||
{
|
||||
proxy_new_with_options (ptr_temp_proxy->name,
|
||||
@@ -509,16 +509,16 @@ proxy_use_temp_proxies ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* free all temp proxies */
|
||||
while (weechat_temp_proxies)
|
||||
{
|
||||
next_temp_proxy = weechat_temp_proxies->next_proxy;
|
||||
|
||||
|
||||
if (weechat_temp_proxies->name)
|
||||
free (weechat_temp_proxies->name);
|
||||
free (weechat_temp_proxies);
|
||||
|
||||
|
||||
weechat_temp_proxies = next_temp_proxy;
|
||||
}
|
||||
last_weechat_temp_proxy = NULL;
|
||||
@@ -532,10 +532,10 @@ void
|
||||
proxy_free (struct t_proxy *proxy)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!proxy)
|
||||
return;
|
||||
|
||||
|
||||
/* remove proxy from proxies list */
|
||||
if (proxy->prev_proxy)
|
||||
(proxy->prev_proxy)->next_proxy = proxy->next_proxy;
|
||||
@@ -545,7 +545,7 @@ proxy_free (struct t_proxy *proxy)
|
||||
weechat_proxies = proxy->next_proxy;
|
||||
if (last_weechat_proxy == proxy)
|
||||
last_weechat_proxy = proxy->prev_proxy;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (proxy->name)
|
||||
free (proxy->name);
|
||||
@@ -553,7 +553,7 @@ proxy_free (struct t_proxy *proxy)
|
||||
{
|
||||
config_file_option_free (proxy->options[i]);
|
||||
}
|
||||
|
||||
|
||||
free (proxy);
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ void
|
||||
proxy_print_log ()
|
||||
{
|
||||
struct t_proxy *ptr_proxy;
|
||||
|
||||
|
||||
for (ptr_proxy = weechat_proxies; ptr_proxy;
|
||||
ptr_proxy = ptr_proxy->next_proxy)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ struct t_proxy
|
||||
{
|
||||
char *name; /* proxy name */
|
||||
struct t_config_option *options[PROXY_NUM_OPTIONS];
|
||||
|
||||
|
||||
struct t_proxy *prev_proxy; /* link to previous bar */
|
||||
struct t_proxy *next_proxy; /* link to next bar */
|
||||
};
|
||||
|
||||
+153
-153
@@ -69,17 +69,17 @@ char *
|
||||
string_strndup (const char *string, int length)
|
||||
{
|
||||
char *result;
|
||||
|
||||
|
||||
if ((int)strlen (string) < length)
|
||||
return strdup (string);
|
||||
|
||||
|
||||
result = malloc (length + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
||||
memcpy (result, string, length);
|
||||
result[length] = '\0';
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -121,10 +121,10 @@ int
|
||||
string_strcasecmp (const char *string1, const char *string2)
|
||||
{
|
||||
int diff;
|
||||
|
||||
|
||||
if (!string1 || !string2)
|
||||
return (string1) ? 1 : ((string2) ? -1 : 0);
|
||||
|
||||
|
||||
while (string1[0] && string2[0])
|
||||
{
|
||||
diff = utf8_charcasecmp (string1, string2);
|
||||
@@ -134,7 +134,7 @@ string_strcasecmp (const char *string1, const char *string2)
|
||||
string1 = utf8_next_char (string1);
|
||||
string2 = utf8_next_char (string2);
|
||||
}
|
||||
|
||||
|
||||
return (string1[0]) ? 1 : ((string2[0]) ? -1 : 0);
|
||||
}
|
||||
|
||||
@@ -147,22 +147,22 @@ int
|
||||
string_strncasecmp (const char *string1, const char *string2, int max)
|
||||
{
|
||||
int count, diff;
|
||||
|
||||
|
||||
if (!string1 || !string2)
|
||||
return (string1) ? 1 : ((string2) ? -1 : 0);
|
||||
|
||||
|
||||
count = 0;
|
||||
while ((count < max) && string1[0] && string2[0])
|
||||
{
|
||||
diff = utf8_charcasecmp (string1, string2);
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
|
||||
|
||||
string1 = utf8_next_char (string1);
|
||||
string2 = utf8_next_char (string2);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
if (count >= max)
|
||||
return 0;
|
||||
else
|
||||
@@ -178,14 +178,14 @@ string_strcmp_ignore_chars (const char *string1, const char *string2,
|
||||
const char *chars_ignored, int case_sensitive)
|
||||
{
|
||||
int diff;
|
||||
|
||||
|
||||
if (!string1 && !string2)
|
||||
return 0;
|
||||
if (!string1 && string2)
|
||||
return -1;
|
||||
if (string1 && !string2)
|
||||
return 1;
|
||||
|
||||
|
||||
while (string1 && string1[0] && string2 && string2[0])
|
||||
{
|
||||
/* skip ignored chars */
|
||||
@@ -205,16 +205,16 @@ string_strcmp_ignore_chars (const char *string1, const char *string2,
|
||||
return -1;
|
||||
if (string1 && string1[0] && (!string2 || !string2[0]))
|
||||
return 1;
|
||||
|
||||
|
||||
/* look at diff */
|
||||
diff = (case_sensitive) ?
|
||||
(int)string1[0] - (int)string2[0] : utf8_charcasecmp (string1, string2);
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
|
||||
|
||||
string1 = utf8_next_char (string1);
|
||||
string2 = utf8_next_char (string2);
|
||||
|
||||
|
||||
/* skip ignored chars */
|
||||
while (string1 && string1[0] && strchr (chars_ignored, string1[0]))
|
||||
{
|
||||
@@ -240,20 +240,20 @@ char *
|
||||
string_strcasestr (const char *string, const char *search)
|
||||
{
|
||||
int length_search;
|
||||
|
||||
|
||||
length_search = utf8_strlen (search);
|
||||
|
||||
|
||||
if (!string || !search || (length_search == 0))
|
||||
return NULL;
|
||||
|
||||
|
||||
while (string[0])
|
||||
{
|
||||
if (string_strncasecmp (string, search, length_search) == 0)
|
||||
return (char *)string;
|
||||
|
||||
|
||||
string = utf8_next_char (string);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -268,19 +268,19 @@ string_match (const char *string, const char *mask, int case_sensitive)
|
||||
{
|
||||
char last, *mask2;
|
||||
int len_string, len_mask, rc;
|
||||
|
||||
|
||||
if (!mask || !mask[0])
|
||||
return 0;
|
||||
|
||||
|
||||
/* if mask is "*", then any string matches */
|
||||
if (strcmp (mask, "*") == 0)
|
||||
return 1;
|
||||
|
||||
|
||||
len_string = strlen (string);
|
||||
len_mask = strlen (mask);
|
||||
|
||||
|
||||
last = mask[len_mask - 1];
|
||||
|
||||
|
||||
/* mask begins with "*" */
|
||||
if ((mask[0] == '*') && (last != '*'))
|
||||
{
|
||||
@@ -296,7 +296,7 @@ string_match (const char *string, const char *mask, int case_sensitive)
|
||||
/* no match */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* mask ends with "*" */
|
||||
if ((mask[0] != '*') && (last == '*'))
|
||||
{
|
||||
@@ -312,7 +312,7 @@ string_match (const char *string, const char *mask, int case_sensitive)
|
||||
/* no match */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* mask begins and ends with "*" */
|
||||
if ((mask[0] == '*') && (last == '*'))
|
||||
{
|
||||
@@ -331,12 +331,12 @@ string_match (const char *string, const char *mask, int case_sensitive)
|
||||
free (mask2);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* no "*" at all, compare strings */
|
||||
if ((case_sensitive && (strcmp (string, mask) == 0))
|
||||
|| (!case_sensitive && (string_strcasecmp (string, mask) == 0)))
|
||||
return 1;
|
||||
|
||||
|
||||
/* no match */
|
||||
return 0;
|
||||
}
|
||||
@@ -352,13 +352,13 @@ string_replace (const char *string, const char *search, const char *replace)
|
||||
const char *pos;
|
||||
char *new_string;
|
||||
int length1, length2, length_new, count;
|
||||
|
||||
|
||||
if (!string || !search || !replace)
|
||||
return NULL;
|
||||
|
||||
|
||||
length1 = strlen (search);
|
||||
length2 = strlen (replace);
|
||||
|
||||
|
||||
/* count number of strings to replace */
|
||||
count = 0;
|
||||
pos = string;
|
||||
@@ -367,19 +367,19 @@ string_replace (const char *string, const char *search, const char *replace)
|
||||
count++;
|
||||
pos += length1;
|
||||
}
|
||||
|
||||
|
||||
/* easy: no string to replace! */
|
||||
if (count == 0)
|
||||
return strdup (string);
|
||||
|
||||
|
||||
/* compute needed memory for new string */
|
||||
length_new = strlen (string) - (count * length1) + (count * length2) + 1;
|
||||
|
||||
|
||||
/* allocate new string */
|
||||
new_string = malloc (length_new);
|
||||
if (!new_string)
|
||||
return strdup (string);
|
||||
|
||||
|
||||
/* replace all occurrences */
|
||||
new_string[0] = '\0';
|
||||
while (string && string[0])
|
||||
@@ -409,22 +409,22 @@ string_expand_home (const char *path)
|
||||
{
|
||||
char *ptr_home, *str;
|
||||
int length;
|
||||
|
||||
|
||||
if (!path)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!path[0] || (path[0] != '~') || (path[1] != DIR_SEPARATOR_CHAR))
|
||||
return strdup (path);
|
||||
|
||||
|
||||
ptr_home = getenv ("HOME");
|
||||
|
||||
|
||||
length = strlen (ptr_home) + strlen (path + 1) + 1;
|
||||
str = malloc (length);
|
||||
if (!str)
|
||||
return strdup (path);
|
||||
|
||||
|
||||
snprintf (str, length, "%s%s", ptr_home, path + 1);
|
||||
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ string_remove_quotes (const char *string, const char *quotes)
|
||||
{
|
||||
int length;
|
||||
const char *pos_start, *pos_end;
|
||||
|
||||
|
||||
if (!string || !quotes)
|
||||
return NULL;
|
||||
|
||||
@@ -460,14 +460,14 @@ string_remove_quotes (const char *string, const char *quotes)
|
||||
}
|
||||
if (!pos_start[0] || !pos_end[0] || (pos_end <= pos_start))
|
||||
return strdup (string);
|
||||
|
||||
|
||||
if (strchr (quotes, pos_start[0]) && (pos_end[0] == pos_start[0]))
|
||||
{
|
||||
if (pos_end == (pos_start + 1))
|
||||
return strdup ("");
|
||||
return string_strndup (pos_start + 1, pos_end - pos_start - 1);
|
||||
}
|
||||
|
||||
|
||||
return strdup (string);
|
||||
}
|
||||
|
||||
@@ -480,16 +480,16 @@ char *
|
||||
string_strip (const char *string, int left, int right, const char *chars)
|
||||
{
|
||||
const char *ptr_start, *ptr_end;
|
||||
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!string[0])
|
||||
return strdup (string);
|
||||
|
||||
|
||||
ptr_start = string;
|
||||
ptr_end = string + strlen (string) - 1;
|
||||
|
||||
|
||||
if (left)
|
||||
{
|
||||
while (ptr_start[0] && strchr (chars, ptr_start[0]))
|
||||
@@ -499,7 +499,7 @@ string_strip (const char *string, int left, int right, const char *chars)
|
||||
if (!ptr_start[0])
|
||||
return strdup (ptr_start);
|
||||
}
|
||||
|
||||
|
||||
if (right)
|
||||
{
|
||||
while ((ptr_end >= ptr_start) && strchr (chars, ptr_end[0]))
|
||||
@@ -509,7 +509,7 @@ string_strip (const char *string, int left, int right, const char *chars)
|
||||
if (ptr_end < ptr_start)
|
||||
return strdup ("");
|
||||
}
|
||||
|
||||
|
||||
return string_strndup (ptr_start, ptr_end - ptr_start + 1);
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ string_convert_hex_chars (const char *string)
|
||||
}
|
||||
output[pos_output] = '\0';
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -593,13 +593,13 @@ int
|
||||
string_is_word_char (const char *string)
|
||||
{
|
||||
wint_t c = utf8_wide_char (string);
|
||||
|
||||
|
||||
if (c == WEOF)
|
||||
return 0;
|
||||
|
||||
|
||||
if (iswalnum (c))
|
||||
return 1;
|
||||
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '-':
|
||||
@@ -607,7 +607,7 @@ string_is_word_char (const char *string)
|
||||
case '|':
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* not a 'word char' */
|
||||
return 0;
|
||||
}
|
||||
@@ -623,10 +623,10 @@ string_has_highlight (const char *string, const char *highlight_words)
|
||||
{
|
||||
char *msg, *highlight, *match, *match_pre, *match_post, *msg_pos, *pos, *pos_end;
|
||||
int end, length, startswith, endswith, wildcard_start, wildcard_end;
|
||||
|
||||
|
||||
if (!string || !string[0] || !highlight_words || !highlight_words[0])
|
||||
return 0;
|
||||
|
||||
|
||||
/* convert both strings to lower case */
|
||||
msg = strdup (string);
|
||||
if (!msg)
|
||||
@@ -639,7 +639,7 @@ string_has_highlight (const char *string, const char *highlight_words)
|
||||
return 0;
|
||||
}
|
||||
string_tolower (highlight);
|
||||
|
||||
|
||||
pos = highlight;
|
||||
end = 0;
|
||||
while (!end)
|
||||
@@ -657,7 +657,7 @@ string_has_highlight (const char *string, const char *highlight_words)
|
||||
free (highlight);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
length = pos_end - pos;
|
||||
pos_end[0] = '\0';
|
||||
if (length > 0)
|
||||
@@ -673,7 +673,7 @@ string_has_highlight (const char *string, const char *highlight_words)
|
||||
length--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
msg_pos = msg;
|
||||
@@ -699,14 +699,14 @@ string_has_highlight (const char *string, const char *highlight_words)
|
||||
msg_pos = match_post;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!end)
|
||||
pos = pos_end + 1;
|
||||
}
|
||||
|
||||
|
||||
free (msg);
|
||||
free (highlight);
|
||||
|
||||
|
||||
/* no highlight found */
|
||||
return 0;
|
||||
}
|
||||
@@ -724,16 +724,16 @@ string_has_highlight_regex_compiled (const char *string, regex_t *regex)
|
||||
int rc, startswith, endswith;
|
||||
regmatch_t regex_match;
|
||||
const char *match_pre;
|
||||
|
||||
|
||||
if (!string || !regex)
|
||||
return 0;
|
||||
|
||||
|
||||
while (string && string[0])
|
||||
{
|
||||
rc = regexec (regex, string, 1, ®ex_match, 0);
|
||||
if ((rc != 0) || (regex_match.rm_so < 0) || (regex_match.rm_eo < 0))
|
||||
break;
|
||||
|
||||
|
||||
startswith = (regex_match.rm_so == 0);
|
||||
if (!startswith)
|
||||
{
|
||||
@@ -748,10 +748,10 @@ string_has_highlight_regex_compiled (const char *string, regex_t *regex)
|
||||
}
|
||||
if (startswith && endswith)
|
||||
return 1;
|
||||
|
||||
|
||||
string += regex_match.rm_eo;
|
||||
}
|
||||
|
||||
|
||||
/* no highlight found */
|
||||
return 0;
|
||||
}
|
||||
@@ -767,17 +767,17 @@ string_has_highlight_regex (const char *string, const char *regex)
|
||||
{
|
||||
regex_t reg;
|
||||
int rc;
|
||||
|
||||
|
||||
if (!string || !regex || !regex[0])
|
||||
return 0;
|
||||
|
||||
|
||||
if (regcomp (®, regex, REG_EXTENDED) != 0)
|
||||
return 0;
|
||||
|
||||
|
||||
rc = string_has_highlight_regex_compiled (string, ®);
|
||||
|
||||
|
||||
regfree (®);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -793,14 +793,14 @@ string_mask_to_regex (const char *mask)
|
||||
const char *ptr_mask;
|
||||
int index_result;
|
||||
char *regex_special_char = ".[]{}()?+";
|
||||
|
||||
|
||||
if (!mask)
|
||||
return NULL;
|
||||
|
||||
|
||||
result = malloc ((strlen (mask) * 2) + 1);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
||||
result[0] = '\0';
|
||||
index_result = 0;
|
||||
ptr_mask = mask;
|
||||
@@ -821,13 +821,13 @@ string_mask_to_regex (const char *mask)
|
||||
/* standard char, just copy it */
|
||||
else
|
||||
result[index_result++] = ptr_mask[0];
|
||||
|
||||
|
||||
ptr_mask++;
|
||||
}
|
||||
|
||||
|
||||
/* add final '\0' */
|
||||
result[index_result] = '\0';
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -853,17 +853,17 @@ string_split (const char *string, const char *separators, int keep_eol,
|
||||
int i, j, n_items;
|
||||
char *string2, **array;
|
||||
char *ptr, *ptr1, *ptr2;
|
||||
|
||||
|
||||
if (num_items != NULL)
|
||||
*num_items = 0;
|
||||
|
||||
|
||||
if (!string || !string[0] || !separators || !separators[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
string2 = string_strip (string, 1, (keep_eol == 2) ? 0 : 1, separators);
|
||||
if (!string2 || !string2[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
/* calculate number of items */
|
||||
ptr = string2;
|
||||
i = 1;
|
||||
@@ -876,16 +876,16 @@ string_split (const char *string, const char *separators, int keep_eol,
|
||||
i++;
|
||||
}
|
||||
n_items = i;
|
||||
|
||||
|
||||
if ((num_items_max != 0) && (n_items > num_items_max))
|
||||
n_items = num_items_max;
|
||||
|
||||
|
||||
array = malloc ((n_items + 1) * sizeof (array[0]));
|
||||
if (!array)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr1 = string2;
|
||||
|
||||
|
||||
for (i = 0; i < n_items; i++)
|
||||
{
|
||||
while (ptr1[0] && (strchr (separators, ptr1[0]) != NULL))
|
||||
@@ -911,7 +911,7 @@ string_split (const char *string, const char *separators, int keep_eol,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((ptr1 == NULL) || (ptr2 == NULL))
|
||||
{
|
||||
array[i] = NULL;
|
||||
@@ -960,13 +960,13 @@ string_split (const char *string, const char *separators, int keep_eol,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
array[i] = NULL;
|
||||
if (num_items != NULL)
|
||||
*num_items = i;
|
||||
|
||||
|
||||
free (string2);
|
||||
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -978,7 +978,7 @@ void
|
||||
string_free_split (char **split_string)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (split_string)
|
||||
{
|
||||
for (i = 0; split_string[i]; i++)
|
||||
@@ -999,23 +999,23 @@ string_build_with_split_string (const char **split_string,
|
||||
{
|
||||
int i, length, length_separator;
|
||||
char *result;
|
||||
|
||||
|
||||
if (!split_string)
|
||||
return NULL;
|
||||
|
||||
|
||||
length = 0;
|
||||
length_separator = (separator) ? strlen (separator) : 0;
|
||||
|
||||
|
||||
for (i = 0; split_string[i]; i++)
|
||||
{
|
||||
length += strlen (split_string[i]) + length_separator;
|
||||
}
|
||||
|
||||
|
||||
result = malloc (length + 1);
|
||||
if (result)
|
||||
{
|
||||
result[0] = '\0';
|
||||
|
||||
|
||||
for (i = 0; split_string[i]; i++)
|
||||
{
|
||||
strcat (result, split_string[i]);
|
||||
@@ -1023,7 +1023,7 @@ string_build_with_split_string (const char **split_string,
|
||||
strcat (result, separator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1045,7 +1045,7 @@ string_split_command (const char *command, char separator)
|
||||
|
||||
if (!command || !command[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
nb_substr = 1;
|
||||
ptr = command;
|
||||
while ( (p = strchr(ptr, separator)) != NULL)
|
||||
@@ -1057,14 +1057,14 @@ string_split_command (const char *command, char separator)
|
||||
array = malloc ((nb_substr + 1) * sizeof (array[0]));
|
||||
if (!array)
|
||||
return NULL;
|
||||
|
||||
|
||||
buffer = malloc (strlen(command) + 1);
|
||||
if (!buffer)
|
||||
{
|
||||
free (array);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ptr = command;
|
||||
str_idx = 0;
|
||||
arr_idx = 0;
|
||||
@@ -1097,17 +1097,17 @@ string_split_command (const char *command, char separator)
|
||||
str_idx++;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
|
||||
buffer[str_idx] = '\0';
|
||||
p = buffer;
|
||||
while (*p == ' ') p++;
|
||||
if (p && p[0])
|
||||
array[arr_idx++] = strdup (p);
|
||||
|
||||
|
||||
array[arr_idx] = NULL;
|
||||
|
||||
|
||||
free (buffer);
|
||||
|
||||
|
||||
array2 = realloc (array, (arr_idx + 1) * sizeof(array[0]));
|
||||
if (!array2)
|
||||
{
|
||||
@@ -1115,7 +1115,7 @@ string_split_command (const char *command, char separator)
|
||||
free (array);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return array2;
|
||||
}
|
||||
|
||||
@@ -1147,14 +1147,14 @@ string_iconv (int from_utf8, const char *from_code, const char *to_code,
|
||||
const char *string)
|
||||
{
|
||||
char *outbuf;
|
||||
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
iconv_t cd;
|
||||
char *inbuf, *ptr_inbuf, *ptr_outbuf, *next_char;
|
||||
char *ptr_inbuf_shift;
|
||||
int done;
|
||||
size_t err, inbytesleft, outbytesleft;
|
||||
|
||||
|
||||
if (from_code && from_code[0] && to_code && to_code[0]
|
||||
&& (string_strcasecmp(from_code, to_code) != 0))
|
||||
{
|
||||
@@ -1243,7 +1243,7 @@ string_iconv (int from_utf8, const char *from_code, const char *to_code,
|
||||
(void) to_code;
|
||||
outbuf = strdup (string);
|
||||
#endif /* HAVE_ICONV */
|
||||
|
||||
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
@@ -1257,24 +1257,24 @@ char *
|
||||
string_iconv_to_internal (const char *charset, const char *string)
|
||||
{
|
||||
char *input, *output;
|
||||
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
|
||||
input = strdup (string);
|
||||
if (!input)
|
||||
return NULL;
|
||||
|
||||
|
||||
/*
|
||||
* optimized for UTF-8: if charset is NULL => we use term charset => if
|
||||
* this charset is already UTF-8, then no iconv is needed
|
||||
*/
|
||||
if (local_utf8 && (!charset || !charset[0]))
|
||||
return input;
|
||||
|
||||
|
||||
if (utf8_has_8bits (input) && utf8_is_valid (input, NULL))
|
||||
return input;
|
||||
|
||||
|
||||
output = string_iconv (0,
|
||||
(charset && charset[0]) ?
|
||||
charset : weechat_local_charset,
|
||||
@@ -1297,21 +1297,21 @@ char *
|
||||
string_iconv_from_internal (const char *charset, const char *string)
|
||||
{
|
||||
char *input, *output;
|
||||
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
|
||||
input = strdup (string);
|
||||
if (!input)
|
||||
return NULL;
|
||||
|
||||
|
||||
/*
|
||||
* optimized for UTF-8: if charset is NULL => we use term charset => if
|
||||
* this charset is already UTF-8, then no iconv needed
|
||||
*/
|
||||
if (local_utf8 && (!charset || !charset[0]))
|
||||
return input;
|
||||
|
||||
|
||||
utf8_normalize (input, '?');
|
||||
output = string_iconv (1,
|
||||
WEECHAT_INTERNAL_CHARSET,
|
||||
@@ -1334,7 +1334,7 @@ string_iconv_fprintf (FILE *file, const char *data, ...)
|
||||
{
|
||||
char *buf2;
|
||||
int rc, num_written;
|
||||
|
||||
|
||||
rc = 0;
|
||||
weechat_va_format (data);
|
||||
if (vbuffer)
|
||||
@@ -1346,7 +1346,7 @@ string_iconv_fprintf (FILE *file, const char *data, ...)
|
||||
free (buf2);
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1363,9 +1363,9 @@ string_format_size (unsigned long long size)
|
||||
float unit_divide[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
|
||||
char format_size[128], str_size[128];
|
||||
int num_unit;
|
||||
|
||||
|
||||
str_size[0] = '\0';
|
||||
|
||||
|
||||
if (size < 1024*10)
|
||||
num_unit = 0;
|
||||
else if (size < 1024*1024)
|
||||
@@ -1374,7 +1374,7 @@ string_format_size (unsigned long long size)
|
||||
num_unit = 2;
|
||||
else
|
||||
num_unit = 3;
|
||||
|
||||
|
||||
snprintf (format_size, sizeof (format_size),
|
||||
"%s %%s",
|
||||
unit_format[num_unit]);
|
||||
@@ -1382,7 +1382,7 @@ string_format_size (unsigned long long size)
|
||||
format_size,
|
||||
((float)size) / ((float)(unit_divide[num_unit])),
|
||||
(size <= 1) ? _("byte") : _(unit_name[num_unit]));
|
||||
|
||||
|
||||
return strdup (str_size);
|
||||
}
|
||||
|
||||
@@ -1395,7 +1395,7 @@ string_convbase64_8x3_to_6x4 (const char *from, char *to)
|
||||
{
|
||||
unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
|
||||
to[0] = base64_table [ (from[0] & 0xfc) >> 2 ];
|
||||
to[1] = base64_table [ ((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4) ];
|
||||
to[2] = base64_table [ ((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6) ];
|
||||
@@ -1413,10 +1413,10 @@ string_encode_base64 (const char *from, int length, char *to)
|
||||
{
|
||||
const char *ptr_from;
|
||||
char *ptr_to;
|
||||
|
||||
|
||||
ptr_from = from;
|
||||
ptr_to = to;
|
||||
|
||||
|
||||
while (length >= 3)
|
||||
{
|
||||
string_convbase64_8x3_to_6x4 (ptr_from, ptr_to);
|
||||
@@ -1424,7 +1424,7 @@ string_encode_base64 (const char *from, int length, char *to)
|
||||
ptr_to += 4 * sizeof (*ptr_to);
|
||||
length -= 3;
|
||||
}
|
||||
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
char rest[3] = { 0, 0, 0 };
|
||||
@@ -1475,13 +1475,13 @@ string_decode_base64 (const char *from, char *to)
|
||||
unsigned char c, in[4], out[3];
|
||||
unsigned char base64_table[]="|$$$}rstuvwxyz{$$$$$$$>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
|
||||
|
||||
|
||||
ptr_from = from;
|
||||
ptr_to = to;
|
||||
|
||||
|
||||
ptr_to[0] = '\0';
|
||||
to_length = 0;
|
||||
|
||||
|
||||
while (ptr_from && ptr_from[0])
|
||||
{
|
||||
length = 0;
|
||||
@@ -1519,9 +1519,9 @@ string_decode_base64 (const char *from, char *to)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_to[0] = '\0';
|
||||
|
||||
|
||||
return to_length;
|
||||
}
|
||||
|
||||
@@ -1534,24 +1534,24 @@ int
|
||||
string_is_command_char (const char *string)
|
||||
{
|
||||
const char *ptr_command_chars;
|
||||
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
if (string[0] == '/')
|
||||
return 1;
|
||||
|
||||
|
||||
ptr_command_chars = CONFIG_STRING(config_look_command_chars);
|
||||
if (!ptr_command_chars || !ptr_command_chars[0])
|
||||
return 0;
|
||||
|
||||
|
||||
while (ptr_command_chars && ptr_command_chars[0])
|
||||
{
|
||||
if (utf8_charcmp (ptr_command_chars, string) == 0)
|
||||
return 1;
|
||||
ptr_command_chars = utf8_next_char (ptr_command_chars);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1566,11 +1566,11 @@ const char *
|
||||
string_input_for_buffer (const char *string)
|
||||
{
|
||||
char *pos_slash, *pos_space, *next_char;
|
||||
|
||||
|
||||
/* special case for C comments pasted in input line */
|
||||
if (strncmp (string, "/*", 2) == 0)
|
||||
return string;
|
||||
|
||||
|
||||
/*
|
||||
* special case if string starts with '/': to allow to paste a path line
|
||||
* "/path/to/file.txt", we check if next '/' is after a space or not
|
||||
@@ -1579,28 +1579,28 @@ string_input_for_buffer (const char *string)
|
||||
{
|
||||
pos_slash = strchr (string + 1, '/');
|
||||
pos_space = strchr (string + 1, ' ');
|
||||
|
||||
|
||||
/*
|
||||
* if there's no other '/' of if '/' is after first space,
|
||||
* then it is a command, and return NULL
|
||||
*/
|
||||
if (!pos_slash || (pos_space && pos_slash > pos_space))
|
||||
return NULL;
|
||||
|
||||
|
||||
return (string[1] == '/') ? string + 1 : string;
|
||||
}
|
||||
|
||||
|
||||
/* if string does not start with a command char, then it's not command */
|
||||
if (!string_is_command_char (string))
|
||||
return string;
|
||||
|
||||
|
||||
/* check if first char is doubled: if yes, then it's not a command */
|
||||
next_char = utf8_next_char (string);
|
||||
if (!next_char || !next_char[0])
|
||||
return string;
|
||||
if (utf8_charcmp (string, next_char) == 0)
|
||||
return next_char;
|
||||
|
||||
|
||||
/* string is a command */
|
||||
return NULL;
|
||||
}
|
||||
@@ -1619,15 +1619,15 @@ string_replace_with_hashtable (const char *string,
|
||||
int length, length_value, index_string, index_result;
|
||||
char *result, *result2, *key;
|
||||
const char *pos_end_name, *ptr_value;
|
||||
|
||||
|
||||
*errors = 0;
|
||||
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return strdup (string);
|
||||
|
||||
|
||||
length = strlen (string) + 1;
|
||||
result = malloc (length);
|
||||
if (result)
|
||||
@@ -1676,7 +1676,7 @@ string_replace_with_hashtable (const char *string,
|
||||
result[index_result++] = string[index_string++];
|
||||
(*errors)++;
|
||||
}
|
||||
|
||||
|
||||
free (key);
|
||||
}
|
||||
else
|
||||
@@ -1690,6 +1690,6 @@ string_replace_with_hashtable (const char *string,
|
||||
}
|
||||
result[index_result] = '\0';
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
+54
-54
@@ -94,7 +94,7 @@ upgrade_file_write_integer (struct t_upgrade_file *upgrade_file, int value)
|
||||
{
|
||||
if (fwrite ((void *)(&value), sizeof (value), 1, upgrade_file->file) <= 0)
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ upgrade_file_write_time (struct t_upgrade_file *upgrade_file, time_t date)
|
||||
{
|
||||
if (fwrite ((void *)(&date), sizeof (date), 1, upgrade_file->file) <= 0)
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ upgrade_file_write_string (struct t_upgrade_file *upgrade_file,
|
||||
const char *string)
|
||||
{
|
||||
int length;
|
||||
|
||||
|
||||
if (string && string[0])
|
||||
{
|
||||
length = strlen (string);
|
||||
@@ -136,7 +136,7 @@ upgrade_file_write_string (struct t_upgrade_file *upgrade_file,
|
||||
if (!upgrade_file_write_integer (upgrade_file, 0))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ upgrade_file_write_buffer (struct t_upgrade_file *upgrade_file, void *pointer,
|
||||
if (!upgrade_file_write_integer (upgrade_file, 0))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -176,10 +176,10 @@ upgrade_file_new (const char *filename, int write)
|
||||
{
|
||||
int length;
|
||||
struct t_upgrade_file *new_upgrade_file;
|
||||
|
||||
|
||||
if (!filename)
|
||||
return NULL;
|
||||
|
||||
|
||||
new_upgrade_file = malloc (sizeof (*new_upgrade_file));
|
||||
if (new_upgrade_file)
|
||||
{
|
||||
@@ -193,33 +193,33 @@ upgrade_file_new (const char *filename, int write)
|
||||
}
|
||||
snprintf (new_upgrade_file->filename, length, "%s/%s.upgrade",
|
||||
weechat_home, filename);
|
||||
|
||||
|
||||
/* open file in read or write mode */
|
||||
if (write)
|
||||
new_upgrade_file->file = fopen (new_upgrade_file->filename, "wb");
|
||||
else
|
||||
new_upgrade_file->file = fopen (new_upgrade_file->filename, "rb");
|
||||
|
||||
|
||||
if (!new_upgrade_file->file)
|
||||
{
|
||||
free (new_upgrade_file->filename);
|
||||
free (new_upgrade_file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* change permissions if write mode */
|
||||
if (write)
|
||||
{
|
||||
chmod (new_upgrade_file->filename, 0600);
|
||||
|
||||
|
||||
/* write signature */
|
||||
upgrade_file_write_string (new_upgrade_file, UPGRADE_SIGNATURE);
|
||||
}
|
||||
|
||||
|
||||
/* init positions */
|
||||
new_upgrade_file->last_read_pos = 0;
|
||||
new_upgrade_file->last_read_length = 0;
|
||||
|
||||
|
||||
/* add upgrade file to list of upgrade files */
|
||||
new_upgrade_file->prev_upgrade = last_upgrade_file;
|
||||
new_upgrade_file->next_upgrade = NULL;
|
||||
@@ -245,7 +245,7 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
|
||||
char **argv;
|
||||
const char *fields;
|
||||
void *buf;
|
||||
|
||||
|
||||
/* write all infolist variables */
|
||||
infolist_reset_item_cursor (infolist);
|
||||
while (infolist_next (infolist))
|
||||
@@ -261,7 +261,7 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
|
||||
UPGRADE_ERROR(_("write - object id"), "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
fields = infolist_fields (infolist);
|
||||
if (fields)
|
||||
{
|
||||
@@ -376,12 +376,12 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
|
||||
if (argv)
|
||||
string_free_split (argv);
|
||||
}
|
||||
|
||||
|
||||
/* write object end */
|
||||
if (!upgrade_file_write_integer (upgrade_file, UPGRADE_TYPE_OBJECT_END))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -416,28 +416,28 @@ int
|
||||
upgrade_file_read_string (struct t_upgrade_file *upgrade_file, char **string)
|
||||
{
|
||||
int length;
|
||||
|
||||
|
||||
if (string && *string)
|
||||
{
|
||||
free (*string);
|
||||
*string = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!upgrade_file_read_integer (upgrade_file, &length))
|
||||
return 0;
|
||||
|
||||
|
||||
upgrade_file->last_read_pos = ftell (upgrade_file->file);
|
||||
upgrade_file->last_read_length = length;
|
||||
|
||||
|
||||
if (string)
|
||||
{
|
||||
if (length == 0)
|
||||
return 1;
|
||||
|
||||
|
||||
(*string) = malloc (length + 1);
|
||||
if (!(*string))
|
||||
return 0;
|
||||
|
||||
|
||||
if (fread ((void *)(*string), length, 1, upgrade_file->file) <= 0)
|
||||
{
|
||||
free (*string);
|
||||
@@ -464,10 +464,10 @@ upgrade_file_read_string_utf8 (struct t_upgrade_file *upgrade_file,
|
||||
{
|
||||
if (!upgrade_file_read_string (upgrade_file, string))
|
||||
return 0;
|
||||
|
||||
|
||||
if (string && *string)
|
||||
utf8_normalize (*string, '?');
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -481,23 +481,23 @@ upgrade_file_read_buffer (struct t_upgrade_file *upgrade_file,
|
||||
{
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
|
||||
if (*buffer)
|
||||
{
|
||||
free (*buffer);
|
||||
*buffer = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!upgrade_file_read_integer (upgrade_file, size))
|
||||
return 0;
|
||||
|
||||
|
||||
if (*size > 0)
|
||||
{
|
||||
upgrade_file->last_read_pos = ftell (upgrade_file->file);
|
||||
upgrade_file->last_read_length = *size;
|
||||
|
||||
|
||||
*buffer = malloc (*size);
|
||||
|
||||
|
||||
if (*buffer)
|
||||
{
|
||||
if (fread (*buffer, *size, 1, upgrade_file->file) <= 0)
|
||||
@@ -509,7 +509,7 @@ upgrade_file_read_buffer (struct t_upgrade_file *upgrade_file,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ upgrade_file_read_time (struct t_upgrade_file *upgrade_file, time_t *time)
|
||||
{
|
||||
upgrade_file->last_read_pos = ftell (upgrade_file->file);
|
||||
upgrade_file->last_read_length = sizeof (*time);
|
||||
|
||||
|
||||
if (time)
|
||||
{
|
||||
if (fread ((void *)time, sizeof (*time), 1, upgrade_file->file) <= 0)
|
||||
@@ -533,7 +533,7 @@ upgrade_file_read_time (struct t_upgrade_file *upgrade_file, time_t *time)
|
||||
if (fseek (upgrade_file->file, sizeof (*time), SEEK_CUR) < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -551,14 +551,14 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
|
||||
char *name, *value_str;
|
||||
void *buffer;
|
||||
time_t time;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
infolist = NULL;
|
||||
name = NULL;
|
||||
value_str = NULL;
|
||||
buffer = NULL;
|
||||
|
||||
|
||||
if (!upgrade_file_read_integer (upgrade_file, &type))
|
||||
{
|
||||
if (feof (upgrade_file->file))
|
||||
@@ -567,19 +567,19 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
|
||||
UPGRADE_ERROR(_("read - object type"), "");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (type != UPGRADE_TYPE_OBJECT_START)
|
||||
{
|
||||
UPGRADE_ERROR(_("read - bad object type ('object start' expected)"), "");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (!upgrade_file_read_integer (upgrade_file, &object_id))
|
||||
{
|
||||
UPGRADE_ERROR(_("read - object id"), "");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
infolist = infolist_new ();
|
||||
if (!infolist)
|
||||
{
|
||||
@@ -592,7 +592,7 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
|
||||
UPGRADE_ERROR(_("read - infolist item creation"), "");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (!upgrade_file_read_integer (upgrade_file, &type))
|
||||
@@ -600,10 +600,10 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
|
||||
UPGRADE_ERROR(_("read - object type"), "");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (type == UPGRADE_TYPE_OBJECT_END)
|
||||
break;
|
||||
|
||||
|
||||
if (type == UPGRADE_TYPE_OBJECT_VAR)
|
||||
{
|
||||
if (!upgrade_file_read_string (upgrade_file, &name))
|
||||
@@ -621,7 +621,7 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
|
||||
UPGRADE_ERROR(_("read - variable type"), "");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
switch (type_var)
|
||||
{
|
||||
case INFOLIST_INTEGER:
|
||||
@@ -661,9 +661,9 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rc = 1;
|
||||
|
||||
|
||||
if (upgrade_file->callback_read)
|
||||
{
|
||||
if ((int)(upgrade_file->callback_read) (upgrade_file->callback_read_data,
|
||||
@@ -672,7 +672,7 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
|
||||
infolist) == WEECHAT_RC_ERROR)
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (infolist)
|
||||
infolist_free (infolist);
|
||||
@@ -682,7 +682,7 @@ end:
|
||||
free (value_str);
|
||||
if (buffer)
|
||||
free (buffer);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -700,35 +700,35 @@ upgrade_file_read (struct t_upgrade_file *upgrade_file,
|
||||
void *callback_read_data)
|
||||
{
|
||||
char *signature;
|
||||
|
||||
|
||||
if (!upgrade_file)
|
||||
return 0;
|
||||
|
||||
|
||||
upgrade_file->callback_read = callback_read;
|
||||
upgrade_file->callback_read_data = callback_read_data;
|
||||
|
||||
|
||||
signature = NULL;
|
||||
if (!upgrade_file_read_string (upgrade_file, &signature))
|
||||
{
|
||||
UPGRADE_ERROR(_("read - signature not found"), "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (!signature || (strcmp (signature, UPGRADE_SIGNATURE) != 0))
|
||||
{
|
||||
UPGRADE_ERROR(_("read - bad signature (upgrade file format may have "
|
||||
"changed since last version)"), "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
free (signature);
|
||||
|
||||
|
||||
while (!feof (upgrade_file->file))
|
||||
{
|
||||
if (!upgrade_file_read_object (upgrade_file))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+48
-48
@@ -71,14 +71,14 @@ upgrade_weechat_save_history (struct t_upgrade_file *upgrade_file,
|
||||
struct t_infolist_item *ptr_item;
|
||||
struct t_gui_history *ptr_history;
|
||||
int rc;
|
||||
|
||||
|
||||
if (!last_history)
|
||||
return 1;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (!ptr_infolist)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_history = last_history;
|
||||
while (ptr_history)
|
||||
{
|
||||
@@ -88,23 +88,23 @@ upgrade_weechat_save_history (struct t_upgrade_file *upgrade_file,
|
||||
infolist_free (ptr_infolist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (!infolist_new_var_string (ptr_item, "text", ptr_history->text))
|
||||
{
|
||||
infolist_free (ptr_infolist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ptr_history = ptr_history->prev_history;
|
||||
}
|
||||
|
||||
|
||||
rc = upgrade_file_write_object (upgrade_file,
|
||||
UPGRADE_WEECHAT_TYPE_HISTORY,
|
||||
ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
if (!rc)
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_line *ptr_line;
|
||||
int rc;
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
|
||||
infolist_free (ptr_infolist);
|
||||
if (!rc)
|
||||
return 0;
|
||||
|
||||
|
||||
/* save nicklist */
|
||||
if (ptr_buffer->nicklist)
|
||||
{
|
||||
@@ -157,7 +157,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* save buffer lines */
|
||||
for (ptr_line = ptr_buffer->own_lines->first_line; ptr_line;
|
||||
ptr_line = ptr_line->next_line)
|
||||
@@ -179,7 +179,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* save command/text history of buffer */
|
||||
if (ptr_buffer->history)
|
||||
{
|
||||
@@ -189,7 +189,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -203,11 +203,11 @@ upgrade_weechat_save_misc (struct t_upgrade_file *upgrade_file)
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_infolist_item *ptr_item;
|
||||
int rc;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (!ptr_infolist)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (ptr_infolist);
|
||||
if (!ptr_item)
|
||||
{
|
||||
@@ -229,12 +229,12 @@ upgrade_weechat_save_misc (struct t_upgrade_file *upgrade_file)
|
||||
infolist_free (ptr_infolist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
rc = upgrade_file_write_object (upgrade_file,
|
||||
UPGRADE_WEECHAT_TYPE_MISC,
|
||||
ptr_infolist);
|
||||
infolist_free (ptr_infolist);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ upgrade_weechat_save_hotlist (struct t_upgrade_file *upgrade_file)
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
int rc;
|
||||
|
||||
|
||||
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
@@ -267,7 +267,7 @@ upgrade_weechat_save_hotlist (struct t_upgrade_file *upgrade_file)
|
||||
if (!rc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -282,39 +282,39 @@ upgrade_weechat_save_layout_window_tree (struct t_upgrade_file *upgrade_file,
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
int rc;
|
||||
|
||||
|
||||
ptr_infolist = infolist_new ();
|
||||
if (!ptr_infolist)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!gui_layout_window_add_to_infolist (ptr_infolist, layout_window))
|
||||
{
|
||||
infolist_free (ptr_infolist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
rc = upgrade_file_write_object (upgrade_file,
|
||||
UPGRADE_WEECHAT_TYPE_LAYOUT_WINDOW,
|
||||
ptr_infolist);
|
||||
|
||||
|
||||
infolist_free (ptr_infolist);
|
||||
if (!rc)
|
||||
return 0;
|
||||
|
||||
|
||||
if (layout_window->child1)
|
||||
{
|
||||
if (!upgrade_weechat_save_layout_window_tree (upgrade_file,
|
||||
layout_window->child1))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (layout_window->child2)
|
||||
{
|
||||
if (!upgrade_weechat_save_layout_window_tree (upgrade_file,
|
||||
layout_window->child2))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -327,16 +327,16 @@ upgrade_weechat_save_layout_window (struct t_upgrade_file *upgrade_file)
|
||||
{
|
||||
struct t_gui_layout_window *layout_windows;
|
||||
int rc;
|
||||
|
||||
|
||||
/* get current layout for windows */
|
||||
layout_windows = NULL;
|
||||
gui_layout_window_save (&layout_windows);
|
||||
|
||||
/* save tree with layout of windows */
|
||||
rc = upgrade_weechat_save_layout_window_tree (upgrade_file, layout_windows);
|
||||
|
||||
|
||||
gui_layout_window_remove_all (&layout_windows);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ upgrade_weechat_save ()
|
||||
{
|
||||
int rc;
|
||||
struct t_upgrade_file *upgrade_file;
|
||||
|
||||
|
||||
upgrade_file = upgrade_file_new (WEECHAT_UPGRADE_FILENAME, 1);
|
||||
if (!upgrade_file)
|
||||
return 0;
|
||||
@@ -361,9 +361,9 @@ upgrade_weechat_save ()
|
||||
rc &= upgrade_weechat_save_misc (upgrade_file);
|
||||
rc &= upgrade_weechat_save_hotlist (upgrade_file);
|
||||
rc &= upgrade_weechat_save_layout_window (upgrade_file);
|
||||
|
||||
|
||||
upgrade_file_close (upgrade_file);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -387,11 +387,11 @@ upgrade_weechat_read_cb (void *data,
|
||||
struct timeval creation_time;
|
||||
void *buf;
|
||||
int i, size, index, length;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) upgrade_file;
|
||||
|
||||
|
||||
infolist_reset_item_cursor (infolist);
|
||||
while (infolist_next (infolist))
|
||||
{
|
||||
@@ -673,7 +673,7 @@ upgrade_weechat_read_cb (void *data,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -687,40 +687,40 @@ upgrade_weechat_load ()
|
||||
{
|
||||
int rc;
|
||||
struct t_upgrade_file *upgrade_file;
|
||||
|
||||
|
||||
upgrade_file = upgrade_file_new (WEECHAT_UPGRADE_FILENAME, 0);
|
||||
rc = upgrade_file_read (upgrade_file, &upgrade_weechat_read_cb, NULL);
|
||||
|
||||
|
||||
if (!hotlist_reset)
|
||||
gui_hotlist_clear ();
|
||||
|
||||
|
||||
gui_color_buffer_assign ();
|
||||
gui_color_buffer_display ();
|
||||
|
||||
|
||||
if (upgrade_layout_buffers)
|
||||
{
|
||||
gui_layout_buffer_apply (upgrade_layout_buffers);
|
||||
gui_layout_buffer_remove_all (&upgrade_layout_buffers,
|
||||
&last_upgrade_layout_buffer);
|
||||
}
|
||||
|
||||
|
||||
if (upgrade_layout_windows)
|
||||
{
|
||||
gui_layout_window_apply (upgrade_layout_windows, -1);
|
||||
gui_layout_window_remove_all (&upgrade_layout_windows);
|
||||
}
|
||||
|
||||
|
||||
if (upgrade_set_current_window > 0)
|
||||
gui_window_switch_by_number (upgrade_set_current_window);
|
||||
|
||||
|
||||
if (upgrade_set_current_buffer)
|
||||
{
|
||||
gui_window_switch_to_buffer (gui_current_window,
|
||||
upgrade_set_current_buffer, 0);
|
||||
}
|
||||
|
||||
|
||||
gui_layout_buffer_get_number_all (gui_layout_buffers);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ upgrade_weechat_remove_file_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (string_match (filename, "*.upgrade", 1))
|
||||
{
|
||||
if (weechat_debug_core >= 2)
|
||||
@@ -752,13 +752,13 @@ upgrade_weechat_end ()
|
||||
{
|
||||
struct timeval tv_now;
|
||||
long time_diff;
|
||||
|
||||
|
||||
/* remove .upgrade files */
|
||||
util_exec_on_files (weechat_home,
|
||||
0,
|
||||
NULL,
|
||||
&upgrade_weechat_remove_file_cb);
|
||||
|
||||
|
||||
/* display message for end of /upgrade with duration */
|
||||
gettimeofday (&tv_now, NULL);
|
||||
time_diff = util_timeval_diff (&weechat_current_start_timeval, &tv_now);
|
||||
@@ -767,10 +767,10 @@ upgrade_weechat_end ()
|
||||
_("Upgrade done (%.02f %s)"),
|
||||
((float)time_diff) / 1000,
|
||||
NG_("second", "seconds", time_diff / 1000));
|
||||
|
||||
|
||||
/* upgrading ended */
|
||||
weechat_upgrading = 0;
|
||||
|
||||
|
||||
/* send signal for end of /upgrade */
|
||||
hook_signal_send ("upgrade_ended", WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
|
||||
+38
-38
@@ -137,7 +137,7 @@ void
|
||||
utf8_normalize (char *string, char replacement)
|
||||
{
|
||||
char *error;
|
||||
|
||||
|
||||
while (string && string[0])
|
||||
{
|
||||
if (utf8_is_valid (string, &error))
|
||||
@@ -156,9 +156,9 @@ utf8_prev_char (const char *string_start, const char *string)
|
||||
{
|
||||
if (!string || (string <= string_start))
|
||||
return NULL;
|
||||
|
||||
|
||||
string--;
|
||||
|
||||
|
||||
if (((unsigned char)(string[0]) & 0xC0) == 0x80)
|
||||
{
|
||||
/* UTF-8, at least 2 bytes */
|
||||
@@ -197,7 +197,7 @@ utf8_next_char (const char *string)
|
||||
{
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* UTF-8, 2 bytes: 110vvvvv 10vvvvvv */
|
||||
if (((unsigned char)(string[0]) & 0xE0) == 0xC0)
|
||||
{
|
||||
@@ -237,12 +237,12 @@ int
|
||||
utf8_char_int (const char *string)
|
||||
{
|
||||
const unsigned char *ptr_string;
|
||||
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
|
||||
|
||||
/* UTF-8, 2 bytes: 110vvvvv 10vvvvvv */
|
||||
if ((ptr_string[0] & 0xE0) == 0xC0)
|
||||
{
|
||||
@@ -293,10 +293,10 @@ utf8_wide_char (const char *string)
|
||||
{
|
||||
int char_size;
|
||||
wint_t result;
|
||||
|
||||
|
||||
if (!string || !string[0])
|
||||
return WEOF;
|
||||
|
||||
|
||||
char_size = utf8_char_size (string);
|
||||
switch (char_size)
|
||||
{
|
||||
@@ -333,7 +333,7 @@ utf8_char_size (const char *string)
|
||||
{
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
return utf8_next_char (string) - string;
|
||||
}
|
||||
|
||||
@@ -345,10 +345,10 @@ int
|
||||
utf8_strlen (const char *string)
|
||||
{
|
||||
int length;
|
||||
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
length = 0;
|
||||
while (string && string[0])
|
||||
{
|
||||
@@ -367,10 +367,10 @@ utf8_strnlen (const char *string, int bytes)
|
||||
{
|
||||
char *start;
|
||||
int length;
|
||||
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
start = (char *)string;
|
||||
length = 0;
|
||||
while (string && string[0] && (string - start < bytes))
|
||||
@@ -391,24 +391,24 @@ utf8_strlen_screen (const char *string)
|
||||
{
|
||||
int length, num_char;
|
||||
wchar_t *wstring;
|
||||
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!local_utf8)
|
||||
return utf8_strlen (string);
|
||||
|
||||
|
||||
num_char = mbstowcs (NULL, string, 0) + 1;
|
||||
wstring = malloc ((num_char + 1) * sizeof (wstring[0]));
|
||||
if (!wstring)
|
||||
return utf8_strlen (string);
|
||||
|
||||
|
||||
if (mbstowcs (wstring, string, num_char) == (size_t)(-1))
|
||||
{
|
||||
free (wstring);
|
||||
return utf8_strlen (string);
|
||||
}
|
||||
|
||||
|
||||
length = wcswidth (wstring, num_char);
|
||||
free (wstring);
|
||||
return length;
|
||||
@@ -422,13 +422,13 @@ int
|
||||
utf8_charcmp (const char *string1, const char *string2)
|
||||
{
|
||||
int length1, length2, i, diff;
|
||||
|
||||
|
||||
if (!string1 || !string2)
|
||||
return (string1) ? 1 : ((string2) ? -1 : 0);
|
||||
|
||||
|
||||
length1 = utf8_char_size (string1);
|
||||
length2 = utf8_char_size (string2);
|
||||
|
||||
|
||||
i = 0;
|
||||
while ((i < length1) && (i < length2))
|
||||
{
|
||||
@@ -455,18 +455,18 @@ int
|
||||
utf8_charcasecmp (const char *string1, const char *string2)
|
||||
{
|
||||
wint_t wchar1, wchar2;
|
||||
|
||||
|
||||
if (!string1 || !string2)
|
||||
return (string1) ? 1 : ((string2) ? -1 : 0);
|
||||
|
||||
|
||||
wchar1 = utf8_wide_char (string1);
|
||||
if ((wchar1 >= 'A') && (wchar1 <= 'Z'))
|
||||
wchar1 += ('a' - 'A');
|
||||
|
||||
|
||||
wchar2 = utf8_wide_char (string2);
|
||||
if ((wchar2 >= 'A') && (wchar2 <= 'Z'))
|
||||
wchar2 += ('a' - 'A');
|
||||
|
||||
|
||||
return (wchar1 < wchar2) ? -1 : ((wchar1 == wchar2) ? 0 : 1);
|
||||
}
|
||||
|
||||
@@ -480,17 +480,17 @@ utf8_char_size_screen (const char *string)
|
||||
{
|
||||
int char_size;
|
||||
char utf_char[16];
|
||||
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
char_size = utf8_char_size (string);
|
||||
if (char_size == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
memcpy (utf_char, string, char_size);
|
||||
utf_char[char_size] = '\0';
|
||||
|
||||
|
||||
return utf8_strlen_screen (utf_char);
|
||||
}
|
||||
|
||||
@@ -503,7 +503,7 @@ utf8_add_offset (const char *string, int offset)
|
||||
{
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
|
||||
while (string && string[0] && (offset > 0))
|
||||
{
|
||||
string = utf8_next_char (string);
|
||||
@@ -522,10 +522,10 @@ utf8_real_pos (const char *string, int pos)
|
||||
{
|
||||
int count, real_pos;
|
||||
char *next_char;
|
||||
|
||||
|
||||
if (!string)
|
||||
return pos;
|
||||
|
||||
|
||||
count = 0;
|
||||
real_pos = 0;
|
||||
while (string && string[0] && (count < pos))
|
||||
@@ -548,10 +548,10 @@ utf8_pos (const char *string, int real_pos)
|
||||
{
|
||||
int count;
|
||||
char *limit;
|
||||
|
||||
|
||||
if (!string || !weechat_local_charset)
|
||||
return real_pos;
|
||||
|
||||
|
||||
count = 0;
|
||||
limit = (char *)string + real_pos;
|
||||
while (string && string[0] && (string < limit))
|
||||
@@ -570,13 +570,13 @@ char *
|
||||
utf8_strndup (const char *string, int length)
|
||||
{
|
||||
const char *end;
|
||||
|
||||
|
||||
if (!string || (length < 0))
|
||||
return NULL;
|
||||
|
||||
|
||||
if (length == 0)
|
||||
return strdup ("");
|
||||
|
||||
|
||||
end = utf8_add_offset (string, length);
|
||||
if (!end || (end == string))
|
||||
return strdup (string);
|
||||
|
||||
+32
-32
@@ -73,10 +73,10 @@ long
|
||||
util_timeval_diff (struct timeval *tv1, struct timeval *tv2)
|
||||
{
|
||||
long diff_sec, diff_usec;
|
||||
|
||||
|
||||
diff_sec = tv2->tv_sec - tv1->tv_sec;
|
||||
diff_usec = tv2->tv_usec - tv1->tv_usec;
|
||||
|
||||
|
||||
if (diff_usec < 0)
|
||||
{
|
||||
diff_usec += 1000000;
|
||||
@@ -93,7 +93,7 @@ void
|
||||
util_timeval_add (struct timeval *tv, long interval)
|
||||
{
|
||||
long usec;
|
||||
|
||||
|
||||
tv->tv_sec += (interval / 1000);
|
||||
usec = tv->tv_usec + ((interval % 1000) * 1000);
|
||||
if (usec > 1000000)
|
||||
@@ -115,11 +115,11 @@ util_get_time_string (const time_t *date)
|
||||
{
|
||||
struct tm *local_time;
|
||||
static char text_time[128];
|
||||
|
||||
|
||||
local_time = localtime (date);
|
||||
strftime (text_time, sizeof (text_time),
|
||||
CONFIG_STRING(config_look_time_format), local_time);
|
||||
|
||||
|
||||
return text_time;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ void
|
||||
util_catch_signal (int signum, void (*handler)(int))
|
||||
{
|
||||
struct sigaction act;
|
||||
|
||||
|
||||
sigemptyset (&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
act.sa_handler = handler;
|
||||
@@ -148,18 +148,18 @@ util_mkdir_home (const char *directory, int mode)
|
||||
{
|
||||
char *dir_name;
|
||||
int dir_length;
|
||||
|
||||
|
||||
if (!directory)
|
||||
return 0;
|
||||
|
||||
|
||||
/* build directory, adding WeeChat home */
|
||||
dir_length = strlen (weechat_home) + strlen (directory) + 2;
|
||||
dir_name = malloc (dir_length);
|
||||
if (!dir_name)
|
||||
return 0;
|
||||
|
||||
|
||||
snprintf (dir_name, dir_length, "%s/%s", weechat_home, directory);
|
||||
|
||||
|
||||
if (mkdir (dir_name, mode) < 0)
|
||||
{
|
||||
if (errno != EEXIST)
|
||||
@@ -168,7 +168,7 @@ util_mkdir_home (const char *directory, int mode)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free (dir_name);
|
||||
return 1;
|
||||
}
|
||||
@@ -183,13 +183,13 @@ util_mkdir (const char *directory, int mode)
|
||||
{
|
||||
if (!directory)
|
||||
return 0;
|
||||
|
||||
|
||||
if (mkdir (directory, mode) < 0)
|
||||
{
|
||||
if (errno != EEXIST)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -204,26 +204,26 @@ util_mkdir_parents (const char *directory, int mode)
|
||||
char *string, *ptr_string, *pos_sep;
|
||||
struct stat buf;
|
||||
int rc;
|
||||
|
||||
|
||||
if (!directory)
|
||||
return 0;
|
||||
|
||||
|
||||
string = strdup (directory);
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_string = string;
|
||||
while (ptr_string[0] == DIR_SEPARATOR_CHAR)
|
||||
{
|
||||
ptr_string++;
|
||||
}
|
||||
|
||||
|
||||
while (ptr_string && ptr_string[0])
|
||||
{
|
||||
pos_sep = strchr (ptr_string, DIR_SEPARATOR_CHAR);
|
||||
if (pos_sep)
|
||||
pos_sep[0] = '\0';
|
||||
|
||||
|
||||
rc = stat (string, &buf);
|
||||
if ((rc < 0) || !S_ISDIR(buf.st_mode))
|
||||
{
|
||||
@@ -234,7 +234,7 @@ util_mkdir_parents (const char *directory, int mode)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (pos_sep)
|
||||
{
|
||||
pos_sep[0] = DIR_SEPARATOR_CHAR;
|
||||
@@ -243,9 +243,9 @@ util_mkdir_parents (const char *directory, int mode)
|
||||
else
|
||||
ptr_string = NULL;
|
||||
}
|
||||
|
||||
|
||||
free (string);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@ util_exec_on_files (const char *directory, int hidden_files, void *data,
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
struct stat statbuf;
|
||||
|
||||
|
||||
if (!directory || !callback)
|
||||
return;
|
||||
|
||||
|
||||
dir = opendir (directory);
|
||||
if (dir)
|
||||
{
|
||||
@@ -302,11 +302,11 @@ util_search_full_lib_name (const char *filename, const char *sys_directory)
|
||||
char *name_with_ext, *final_name;
|
||||
int length;
|
||||
struct stat st;
|
||||
|
||||
|
||||
/* filename is already a full path */
|
||||
if (strchr (filename, '/') || strchr (filename, '\\'))
|
||||
return strdup (filename);
|
||||
|
||||
|
||||
length = strlen (filename) + 16;
|
||||
if (CONFIG_STRING(config_plugin_extension)
|
||||
&& CONFIG_STRING(config_plugin_extension)[0])
|
||||
@@ -319,7 +319,7 @@ util_search_full_lib_name (const char *filename, const char *sys_directory)
|
||||
&& CONFIG_STRING(config_plugin_extension)
|
||||
&& CONFIG_STRING(config_plugin_extension)[0])
|
||||
strcat (name_with_ext, CONFIG_STRING(config_plugin_extension));
|
||||
|
||||
|
||||
/* try WeeChat user's dir */
|
||||
length = strlen (weechat_home) + strlen (name_with_ext) +
|
||||
strlen (sys_directory) + 16;
|
||||
@@ -337,7 +337,7 @@ util_search_full_lib_name (const char *filename, const char *sys_directory)
|
||||
return final_name;
|
||||
}
|
||||
free (final_name);
|
||||
|
||||
|
||||
/* try WeeChat global lib dir */
|
||||
length = strlen (WEECHAT_LIBDIR) + strlen (name_with_ext) +
|
||||
strlen (sys_directory) + 16;
|
||||
@@ -372,10 +372,10 @@ util_file_get_content (const char *filename)
|
||||
char *buffer, *buffer2;
|
||||
FILE *f;
|
||||
size_t count, fp;
|
||||
|
||||
|
||||
buffer = NULL;
|
||||
fp = 0;
|
||||
|
||||
|
||||
f = fopen (filename, "r");
|
||||
if (f)
|
||||
{
|
||||
@@ -408,7 +408,7 @@ util_file_get_content (const char *filename)
|
||||
buffer[fp] = '\0';
|
||||
fclose (f);
|
||||
}
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ util_version_number (const char *version)
|
||||
char **items, buf[64], *ptr_item, *error;
|
||||
int num_items, i, version_int[4], index_buf;
|
||||
long number;
|
||||
|
||||
|
||||
items = string_split (version, ".", 0, 4, &num_items);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -468,7 +468,7 @@ util_version_number (const char *version)
|
||||
}
|
||||
if (items)
|
||||
string_free_split (items);
|
||||
|
||||
|
||||
return (version_int[0] << 24) | (version_int[1] << 16)
|
||||
| (version_int[2] << 8) | version_int[3];
|
||||
}
|
||||
|
||||
+10
-10
@@ -197,14 +197,14 @@ void
|
||||
weechat_parse_args (int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
weechat_argv0 = strdup (argv[0]);
|
||||
weechat_upgrading = 0;
|
||||
weechat_home = NULL;
|
||||
weechat_server_cmd_line = 0;
|
||||
weechat_auto_load_plugins = 1;
|
||||
weechat_plugin_no_dlclose = 0;
|
||||
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if ((strcmp (argv[i], "-c") == 0)
|
||||
@@ -323,7 +323,7 @@ weechat_create_home_dirs ()
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* create home directory; error is fatal */
|
||||
if (!util_mkdir (weechat_home, 0755))
|
||||
{
|
||||
@@ -383,7 +383,7 @@ weechat_shutdown (int return_code, int crash)
|
||||
free (weechat_local_charset);
|
||||
|
||||
network_end ();
|
||||
|
||||
|
||||
if (crash)
|
||||
abort();
|
||||
else
|
||||
@@ -398,21 +398,21 @@ int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
weechat_init_vars (); /* initialize some variables */
|
||||
|
||||
|
||||
setlocale (LC_ALL, ""); /* initialize gettext */
|
||||
#ifdef ENABLE_NLS
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
bind_textdomain_codeset (PACKAGE, "UTF-8");
|
||||
textdomain (PACKAGE);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_LANGINFO_CODESET
|
||||
weechat_local_charset = strdup (nl_langinfo (CODESET));
|
||||
#else
|
||||
weechat_local_charset = strdup ("");
|
||||
#endif
|
||||
utf8_init ();
|
||||
|
||||
|
||||
util_catch_signal (SIGINT, SIG_IGN); /* ignore SIGINT signal */
|
||||
util_catch_signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
|
||||
util_catch_signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */
|
||||
@@ -449,9 +449,9 @@ main (int argc, char *argv[])
|
||||
gui_layout_window_apply (gui_layout_windows, -1); /* apply win layout */
|
||||
if (weechat_upgrading)
|
||||
upgrade_weechat_end (); /* remove .upgrade files + signal */
|
||||
|
||||
|
||||
gui_main_loop (); /* WeeChat main loop */
|
||||
|
||||
|
||||
gui_layout_save_on_exit (); /* save layout */
|
||||
plugin_end (); /* end plugin interface(s) */
|
||||
if (CONFIG_BOOLEAN(config_look_save_config_on_exit))
|
||||
@@ -463,6 +463,6 @@ main (int argc, char *argv[])
|
||||
unhook_all (); /* remove all hooks */
|
||||
hdata_end (); /* end hdata */
|
||||
weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */
|
||||
|
||||
|
||||
return EXIT_SUCCESS; /* make C compiler happy */
|
||||
}
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@
|
||||
"\n" \
|
||||
"You should have received a copy of the GNU General Public License\n" \
|
||||
"along with WeeChat. If not, see <http://www.gnu.org/licenses/>.\n\n"
|
||||
|
||||
|
||||
/* directory separator, depending on OS */
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -47,7 +47,7 @@ IF(NCURSES_FOUND)
|
||||
ADD_DEFINITIONS(-DHAVE_NCURSES_H)
|
||||
ENDIF(NCURSES_HEADERS)
|
||||
ENDIF(NCURSESW_HEADERS)
|
||||
|
||||
|
||||
LIST(APPEND EXTRA_LIBS ${NCURSES_LIBRARY})
|
||||
ENDIF(NCURSES_FOUND)
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ int
|
||||
gui_bar_window_objects_init (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
struct t_gui_bar_window_curses_objects *new_objects;
|
||||
|
||||
|
||||
new_objects = malloc (sizeof (*new_objects));
|
||||
if (new_objects)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ gui_bar_window_create_win (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
if (CONFIG_BOOLEAN(bar_window->bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
return;
|
||||
|
||||
|
||||
if (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar)
|
||||
{
|
||||
delwin (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar);
|
||||
@@ -103,12 +103,12 @@ gui_bar_window_create_win (struct t_gui_bar_window *bar_window)
|
||||
delwin (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator);
|
||||
GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator = NULL;
|
||||
}
|
||||
|
||||
|
||||
GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar = newwin (bar_window->height,
|
||||
bar_window->width,
|
||||
bar_window->y,
|
||||
bar_window->x);
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SEPARATOR]))
|
||||
{
|
||||
switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
|
||||
@@ -161,7 +161,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
{
|
||||
int x_with_hidden, size_on_screen, low_char, hidden;
|
||||
char utf_char[16], *next_char, *output;
|
||||
|
||||
|
||||
if (!string || !string[0])
|
||||
return 1;
|
||||
|
||||
@@ -173,11 +173,11 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
|
||||
}
|
||||
|
||||
|
||||
x_with_hidden = *x;
|
||||
|
||||
hidden = 0;
|
||||
|
||||
|
||||
while (string && string[0])
|
||||
{
|
||||
switch (string[0])
|
||||
@@ -317,10 +317,10 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
next_char = utf8_next_char (string);
|
||||
if (!next_char)
|
||||
break;
|
||||
|
||||
|
||||
memcpy (utf_char, string, next_char - string);
|
||||
utf_char[next_char - string] = '\0';
|
||||
|
||||
|
||||
if ((((unsigned char)utf_char[0]) < 32) && (!utf_char[1]))
|
||||
{
|
||||
low_char = 1;
|
||||
@@ -333,7 +333,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
if (!gui_chat_utf_char_valid (utf_char))
|
||||
snprintf (utf_char, sizeof (utf_char), " ");
|
||||
}
|
||||
|
||||
|
||||
size_on_screen = utf8_char_size_screen (utf_char);
|
||||
if (size_on_screen > 0)
|
||||
{
|
||||
@@ -355,7 +355,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
(*y)++;
|
||||
wmove (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, *y, *x);
|
||||
}
|
||||
|
||||
|
||||
output = string_iconv_from_internal (NULL, utf_char);
|
||||
if (low_char)
|
||||
wattron (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, A_REVERSE);
|
||||
@@ -365,7 +365,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
wattroff (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, A_REVERSE);
|
||||
if (output)
|
||||
free (output);
|
||||
|
||||
|
||||
*x += size_on_screen;
|
||||
}
|
||||
}
|
||||
@@ -399,10 +399,10 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
int diff, max_length, optimal_number_of_lines;
|
||||
int some_data_not_displayed, separator_horizontal, separator_vertical;
|
||||
int index_item, index_subitem, index_line;
|
||||
|
||||
|
||||
if (!gui_init_ok)
|
||||
return;
|
||||
|
||||
|
||||
if (!str_start_input[0])
|
||||
{
|
||||
snprintf (str_start_input, sizeof (str_start_input), "%c%c%c",
|
||||
@@ -410,34 +410,34 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
GUI_COLOR_BAR_CHAR,
|
||||
GUI_COLOR_BAR_START_INPUT_CHAR);
|
||||
length_start_input = strlen (str_start_input);
|
||||
|
||||
|
||||
snprintf (str_start_input_hidden, sizeof (str_start_input_hidden), "%c%c%c",
|
||||
GUI_COLOR_COLOR_CHAR,
|
||||
GUI_COLOR_BAR_CHAR,
|
||||
GUI_COLOR_BAR_START_INPUT_HIDDEN_CHAR);
|
||||
length_start_input_hidden = strlen (str_start_input_hidden);
|
||||
|
||||
|
||||
snprintf (str_cursor, sizeof (str_cursor), "%c%c%c",
|
||||
GUI_COLOR_COLOR_CHAR,
|
||||
GUI_COLOR_BAR_CHAR,
|
||||
GUI_COLOR_BAR_MOVE_CURSOR_CHAR);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* these values will be overwritten later (by gui_bar_window_print_string)
|
||||
* if cursor has to move somewhere in bar window
|
||||
*/
|
||||
bar_window->cursor_x = -1;
|
||||
bar_window->cursor_y = -1;
|
||||
|
||||
|
||||
/* remove coords */
|
||||
gui_bar_window_coords_free (bar_window);
|
||||
index_item = -1;
|
||||
index_subitem = -1;
|
||||
index_line = 0;
|
||||
|
||||
|
||||
filling = gui_bar_get_filling (bar_window->bar);
|
||||
|
||||
|
||||
content = gui_bar_window_content_get_with_filling (bar_window, window);
|
||||
if (content)
|
||||
{
|
||||
@@ -452,7 +452,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
bar_window->scroll_x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
items = string_split (content, "\n", 0, 0, &items_count);
|
||||
if (items_count == 0)
|
||||
{
|
||||
@@ -473,14 +473,14 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
for (line = 0; line < items_count; line++)
|
||||
{
|
||||
length_on_screen = gui_chat_strlen_screen (items[line]);
|
||||
|
||||
|
||||
pos_cursor = strstr (items[line], str_cursor);
|
||||
if (pos_cursor && (gui_chat_strlen_screen (pos_cursor) == 0))
|
||||
length_on_screen++;
|
||||
|
||||
|
||||
if (length_on_screen > max_length)
|
||||
max_length = length_on_screen;
|
||||
|
||||
|
||||
if (length_on_screen % bar_window->width == 0)
|
||||
num_lines = length_on_screen / bar_window->width;
|
||||
else
|
||||
@@ -491,7 +491,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
}
|
||||
if (max_length == 0)
|
||||
max_length = 1;
|
||||
|
||||
|
||||
switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
|
||||
{
|
||||
case GUI_BAR_POSITION_BOTTOM:
|
||||
@@ -512,7 +512,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
|
||||
@@ -540,7 +540,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
chars_available =
|
||||
((bar_window->height - y - 1) * bar_window->width) + /* next lines */
|
||||
(bar_window->width - x - 1); /* chars on current line */
|
||||
|
||||
|
||||
length_screen_before_cursor = -1;
|
||||
length_screen_after_cursor = -1;
|
||||
|
||||
@@ -551,13 +551,13 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
length_screen_after_cursor = gui_chat_strlen_screen (pos_cursor);
|
||||
free (buf);
|
||||
}
|
||||
|
||||
|
||||
if ((length_screen_before_cursor < 0) || (length_screen_after_cursor < 0))
|
||||
{
|
||||
length_screen_before_cursor = gui_chat_strlen_screen (items[line]);
|
||||
length_screen_after_cursor = 0;
|
||||
}
|
||||
|
||||
|
||||
diff = length_screen_before_cursor - chars_available;
|
||||
if (diff > 0)
|
||||
{
|
||||
@@ -567,12 +567,12 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
- 1
|
||||
- (diff % CONFIG_INTEGER(config_look_input_cursor_scroll)));
|
||||
}
|
||||
|
||||
|
||||
/* compute new start for displaying input */
|
||||
new_start_input = pos_after_start_input + gui_chat_string_real_pos (pos_after_start_input, diff);
|
||||
if (new_start_input > pos_cursor)
|
||||
new_start_input = pos_cursor;
|
||||
|
||||
|
||||
buf = malloc (strlen (items[line]) + length_start_input_hidden + 1);
|
||||
if (buf)
|
||||
{
|
||||
@@ -597,7 +597,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
/* add input (will be displayed) */
|
||||
size = strlen (new_start_input) + 1;
|
||||
memmove (buf + index, new_start_input, size);
|
||||
|
||||
|
||||
free (items[line]);
|
||||
items[line] = buf;
|
||||
}
|
||||
@@ -605,7 +605,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((bar_window->scroll_y == 0)
|
||||
|| (line >= bar_window->scroll_y))
|
||||
{
|
||||
@@ -618,7 +618,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
{
|
||||
some_data_not_displayed = 1;
|
||||
}
|
||||
|
||||
|
||||
if (x < bar_window->width)
|
||||
{
|
||||
if (filling == GUI_BAR_FILLING_HORIZONTAL)
|
||||
@@ -644,7 +644,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
&index_line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
@@ -706,7 +706,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
|
||||
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* move cursor if it was asked in an item content (input_text does that
|
||||
* to move cursor in user input text)
|
||||
@@ -729,7 +729,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
}
|
||||
else
|
||||
wnoutrefresh (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar);
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SEPARATOR]))
|
||||
{
|
||||
separator_horizontal = ACS_HLINE;
|
||||
@@ -779,7 +779,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
}
|
||||
wnoutrefresh (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator);
|
||||
}
|
||||
|
||||
|
||||
refresh ();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,22 +67,22 @@ int
|
||||
gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
{
|
||||
struct t_gui_line *last_read_line;
|
||||
|
||||
|
||||
/* marker is disabled in config? */
|
||||
if (CONFIG_INTEGER(config_look_read_marker) != CONFIG_LOOK_READ_MARKER_LINE)
|
||||
return 0;
|
||||
|
||||
|
||||
/* marker is not set for buffer? */
|
||||
if (!buffer->lines->last_read_line)
|
||||
return 0;
|
||||
|
||||
|
||||
last_read_line = buffer->lines->last_read_line;
|
||||
if (!last_read_line->data->displayed)
|
||||
last_read_line = gui_line_get_prev_displayed (last_read_line);
|
||||
|
||||
|
||||
if (!last_read_line)
|
||||
return 0;
|
||||
|
||||
|
||||
while (line)
|
||||
{
|
||||
if (last_read_line == line)
|
||||
@@ -91,10 +91,10 @@ gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
return 1;
|
||||
return (gui_line_get_next_displayed (line) != NULL) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
if (line->data->displayed)
|
||||
break;
|
||||
|
||||
|
||||
line = line->next_line;
|
||||
}
|
||||
return 0;
|
||||
@@ -112,7 +112,7 @@ gui_chat_reset_style (struct t_gui_window *window, struct t_gui_line *line,
|
||||
int color_default)
|
||||
{
|
||||
int color;
|
||||
|
||||
|
||||
color = color_default;
|
||||
if ((window != gui_current_window) &&
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_window))
|
||||
@@ -124,7 +124,7 @@ gui_chat_reset_style (struct t_gui_window *window, struct t_gui_line *line,
|
||||
{
|
||||
color = color_inactive_buffer;
|
||||
}
|
||||
|
||||
|
||||
if (reset_attributes)
|
||||
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat, color);
|
||||
else
|
||||
@@ -166,7 +166,7 @@ gui_chat_display_horizontal_line (struct t_gui_window *window, int simulate)
|
||||
{
|
||||
int x, size_on_screen;
|
||||
char *read_marker_string, *default_string = "- ";
|
||||
|
||||
|
||||
if (!simulate)
|
||||
{
|
||||
gui_window_coords_init_line (window, window->win_chat_cursor_y);
|
||||
@@ -218,7 +218,7 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
|
||||
apply_style = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while (string[0])
|
||||
{
|
||||
switch (string[0])
|
||||
@@ -320,7 +320,7 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* nothing found except color/attrib codes, so return NULL */
|
||||
return NULL;
|
||||
}
|
||||
@@ -339,17 +339,17 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
|
||||
{
|
||||
char *next_char, *output, utf_char[16];
|
||||
int x, chars_displayed, display_char, size_on_screen;
|
||||
|
||||
|
||||
if (display)
|
||||
{
|
||||
wmove (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
window->win_chat_cursor_y,
|
||||
window->win_chat_cursor_x);
|
||||
}
|
||||
|
||||
|
||||
chars_displayed = 0;
|
||||
x = window->win_chat_cursor_x;
|
||||
|
||||
|
||||
while (string && string[0])
|
||||
{
|
||||
string = gui_chat_string_next_char (window, line,
|
||||
@@ -357,7 +357,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
|
||||
apply_style_inactive);
|
||||
if (!string)
|
||||
return chars_displayed;
|
||||
|
||||
|
||||
next_char = utf8_next_char (string);
|
||||
if (display && next_char)
|
||||
{
|
||||
@@ -365,10 +365,10 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
|
||||
utf_char[next_char - string] = '\0';
|
||||
if (!gui_chat_utf_char_valid (utf_char))
|
||||
snprintf (utf_char, sizeof (utf_char), " ");
|
||||
|
||||
|
||||
display_char = (window->buffer->type != GUI_BUFFER_TYPE_FREE)
|
||||
|| (x >= window->scroll->start_col);
|
||||
|
||||
|
||||
size_on_screen = utf8_strlen_screen (utf_char);
|
||||
if ((max_chars_on_screen > 0)
|
||||
&& (chars_displayed + size_on_screen > max_chars_on_screen))
|
||||
@@ -386,10 +386,10 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
|
||||
}
|
||||
x += size_on_screen;
|
||||
}
|
||||
|
||||
|
||||
string = next_char;
|
||||
}
|
||||
|
||||
|
||||
return chars_displayed;
|
||||
}
|
||||
|
||||
@@ -412,25 +412,25 @@ gui_chat_display_word (struct t_gui_window *window,
|
||||
attr_t *ptr_attrs;
|
||||
short pair;
|
||||
short *ptr_pair;
|
||||
|
||||
|
||||
if (!word ||
|
||||
((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height)))
|
||||
return;
|
||||
|
||||
|
||||
if (!simulate && (window->win_chat_cursor_y < window->coords_size))
|
||||
window->coords[window->win_chat_cursor_y].line = line;
|
||||
|
||||
|
||||
data = strdup (word);
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
|
||||
end_line = data + strlen (data);
|
||||
|
||||
|
||||
if (word_end && word_end[0])
|
||||
data[word_end - word] = '\0';
|
||||
else
|
||||
word_end = NULL;
|
||||
|
||||
|
||||
ptr_data = data;
|
||||
while (ptr_data && ptr_data[0])
|
||||
{
|
||||
@@ -483,7 +483,7 @@ gui_chat_display_word (struct t_gui_window *window,
|
||||
if (window->win_chat_cursor_y < window->coords_size)
|
||||
window->coords[window->win_chat_cursor_y].data = (char *)word + (ptr_data - data);
|
||||
}
|
||||
|
||||
|
||||
chars_to_display = gui_chat_strlen_screen (ptr_data);
|
||||
|
||||
/* too long for current line */
|
||||
@@ -527,9 +527,9 @@ gui_chat_display_word (struct t_gui_window *window,
|
||||
}
|
||||
ptr_data += strlen (ptr_data);
|
||||
}
|
||||
|
||||
|
||||
window->win_chat_cursor_x += num_displayed;
|
||||
|
||||
|
||||
/* display new line? */
|
||||
if ((!prefix && (ptr_data >= end_line)) ||
|
||||
(((simulate) ||
|
||||
@@ -537,12 +537,12 @@ gui_chat_display_word (struct t_gui_window *window,
|
||||
(window->win_chat_cursor_x > (gui_chat_get_real_width (window) - 1))))
|
||||
gui_chat_display_new_line (window, num_lines, count,
|
||||
lines_displayed, simulate);
|
||||
|
||||
|
||||
if ((!prefix && (ptr_data >= end_line)) ||
|
||||
((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height)))
|
||||
ptr_data = NULL;
|
||||
}
|
||||
|
||||
|
||||
free (data);
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
const char *short_name;
|
||||
int i, length, length_allowed, num_spaces;
|
||||
struct t_gui_lines *mixed_lines;
|
||||
|
||||
|
||||
if (!simulate)
|
||||
{
|
||||
if (window->win_chat_cursor_y < window->coords_size)
|
||||
@@ -573,7 +573,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
GUI_COLOR_CHAT_INACTIVE_BUFFER,
|
||||
GUI_COLOR_CHAT);
|
||||
}
|
||||
|
||||
|
||||
/* display time */
|
||||
if (window->buffer->time_for_each_line
|
||||
&& (line->data->str_time && line->data->str_time[0]))
|
||||
@@ -586,7 +586,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_time));
|
||||
if (window->win_chat_cursor_y < window->coords_size)
|
||||
window->coords[window->win_chat_cursor_y].time_x2 = window->win_chat_cursor_x - 1;
|
||||
|
||||
|
||||
if (!simulate)
|
||||
{
|
||||
gui_chat_reset_style (window, line, 1,
|
||||
@@ -599,7 +599,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
simulate,
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_time));
|
||||
}
|
||||
|
||||
|
||||
/* display buffer name (if many buffers are merged) */
|
||||
mixed_lines = line->data->buffer->mixed_lines;
|
||||
if (mixed_lines)
|
||||
@@ -617,7 +617,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
short_name = gui_buffer_get_short_name (line->data->buffer);
|
||||
length = gui_chat_strlen_screen (short_name);
|
||||
num_spaces = length_allowed - length;
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_RIGHT)
|
||||
{
|
||||
if (!simulate)
|
||||
@@ -635,7 +635,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_prefix_buffer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!simulate)
|
||||
{
|
||||
gui_chat_reset_style (window, line, 1,
|
||||
@@ -647,10 +647,10 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
GUI_COLOR_CHAT_PREFIX_BUFFER,
|
||||
GUI_COLOR_CHAT_PREFIX_BUFFER);
|
||||
}
|
||||
|
||||
|
||||
if (window->win_chat_cursor_y < window->coords_size)
|
||||
window->coords[window->win_chat_cursor_y].buffer_x1 = window->win_chat_cursor_x;
|
||||
|
||||
|
||||
/* not enough space to display full buffer name? => truncate it! */
|
||||
if ((CONFIG_INTEGER(config_look_prefix_buffer_align) != CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE)
|
||||
&& (num_spaces < 0))
|
||||
@@ -671,10 +671,10 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
lines_displayed, simulate,
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_prefix_buffer));
|
||||
}
|
||||
|
||||
|
||||
if (window->win_chat_cursor_y < window->coords_size)
|
||||
window->coords[window->win_chat_cursor_y].buffer_x2 = window->win_chat_cursor_x - 1;
|
||||
|
||||
|
||||
if ((CONFIG_INTEGER(config_look_prefix_buffer_align) != CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE)
|
||||
&& (num_spaces < 0))
|
||||
{
|
||||
@@ -720,7 +720,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* display prefix */
|
||||
if (line->data->prefix
|
||||
&& (line->data->prefix[0]
|
||||
@@ -733,7 +733,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
GUI_COLOR_CHAT_INACTIVE_BUFFER,
|
||||
GUI_COLOR_CHAT);
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(config_look_prefix_align_max) > 0)
|
||||
{
|
||||
length_allowed =
|
||||
@@ -742,9 +742,9 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
}
|
||||
else
|
||||
length_allowed = window->buffer->lines->prefix_max_length;
|
||||
|
||||
|
||||
num_spaces = length_allowed - line->data->prefix_length;
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_RIGHT)
|
||||
{
|
||||
for (i = 0; i < num_spaces; i++)
|
||||
@@ -755,7 +755,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_prefix));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
prefix_highlighted = NULL;
|
||||
if (line->data->highlight)
|
||||
{
|
||||
@@ -798,10 +798,10 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
GUI_COLOR_CHAT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (window->win_chat_cursor_y < window->coords_size)
|
||||
window->coords[window->win_chat_cursor_y].prefix_x1 = window->win_chat_cursor_x;
|
||||
|
||||
|
||||
/* not enough space to display full prefix? => truncate it! */
|
||||
if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
|
||||
&& (num_spaces < 0))
|
||||
@@ -825,13 +825,13 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
simulate,
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_prefix));
|
||||
}
|
||||
|
||||
|
||||
if (window->win_chat_cursor_y < window->coords_size)
|
||||
window->coords[window->win_chat_cursor_y].prefix_x2 = window->win_chat_cursor_x - 1;
|
||||
|
||||
|
||||
if (prefix_highlighted)
|
||||
free (prefix_highlighted);
|
||||
|
||||
|
||||
if (!simulate)
|
||||
{
|
||||
gui_chat_reset_style (window, line, 1,
|
||||
@@ -839,7 +839,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
GUI_COLOR_CHAT_INACTIVE_BUFFER,
|
||||
GUI_COLOR_CHAT);
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_LEFT)
|
||||
{
|
||||
for (i = 0; i < num_spaces; i++)
|
||||
@@ -916,10 +916,10 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
int word_length_with_spaces, word_length;
|
||||
char *ptr_data, *ptr_end_offset, *next_char;
|
||||
char *ptr_style, *message_with_tags;
|
||||
|
||||
|
||||
if (!line)
|
||||
return 0;
|
||||
|
||||
|
||||
if (simulate)
|
||||
{
|
||||
x = window->win_chat_cursor_x;
|
||||
@@ -938,18 +938,18 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
window->win_chat_cursor_x = x;
|
||||
window->win_chat_cursor_y = y;
|
||||
}
|
||||
|
||||
|
||||
/* calculate marker position (maybe not used for this line!) */
|
||||
if (window->buffer->time_for_each_line && line->data->str_time)
|
||||
read_marker_x = x + gui_chat_strlen_screen (line->data->str_time);
|
||||
else
|
||||
read_marker_x = x;
|
||||
read_marker_y = y;
|
||||
|
||||
|
||||
lines_displayed = 0;
|
||||
|
||||
|
||||
marker_line = gui_chat_marker_for_line (window->buffer, line);
|
||||
|
||||
|
||||
/* display time and prefix */
|
||||
gui_chat_display_time_to_prefix (window, line, num_lines, count,
|
||||
&lines_displayed, simulate);
|
||||
@@ -959,7 +959,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
window->coords[window->win_chat_cursor_y].data = line->data->message;
|
||||
window->coords_x_message = window->win_chat_cursor_x;
|
||||
}
|
||||
|
||||
|
||||
/* reset color & style for a new line */
|
||||
if (!simulate)
|
||||
{
|
||||
@@ -978,7 +978,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
GUI_COLOR_CHAT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!line->data->message || !line->data->message[0])
|
||||
{
|
||||
gui_chat_display_new_line (window, num_lines, count,
|
||||
@@ -997,9 +997,9 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
&word_start_offset,
|
||||
&word_end_offset,
|
||||
&word_length_with_spaces, &word_length);
|
||||
|
||||
|
||||
ptr_end_offset = ptr_data + word_end_offset;
|
||||
|
||||
|
||||
if (word_length > 0)
|
||||
{
|
||||
/* spaces + word too long for current line but ok for next line */
|
||||
@@ -1029,14 +1029,14 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
/* jump to start of word */
|
||||
ptr_data += word_start_offset;
|
||||
}
|
||||
|
||||
|
||||
/* display word */
|
||||
gui_chat_display_word (window, line, ptr_data,
|
||||
ptr_end_offset + 1,
|
||||
0, num_lines, count, &lines_displayed,
|
||||
simulate,
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_message));
|
||||
|
||||
|
||||
if ((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height))
|
||||
ptr_data = NULL;
|
||||
else
|
||||
@@ -1045,7 +1045,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
ptr_data = ptr_end_offset + 1;
|
||||
if (*(ptr_data - 1) == '\0')
|
||||
ptr_data = NULL;
|
||||
|
||||
|
||||
if (window->win_chat_cursor_x == 0)
|
||||
{
|
||||
while (ptr_data && (ptr_data[0] == ' '))
|
||||
@@ -1071,14 +1071,14 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
if (message_with_tags)
|
||||
free (message_with_tags);
|
||||
}
|
||||
|
||||
|
||||
if (marker_line)
|
||||
{
|
||||
gui_chat_display_horizontal_line (window, simulate);
|
||||
gui_chat_display_new_line (window, num_lines, count,
|
||||
&lines_displayed, simulate);
|
||||
}
|
||||
|
||||
|
||||
if (simulate)
|
||||
{
|
||||
window->win_chat_cursor_x = x;
|
||||
@@ -1114,7 +1114,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return lines_displayed;
|
||||
}
|
||||
|
||||
@@ -1132,15 +1132,15 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
|
||||
GUI_COLOR_CHAT_INACTIVE_WINDOW,
|
||||
GUI_COLOR_CHAT_INACTIVE_BUFFER,
|
||||
GUI_COLOR_CHAT);
|
||||
|
||||
|
||||
window->win_chat_cursor_x = 0;
|
||||
window->win_chat_cursor_y = y;
|
||||
|
||||
|
||||
wmove (GUI_WINDOW_OBJECTS(window)->win_chat,
|
||||
window->win_chat_cursor_y,
|
||||
window->win_chat_cursor_x);
|
||||
wclrtoeol (GUI_WINDOW_OBJECTS(window)->win_chat);
|
||||
|
||||
|
||||
if (gui_chat_display_word_raw (window, line, line->data->message,
|
||||
window->win_chat_width, 1,
|
||||
CONFIG_BOOLEAN(config_look_color_inactive_message)) < window->win_chat_width)
|
||||
@@ -1160,12 +1160,12 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
|
||||
int difference)
|
||||
{
|
||||
int backward, current_size;
|
||||
|
||||
|
||||
if (!line || !line_pos)
|
||||
return;
|
||||
|
||||
|
||||
backward = (difference < 0);
|
||||
|
||||
|
||||
if (!(*line))
|
||||
{
|
||||
/* if looking backward, start at last line of buffer */
|
||||
@@ -1191,7 +1191,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
|
||||
}
|
||||
else
|
||||
current_size = gui_chat_display_line (window, *line, 0, 1);
|
||||
|
||||
|
||||
while ((*line) && (difference != 0))
|
||||
{
|
||||
/* looking backward */
|
||||
@@ -1231,7 +1231,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
|
||||
difference--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* first or last line reached */
|
||||
if (!(*line))
|
||||
{
|
||||
@@ -1261,21 +1261,21 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
char format_empty[32];
|
||||
int i, line_pos, count, old_scrolling, old_lines_after;
|
||||
int y_start, y_end, y;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->buffer->number == buffer->number)
|
||||
{
|
||||
gui_window_coords_alloc (ptr_win);
|
||||
|
||||
|
||||
gui_chat_reset_style (ptr_win, NULL, 1,
|
||||
GUI_COLOR_CHAT_INACTIVE_WINDOW,
|
||||
GUI_COLOR_CHAT_INACTIVE_BUFFER,
|
||||
GUI_COLOR_CHAT);
|
||||
|
||||
|
||||
if (erase)
|
||||
{
|
||||
snprintf (format_empty, 32, "%%-%ds", ptr_win->win_chat_width);
|
||||
@@ -1285,10 +1285,10 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
format_empty, " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_win->win_chat_cursor_x = 0;
|
||||
ptr_win->win_chat_cursor_y = 0;
|
||||
|
||||
|
||||
switch (ptr_win->buffer->type)
|
||||
{
|
||||
case GUI_BUFFER_TYPE_FORMATTED:
|
||||
@@ -1306,9 +1306,9 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
gui_chat_calculate_line_diff (ptr_win, &ptr_line, &line_pos,
|
||||
(-1) * (ptr_win->win_chat_height - 1));
|
||||
}
|
||||
|
||||
|
||||
count = 0;
|
||||
|
||||
|
||||
if (line_pos > 0)
|
||||
{
|
||||
/* display end of first line at top of screen */
|
||||
@@ -1323,19 +1323,19 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
else
|
||||
ptr_win->scroll->first_line_displayed =
|
||||
(ptr_line == gui_line_get_first_displayed (ptr_win->buffer));
|
||||
|
||||
|
||||
/* display lines */
|
||||
while (ptr_line && (ptr_win->win_chat_cursor_y <= ptr_win->win_chat_height - 1))
|
||||
{
|
||||
count = gui_chat_display_line (ptr_win, ptr_line, 0, 0);
|
||||
ptr_line = gui_line_get_next_displayed (ptr_line);
|
||||
}
|
||||
|
||||
|
||||
old_scrolling = ptr_win->scroll->scrolling;
|
||||
old_lines_after = ptr_win->scroll->lines_after;
|
||||
|
||||
|
||||
ptr_win->scroll->scrolling = (ptr_win->win_chat_cursor_y > ptr_win->win_chat_height - 1);
|
||||
|
||||
|
||||
/* check if last line of buffer is entirely displayed and scrolling */
|
||||
/* if so, disable scroll indicator */
|
||||
if (!ptr_line && ptr_win->scroll->scrolling)
|
||||
@@ -1344,14 +1344,14 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
|| (count == ptr_win->win_chat_height))
|
||||
ptr_win->scroll->scrolling = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!ptr_win->scroll->scrolling
|
||||
&& (ptr_win->scroll->start_line == gui_line_get_first_displayed (ptr_win->buffer)))
|
||||
{
|
||||
ptr_win->scroll->start_line = NULL;
|
||||
ptr_win->scroll->start_line_pos = 0;
|
||||
}
|
||||
|
||||
|
||||
ptr_win->scroll->lines_after = 0;
|
||||
if (ptr_win->scroll->scrolling && ptr_line)
|
||||
{
|
||||
@@ -1364,30 +1364,30 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
}
|
||||
ptr_win->scroll->lines_after++;
|
||||
}
|
||||
|
||||
|
||||
if ((ptr_win->scroll->scrolling != old_scrolling)
|
||||
|| (ptr_win->scroll->lines_after != old_lines_after))
|
||||
{
|
||||
hook_signal_send ("window_scrolled",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, ptr_win);
|
||||
}
|
||||
|
||||
|
||||
if (!ptr_win->scroll->scrolling
|
||||
&& ptr_win->scroll->reset_allowed)
|
||||
{
|
||||
ptr_win->scroll->start_line = NULL;
|
||||
ptr_win->scroll->start_line_pos = 0;
|
||||
}
|
||||
|
||||
|
||||
/* cursor is below end line of chat window? */
|
||||
if (ptr_win->win_chat_cursor_y > ptr_win->win_chat_height - 1)
|
||||
{
|
||||
ptr_win->win_chat_cursor_x = 0;
|
||||
ptr_win->win_chat_cursor_y = ptr_win->win_chat_height - 1;
|
||||
}
|
||||
|
||||
|
||||
ptr_win->scroll->reset_allowed = 0;
|
||||
|
||||
|
||||
break;
|
||||
case GUI_BUFFER_TYPE_FREE:
|
||||
/* display at position of scrolling */
|
||||
@@ -1425,9 +1425,9 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
wnoutrefresh (GUI_WINDOW_OBJECTS(ptr_win)->win_chat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
refresh ();
|
||||
|
||||
|
||||
if (buffer->type == GUI_BUFFER_TYPE_FREE)
|
||||
{
|
||||
for (ptr_line = buffer->lines->first_line; ptr_line;
|
||||
@@ -1436,7 +1436,7 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
ptr_line->data->refresh_needed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
buffer->chat_refresh_needed = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ gui_color_assign (int *color, const char *color_name)
|
||||
{
|
||||
int flag, extra_attr, color_index, number;
|
||||
char *error;
|
||||
|
||||
|
||||
/* read extended attributes */
|
||||
extra_attr = 0;
|
||||
while ((flag = gui_color_attr_get_flag (color_name[0])) > 0)
|
||||
@@ -152,7 +152,7 @@ gui_color_assign (int *color, const char *color_name)
|
||||
extra_attr |= flag;
|
||||
color_name++;
|
||||
}
|
||||
|
||||
|
||||
/* is it a color alias? */
|
||||
number = gui_color_palette_get_alias (color_name);
|
||||
if (number >= 0)
|
||||
@@ -160,7 +160,7 @@ gui_color_assign (int *color, const char *color_name)
|
||||
*color = number | GUI_COLOR_EXTENDED_FLAG | extra_attr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* is it a color number? */
|
||||
error = NULL;
|
||||
number = (int)strtol (color_name, &error, 10);
|
||||
@@ -182,7 +182,7 @@ gui_color_assign (int *color, const char *color_name)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* color not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -202,15 +202,15 @@ gui_color_assign_by_diff (int *color, const char *color_name, int diff)
|
||||
int index, list_size;
|
||||
struct t_weelist_item *ptr_item;
|
||||
const char *name;
|
||||
|
||||
|
||||
index = weelist_search_pos (gui_color_list_with_alias, color_name);
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
|
||||
|
||||
list_size = weelist_size (gui_color_list_with_alias);
|
||||
|
||||
|
||||
diff = diff % (list_size + 1);
|
||||
|
||||
|
||||
if (diff > 0)
|
||||
{
|
||||
index = (index + diff) % (list_size + 1);
|
||||
@@ -227,14 +227,14 @@ gui_color_assign_by_diff (int *color, const char *color_name, int diff)
|
||||
index += list_size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_item = weelist_get (gui_color_list_with_alias, index);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
name = weelist_string (ptr_item);
|
||||
if (name)
|
||||
return gui_color_assign (color, name);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -269,26 +269,26 @@ void
|
||||
gui_color_get_pairs_arrays (short **foregrounds, short **backgrounds)
|
||||
{
|
||||
int i, fg, bg, index;
|
||||
|
||||
|
||||
if (!foregrounds || !backgrounds)
|
||||
return;
|
||||
|
||||
|
||||
*foregrounds = NULL;
|
||||
*backgrounds = NULL;
|
||||
|
||||
|
||||
*foregrounds = malloc (sizeof (*foregrounds[0]) * (gui_color_num_pairs + 1));
|
||||
if (!*foregrounds)
|
||||
goto error;
|
||||
*backgrounds = malloc (sizeof (*backgrounds[0]) * (gui_color_num_pairs + 1));
|
||||
if (!*backgrounds)
|
||||
goto error;
|
||||
|
||||
|
||||
for (i = 0; i <= gui_color_num_pairs; i++)
|
||||
{
|
||||
(*foregrounds)[i] = -2;
|
||||
(*backgrounds)[i] = -2;
|
||||
}
|
||||
|
||||
|
||||
for (bg = -1; bg <= gui_color_term_colors; bg++)
|
||||
{
|
||||
for (fg = -1; fg <= gui_color_term_colors; fg++)
|
||||
@@ -302,7 +302,7 @@ gui_color_get_pairs_arrays (short **foregrounds, short **backgrounds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
@@ -329,12 +329,12 @@ gui_color_timer_warning_pairs_full (void *data, int remaining_calls)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
gui_chat_printf (NULL,
|
||||
_("Warning: the %d color pairs are used, do "
|
||||
"\"/color reset\" to remove unused pairs"),
|
||||
gui_color_num_pairs);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -348,20 +348,20 @@ int
|
||||
gui_color_get_pair (int fg, int bg)
|
||||
{
|
||||
int index;
|
||||
|
||||
|
||||
/* only one color when displaying terminal colors */
|
||||
if (gui_color_use_term_colors)
|
||||
return COLOR_WHITE;
|
||||
|
||||
|
||||
/* if invalid color, use default fg/bg */
|
||||
if (fg > gui_color_term_colors)
|
||||
fg = -1;
|
||||
if (bg > gui_color_term_colors)
|
||||
bg = -1;
|
||||
|
||||
|
||||
/* compute index for gui_color_pairs with foreground and background */
|
||||
index = ((bg + 1) * (gui_color_term_colors + 2)) + (fg + 1);
|
||||
|
||||
|
||||
/* pair not allocated for this fg/bg? */
|
||||
if (gui_color_pairs[index] == 0)
|
||||
{
|
||||
@@ -378,7 +378,7 @@ gui_color_get_pair (int fg, int bg)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* create a new pair if no pair exists for this fg/bg */
|
||||
gui_color_pairs_used++;
|
||||
gui_color_pairs[index] = gui_color_pairs_used;
|
||||
@@ -391,7 +391,7 @@ gui_color_get_pair (int fg, int bg)
|
||||
}
|
||||
gui_color_buffer_refresh_needed = 1;
|
||||
}
|
||||
|
||||
|
||||
return gui_color_pairs[index];
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ int
|
||||
gui_color_weechat_get_pair (int weechat_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
|
||||
if ((weechat_color < 0) || (weechat_color > GUI_COLOR_NUM_COLORS - 1))
|
||||
{
|
||||
fg = -1;
|
||||
@@ -413,13 +413,13 @@ gui_color_weechat_get_pair (int weechat_color)
|
||||
{
|
||||
fg = gui_color[weechat_color]->foreground;
|
||||
bg = gui_color[weechat_color]->background;
|
||||
|
||||
|
||||
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
|
||||
fg &= GUI_COLOR_EXTENDED_MASK;
|
||||
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
|
||||
bg &= GUI_COLOR_EXTENDED_MASK;
|
||||
}
|
||||
|
||||
|
||||
return gui_color_get_pair (fg, bg);
|
||||
}
|
||||
|
||||
@@ -434,14 +434,14 @@ gui_color_get_name (int num_color)
|
||||
static int index_color = 0;
|
||||
char str_attr[8];
|
||||
struct t_gui_color_palette *ptr_color_palette;
|
||||
|
||||
|
||||
/* init color string */
|
||||
index_color = (index_color + 1) % 16;
|
||||
color[index_color][0] = '\0';
|
||||
|
||||
|
||||
/* build string with extra-attributes */
|
||||
gui_color_attr_build_string (num_color, str_attr);
|
||||
|
||||
|
||||
if (num_color & GUI_COLOR_EXTENDED_FLAG)
|
||||
{
|
||||
/* search alias */
|
||||
@@ -466,7 +466,7 @@ gui_color_get_name (int num_color)
|
||||
str_attr,
|
||||
gui_weechat_colors[num_color & GUI_COLOR_EXTENDED_MASK].string);
|
||||
}
|
||||
|
||||
|
||||
return color[index_color];
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ gui_color_build (int number, int foreground, int background)
|
||||
foreground = 0;
|
||||
if (background < 0)
|
||||
background = 0;
|
||||
|
||||
|
||||
/* allocate color */
|
||||
if (!gui_color[number])
|
||||
{
|
||||
@@ -493,7 +493,7 @@ gui_color_build (int number, int foreground, int background)
|
||||
return;
|
||||
gui_color[number]->string = malloc (4);
|
||||
}
|
||||
|
||||
|
||||
/* set foreground and attributes */
|
||||
if (foreground & GUI_COLOR_EXTENDED_FLAG)
|
||||
{
|
||||
@@ -511,13 +511,13 @@ gui_color_build (int number, int foreground, int background)
|
||||
gui_color[number]->attributes |= A_REVERSE;
|
||||
if (foreground & GUI_COLOR_EXTENDED_UNDERLINE_FLAG)
|
||||
gui_color[number]->attributes |= A_UNDERLINE;
|
||||
|
||||
|
||||
/* set background */
|
||||
if (background & GUI_COLOR_EXTENDED_FLAG)
|
||||
gui_color[number]->background = background & GUI_COLOR_EXTENDED_MASK;
|
||||
else
|
||||
gui_color[number]->background = gui_weechat_colors[background & GUI_COLOR_EXTENDED_MASK].background;
|
||||
|
||||
|
||||
/* set string */
|
||||
if (gui_color[number]->string)
|
||||
{
|
||||
@@ -535,7 +535,7 @@ void
|
||||
gui_color_init_vars ()
|
||||
{
|
||||
int size;
|
||||
|
||||
|
||||
gui_color_term_has_colors = (has_colors ()) ? 1 : 0;
|
||||
gui_color_term_colors = 0;
|
||||
gui_color_term_color_pairs = 0;
|
||||
@@ -547,13 +547,13 @@ gui_color_init_vars ()
|
||||
gui_color_pairs = NULL;
|
||||
}
|
||||
gui_color_pairs_used = 0;
|
||||
|
||||
|
||||
if (gui_color_term_has_colors)
|
||||
{
|
||||
gui_color_term_colors = COLORS;
|
||||
gui_color_term_color_pairs = COLOR_PAIRS;
|
||||
gui_color_term_can_change_color = (can_change_color ()) ? 1 : 0;
|
||||
|
||||
|
||||
gui_color_num_pairs = (gui_color_term_color_pairs >= 256) ?
|
||||
255 : gui_color_term_color_pairs - 1;
|
||||
size = (gui_color_term_colors + 2)
|
||||
@@ -563,7 +563,7 @@ gui_color_init_vars ()
|
||||
if (gui_color_pairs)
|
||||
memset (gui_color_pairs, 0, size);
|
||||
gui_color_pairs_used = 0;
|
||||
|
||||
|
||||
/* reserved for future usage */
|
||||
/*
|
||||
gui_color_term_color_content = malloc (sizeof (gui_color_term_color_content[0]) *
|
||||
@@ -621,7 +621,7 @@ void
|
||||
gui_color_init_pairs_terminal ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (gui_color_term_has_colors)
|
||||
{
|
||||
for (i = 1; i <= gui_color_num_pairs; i++)
|
||||
@@ -644,7 +644,7 @@ gui_color_init_pairs_weechat ()
|
||||
{
|
||||
int i;
|
||||
short *foregrounds, *backgrounds;
|
||||
|
||||
|
||||
if (gui_color_term_has_colors)
|
||||
{
|
||||
gui_color_get_pairs_arrays (&foregrounds, &backgrounds);
|
||||
@@ -676,7 +676,7 @@ gui_color_display_terminal_colors ()
|
||||
{
|
||||
int lines, line, col, color;
|
||||
char str_line[1024], str_color[64];
|
||||
|
||||
|
||||
initscr ();
|
||||
if (has_colors ())
|
||||
{
|
||||
@@ -754,12 +754,12 @@ gui_color_buffer_display ()
|
||||
int y, i, lines, line, col, color, max_color, num_items;
|
||||
char str_line[1024], str_color[64], str_rgb[64], **items;
|
||||
struct t_gui_color_palette *color_palette;
|
||||
|
||||
|
||||
if (!gui_color_buffer)
|
||||
return;
|
||||
|
||||
|
||||
gui_buffer_clear (gui_color_buffer);
|
||||
|
||||
|
||||
/* set title buffer */
|
||||
gui_buffer_set_title (gui_color_buffer,
|
||||
_("WeeChat colors | Actions: "
|
||||
@@ -767,7 +767,7 @@ gui_color_buffer_display ()
|
||||
"[z] Reset colors [q] Close buffer | "
|
||||
"Keys: [alt-c] Temporarily switch to terminal "
|
||||
"colors"));
|
||||
|
||||
|
||||
/* display terminal/colors infos */
|
||||
y = 0;
|
||||
gui_chat_printf_y (gui_color_buffer, y++,
|
||||
@@ -777,7 +777,7 @@ gui_color_buffer_display ()
|
||||
gui_color_term_colors,
|
||||
gui_color_term_color_pairs,
|
||||
(gui_color_term_can_change_color) ? "yes" : "no");
|
||||
|
||||
|
||||
/* display palette of colors */
|
||||
y++;
|
||||
if (gui_color_use_term_colors)
|
||||
@@ -851,7 +851,7 @@ gui_color_buffer_display ()
|
||||
_("Last auto reset of pairs: %s"),
|
||||
(gui_color_pairs_auto_reset_last == 0) ?
|
||||
"-" : ctime (&gui_color_pairs_auto_reset_last));
|
||||
|
||||
|
||||
/* display WeeChat basic colors */
|
||||
y++;
|
||||
gui_chat_printf_y (gui_color_buffer, y++,
|
||||
@@ -887,7 +887,7 @@ gui_color_buffer_display ()
|
||||
gui_chat_printf_y (gui_color_buffer, y++,
|
||||
" %s", str_line);
|
||||
}
|
||||
|
||||
|
||||
/* display nick colors */
|
||||
y++;
|
||||
gui_chat_printf_y (gui_color_buffer, y++,
|
||||
@@ -927,7 +927,7 @@ gui_color_buffer_display ()
|
||||
}
|
||||
string_free_split (items);
|
||||
}
|
||||
|
||||
|
||||
/* display palette colors */
|
||||
if (hashtable_get_integer (gui_color_hash_palette_color,
|
||||
"items_count") > 0)
|
||||
@@ -969,7 +969,7 @@ gui_color_buffer_display ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* display content of colors */
|
||||
if (gui_color_term_color_content)
|
||||
{
|
||||
@@ -999,9 +999,9 @@ gui_color_timer_cb (void *data, int remaining_calls)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
gui_color_timer--;
|
||||
|
||||
|
||||
if (gui_color_timer <= 0)
|
||||
{
|
||||
if (gui_color_use_term_colors)
|
||||
@@ -1014,7 +1014,7 @@ gui_color_timer_cb (void *data, int remaining_calls)
|
||||
gui_color_buffer_display_timer ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ gui_color_switch_colors ()
|
||||
unhook (gui_color_hook_timer);
|
||||
gui_color_hook_timer = NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* when we press alt-c many times quickly, this just adds some time for
|
||||
* display of terminal colors
|
||||
@@ -1045,19 +1045,19 @@ gui_color_switch_colors ()
|
||||
else
|
||||
{
|
||||
gui_color_use_term_colors ^= 1;
|
||||
|
||||
|
||||
if (gui_color_use_term_colors)
|
||||
gui_color_init_pairs_terminal ();
|
||||
else
|
||||
gui_color_init_pairs_weechat ();
|
||||
|
||||
|
||||
gui_color_buffer_refresh_needed = 1;
|
||||
gui_window_ask_refresh (1);
|
||||
|
||||
if (gui_color_use_term_colors)
|
||||
gui_color_timer = GUI_COLOR_TIMER_TERM_COLORS;
|
||||
}
|
||||
|
||||
|
||||
if (gui_color_use_term_colors)
|
||||
{
|
||||
gui_color_hook_timer = hook_timer (NULL, 1000, 0, 0,
|
||||
@@ -1116,7 +1116,7 @@ gui_color_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
{
|
||||
gui_color_reset_pairs ();
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1130,9 +1130,9 @@ gui_color_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
gui_color_buffer = NULL;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1175,12 +1175,12 @@ gui_color_buffer_open ()
|
||||
gui_buffer_set (gui_color_buffer, "key_bind_meta-c", "/color switch");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!gui_color_buffer)
|
||||
return;
|
||||
|
||||
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_color_buffer, 1);
|
||||
|
||||
|
||||
gui_color_buffer_display ();
|
||||
}
|
||||
|
||||
@@ -1196,13 +1196,13 @@ gui_color_palette_add_alias_cb (void *data,
|
||||
struct t_gui_color_palette *color_palette;
|
||||
char *error;
|
||||
int number;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
color_palette = (struct t_gui_color_palette *)value;
|
||||
|
||||
|
||||
if (color_palette && color_palette->alias)
|
||||
{
|
||||
error = NULL;
|
||||
@@ -1226,13 +1226,13 @@ gui_color_palette_build_aliases ()
|
||||
int i;
|
||||
struct t_gui_color_palette *color_palette;
|
||||
char str_number[64];
|
||||
|
||||
|
||||
if (!gui_color_hash_palette_alias || !gui_color_list_with_alias
|
||||
|| !gui_color_hash_palette_color)
|
||||
{
|
||||
gui_color_palette_alloc_structs ();
|
||||
}
|
||||
|
||||
|
||||
hashtable_remove_all (gui_color_hash_palette_alias);
|
||||
weelist_remove_all (gui_color_list_with_alias);
|
||||
for (i = 0; i < GUI_CURSES_NUM_WEECHAT_COLORS; i++)
|
||||
@@ -1277,10 +1277,10 @@ gui_color_palette_new (int number, const char *value)
|
||||
char **items, *pos, *pos2, *error1, *error2, *error3;
|
||||
char *str_alias, *str_rgb, str_number[64];
|
||||
int num_items, i, r, g, b;
|
||||
|
||||
|
||||
if (!value)
|
||||
return NULL;
|
||||
|
||||
|
||||
new_color_palette = malloc (sizeof (*new_color_palette));
|
||||
if (new_color_palette)
|
||||
{
|
||||
@@ -1288,10 +1288,10 @@ gui_color_palette_new (int number, const char *value)
|
||||
new_color_palette->r = -1;
|
||||
new_color_palette->g = -1;
|
||||
new_color_palette->b = -1;
|
||||
|
||||
|
||||
str_alias = NULL;
|
||||
str_rgb = NULL;
|
||||
|
||||
|
||||
items = string_split (value, ";", 0, 0, &num_items);
|
||||
if (items)
|
||||
{
|
||||
@@ -1307,12 +1307,12 @@ gui_color_palette_new (int number, const char *value)
|
||||
str_alias = items[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (str_alias)
|
||||
{
|
||||
new_color_palette->alias = strdup (str_alias);
|
||||
}
|
||||
|
||||
|
||||
if (str_rgb)
|
||||
{
|
||||
pos = strchr (str_rgb, '/');
|
||||
@@ -1350,7 +1350,7 @@ gui_color_palette_new (int number, const char *value)
|
||||
new_color_palette->alias = strdup (str_number);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_color_palette;
|
||||
}
|
||||
|
||||
@@ -1363,10 +1363,10 @@ gui_color_palette_free (struct t_gui_color_palette *color_palette)
|
||||
{
|
||||
if (!color_palette)
|
||||
return;
|
||||
|
||||
|
||||
if (color_palette->alias)
|
||||
free (color_palette->alias);
|
||||
|
||||
|
||||
free (color_palette);
|
||||
}
|
||||
|
||||
@@ -1386,9 +1386,9 @@ gui_color_init_weechat ()
|
||||
{
|
||||
gui_weechat_colors = gui_weechat_colors_no_bold;
|
||||
}
|
||||
|
||||
|
||||
gui_color_build (GUI_COLOR_SEPARATOR, CONFIG_COLOR(config_color_separator), CONFIG_COLOR(config_color_chat_bg));
|
||||
|
||||
|
||||
gui_color_build (GUI_COLOR_CHAT, CONFIG_COLOR(config_color_chat), CONFIG_COLOR(config_color_chat_bg));
|
||||
gui_color_build (GUI_COLOR_CHAT_TIME, CONFIG_COLOR(config_color_chat_time), CONFIG_COLOR(config_color_chat_bg));
|
||||
gui_color_build (GUI_COLOR_CHAT_TIME_DELIMITERS, CONFIG_COLOR(config_color_chat_time_delimiters), CONFIG_COLOR(config_color_chat_bg));
|
||||
@@ -1416,7 +1416,7 @@ gui_color_init_weechat ()
|
||||
gui_color_build (GUI_COLOR_CHAT_INACTIVE_WINDOW, CONFIG_COLOR(config_color_chat_inactive_window), CONFIG_COLOR(config_color_chat_bg));
|
||||
gui_color_build (GUI_COLOR_CHAT_INACTIVE_BUFFER, CONFIG_COLOR(config_color_chat_inactive_buffer), CONFIG_COLOR(config_color_chat_bg));
|
||||
gui_color_build (GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER, CONFIG_COLOR(config_color_chat_prefix_buffer_inactive_buffer), CONFIG_COLOR(config_color_chat_bg));
|
||||
|
||||
|
||||
/*
|
||||
* define old nick colors for compatibility on /upgrade with previous
|
||||
* versions: these colors have been removed in version 0.3.4 and replaced
|
||||
@@ -1443,7 +1443,7 @@ void
|
||||
gui_color_pre_init ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
|
||||
{
|
||||
gui_color[i] = NULL;
|
||||
@@ -1476,7 +1476,7 @@ void
|
||||
gui_color_dump ()
|
||||
{
|
||||
int fg, bg, index, used;
|
||||
|
||||
|
||||
gui_chat_printf (NULL, "");
|
||||
gui_chat_printf (NULL,
|
||||
_("WeeChat colors (in use: %d, left: %d):"),
|
||||
@@ -1510,7 +1510,7 @@ void
|
||||
gui_color_end ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
|
||||
{
|
||||
gui_color_free (gui_color[i]);
|
||||
|
||||
@@ -59,14 +59,14 @@ gui_key_default_bind (int context, const char *key, const char *command)
|
||||
{
|
||||
struct t_gui_key *ptr_key;
|
||||
char *internal_code;
|
||||
|
||||
|
||||
internal_code = gui_key_get_internal_code (key);
|
||||
|
||||
|
||||
ptr_key = gui_key_search (gui_keys[context],
|
||||
(internal_code) ? internal_code : key);
|
||||
if (!ptr_key)
|
||||
gui_key_new (NULL, context, key, command);
|
||||
|
||||
|
||||
if (internal_code)
|
||||
free (internal_code);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ gui_key_default_bindings (int context)
|
||||
BIND(/* m-< */ "meta-<", "/input jump_previously_visited_buffer");
|
||||
BIND(/* m-> */ "meta->", "/input jump_next_visited_buffer");
|
||||
BIND(/* m-m */ "meta-m", "/mouse toggle");
|
||||
|
||||
|
||||
/* bind meta-j + {01..99} to switch to buffers # > 10 */
|
||||
for (i = 1; i < 100; i++)
|
||||
{
|
||||
@@ -292,7 +292,7 @@ gui_key_flush ()
|
||||
static int length_key_str = 0;
|
||||
char key_temp[2], *key_utf, *input_old, *ptr_char, *next_char, *ptr_error;
|
||||
char utf_partial_char[16];
|
||||
|
||||
|
||||
/*
|
||||
* if there's no paste pending, then we use buffer and do actions
|
||||
* according to keys
|
||||
@@ -301,13 +301,13 @@ gui_key_flush ()
|
||||
{
|
||||
if (gui_key_buffer_size > 0)
|
||||
gui_key_last_activity_time = time (NULL);
|
||||
|
||||
|
||||
for (i = 0; i < gui_key_buffer_size; i++)
|
||||
{
|
||||
key = gui_key_buffer[i];
|
||||
insert_ok = 1;
|
||||
utf_partial_char[0] = '\0';
|
||||
|
||||
|
||||
if (gui_mouse_event_pending || (key < 32) || (key == 127))
|
||||
{
|
||||
if (gui_mouse_event_pending)
|
||||
@@ -340,7 +340,7 @@ gui_key_flush ()
|
||||
key_str[length_key_str] = (char)key;
|
||||
key_str[length_key_str + 1] = '\0';
|
||||
length_key_str++;
|
||||
|
||||
|
||||
/*
|
||||
* replace invalid chars by "?", but NOT last char of
|
||||
* string, if it is incomplete UTF-8 char (another char
|
||||
@@ -385,13 +385,13 @@ gui_key_flush ()
|
||||
{
|
||||
hook_signal_send ("key_pressed",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, key_str);
|
||||
|
||||
|
||||
if (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
|
||||
input_old = (gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
else
|
||||
input_old = NULL;
|
||||
|
||||
|
||||
if ((gui_key_pressed (key_str) != 0) && (insert_ok)
|
||||
&& (!gui_cursor_mode))
|
||||
{
|
||||
@@ -402,7 +402,7 @@ gui_key_flush ()
|
||||
gui_completion_stop (gui_current_window->buffer->completion, 0);
|
||||
gui_input_text_changed_modifier_and_signal (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
||||
|
||||
/* incremental text search in buffer */
|
||||
if ((gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
|
||||
&& ((input_old == NULL)
|
||||
@@ -436,11 +436,11 @@ gui_key_flush ()
|
||||
gui_window_search_restart (gui_current_window);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (input_old)
|
||||
free (input_old);
|
||||
}
|
||||
|
||||
|
||||
/* prepare incomplete UTF-8 char for next iteration */
|
||||
if (utf_partial_char[0])
|
||||
strcpy (key_str, utf_partial_char);
|
||||
@@ -448,7 +448,7 @@ gui_key_flush ()
|
||||
key_str[0] = '\0';
|
||||
length_key_str = strlen (key_str);
|
||||
}
|
||||
|
||||
|
||||
gui_key_buffer_reset ();
|
||||
}
|
||||
}
|
||||
@@ -462,11 +462,11 @@ gui_key_read_cb (void *data, int fd)
|
||||
{
|
||||
int ret, i, accept_paste, cancel_paste, text_added_to_buffer, paste_lines;
|
||||
unsigned char buffer[4096];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) fd;
|
||||
|
||||
|
||||
accept_paste = 0;
|
||||
cancel_paste = 0;
|
||||
text_added_to_buffer = 0;
|
||||
@@ -484,11 +484,11 @@ gui_key_read_cb (void *data, int fd)
|
||||
}
|
||||
if (ret <= 0)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* ctrl-Y: accept paste */
|
||||
if (buffer[0] == 25)
|
||||
accept_paste = 1;
|
||||
|
||||
|
||||
/* ctrl-N: cancel paste */
|
||||
if (buffer[0] == 14)
|
||||
cancel_paste = 1;
|
||||
@@ -506,7 +506,7 @@ gui_key_read_cb (void *data, int fd)
|
||||
}
|
||||
if (ret < 0)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
for (i = 0; i < ret; i++)
|
||||
{
|
||||
/* add all chars (ignore a '\n' after a '\r') */
|
||||
@@ -517,10 +517,10 @@ gui_key_read_cb (void *data, int fd)
|
||||
gui_key_buffer_add (buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
text_added_to_buffer = 1;
|
||||
}
|
||||
|
||||
|
||||
if (gui_key_paste_pending)
|
||||
{
|
||||
/* user is ok for pasting text, let's paste! */
|
||||
@@ -548,8 +548,8 @@ gui_key_read_cb (void *data, int fd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gui_key_flush ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -73,10 +73,10 @@ gui_main_pre_init (int *argc, char **argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
/* pre-init colors */
|
||||
gui_color_pre_init ();
|
||||
|
||||
|
||||
/* init some variables for chat area */
|
||||
gui_chat_init ();
|
||||
}
|
||||
@@ -91,68 +91,68 @@ gui_main_init ()
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
|
||||
|
||||
initscr ();
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(config_look_eat_newline_glitch))
|
||||
gui_term_set_eat_newline_glitch (0);
|
||||
|
||||
|
||||
curs_set (1);
|
||||
noecho ();
|
||||
nodelay (stdscr, TRUE);
|
||||
raw ();
|
||||
|
||||
|
||||
gui_color_init ();
|
||||
|
||||
|
||||
/* build prefixes according to config */
|
||||
gui_chat_prefix_build ();
|
||||
|
||||
|
||||
refresh ();
|
||||
|
||||
|
||||
gui_term_cols = COLS;
|
||||
gui_term_lines = LINES;
|
||||
|
||||
|
||||
gui_window_read_terminal_size ();
|
||||
|
||||
|
||||
/* init clipboard buffer */
|
||||
gui_input_clipboard = NULL;
|
||||
|
||||
|
||||
/* get time length */
|
||||
gui_chat_time_length = gui_chat_get_time_length ();
|
||||
|
||||
|
||||
/* init bar items */
|
||||
gui_bar_item_init ();
|
||||
|
||||
|
||||
gui_init_ok = 0;
|
||||
|
||||
|
||||
/* create core buffer */
|
||||
ptr_buffer = gui_buffer_new (NULL, GUI_BUFFER_MAIN,
|
||||
NULL, NULL, NULL, NULL);
|
||||
if (ptr_buffer)
|
||||
{
|
||||
gui_init_ok = 1;
|
||||
|
||||
|
||||
ptr_buffer->num_displayed = 1;
|
||||
|
||||
|
||||
/* set short name */
|
||||
if (!ptr_buffer->short_name)
|
||||
ptr_buffer->short_name = strdup (GUI_BUFFER_MAIN);
|
||||
|
||||
|
||||
/* set title for core buffer */
|
||||
gui_buffer_set_title (ptr_buffer,
|
||||
"WeeChat " PACKAGE_VERSION " "
|
||||
WEECHAT_COPYRIGHT_DATE " - " WEECHAT_WEBSITE);
|
||||
|
||||
|
||||
/* create main window (using full space) */
|
||||
if (gui_window_new (NULL, ptr_buffer, 0, 0,
|
||||
gui_term_cols, gui_term_lines, 100, 100))
|
||||
{
|
||||
gui_current_window = gui_windows;
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* create bar windows for root bars (they were read from config,
|
||||
* but no window was created, GUI was not initialized)
|
||||
@@ -172,7 +172,7 @@ gui_main_init ()
|
||||
gui_bar_window_create_win (ptr_bar_win);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(config_look_mouse))
|
||||
gui_mouse_enable ();
|
||||
else
|
||||
@@ -241,21 +241,21 @@ gui_main_refreshs ()
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* refresh color buffer if needed */
|
||||
if (gui_color_buffer_refresh_needed)
|
||||
{
|
||||
gui_color_buffer_display ();
|
||||
gui_color_buffer_refresh_needed = 0;
|
||||
}
|
||||
|
||||
|
||||
/* refresh window if needed */
|
||||
if (gui_window_refresh_needed)
|
||||
{
|
||||
gui_window_refresh_screen ((gui_window_refresh_needed > 1) ? 1 : 0);
|
||||
gui_window_refresh_needed = 0;
|
||||
}
|
||||
|
||||
|
||||
/* refresh bars if needed */
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
@@ -264,7 +264,7 @@ gui_main_refreshs ()
|
||||
gui_bar_draw (ptr_bar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* refresh windows if needed */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -275,7 +275,7 @@ gui_main_refreshs ()
|
||||
ptr_win->refresh_needed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* refresh chat buffers if needed */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
@@ -286,7 +286,7 @@ gui_main_refreshs ()
|
||||
(ptr_buffer->chat_refresh_needed) > 1 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* refresh bars if needed */
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
@@ -295,7 +295,7 @@ gui_main_refreshs ()
|
||||
gui_bar_draw (ptr_bar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* move cursor (for cursor mode) */
|
||||
if (gui_cursor_mode)
|
||||
gui_window_move_cursor ();
|
||||
@@ -313,25 +313,25 @@ gui_main_loop ()
|
||||
fd_set read_fds, write_fds, except_fds;
|
||||
int max_fd;
|
||||
int ready;
|
||||
|
||||
|
||||
weechat_quit = 0;
|
||||
|
||||
|
||||
/* catch SIGTERM signal: quit program */
|
||||
util_catch_signal (SIGTERM, &gui_main_signal_sigterm);
|
||||
util_catch_signal (SIGQUIT, &gui_main_signal_sigquit);
|
||||
|
||||
|
||||
/* catch SIGHUP signal: reload configuration */
|
||||
util_catch_signal (SIGHUP, &gui_main_signal_sighup);
|
||||
|
||||
|
||||
/* catch SIGWINCH signal: redraw screen */
|
||||
util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch);
|
||||
|
||||
|
||||
/* hook stdin (read keyboard) */
|
||||
hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0,
|
||||
&gui_key_read_cb, NULL);
|
||||
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
|
||||
|
||||
while (!weechat_quit)
|
||||
{
|
||||
/* reload config, if SIGHUP reveived */
|
||||
@@ -342,7 +342,7 @@ gui_main_loop ()
|
||||
"files"));
|
||||
command_reload (NULL, NULL, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* execute hook timers */
|
||||
hook_timer_exec ();
|
||||
|
||||
@@ -354,13 +354,13 @@ gui_main_loop ()
|
||||
gui_color_pairs_auto_reset = 0;
|
||||
gui_color_pairs_auto_reset_pending = 1;
|
||||
}
|
||||
|
||||
|
||||
gui_main_refreshs ();
|
||||
if (gui_window_refresh_needed)
|
||||
gui_main_refreshs ();
|
||||
|
||||
|
||||
gui_color_pairs_auto_reset_pending = 0;
|
||||
|
||||
|
||||
/* wait for keyboard or network activity */
|
||||
FD_ZERO (&read_fds);
|
||||
FD_ZERO (&write_fds);
|
||||
@@ -374,7 +374,7 @@ gui_main_loop ()
|
||||
hook_fd_exec (&read_fds, &write_fds, &except_fds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* remove keyboard hook */
|
||||
unhook (hook_fd_keyboard);
|
||||
}
|
||||
@@ -400,55 +400,55 @@ gui_main_end (int clean_exit)
|
||||
if (gui_window_refresh_needed)
|
||||
gui_main_refreshs ();
|
||||
}
|
||||
|
||||
|
||||
/* disable mouse */
|
||||
gui_mouse_disable ();
|
||||
|
||||
|
||||
/* remove bar items and bars */
|
||||
gui_bar_item_end ();
|
||||
gui_bar_free_all ();
|
||||
|
||||
|
||||
/* remove filters */
|
||||
gui_filter_free_all ();
|
||||
|
||||
|
||||
/* free clipboard buffer */
|
||||
if (gui_input_clipboard)
|
||||
free (gui_input_clipboard);
|
||||
|
||||
|
||||
/* delete layout saved */
|
||||
gui_layout_window_remove_all (&gui_layout_windows);
|
||||
gui_layout_buffer_remove_all (&gui_layout_buffers, &last_gui_layout_buffer);
|
||||
|
||||
|
||||
/* delete all windows */
|
||||
while (gui_windows)
|
||||
{
|
||||
gui_window_free (gui_windows);
|
||||
}
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
|
||||
|
||||
/* delete all buffers */
|
||||
while (gui_buffers)
|
||||
{
|
||||
gui_buffer_close (gui_buffers);
|
||||
}
|
||||
|
||||
|
||||
gui_ok = 0;
|
||||
gui_init_ok = 0;
|
||||
|
||||
|
||||
/* delete global history */
|
||||
gui_history_global_free ();
|
||||
|
||||
|
||||
/* reset title */
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_set_title (NULL);
|
||||
|
||||
|
||||
/* end color */
|
||||
gui_color_end ();
|
||||
|
||||
|
||||
/* free some variables used for chat area */
|
||||
gui_chat_end ();
|
||||
}
|
||||
|
||||
|
||||
/* end of Curses output */
|
||||
refresh ();
|
||||
endwin ();
|
||||
|
||||
@@ -139,9 +139,9 @@ gui_mouse_grab_event2input ()
|
||||
{
|
||||
struct t_gui_focus_info *focus_info;
|
||||
static char area[256];
|
||||
|
||||
|
||||
area[0] = '\0';
|
||||
|
||||
|
||||
focus_info = gui_focus_get_info (gui_mouse_event_x[0],
|
||||
gui_mouse_event_y[0]);
|
||||
if (focus_info)
|
||||
@@ -166,7 +166,7 @@ gui_mouse_grab_event2input ()
|
||||
}
|
||||
gui_focus_free_info (focus_info);
|
||||
}
|
||||
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ void
|
||||
gui_mouse_grab_end (const char *mouse_key)
|
||||
{
|
||||
char mouse_key_input[256];
|
||||
|
||||
|
||||
/* insert mouse key in input */
|
||||
if (gui_current_window->buffer->input)
|
||||
{
|
||||
@@ -202,7 +202,7 @@ gui_mouse_grab_end (const char *mouse_key)
|
||||
gui_completion_stop (gui_current_window->buffer->completion, 1);
|
||||
gui_input_text_changed_modifier_and_signal (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
||||
|
||||
gui_mouse_grab = 0;
|
||||
}
|
||||
|
||||
@@ -216,9 +216,9 @@ gui_mouse_event_timer_cb (void *data, int remaining_calls)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
gui_mouse_event_end ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -230,10 +230,10 @@ void
|
||||
gui_mouse_event_init ()
|
||||
{
|
||||
gui_mouse_event_pending = 1;
|
||||
|
||||
|
||||
if (gui_mouse_event_timer)
|
||||
unhook (gui_mouse_event_timer);
|
||||
|
||||
|
||||
gui_mouse_event_timer = hook_timer (NULL,
|
||||
CONFIG_INTEGER(config_look_mouse_timer_delay),
|
||||
0, 1,
|
||||
@@ -251,9 +251,9 @@ gui_mouse_event_code2key (const char *code)
|
||||
double diff_x, diff_y, distance, angle, pi4;
|
||||
static char key[128];
|
||||
char *ptr_code;
|
||||
|
||||
|
||||
key[0] = '\0';
|
||||
|
||||
|
||||
/*
|
||||
* mouse code must have at least:
|
||||
* one code (for event) + X + Y == 3 bytes or 3 UTF-8 chars
|
||||
@@ -262,7 +262,7 @@ gui_mouse_event_code2key (const char *code)
|
||||
length = (code_utf8) ? utf8_strlen (code) : (int)strlen (code);
|
||||
if (length < 3)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* get coordinates and button */
|
||||
if (code_utf8)
|
||||
{
|
||||
@@ -283,23 +283,23 @@ gui_mouse_event_code2key (const char *code)
|
||||
x = 0;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
|
||||
|
||||
/* ignore code if it's motion/end code received as first event */
|
||||
if ((gui_mouse_event_index == 0)
|
||||
&& (MOUSE_CODE_MOTION(code[0]) || MOUSE_CODE_END(code[0])))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* set data in "gui_mouse_event_xxx" */
|
||||
gui_mouse_event_x[gui_mouse_event_index] = x;
|
||||
gui_mouse_event_y[gui_mouse_event_index] = y;
|
||||
if (gui_mouse_event_index == 0)
|
||||
gui_mouse_event_button = code[0];
|
||||
|
||||
|
||||
if (gui_mouse_event_index == 0)
|
||||
gui_mouse_event_index = 1;
|
||||
|
||||
|
||||
/*
|
||||
* browse wheel codes, if one code is found, return event name immediately
|
||||
*/
|
||||
@@ -313,10 +313,10 @@ gui_mouse_event_code2key (const char *code)
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!MOUSE_CODE_END(code[0]))
|
||||
return NULL;
|
||||
|
||||
|
||||
/* add name of button event */
|
||||
for (i = 0; gui_mouse_button_codes[i][0]; i++)
|
||||
{
|
||||
@@ -326,16 +326,16 @@ gui_mouse_event_code2key (const char *code)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Mouse gesture: if (x,y) on release is different from (x,y) on click,
|
||||
* compute distance and angle between 2 points.
|
||||
*
|
||||
* Distance: sqrt((x2-x1)²+(y2-y1)²)
|
||||
* Angle : atan2(x1-x1, y2-y1)
|
||||
*
|
||||
*
|
||||
* Angle:
|
||||
*
|
||||
*
|
||||
* 3.14 pi
|
||||
* /\
|
||||
* -2.35 || 2.35 3/4 * pi
|
||||
@@ -360,7 +360,7 @@ gui_mouse_event_code2key (const char *code)
|
||||
* buttonX-gesture-right | 3..39 | 0.78..2.35
|
||||
* buttonX-gesture-right-long | >= 40 |
|
||||
*/
|
||||
|
||||
|
||||
distance = 0;
|
||||
if (key[0]
|
||||
&& ((gui_mouse_event_x[0] != gui_mouse_event_x[1])
|
||||
@@ -400,7 +400,7 @@ gui_mouse_event_code2key (const char *code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -412,16 +412,16 @@ void
|
||||
gui_mouse_event_end ()
|
||||
{
|
||||
const char *mouse_key;
|
||||
|
||||
|
||||
gui_mouse_event_pending = 0;
|
||||
|
||||
|
||||
/* end mouse event timer */
|
||||
if (gui_mouse_event_timer)
|
||||
{
|
||||
unhook (gui_mouse_event_timer);
|
||||
gui_mouse_event_timer = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* get key from mouse code */
|
||||
mouse_key = gui_mouse_event_code2key (gui_key_combo_buffer);
|
||||
if (mouse_key && mouse_key[0])
|
||||
@@ -438,6 +438,6 @@ gui_mouse_event_end ()
|
||||
}
|
||||
gui_mouse_event_reset ();
|
||||
}
|
||||
|
||||
|
||||
gui_key_combo_buffer[0] = '\0';
|
||||
}
|
||||
|
||||
+149
-149
@@ -93,7 +93,7 @@ gui_window_read_terminal_size ()
|
||||
{
|
||||
struct winsize size;
|
||||
int new_width, new_height;
|
||||
|
||||
|
||||
if (ioctl (fileno (stdout), TIOCGWINSZ, &size) == 0)
|
||||
{
|
||||
resizeterm (size.ws_row, size.ws_col);
|
||||
@@ -106,7 +106,7 @@ gui_window_read_terminal_size ()
|
||||
gui_term_cols = new_width;
|
||||
gui_term_lines = new_height;
|
||||
}
|
||||
|
||||
|
||||
gui_ok = ((gui_term_cols >= GUI_WINDOW_MIN_WIDTH)
|
||||
&& (gui_term_lines >= GUI_WINDOW_MIN_HEIGHT));
|
||||
}
|
||||
@@ -119,7 +119,7 @@ int
|
||||
gui_window_objects_init (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window_curses_objects *new_objects;
|
||||
|
||||
|
||||
new_objects = malloc (sizeof (*new_objects));
|
||||
if (new_objects)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ gui_window_clear_weechat (WINDOW *window, int weechat_color)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
wbkgdset (window, ' ' | COLOR_PAIR (gui_color_weechat_get_pair (weechat_color)));
|
||||
werase (window);
|
||||
wmove (window, 0, 0);
|
||||
@@ -174,17 +174,17 @@ gui_window_clear (WINDOW *window, int fg, int bg)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
|
||||
fg &= GUI_COLOR_EXTENDED_MASK;
|
||||
else
|
||||
fg = gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].foreground;
|
||||
|
||||
|
||||
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
|
||||
bg &= GUI_COLOR_EXTENDED_MASK;
|
||||
else
|
||||
bg = gui_weechat_colors[bg & GUI_COLOR_EXTENDED_MASK].background;
|
||||
|
||||
|
||||
wbkgdset (window, ' ' | COLOR_PAIR (gui_color_get_pair (fg, bg)));
|
||||
werase (window);
|
||||
wmove (window, 0, 0);
|
||||
@@ -241,7 +241,7 @@ gui_window_reset_style (WINDOW *window, int weechat_color)
|
||||
gui_window_current_style_bg = -1;
|
||||
gui_window_current_style_attr = 0;
|
||||
gui_window_current_color_attr = 0;
|
||||
|
||||
|
||||
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
|
||||
wattron (window, COLOR_PAIR(gui_color_weechat_get_pair (weechat_color)) |
|
||||
gui_color[weechat_color]->attributes);
|
||||
@@ -289,7 +289,7 @@ gui_window_set_color (WINDOW *window, int fg, int bg)
|
||||
{
|
||||
gui_window_current_style_fg = fg;
|
||||
gui_window_current_style_bg = bg;
|
||||
|
||||
|
||||
wattron (window, COLOR_PAIR(gui_color_get_pair (fg, bg)));
|
||||
}
|
||||
|
||||
@@ -301,13 +301,13 @@ void
|
||||
gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
|
||||
if ((num_color >= 0) && (num_color < GUI_COLOR_NUM_COLORS))
|
||||
{
|
||||
gui_window_reset_style (window, num_color);
|
||||
fg = gui_color[num_color]->foreground;
|
||||
bg = gui_color[num_color]->background;
|
||||
|
||||
|
||||
/*
|
||||
* if not real white, we use default terminal foreground instead of
|
||||
* white if bold attribute is set
|
||||
@@ -317,7 +317,7 @@ gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
{
|
||||
fg = -1;
|
||||
}
|
||||
|
||||
|
||||
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
|
||||
fg &= GUI_COLOR_EXTENDED_MASK;
|
||||
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
|
||||
@@ -335,11 +335,11 @@ void
|
||||
gui_window_set_custom_color_fg (WINDOW *window, int fg)
|
||||
{
|
||||
int current_bg, attributes;
|
||||
|
||||
|
||||
if (fg >= 0)
|
||||
{
|
||||
current_bg = gui_window_current_style_bg;
|
||||
|
||||
|
||||
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
|
||||
{
|
||||
if (fg & GUI_COLOR_EXTENDED_BOLD_FLAG)
|
||||
@@ -375,7 +375,7 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg)
|
||||
attributes |= gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes;
|
||||
gui_window_set_color_style (window, attributes);
|
||||
fg = gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].foreground;
|
||||
|
||||
|
||||
/*
|
||||
* if not real white, we use default terminal foreground instead of
|
||||
* white if bold attribute is set
|
||||
@@ -385,7 +385,7 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg)
|
||||
{
|
||||
fg = -1;
|
||||
}
|
||||
|
||||
|
||||
gui_window_set_color (window, fg, current_bg);
|
||||
}
|
||||
}
|
||||
@@ -400,12 +400,12 @@ void
|
||||
gui_window_set_custom_color_bg (WINDOW *window, int bg)
|
||||
{
|
||||
int current_attr, current_fg;
|
||||
|
||||
|
||||
if (bg >= 0)
|
||||
{
|
||||
current_attr = gui_window_current_style_attr;
|
||||
current_fg = gui_window_current_style_fg;
|
||||
|
||||
|
||||
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
|
||||
{
|
||||
gui_window_set_color (window,
|
||||
@@ -432,7 +432,7 @@ void
|
||||
gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
|
||||
{
|
||||
int attributes;
|
||||
|
||||
|
||||
if ((fg >= 0) && (bg >= 0))
|
||||
{
|
||||
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
|
||||
@@ -468,7 +468,7 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
|
||||
attributes |= gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes;
|
||||
gui_window_set_color_style (window, attributes);
|
||||
fg = gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].foreground;
|
||||
|
||||
|
||||
/*
|
||||
* if not real white, we use default terminal foreground instead of
|
||||
* white if bold attribute is set
|
||||
@@ -479,7 +479,7 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
|
||||
fg = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
|
||||
bg &= GUI_COLOR_EXTENDED_MASK;
|
||||
else
|
||||
@@ -488,7 +488,7 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
|
||||
bg = (gui_color_term_colors >= 16) ?
|
||||
gui_weechat_colors[bg].background : gui_weechat_colors[bg].foreground;
|
||||
}
|
||||
|
||||
|
||||
gui_window_set_color (window, fg, bg);
|
||||
}
|
||||
}
|
||||
@@ -522,9 +522,9 @@ gui_window_string_apply_color_fg (unsigned char **string, WINDOW *window)
|
||||
unsigned char *ptr_string;
|
||||
char str_fg[6], *error;
|
||||
int fg, extra_attr, flag;
|
||||
|
||||
|
||||
ptr_string = *string;
|
||||
|
||||
|
||||
if (ptr_string[0] == GUI_COLOR_EXTENDED_CHAR)
|
||||
{
|
||||
ptr_string++;
|
||||
@@ -577,7 +577,7 @@ gui_window_string_apply_color_fg (unsigned char **string, WINDOW *window)
|
||||
ptr_string += 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*string = ptr_string;
|
||||
}
|
||||
|
||||
@@ -594,9 +594,9 @@ gui_window_string_apply_color_bg (unsigned char **string, WINDOW *window)
|
||||
unsigned char *ptr_string;
|
||||
char str_bg[6], *error;
|
||||
int bg;
|
||||
|
||||
|
||||
ptr_string = *string;
|
||||
|
||||
|
||||
if (ptr_string[0] == GUI_COLOR_EXTENDED_CHAR)
|
||||
{
|
||||
if (ptr_string[1] && ptr_string[2] && ptr_string[3]
|
||||
@@ -636,7 +636,7 @@ gui_window_string_apply_color_bg (unsigned char **string, WINDOW *window)
|
||||
ptr_string += 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*string = ptr_string;
|
||||
}
|
||||
|
||||
@@ -654,9 +654,9 @@ gui_window_string_apply_color_fg_bg (unsigned char **string, WINDOW *window)
|
||||
unsigned char *ptr_string;
|
||||
char str_fg[6], str_bg[6], *error;
|
||||
int fg, bg, extra_attr, flag;
|
||||
|
||||
|
||||
ptr_string = *string;
|
||||
|
||||
|
||||
str_fg[0] = '\0';
|
||||
str_bg[0] = '\0';
|
||||
fg = -1;
|
||||
@@ -756,7 +756,7 @@ gui_window_string_apply_color_fg_bg (unsigned char **string, WINDOW *window)
|
||||
{
|
||||
gui_window_set_custom_color_fg_bg (window, fg, bg);
|
||||
}
|
||||
|
||||
|
||||
*string = ptr_string;
|
||||
}
|
||||
|
||||
@@ -774,9 +774,9 @@ gui_window_string_apply_color_pair (unsigned char **string, WINDOW *window)
|
||||
unsigned char *ptr_string;
|
||||
char str_pair[6], *error;
|
||||
int pair;
|
||||
|
||||
|
||||
ptr_string = *string;
|
||||
|
||||
|
||||
if ((isdigit (ptr_string[0])) && (isdigit (ptr_string[1]))
|
||||
&& (isdigit (ptr_string[2])) && (isdigit (ptr_string[3]))
|
||||
&& (isdigit (ptr_string[4])))
|
||||
@@ -794,7 +794,7 @@ gui_window_string_apply_color_pair (unsigned char **string, WINDOW *window)
|
||||
}
|
||||
ptr_string += 5;
|
||||
}
|
||||
|
||||
|
||||
*string = ptr_string;
|
||||
}
|
||||
|
||||
@@ -813,9 +813,9 @@ gui_window_string_apply_color_weechat (unsigned char **string, WINDOW *window)
|
||||
unsigned char *ptr_string;
|
||||
char str_number[3], *error;
|
||||
int weechat_color;
|
||||
|
||||
|
||||
ptr_string = *string;
|
||||
|
||||
|
||||
if (isdigit (ptr_string[0]) && isdigit (ptr_string[1]))
|
||||
{
|
||||
if (window)
|
||||
@@ -833,7 +833,7 @@ gui_window_string_apply_color_weechat (unsigned char **string, WINDOW *window)
|
||||
}
|
||||
ptr_string += 2;
|
||||
}
|
||||
|
||||
|
||||
*string = ptr_string;
|
||||
}
|
||||
|
||||
@@ -850,9 +850,9 @@ void
|
||||
gui_window_string_apply_color_set_attr (unsigned char **string, WINDOW *window)
|
||||
{
|
||||
unsigned char *ptr_string;
|
||||
|
||||
|
||||
ptr_string = *string;
|
||||
|
||||
|
||||
switch (ptr_string[0])
|
||||
{
|
||||
case GUI_COLOR_ATTR_BOLD_CHAR:
|
||||
@@ -875,7 +875,7 @@ gui_window_string_apply_color_set_attr (unsigned char **string, WINDOW *window)
|
||||
gui_window_set_color_style (window, A_UNDERLINE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*string = ptr_string;
|
||||
}
|
||||
|
||||
@@ -892,9 +892,9 @@ void
|
||||
gui_window_string_apply_color_remove_attr (unsigned char **string, WINDOW *window)
|
||||
{
|
||||
unsigned char *ptr_string;
|
||||
|
||||
|
||||
ptr_string = *string;
|
||||
|
||||
|
||||
switch (ptr_string[0])
|
||||
{
|
||||
case GUI_COLOR_ATTR_BOLD_CHAR:
|
||||
@@ -917,7 +917,7 @@ gui_window_string_apply_color_remove_attr (unsigned char **string, WINDOW *windo
|
||||
gui_window_remove_color_style (window, A_UNDERLINE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*string = ptr_string;
|
||||
}
|
||||
|
||||
@@ -938,18 +938,18 @@ gui_window_calculate_pos_size (struct t_gui_window *window)
|
||||
gui_ok = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (ptr_bar_win = window->bar_windows; ptr_bar_win;
|
||||
ptr_bar_win = ptr_bar_win->next_bar_window)
|
||||
{
|
||||
gui_bar_window_calculate_pos_size (ptr_bar_win, window);
|
||||
}
|
||||
|
||||
|
||||
add_bottom = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_RIGHT);
|
||||
|
||||
|
||||
window->win_chat_x = window->win_x + add_left;
|
||||
window->win_chat_y = window->win_y + add_top;
|
||||
window->win_chat_width = window->win_width - add_left - add_right;
|
||||
@@ -969,13 +969,13 @@ void
|
||||
gui_window_draw_separator (struct t_gui_window *window)
|
||||
{
|
||||
int separator_vertical;
|
||||
|
||||
|
||||
if (GUI_WINDOW_OBJECTS(window)->win_separator)
|
||||
{
|
||||
delwin (GUI_WINDOW_OBJECTS(window)->win_separator);
|
||||
GUI_WINDOW_OBJECTS(window)->win_separator = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (window->win_x > gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT))
|
||||
{
|
||||
GUI_WINDOW_OBJECTS(window)->win_separator = newwin (window->win_height,
|
||||
@@ -1007,7 +1007,7 @@ gui_window_redraw_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
gui_chat_draw (buffer, 1);
|
||||
}
|
||||
|
||||
@@ -1022,7 +1022,7 @@ gui_window_redraw_all_buffers ()
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -1041,14 +1041,14 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
|
||||
{
|
||||
struct t_gui_bar_window *ptr_bar_window;
|
||||
struct t_gui_buffer *old_buffer;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
gui_buffer_add_value_num_displayed (window->buffer, -1);
|
||||
|
||||
|
||||
old_buffer = window->buffer;
|
||||
|
||||
|
||||
if (window->buffer->number != buffer->number)
|
||||
{
|
||||
gui_window_scroll_switch (window, buffer);
|
||||
@@ -1071,18 +1071,18 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window->buffer = buffer;
|
||||
gui_buffer_add_value_num_displayed (buffer, 1);
|
||||
|
||||
|
||||
if (!weechat_upgrading && (old_buffer != buffer))
|
||||
gui_hotlist_remove_buffer (buffer);
|
||||
|
||||
|
||||
if (gui_ok)
|
||||
{
|
||||
gui_bar_window_remove_unused_bars (window);
|
||||
gui_bar_window_add_missing_bars (window);
|
||||
|
||||
|
||||
/* create bar windows */
|
||||
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
|
||||
ptr_bar_window = ptr_bar_window->next_bar_window)
|
||||
@@ -1091,12 +1091,12 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
|
||||
gui_bar_window_calculate_pos_size (ptr_bar_window, window);
|
||||
gui_bar_window_create_win (ptr_bar_window);
|
||||
}
|
||||
|
||||
|
||||
gui_window_calculate_pos_size (window);
|
||||
|
||||
|
||||
/* destroy Curses windows */
|
||||
gui_window_objects_free (window, 0);
|
||||
|
||||
|
||||
/* create Curses windows */
|
||||
if (GUI_WINDOW_OBJECTS(window)->win_chat)
|
||||
delwin (GUI_WINDOW_OBJECTS(window)->win_chat);
|
||||
@@ -1107,29 +1107,29 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
|
||||
gui_window_draw_separator (window);
|
||||
gui_buffer_ask_chat_refresh (window->buffer, 2);
|
||||
}
|
||||
|
||||
|
||||
if (window->buffer->type == GUI_BUFFER_TYPE_FREE)
|
||||
{
|
||||
window->scroll->scrolling = 0;
|
||||
window->scroll->lines_after = 0;
|
||||
}
|
||||
|
||||
|
||||
gui_buffer_set_active_buffer (buffer);
|
||||
|
||||
|
||||
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
|
||||
ptr_bar_window = ptr_bar_window->next_bar_window)
|
||||
{
|
||||
ptr_bar_window->bar->bar_refresh_needed = 1;
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(config_look_read_marker_always_show)
|
||||
&& set_last_read && !window->buffer->lines->last_read_line)
|
||||
{
|
||||
window->buffer->lines->last_read_line = window->buffer->lines->last_line;
|
||||
}
|
||||
|
||||
|
||||
gui_input_move_to_buffer (old_buffer, window->buffer);
|
||||
|
||||
|
||||
hook_signal_send ("buffer_switch",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
}
|
||||
@@ -1143,12 +1143,12 @@ gui_window_switch (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *old_window;
|
||||
int changes;
|
||||
|
||||
|
||||
if (gui_current_window == window)
|
||||
return;
|
||||
|
||||
|
||||
old_window = gui_current_window;
|
||||
|
||||
|
||||
gui_current_window = window;
|
||||
changes = gui_bar_window_remove_unused_bars (old_window)
|
||||
|| gui_bar_window_add_missing_bars (old_window);
|
||||
@@ -1159,12 +1159,12 @@ gui_window_switch (struct t_gui_window *window)
|
||||
gui_current_window->buffer, 1);
|
||||
gui_current_window = window;
|
||||
}
|
||||
|
||||
|
||||
gui_window_switch_to_buffer (gui_current_window,
|
||||
gui_current_window->buffer, 1);
|
||||
|
||||
|
||||
old_window->refresh_needed = 1;
|
||||
|
||||
|
||||
gui_input_move_to_buffer (old_window->buffer, window->buffer);
|
||||
}
|
||||
|
||||
@@ -1177,17 +1177,17 @@ gui_window_page_up (struct t_gui_window *window)
|
||||
{
|
||||
char scroll[32];
|
||||
int num_lines;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
num_lines = ((window->win_chat_height - 1) *
|
||||
CONFIG_INTEGER(config_look_scroll_page_percent)) / 100;
|
||||
if (num_lines < 1)
|
||||
num_lines = 1;
|
||||
else if (num_lines > window->win_chat_height - 1)
|
||||
num_lines = window->win_chat_height - 1;
|
||||
|
||||
|
||||
switch (window->buffer->type)
|
||||
{
|
||||
case GUI_BUFFER_TYPE_FORMATTED:
|
||||
@@ -1227,17 +1227,17 @@ gui_window_page_down (struct t_gui_window *window)
|
||||
struct t_gui_line *ptr_line;
|
||||
int line_pos, num_lines;
|
||||
char scroll[32];
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
num_lines = ((window->win_chat_height - 1) *
|
||||
CONFIG_INTEGER(config_look_scroll_page_percent)) / 100;
|
||||
if (num_lines < 1)
|
||||
num_lines = 1;
|
||||
else if (num_lines > window->win_chat_height - 1)
|
||||
num_lines = window->win_chat_height - 1;
|
||||
|
||||
|
||||
switch (window->buffer->type)
|
||||
{
|
||||
case GUI_BUFFER_TYPE_FORMATTED:
|
||||
@@ -1246,7 +1246,7 @@ gui_window_page_down (struct t_gui_window *window)
|
||||
gui_chat_calculate_line_diff (window, &window->scroll->start_line,
|
||||
&window->scroll->start_line_pos,
|
||||
num_lines);
|
||||
|
||||
|
||||
/* check if we can display all */
|
||||
ptr_line = window->scroll->start_line;
|
||||
line_pos = window->scroll->start_line_pos;
|
||||
@@ -1282,7 +1282,7 @@ void
|
||||
gui_window_scroll_up (struct t_gui_window *window)
|
||||
{
|
||||
char scroll[32];
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
@@ -1326,10 +1326,10 @@ gui_window_scroll_down (struct t_gui_window *window)
|
||||
struct t_gui_line *ptr_line;
|
||||
int line_pos;
|
||||
char scroll[32];
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
switch (window->buffer->type)
|
||||
{
|
||||
case GUI_BUFFER_TYPE_FORMATTED:
|
||||
@@ -1338,14 +1338,14 @@ gui_window_scroll_down (struct t_gui_window *window)
|
||||
gui_chat_calculate_line_diff (window, &window->scroll->start_line,
|
||||
&window->scroll->start_line_pos,
|
||||
CONFIG_INTEGER(config_look_scroll_amount));
|
||||
|
||||
|
||||
/* check if we can display all */
|
||||
ptr_line = window->scroll->start_line;
|
||||
line_pos = window->scroll->start_line_pos;
|
||||
gui_chat_calculate_line_diff (window, &ptr_line,
|
||||
&line_pos,
|
||||
window->win_chat_height - 1);
|
||||
|
||||
|
||||
if (!ptr_line)
|
||||
{
|
||||
window->scroll->start_line = NULL;
|
||||
@@ -1376,7 +1376,7 @@ gui_window_scroll_top (struct t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
switch (window->buffer->type)
|
||||
{
|
||||
case GUI_BUFFER_TYPE_FORMATTED:
|
||||
@@ -1410,7 +1410,7 @@ void
|
||||
gui_window_scroll_bottom (struct t_gui_window *window)
|
||||
{
|
||||
char scroll[32];
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
@@ -1459,10 +1459,10 @@ gui_window_auto_resize (struct t_gui_window_tree *tree,
|
||||
{
|
||||
int size1, size2;
|
||||
struct t_gui_window_tree *parent;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return 0;
|
||||
|
||||
|
||||
if (tree)
|
||||
{
|
||||
if (tree->window)
|
||||
@@ -1533,10 +1533,10 @@ gui_window_refresh_windows ()
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
int add_bottom, add_top, add_left, add_right;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
old_current_window = gui_current_window;
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
@@ -1549,12 +1549,12 @@ gui_window_refresh_windows ()
|
||||
gui_bar_ask_refresh (ptr_bar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
|
||||
|
||||
|
||||
if (gui_window_auto_resize (gui_windows_tree, add_left, add_top,
|
||||
gui_window_get_width () - add_left - add_right,
|
||||
gui_window_get_height () - add_top - add_bottom,
|
||||
@@ -1568,7 +1568,7 @@ gui_window_refresh_windows ()
|
||||
}
|
||||
gui_window_zoom (gui_current_window);
|
||||
}
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
gui_window_calculate_pos_size (ptr_win);
|
||||
@@ -1579,7 +1579,7 @@ gui_window_refresh_windows ()
|
||||
}
|
||||
ptr_win->refresh_needed = 1;
|
||||
}
|
||||
|
||||
|
||||
gui_current_window = old_current_window;
|
||||
}
|
||||
|
||||
@@ -1592,15 +1592,15 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage)
|
||||
{
|
||||
struct t_gui_window *new_window;
|
||||
int height1, height2;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return NULL;
|
||||
|
||||
|
||||
new_window = NULL;
|
||||
|
||||
|
||||
height1 = (window->win_height * percentage) / 100;
|
||||
height2 = window->win_height - height1;
|
||||
|
||||
|
||||
if ((height1 >= GUI_WINDOW_MIN_HEIGHT) && (height2 >= GUI_WINDOW_MIN_HEIGHT)
|
||||
&& (percentage > 0) && (percentage < 100))
|
||||
{
|
||||
@@ -1614,17 +1614,17 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage)
|
||||
window->win_y = new_window->win_y + new_window->win_height;
|
||||
window->win_height = height2;
|
||||
window->win_height_pct = 100 - percentage;
|
||||
|
||||
|
||||
/* assign same buffer for new window (top window) */
|
||||
gui_buffer_add_value_num_displayed (new_window->buffer, 1);
|
||||
|
||||
|
||||
window->refresh_needed = 1;
|
||||
new_window->refresh_needed = 1;
|
||||
|
||||
|
||||
gui_window_switch (new_window);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_window;
|
||||
}
|
||||
|
||||
@@ -1637,15 +1637,15 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
|
||||
{
|
||||
struct t_gui_window *new_window;
|
||||
int width1, width2;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return NULL;
|
||||
|
||||
|
||||
new_window = NULL;
|
||||
|
||||
|
||||
width1 = (window->win_width * percentage) / 100;
|
||||
width2 = window->win_width - width1 - 1;
|
||||
|
||||
|
||||
if ((width1 >= GUI_WINDOW_MIN_WIDTH) && (width2 >= GUI_WINDOW_MIN_WIDTH)
|
||||
&& (percentage > 0) && (percentage < 100))
|
||||
{
|
||||
@@ -1658,20 +1658,20 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
|
||||
/* reduce old window height (left window) */
|
||||
window->win_width = width1;
|
||||
window->win_width_pct = 100 - percentage;
|
||||
|
||||
|
||||
/* assign same buffer for new window (right window) */
|
||||
gui_buffer_add_value_num_displayed (new_window->buffer, 1);
|
||||
|
||||
|
||||
window->refresh_needed = 1;
|
||||
new_window->refresh_needed = 1;
|
||||
|
||||
|
||||
gui_window_switch (new_window);
|
||||
|
||||
|
||||
/* create & draw separator */
|
||||
gui_window_draw_separator (gui_current_window);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_window;
|
||||
}
|
||||
|
||||
@@ -1684,10 +1684,10 @@ gui_window_resize (struct t_gui_window *window, int percentage)
|
||||
{
|
||||
struct t_gui_window_tree *parent;
|
||||
int old_split_pct, add_bottom, add_top, add_left, add_right;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
@@ -1701,12 +1701,12 @@ gui_window_resize (struct t_gui_window *window, int percentage)
|
||||
{
|
||||
parent->split_pct = 100 - percentage;
|
||||
}
|
||||
|
||||
|
||||
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
|
||||
|
||||
|
||||
if (gui_window_auto_resize (gui_windows_tree, add_left, add_top,
|
||||
gui_window_get_width () - add_left - add_right,
|
||||
gui_window_get_height () - add_top - add_bottom,
|
||||
@@ -1726,10 +1726,10 @@ gui_window_resize_delta (struct t_gui_window *window, int delta_percentage)
|
||||
{
|
||||
struct t_gui_window_tree *parent;
|
||||
int old_split_pct, add_bottom, add_top, add_left, add_right;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
@@ -1747,12 +1747,12 @@ gui_window_resize_delta (struct t_gui_window *window, int delta_percentage)
|
||||
parent->split_pct = 1;
|
||||
else if (parent->split_pct > 99)
|
||||
parent->split_pct = 99;
|
||||
|
||||
|
||||
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
|
||||
|
||||
|
||||
if (gui_window_auto_resize (gui_windows_tree, add_left, add_top,
|
||||
gui_window_get_width () - add_left - add_right,
|
||||
gui_window_get_height () - add_top - add_bottom,
|
||||
@@ -1771,19 +1771,19 @@ int
|
||||
gui_window_merge (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window_tree *parent, *sister;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return 0;
|
||||
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
sister = (parent->child1->window == window) ?
|
||||
parent->child2 : parent->child1;
|
||||
|
||||
|
||||
if (!(sister->window))
|
||||
return 0;
|
||||
|
||||
|
||||
if (window->win_y == sister->window->win_y)
|
||||
{
|
||||
/* horizontal merge */
|
||||
@@ -1800,10 +1800,10 @@ gui_window_merge (struct t_gui_window *window)
|
||||
window->win_x = sister->window->win_x;
|
||||
if (sister->window->win_y < window->win_y)
|
||||
window->win_y = sister->window->win_y;
|
||||
|
||||
|
||||
gui_window_free (sister->window);
|
||||
gui_window_tree_node_to_leaf (parent, window);
|
||||
|
||||
|
||||
gui_window_switch_to_buffer (window, window->buffer, 1);
|
||||
return 1;
|
||||
}
|
||||
@@ -1818,17 +1818,17 @@ void
|
||||
gui_window_merge_all (struct t_gui_window *window)
|
||||
{
|
||||
int num_deleted, add_bottom, add_top, add_left, add_right;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
num_deleted = 0;
|
||||
while (gui_windows->next_window)
|
||||
{
|
||||
gui_window_free ((gui_windows == window) ? gui_windows->next_window : gui_windows);
|
||||
num_deleted++;
|
||||
}
|
||||
|
||||
|
||||
if (num_deleted > 0)
|
||||
{
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
@@ -1843,10 +1843,10 @@ gui_window_merge_all (struct t_gui_window *window)
|
||||
window->win_y = add_top;
|
||||
window->win_width = gui_window_get_width () - add_left - add_right;
|
||||
window->win_height = gui_window_get_height () - add_top - add_bottom;
|
||||
|
||||
|
||||
window->win_width_pct = 100;
|
||||
window->win_height_pct = 100;
|
||||
|
||||
|
||||
gui_current_window = window;
|
||||
gui_window_switch_to_buffer (window, window->buffer, 1);
|
||||
}
|
||||
@@ -1866,7 +1866,7 @@ gui_window_side_by_side (struct t_gui_window *win1, struct t_gui_window *win2)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return 0;
|
||||
|
||||
|
||||
/* win2 over win1 ? */
|
||||
if (win2->win_y + win2->win_height == win1->win_y)
|
||||
{
|
||||
@@ -1896,7 +1896,7 @@ gui_window_side_by_side (struct t_gui_window *win1, struct t_gui_window *win2)
|
||||
return 0;
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
/* win2 on the left ? */
|
||||
if (win2->win_x + win2->win_width + 1 == win1->win_x)
|
||||
{
|
||||
@@ -1918,10 +1918,10 @@ void
|
||||
gui_window_switch_up (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -1942,10 +1942,10 @@ void
|
||||
gui_window_switch_down (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -1966,10 +1966,10 @@ void
|
||||
gui_window_switch_left (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -1990,10 +1990,10 @@ void
|
||||
gui_window_switch_right (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -2015,7 +2015,7 @@ int
|
||||
gui_window_balance_count (struct t_gui_window_tree *tree, int split_horizontal)
|
||||
{
|
||||
int count;
|
||||
|
||||
|
||||
count = 0;
|
||||
if (tree)
|
||||
{
|
||||
@@ -2043,7 +2043,7 @@ int
|
||||
gui_window_balance (struct t_gui_window_tree *tree)
|
||||
{
|
||||
int balanced, count_left, count_right, new_split_pct;
|
||||
|
||||
|
||||
balanced = 0;
|
||||
if (tree && tree->child1 && tree->child2)
|
||||
{
|
||||
@@ -2086,12 +2086,12 @@ gui_window_swap (struct t_gui_window *window, int direction)
|
||||
struct t_gui_window_tree *parent, *sister;
|
||||
struct t_gui_window *window2, *ptr_win;
|
||||
struct t_gui_buffer *buffer1;
|
||||
|
||||
|
||||
if (!window || !gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
window2 = NULL;
|
||||
|
||||
|
||||
if (direction == 0)
|
||||
{
|
||||
/* search sister window */
|
||||
@@ -2118,7 +2118,7 @@ gui_window_swap (struct t_gui_window *window, int direction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* let's swap! */
|
||||
if (window2 && (window->buffer != window2->buffer))
|
||||
{
|
||||
@@ -2144,7 +2144,7 @@ gui_window_refresh_screen (int full_refresh)
|
||||
gui_window_read_terminal_size ();
|
||||
refresh ();
|
||||
}
|
||||
|
||||
|
||||
gui_window_refresh_windows ();
|
||||
}
|
||||
|
||||
@@ -2158,7 +2158,7 @@ gui_window_set_title (const char *title)
|
||||
char *shell, *shellname;
|
||||
char *envterm = getenv ("TERM");
|
||||
char *envshell = getenv ("SHELL");
|
||||
|
||||
|
||||
if (envterm)
|
||||
{
|
||||
if (title && title[0])
|
||||
|
||||
@@ -45,7 +45,7 @@ int
|
||||
gui_bar_window_objects_init (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
struct t_gui_bar_window_gtk_objects *new_objects;
|
||||
|
||||
|
||||
new_objects = malloc (sizeof (*new_objects));
|
||||
if (new_objects)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ void
|
||||
gui_bar_window_create_win (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
(void) bar_window;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
(void) bar_window;
|
||||
(void) string;
|
||||
(void) max_chars;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
return 0;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
{
|
||||
(void) bar_window;
|
||||
(void) window;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -96,7 +96,7 @@ gui_chat_reset_style (struct t_gui_window *window)
|
||||
GUI_WINDOW_OBJECTS(window)->current_style_bg = -1;
|
||||
GUI_WINDOW_OBJECTS(window)->current_style_attr = 0;
|
||||
GUI_WINDOW_OBJECTS(window)->current_color_attr = 0;
|
||||
|
||||
|
||||
/* TODO: change following function call */
|
||||
/*gui_window_set_weechat_color (window->win_chat, COLOR_WIN_CHAT);*/
|
||||
gui_chat_remove_style (window,
|
||||
@@ -183,7 +183,7 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
|
||||
(void) line;
|
||||
(void) apply_style;
|
||||
(void) apply_style_inactive;
|
||||
|
||||
|
||||
return (char *)string;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ void
|
||||
gui_chat_display_word_raw (struct t_gui_window *window, const char *string)
|
||||
{
|
||||
/*char *prev_char, *next_char, saved_char;*/
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) string;
|
||||
@@ -215,7 +215,7 @@ gui_chat_display_word (struct t_gui_window *window,
|
||||
{
|
||||
/*char *end_line, saved_char_end, saved_char;
|
||||
int pos_saved_char, chars_to_display, num_displayed;*/
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) line;
|
||||
@@ -258,12 +258,12 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **l
|
||||
int *line_pos, int difference)
|
||||
{
|
||||
int backward, current_size;
|
||||
|
||||
|
||||
if (!line || !line_pos)
|
||||
return;
|
||||
|
||||
|
||||
backward = (difference < 0);
|
||||
|
||||
|
||||
if (!(*line))
|
||||
{
|
||||
/* if looking backward, start at last line of buffer */
|
||||
@@ -289,7 +289,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **l
|
||||
}
|
||||
else
|
||||
current_size = gui_chat_display_line (window, *line, 0, 1);
|
||||
|
||||
|
||||
while ((*line) && (difference != 0))
|
||||
{
|
||||
/* looking backward */
|
||||
@@ -329,7 +329,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **l
|
||||
difference--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* first or last line reached */
|
||||
if (!(*line))
|
||||
{
|
||||
@@ -365,10 +365,10 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
int num_unit;
|
||||
char format[32], date[128], *buf;
|
||||
struct tm *date_tmp;*/
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) buffer;
|
||||
(void) erase;
|
||||
|
||||
+11
-11
@@ -65,13 +65,13 @@ int
|
||||
gui_color_search (const char *color_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; gui_weechat_colors[i].string; i++)
|
||||
{
|
||||
if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* color not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ int
|
||||
gui_color_assign (int *color, const char *color_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* look for curses colors in table */
|
||||
i = 0;
|
||||
while (gui_weechat_colors[i].string)
|
||||
@@ -96,7 +96,7 @@ gui_color_assign (int *color, const char *color_name)
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/* color not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ gui_color_assign_by_diff (int *color, const char *color_name, int diff)
|
||||
(void) color;
|
||||
(void) color_name;
|
||||
(void) diff;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ gui_color_get_pair (int fg, int bg)
|
||||
{
|
||||
(void) fg;
|
||||
(void) bg;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ int
|
||||
gui_color_weechat_get_pair (int weechat_color)
|
||||
{
|
||||
(void) weechat_color;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ void
|
||||
gui_color_rebuild_weechat ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
|
||||
{
|
||||
if (gui_color[i])
|
||||
@@ -290,7 +290,7 @@ gui_color_palette_new (int number, const char *value)
|
||||
/* This function does nothing in Gtk GUI */
|
||||
(void) number;
|
||||
(void) value;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ void
|
||||
gui_color_pre_init ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
|
||||
{
|
||||
gui_color[i] = NULL;
|
||||
@@ -348,7 +348,7 @@ void
|
||||
gui_color_end ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
|
||||
{
|
||||
gui_color_free (gui_color[i]);
|
||||
|
||||
+36
-36
@@ -71,10 +71,10 @@ gui_main_pre_init (int *argc, char **argv[])
|
||||
{
|
||||
/* pre-init colors */
|
||||
gui_color_pre_init ();
|
||||
|
||||
|
||||
/* init some variables for chat area */
|
||||
gui_chat_init ();
|
||||
|
||||
|
||||
/* Initialise Gtk */
|
||||
gtk_init (argc, argv);
|
||||
}
|
||||
@@ -90,55 +90,55 @@ gui_main_init ()
|
||||
struct t_gui_bar *ptr_bar;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
GdkColor color_fg, color_bg;
|
||||
|
||||
|
||||
gui_color_init ();
|
||||
|
||||
|
||||
gui_ok = 1;
|
||||
|
||||
|
||||
/* build prefixes according to config */
|
||||
gui_chat_prefix_build ();
|
||||
|
||||
|
||||
/* init clipboard buffer */
|
||||
gui_input_clipboard = NULL;
|
||||
|
||||
|
||||
/* create Gtk widgets */
|
||||
|
||||
|
||||
gdk_color_parse ("white", &color_fg);
|
||||
gdk_color_parse ("black", &color_bg);
|
||||
|
||||
|
||||
gui_gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (gui_gtk_main_window), PACKAGE_STRING);
|
||||
|
||||
|
||||
g_signal_connect (G_OBJECT (gui_gtk_main_window), "destroy", gtk_main_quit, NULL);
|
||||
|
||||
|
||||
gui_gtk_vbox1 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (gui_gtk_vbox1);
|
||||
gtk_container_add (GTK_CONTAINER (gui_gtk_main_window), gui_gtk_vbox1);
|
||||
|
||||
|
||||
gui_gtk_entry_topic = gtk_entry_new ();
|
||||
gtk_widget_show (gui_gtk_entry_topic);
|
||||
gtk_box_pack_start (GTK_BOX (gui_gtk_vbox1), gui_gtk_entry_topic, FALSE, FALSE, 0);
|
||||
gtk_widget_modify_text (gui_gtk_entry_topic, GTK_STATE_NORMAL, &color_fg);
|
||||
gtk_widget_modify_base (gui_gtk_entry_topic, GTK_STATE_NORMAL, &color_bg);
|
||||
|
||||
|
||||
gui_gtk_notebook1 = gtk_notebook_new ();
|
||||
gtk_widget_show (gui_gtk_notebook1);
|
||||
gtk_box_pack_start (GTK_BOX (gui_gtk_vbox1), gui_gtk_notebook1, TRUE, TRUE, 0);
|
||||
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (gui_gtk_notebook1), GTK_POS_BOTTOM);
|
||||
|
||||
|
||||
gui_gtk_vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (gui_gtk_vbox2);
|
||||
gtk_container_add (GTK_CONTAINER (gui_gtk_notebook1), gui_gtk_vbox2);
|
||||
|
||||
|
||||
gui_gtk_hbox1 = gtk_hbox_new (FALSE, 0);
|
||||
gtk_widget_show (gui_gtk_hbox1);
|
||||
gtk_box_pack_start (GTK_BOX (gui_gtk_vbox2), gui_gtk_hbox1, TRUE, TRUE, 0);
|
||||
|
||||
|
||||
gui_gtk_hpaned1 = gtk_hpaned_new ();
|
||||
gtk_widget_show (gui_gtk_hpaned1);
|
||||
gtk_box_pack_start (GTK_BOX (gui_gtk_hbox1), gui_gtk_hpaned1, TRUE, TRUE, 0);
|
||||
gtk_paned_set_position (GTK_PANED (gui_gtk_hpaned1), 0);
|
||||
|
||||
|
||||
gui_gtk_scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (gui_gtk_scrolledwindow_chat);
|
||||
gtk_paned_pack1 (GTK_PANED (gui_gtk_hpaned1), gui_gtk_scrolledwindow_chat,
|
||||
@@ -148,7 +148,7 @@ gui_main_init ()
|
||||
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
||||
gtk_widget_modify_text (gui_gtk_scrolledwindow_chat, GTK_STATE_NORMAL, &color_fg);
|
||||
gtk_widget_modify_base (gui_gtk_scrolledwindow_chat, GTK_STATE_NORMAL, &color_bg);
|
||||
|
||||
|
||||
gui_gtk_scrolledwindow_nick = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (gui_gtk_scrolledwindow_nick);
|
||||
gtk_paned_pack2 (GTK_PANED (gui_gtk_hpaned1), gui_gtk_scrolledwindow_nick,
|
||||
@@ -158,45 +158,45 @@ gui_main_init ()
|
||||
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
||||
gtk_widget_modify_text (gui_gtk_scrolledwindow_nick, GTK_STATE_NORMAL, &color_fg);
|
||||
gtk_widget_modify_base (gui_gtk_scrolledwindow_nick, GTK_STATE_NORMAL, &color_bg);
|
||||
|
||||
|
||||
gui_gtk_entry_input = gtk_entry_new ();
|
||||
gtk_widget_show (gui_gtk_entry_input);
|
||||
gtk_box_pack_start (GTK_BOX (gui_gtk_vbox2), gui_gtk_entry_input, FALSE,
|
||||
FALSE, 0);
|
||||
gtk_widget_modify_text (gui_gtk_entry_input, GTK_STATE_NORMAL, &color_fg);
|
||||
gtk_widget_modify_base (gui_gtk_entry_input, GTK_STATE_NORMAL, &color_bg);
|
||||
|
||||
|
||||
gui_gtk_label1 = gtk_label_new (_("server"));
|
||||
gtk_widget_show (gui_gtk_label1);
|
||||
gtk_notebook_set_tab_label (GTK_NOTEBOOK (gui_gtk_notebook1),
|
||||
gtk_notebook_get_nth_page (GTK_NOTEBOOK (gui_gtk_notebook1), 0),
|
||||
gui_gtk_label1);
|
||||
gtk_label_set_justify (GTK_LABEL (gui_gtk_label1), GTK_JUSTIFY_LEFT);
|
||||
|
||||
|
||||
gtk_widget_show_all (gui_gtk_main_window);
|
||||
|
||||
|
||||
gui_init_ok = 0;
|
||||
|
||||
|
||||
/* create core buffer */
|
||||
ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL);
|
||||
if (ptr_buffer)
|
||||
{
|
||||
gui_init_ok = 1;
|
||||
|
||||
|
||||
/* set title for core buffer */
|
||||
gui_buffer_set_title (ptr_buffer,
|
||||
"WeeChat " WEECHAT_COPYRIGHT_DATE
|
||||
" - " WEECHAT_WEBSITE);
|
||||
|
||||
|
||||
/* create main window (using full space) */
|
||||
if (gui_window_new (NULL, ptr_buffer, 0, 0, 0, 0, 100, 100))
|
||||
{
|
||||
gui_current_window = gui_windows;
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* create bar windows for root bars (they were read from config,
|
||||
* but no window was created (GUI was not initialized)
|
||||
@@ -243,18 +243,18 @@ gui_main_end (int clean_exit)
|
||||
/* remove bar items and bars */
|
||||
gui_bar_item_end ();
|
||||
gui_bar_free_all ();
|
||||
|
||||
|
||||
/* remove filters */
|
||||
gui_filter_free_all ();
|
||||
|
||||
|
||||
/* free clipboard buffer */
|
||||
if (gui_input_clipboard)
|
||||
free(gui_input_clipboard);
|
||||
|
||||
|
||||
/* delete layout saved */
|
||||
gui_layout_window_remove_all (&gui_layout_windows);
|
||||
gui_layout_buffer_remove_all (&gui_layout_buffers, &last_gui_layout_buffer);
|
||||
|
||||
|
||||
/* delete all windows */
|
||||
while (gui_windows)
|
||||
{
|
||||
@@ -262,23 +262,23 @@ gui_main_end (int clean_exit)
|
||||
/* TODO: destroy Gtk widgets */
|
||||
}
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
|
||||
|
||||
/* delete all buffers */
|
||||
while (gui_buffers)
|
||||
{
|
||||
gui_buffer_close (gui_buffers);
|
||||
}
|
||||
|
||||
|
||||
/* delete global history */
|
||||
gui_history_global_free ();
|
||||
|
||||
|
||||
/* reset title */
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_set_title (NULL);
|
||||
|
||||
|
||||
/* end color */
|
||||
gui_color_end ();
|
||||
|
||||
|
||||
/* free some variables used for chat area */
|
||||
gui_chat_end ();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ void
|
||||
gui_mouse_grab_init (int area)
|
||||
{
|
||||
(void) area;
|
||||
|
||||
|
||||
/* This function does nothing in Gtk GUI */
|
||||
}
|
||||
|
||||
@@ -89,9 +89,9 @@ const char *
|
||||
gui_mouse_event_code2key (const char *code)
|
||||
{
|
||||
(void) code;
|
||||
|
||||
|
||||
/* This function does nothing in Gtk GUI */
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ int
|
||||
gui_window_objects_init (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window_gtk_objects *new_objects;
|
||||
|
||||
|
||||
if ((new_objects = malloc (sizeof (*new_objects))))
|
||||
{
|
||||
window->gui_objects = new_objects;
|
||||
@@ -131,7 +131,7 @@ gui_window_draw_separator (struct t_gui_window *window)
|
||||
/* TODO: write this function for Gtk */
|
||||
/*if (window->win_separator)
|
||||
delwin (window->win_separator);
|
||||
|
||||
|
||||
if (window->win_x > 0)
|
||||
{
|
||||
window->win_separator = newwin (window->win_height,
|
||||
@@ -176,14 +176,14 @@ gui_window_switch (struct t_gui_window *window)
|
||||
{
|
||||
if (gui_current_window == window)
|
||||
return;
|
||||
|
||||
|
||||
/* remove unused bars from current window */
|
||||
/* ... */
|
||||
|
||||
|
||||
gui_current_window = window;
|
||||
|
||||
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1);
|
||||
|
||||
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
@@ -197,9 +197,9 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
|
||||
int set_last_read)
|
||||
{
|
||||
GtkTextIter start, end;
|
||||
|
||||
|
||||
gui_buffer_add_value_num_displayed (window->buffer, -1);
|
||||
|
||||
|
||||
if (window->buffer != buffer)
|
||||
{
|
||||
window->scroll->start_line = NULL;
|
||||
@@ -223,10 +223,10 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window->buffer = buffer;
|
||||
gui_window_calculate_pos_size (window);
|
||||
|
||||
|
||||
if (!GUI_WINDOW_OBJECTS(window)->textview_chat)
|
||||
{
|
||||
GUI_WINDOW_OBJECTS(window)->textview_chat = gtk_text_view_new ();
|
||||
@@ -235,20 +235,20 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
|
||||
gtk_widget_set_size_request (GUI_WINDOW_OBJECTS(window)->textview_chat, 300, -1);
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), FALSE);
|
||||
|
||||
|
||||
GUI_WINDOW_OBJECTS(window)->textbuffer_chat = gtk_text_buffer_new (NULL);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), GUI_WINDOW_OBJECTS(window)->textbuffer_chat);
|
||||
|
||||
|
||||
/*GUI_WINDOW_OBJECTS(window)->texttag_chat = gtk_text_buffer_create_tag(GUI_WINDOW_OBJECTS(window)->textbuffer_chat, "courier", "font_family", "lucida");*/
|
||||
gtk_text_buffer_get_bounds (GUI_WINDOW_OBJECTS(window)->textbuffer_chat, &start, &end);
|
||||
gtk_text_buffer_apply_tag (GUI_WINDOW_OBJECTS(window)->textbuffer_chat, GUI_WINDOW_OBJECTS(window)->texttag_chat, &start, &end);
|
||||
}
|
||||
|
||||
|
||||
window->scroll->start_line = NULL;
|
||||
window->scroll->start_line_pos = 0;
|
||||
|
||||
|
||||
gui_buffer_add_value_num_displayed (buffer, 1);
|
||||
|
||||
|
||||
gui_hotlist_remove_buffer (buffer);
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ gui_window_page_up (struct t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
if (!window->scroll->first_line_displayed)
|
||||
{
|
||||
gui_chat_calculate_line_diff (window, &window->scroll->start_line,
|
||||
@@ -282,16 +282,16 @@ gui_window_page_down (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
int line_pos;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
if (window->scroll->start_line)
|
||||
{
|
||||
gui_chat_calculate_line_diff (window, &window->scroll->start_line,
|
||||
&window->scroll->start_line_pos,
|
||||
window->win_chat_height - 1);
|
||||
|
||||
|
||||
/* check if we can display all */
|
||||
ptr_line = window->scroll->start_line;
|
||||
line_pos = window->scroll->start_line_pos;
|
||||
@@ -303,7 +303,7 @@ gui_window_page_down (struct t_gui_window *window)
|
||||
window->scroll->start_line = NULL;
|
||||
window->scroll->start_line_pos = 0;
|
||||
}
|
||||
|
||||
|
||||
gui_chat_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -317,7 +317,7 @@ gui_window_scroll_up (struct t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
if (!window->scroll->first_line_displayed)
|
||||
{
|
||||
gui_chat_calculate_line_diff (window, &window->scroll->start_line,
|
||||
@@ -339,29 +339,29 @@ gui_window_scroll_down (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
int line_pos;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
if (window->scroll->start_line)
|
||||
{
|
||||
gui_chat_calculate_line_diff (window, &window->scroll->start_line,
|
||||
&window->scroll->start_line_pos,
|
||||
CONFIG_INTEGER(config_look_scroll_amount));
|
||||
|
||||
|
||||
/* check if we can display all */
|
||||
ptr_line = window->scroll->start_line;
|
||||
line_pos = window->scroll->start_line_pos;
|
||||
gui_chat_calculate_line_diff (window, &ptr_line,
|
||||
&line_pos,
|
||||
window->win_chat_height - 1);
|
||||
|
||||
|
||||
if (!ptr_line)
|
||||
{
|
||||
window->scroll->start_line = NULL;
|
||||
window->scroll->start_line_pos = 0;
|
||||
}
|
||||
|
||||
|
||||
gui_chat_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -375,7 +375,7 @@ gui_window_scroll_top (struct t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
if (!window->scroll->first_line_displayed)
|
||||
{
|
||||
window->scroll->start_line = window->buffer->lines->first_line;
|
||||
@@ -393,7 +393,7 @@ gui_window_scroll_bottom (struct t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
if (window->scroll->start_line)
|
||||
{
|
||||
window->scroll->start_line = NULL;
|
||||
@@ -415,7 +415,7 @@ gui_window_auto_resize (struct t_gui_window_tree *tree,
|
||||
int simulate)
|
||||
{
|
||||
int size1, size2;
|
||||
|
||||
|
||||
if (tree)
|
||||
{
|
||||
if (tree->window)
|
||||
@@ -465,7 +465,7 @@ void
|
||||
gui_window_refresh_windows ()
|
||||
{
|
||||
/*struct t_gui_window *ptr_win, *old_current_window;*/
|
||||
|
||||
|
||||
if (gui_ok)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
@@ -481,15 +481,15 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage)
|
||||
{
|
||||
struct t_gui_window *new_window;
|
||||
int height1, height2;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return NULL;
|
||||
|
||||
|
||||
new_window = NULL;
|
||||
|
||||
|
||||
height1 = (window->win_height * percentage) / 100;
|
||||
height2 = window->win_height - height1;
|
||||
|
||||
|
||||
if ((percentage > 0) && (percentage <= 100))
|
||||
{
|
||||
new_window = gui_window_new (window, window->buffer,
|
||||
@@ -502,18 +502,18 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage)
|
||||
window->win_y = new_window->win_y + new_window->win_height;
|
||||
window->win_height = height2;
|
||||
window->win_height_pct = 100 - percentage;
|
||||
|
||||
|
||||
/* assign same buffer for new window (top window) */
|
||||
gui_buffer_add_value_num_displayed (new_window->buffer, 1);
|
||||
|
||||
|
||||
gui_window_switch_to_buffer (window, window->buffer, 1);
|
||||
|
||||
|
||||
gui_current_window = new_window;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_window;
|
||||
}
|
||||
|
||||
@@ -526,15 +526,15 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
|
||||
{
|
||||
struct t_gui_window *new_window;
|
||||
int width1, width2;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return NULL;
|
||||
|
||||
|
||||
new_window = NULL;
|
||||
|
||||
|
||||
width1 = (window->win_width * percentage) / 100;
|
||||
width2 = window->win_width - width1 - 1;
|
||||
|
||||
|
||||
if ((percentage > 0) && (percentage <= 100))
|
||||
{
|
||||
new_window = gui_window_new (window, window->buffer,
|
||||
@@ -546,21 +546,21 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
|
||||
/* reduce old window height (left window) */
|
||||
window->win_width = width1;
|
||||
window->win_width_pct = 100 - percentage;
|
||||
|
||||
|
||||
/* assign same buffer for new window (right window) */
|
||||
gui_buffer_add_value_num_displayed (new_window->buffer, 1);
|
||||
|
||||
|
||||
gui_window_switch_to_buffer (window, window->buffer, 1);
|
||||
|
||||
|
||||
gui_current_window = new_window;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
|
||||
|
||||
/* create & draw separator */
|
||||
gui_window_draw_separator (gui_current_window);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_window;
|
||||
}
|
||||
|
||||
@@ -596,16 +596,16 @@ int
|
||||
gui_window_merge (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window_tree *parent, *sister;
|
||||
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
sister = (parent->child1->window == window) ?
|
||||
parent->child2 : parent->child1;
|
||||
|
||||
|
||||
if (!(sister->window))
|
||||
return 0;
|
||||
|
||||
|
||||
if (window->win_y == sister->window->win_y)
|
||||
{
|
||||
/* horizontal merge */
|
||||
@@ -622,10 +622,10 @@ gui_window_merge (struct t_gui_window *window)
|
||||
window->win_x = sister->window->win_x;
|
||||
if (sister->window->win_y < window->win_y)
|
||||
window->win_y = sister->window->win_y;
|
||||
|
||||
|
||||
gui_window_free (sister->window);
|
||||
gui_window_tree_node_to_leaf (parent, window);
|
||||
|
||||
|
||||
gui_window_switch_to_buffer (window, window->buffer, 1);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
return 1;
|
||||
@@ -685,7 +685,7 @@ gui_window_side_by_side (struct t_gui_window *win1, struct t_gui_window *win2)
|
||||
return 0;
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
/* win2 on the left ? */
|
||||
if (win2->win_x + win2->win_width + 1 == win1->win_x)
|
||||
{
|
||||
@@ -707,7 +707,7 @@ void
|
||||
gui_window_switch_up (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -730,7 +730,7 @@ void
|
||||
gui_window_switch_down (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -753,7 +753,7 @@ void
|
||||
gui_window_switch_left (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -776,7 +776,7 @@ void
|
||||
gui_window_switch_right (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -801,7 +801,7 @@ int
|
||||
gui_window_balance (struct t_gui_window_tree *tree)
|
||||
{
|
||||
(void) tree;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
return 0;
|
||||
}
|
||||
@@ -820,7 +820,7 @@ gui_window_swap (struct t_gui_window *window, int direction)
|
||||
{
|
||||
(void) window;
|
||||
(void) direction;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
@@ -832,7 +832,7 @@ void
|
||||
gui_window_refresh_screen (int full_refresh)
|
||||
{
|
||||
(void) full_refresh;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
@@ -844,7 +844,7 @@ void
|
||||
gui_window_set_title (const char *title)
|
||||
{
|
||||
(void) title;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
@@ -857,7 +857,7 @@ gui_window_send_clipboard (const char *storage_unit, const char *text)
|
||||
{
|
||||
(void) storage_unit;
|
||||
(void) text;
|
||||
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
|
||||
+174
-174
File diff suppressed because it is too large
Load Diff
+79
-79
@@ -57,17 +57,17 @@ gui_bar_window_valid (struct t_gui_bar_window *bar_window)
|
||||
struct t_gui_bar *ptr_bar;
|
||||
struct t_gui_window *ptr_window;
|
||||
struct t_gui_bar_window *ptr_bar_window;
|
||||
|
||||
|
||||
if (!bar_window)
|
||||
return 0;
|
||||
|
||||
|
||||
/* check root bars */
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (ptr_bar->bar_window && (ptr_bar->bar_window == bar_window))
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* check window bars */
|
||||
for (ptr_window = gui_windows; ptr_window;
|
||||
ptr_window = ptr_window->next_window)
|
||||
@@ -79,7 +79,7 @@ gui_bar_window_valid (struct t_gui_bar_window *bar_window)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* bar window not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ gui_bar_window_search_bar (struct t_gui_window *window, struct t_gui_bar *bar)
|
||||
if (ptr_bar_win->bar == bar)
|
||||
return ptr_bar_win;
|
||||
}
|
||||
|
||||
|
||||
/* bar window not found for window */
|
||||
return NULL;
|
||||
}
|
||||
@@ -122,12 +122,12 @@ gui_bar_window_search_by_xy (struct t_gui_window *window, int x, int y,
|
||||
struct t_gui_bar_window *ptr_bar_window;
|
||||
int filling, num_cols, column, lines, lines_old, i, j, coord_x, coord_y;
|
||||
int item, subitem;
|
||||
|
||||
|
||||
*bar_window = NULL;
|
||||
*bar_item = NULL;
|
||||
*bar_item_line = -1;
|
||||
*bar_item_col = -1;
|
||||
|
||||
|
||||
if (window)
|
||||
{
|
||||
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
|
||||
@@ -157,14 +157,14 @@ gui_bar_window_search_by_xy (struct t_gui_window *window, int x, int y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (*bar_window)
|
||||
{
|
||||
filling = gui_bar_get_filling ((*bar_window)->bar);
|
||||
|
||||
|
||||
*bar_item_line = y - (*bar_window)->y + (*bar_window)->scroll_y;
|
||||
*bar_item_col = x - (*bar_window)->x + (*bar_window)->scroll_x;
|
||||
|
||||
|
||||
if ((filling == GUI_BAR_FILLING_COLUMNS_HORIZONTAL)
|
||||
&& ((*bar_window)->screen_col_size > 0))
|
||||
{
|
||||
@@ -173,7 +173,7 @@ gui_bar_window_search_by_xy (struct t_gui_window *window, int x, int y,
|
||||
*bar_item_line = (*bar_item_line * num_cols) + column;
|
||||
*bar_item_col = *bar_item_col - (column * ((*bar_window)->screen_col_size));
|
||||
}
|
||||
|
||||
|
||||
if ((filling == GUI_BAR_FILLING_COLUMNS_VERTICAL)
|
||||
&& ((*bar_window)->screen_col_size > 0))
|
||||
{
|
||||
@@ -181,7 +181,7 @@ gui_bar_window_search_by_xy (struct t_gui_window *window, int x, int y,
|
||||
*bar_item_line = (column * ((*bar_window)->height)) + *bar_item_line;
|
||||
*bar_item_col = *bar_item_col % ((*bar_window)->screen_col_size);
|
||||
}
|
||||
|
||||
|
||||
if (filling == GUI_BAR_FILLING_HORIZONTAL)
|
||||
{
|
||||
i = 0;
|
||||
@@ -260,7 +260,7 @@ gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
{
|
||||
struct t_gui_bar_window *ptr_bar_window;
|
||||
int total_size;
|
||||
|
||||
|
||||
total_size = 0;
|
||||
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
|
||||
ptr_bar_window = ptr_bar_window->next_bar_window)
|
||||
@@ -305,10 +305,10 @@ gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
int add_bottom, add_top, add_left, add_right;
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(bar_window->bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
return;
|
||||
|
||||
|
||||
if (window)
|
||||
{
|
||||
x1 = window->win_x;
|
||||
@@ -331,7 +331,7 @@ gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
|
||||
add_left = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_RIGHT);
|
||||
}
|
||||
|
||||
|
||||
switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
|
||||
{
|
||||
case GUI_BAR_POSITION_BOTTOM:
|
||||
@@ -372,7 +372,7 @@ struct t_gui_bar_window *
|
||||
gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_bar_window *ptr_bar_window;
|
||||
|
||||
|
||||
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
|
||||
ptr_bar_window = ptr_bar_window->next_bar_window)
|
||||
{
|
||||
@@ -380,7 +380,7 @@ gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window)
|
||||
CONFIG_INTEGER(ptr_bar_window->bar->options[GUI_BAR_OPTION_PRIORITY]))
|
||||
return ptr_bar_window;
|
||||
}
|
||||
|
||||
|
||||
/* position not found, best position is at the end */
|
||||
return NULL;
|
||||
}
|
||||
@@ -416,14 +416,14 @@ gui_bar_window_content_alloc (struct t_gui_bar_window *bar_window)
|
||||
sizeof (*bar_window->items_refresh_needed));
|
||||
if (!bar_window->items_refresh_needed)
|
||||
goto error;
|
||||
|
||||
|
||||
for (i = 0; i < bar_window->items_count; i++)
|
||||
{
|
||||
bar_window->items_content[i] = NULL;
|
||||
bar_window->items_num_lines[i] = NULL;
|
||||
bar_window->items_refresh_needed[i] = NULL;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < bar_window->items_count; i++)
|
||||
{
|
||||
bar_window->items_subcount[i] = bar_window->bar->items_subcount[i];
|
||||
@@ -450,7 +450,7 @@ gui_bar_window_content_alloc (struct t_gui_bar_window *bar_window)
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
error:
|
||||
if (bar_window->items_subcount)
|
||||
{
|
||||
@@ -497,7 +497,7 @@ void
|
||||
gui_bar_window_content_free (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
||||
if (bar_window->items_content)
|
||||
{
|
||||
for (i = 0; i < bar_window->items_count; i++)
|
||||
@@ -545,7 +545,7 @@ gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window,
|
||||
bar_window->items_content[index_item][index_subitem] = NULL;
|
||||
}
|
||||
bar_window->items_num_lines[index_item][index_subitem] = 0;
|
||||
|
||||
|
||||
/* build item, but only if there's a buffer in window */
|
||||
if ((window && window->buffer)
|
||||
|| (gui_current_window && gui_current_window->buffer))
|
||||
@@ -571,10 +571,10 @@ gui_bar_window_content_build (struct t_gui_bar_window *bar_window,
|
||||
struct t_gui_window *window)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
||||
gui_bar_window_content_free (bar_window);
|
||||
gui_bar_window_content_alloc (bar_window);
|
||||
|
||||
|
||||
for (i = 0; i < bar_window->items_count; i++)
|
||||
{
|
||||
for (j = 0; j < bar_window->items_subcount[i]; j++)
|
||||
@@ -600,7 +600,7 @@ gui_bar_window_content_get (struct t_gui_bar_window *bar_window,
|
||||
gui_bar_window_content_build_item (bar_window, window,
|
||||
index_item, index_subitem);
|
||||
}
|
||||
|
||||
|
||||
/* return content */
|
||||
return bar_window->items_content[index_item][index_subitem];
|
||||
}
|
||||
@@ -625,15 +625,15 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
int length_reinit_color_space, length_start_item, length;
|
||||
int max_length, max_length_screen;
|
||||
int total_items, columns, lines;
|
||||
|
||||
|
||||
if (!bar_window->items_subcount || !bar_window->items_content
|
||||
|| !bar_window->items_num_lines || !bar_window->items_refresh_needed)
|
||||
return NULL;
|
||||
|
||||
|
||||
snprintf (str_reinit_color, sizeof (str_reinit_color),
|
||||
"%c",
|
||||
GUI_COLOR_RESET_CHAR);
|
||||
|
||||
|
||||
snprintf (str_reinit_color_space, sizeof (str_reinit_color_space),
|
||||
"%c ",
|
||||
GUI_COLOR_RESET_CHAR);
|
||||
@@ -646,14 +646,14 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
GUI_COLOR_COLOR_CHAR,
|
||||
GUI_COLOR_BAR_CHAR,
|
||||
GUI_COLOR_BAR_START_LINE_ITEM);
|
||||
|
||||
|
||||
snprintf (str_start_item, sizeof (str_start_item),
|
||||
"%c%c%c",
|
||||
GUI_COLOR_COLOR_CHAR,
|
||||
GUI_COLOR_BAR_CHAR,
|
||||
GUI_COLOR_BAR_START_ITEM);
|
||||
length_start_item = strlen (str_start_item);
|
||||
|
||||
|
||||
content_length = 1;
|
||||
content = malloc (content_length);
|
||||
if (content)
|
||||
@@ -690,7 +690,7 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
}
|
||||
else
|
||||
item_value = NULL;
|
||||
|
||||
|
||||
content_length += ((filling == GUI_BAR_FILLING_HORIZONTAL) ? length_start_item : 0) +
|
||||
length_reinit_color_space +
|
||||
strlen ((item_value) ? item_value : ptr_content);
|
||||
@@ -719,7 +719,7 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
strcat (content,
|
||||
(item_value) ? item_value : ptr_content);
|
||||
first_sub_item = 0;
|
||||
|
||||
|
||||
if (item_value)
|
||||
free (item_value);
|
||||
at_least_one_item = 1;
|
||||
@@ -778,11 +778,11 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
for (j = 0; split_items[i][sub][j]; j++)
|
||||
{
|
||||
total_items++;
|
||||
|
||||
|
||||
length = strlen (split_items[i][sub][j]);
|
||||
if (length > max_length)
|
||||
max_length = length;
|
||||
|
||||
|
||||
length = gui_chat_strlen_screen (split_items[i][sub][j]);
|
||||
if (length > max_length_screen)
|
||||
max_length_screen = length;
|
||||
@@ -813,9 +813,9 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
lines = bar_window->height;
|
||||
}
|
||||
bar_window->screen_col_size = max_length_screen + 1;
|
||||
|
||||
|
||||
/* build array with pointers to split items */
|
||||
|
||||
|
||||
linear_items = malloc (total_items * sizeof (*linear_items));
|
||||
if (linear_items)
|
||||
{
|
||||
@@ -836,7 +836,7 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* build content with lines and columns */
|
||||
content_length = 1 + (lines *
|
||||
((columns *
|
||||
@@ -859,7 +859,7 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
index = (i * columns) + j;
|
||||
else
|
||||
index = (j * lines) + i;
|
||||
|
||||
|
||||
if (index >= total_items)
|
||||
{
|
||||
for (k = 0; k < max_length_screen; k++)
|
||||
@@ -888,10 +888,10 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
content[index_content++] = '\n';
|
||||
}
|
||||
content[index_content] = '\0';
|
||||
|
||||
|
||||
free (linear_items);
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < bar_window->items_count; i++)
|
||||
{
|
||||
if (split_items[i])
|
||||
@@ -909,13 +909,13 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
|
||||
case GUI_BAR_NUM_FILLING:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (content_length == 1)
|
||||
{
|
||||
free (content);
|
||||
content = NULL;
|
||||
}
|
||||
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
@@ -929,7 +929,7 @@ gui_bar_window_coords_add (struct t_gui_bar_window *bar_window,
|
||||
int x, int y)
|
||||
{
|
||||
struct t_gui_bar_window_coords **coords2;
|
||||
|
||||
|
||||
if (!bar_window->coords)
|
||||
{
|
||||
bar_window->coords_count = 1;
|
||||
@@ -968,7 +968,7 @@ void
|
||||
gui_bar_window_coords_free (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (bar_window->coords)
|
||||
{
|
||||
for (i = 0; i < bar_window->coords_count; i++)
|
||||
@@ -991,7 +991,7 @@ gui_bar_window_insert (struct t_gui_bar_window *bar_window,
|
||||
struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_bar_window *pos_bar_window;
|
||||
|
||||
|
||||
if (window->bar_windows)
|
||||
{
|
||||
pos_bar_window = gui_bar_window_find_pos (bar_window->bar, window);
|
||||
@@ -1033,17 +1033,17 @@ void
|
||||
gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_bar_window *new_bar_window;
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
return;
|
||||
|
||||
|
||||
if (window)
|
||||
{
|
||||
if ((CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_WINDOW)
|
||||
&& (!gui_bar_check_conditions_for_window (bar, window)))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
new_bar_window = malloc (sizeof (*new_bar_window));
|
||||
if (new_bar_window)
|
||||
{
|
||||
@@ -1059,7 +1059,7 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
|
||||
new_bar_window->prev_bar_window = NULL;
|
||||
new_bar_window->next_bar_window = NULL;
|
||||
}
|
||||
|
||||
|
||||
new_bar_window->x = 0;
|
||||
new_bar_window->y = 0;
|
||||
new_bar_window->width = 1;
|
||||
@@ -1080,7 +1080,7 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
|
||||
new_bar_window->coords = NULL;
|
||||
gui_bar_window_objects_init (new_bar_window);
|
||||
gui_bar_window_content_alloc (new_bar_window);
|
||||
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
gui_bar_window_calculate_pos_size (new_bar_window, window);
|
||||
@@ -1112,9 +1112,9 @@ gui_bar_window_get_max_size_in_window (struct t_gui_bar_window *bar_window,
|
||||
struct t_gui_window *window)
|
||||
{
|
||||
int max_size;
|
||||
|
||||
|
||||
max_size = 1;
|
||||
|
||||
|
||||
if (bar_window && window)
|
||||
{
|
||||
switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
|
||||
@@ -1133,7 +1133,7 @@ gui_bar_window_get_max_size_in_window (struct t_gui_bar_window *bar_window,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return max_size;
|
||||
}
|
||||
|
||||
@@ -1147,7 +1147,7 @@ gui_bar_window_get_max_size (struct t_gui_bar_window *bar_window,
|
||||
{
|
||||
int max_size_found, max_size;
|
||||
struct t_gui_window *ptr_window;
|
||||
|
||||
|
||||
if (window)
|
||||
{
|
||||
max_size_found = gui_bar_window_get_max_size_in_window (bar_window,
|
||||
@@ -1167,7 +1167,7 @@ gui_bar_window_get_max_size (struct t_gui_bar_window *bar_window,
|
||||
if (max_size_found == INT_MAX)
|
||||
max_size_found = 1;
|
||||
}
|
||||
|
||||
|
||||
return max_size_found;
|
||||
}
|
||||
|
||||
@@ -1180,7 +1180,7 @@ gui_bar_window_set_current_size (struct t_gui_bar_window *bar_window,
|
||||
struct t_gui_window *window, int size)
|
||||
{
|
||||
int new_size, max_size;
|
||||
|
||||
|
||||
if (size == 0)
|
||||
new_size = 1;
|
||||
else
|
||||
@@ -1194,7 +1194,7 @@ gui_bar_window_set_current_size (struct t_gui_bar_window *bar_window,
|
||||
new_size = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (bar_window->current_size != new_size)
|
||||
{
|
||||
max_size = gui_bar_window_get_max_size (bar_window, window);
|
||||
@@ -1235,15 +1235,15 @@ gui_bar_window_free (struct t_gui_bar_window *bar_window,
|
||||
if (window->last_bar_window == bar_window)
|
||||
window->last_bar_window = bar_window->prev_bar_window;
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
gui_bar_window_content_free (bar_window);
|
||||
gui_bar_window_coords_free (bar_window);
|
||||
gui_bar_window_objects_free (bar_window);
|
||||
free (bar_window->gui_objects);
|
||||
|
||||
|
||||
free (bar_window);
|
||||
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
@@ -1258,24 +1258,24 @@ gui_bar_window_remove_unused_bars (struct t_gui_window *window)
|
||||
{
|
||||
int rc;
|
||||
struct t_gui_bar_window *ptr_bar_win, *next_bar_win;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
ptr_bar_win = window->bar_windows;
|
||||
while (ptr_bar_win)
|
||||
{
|
||||
next_bar_win = ptr_bar_win->next_bar_window;
|
||||
|
||||
|
||||
if ((CONFIG_INTEGER(ptr_bar_win->bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_WINDOW)
|
||||
&& (!gui_bar_check_conditions_for_window (ptr_bar_win->bar, window)))
|
||||
{
|
||||
gui_bar_window_free (ptr_bar_win, window);
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
||||
ptr_bar_win = next_bar_win;
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1290,9 +1290,9 @@ gui_bar_window_add_missing_bars (struct t_gui_window *window)
|
||||
{
|
||||
int rc;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_WINDOW)
|
||||
@@ -1305,7 +1305,7 @@ gui_bar_window_add_missing_bars (struct t_gui_window *window)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1323,7 +1323,7 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
|
||||
int add, int percent, int value)
|
||||
{
|
||||
int old_scroll_x, old_scroll_y;
|
||||
|
||||
|
||||
old_scroll_x = bar_window->scroll_x;
|
||||
old_scroll_y = bar_window->scroll_y;
|
||||
|
||||
@@ -1367,13 +1367,13 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
|
||||
bar_window->scroll_y -= value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (bar_window->scroll_x < 0)
|
||||
bar_window->scroll_x = 0;
|
||||
|
||||
|
||||
if (bar_window->scroll_y < 0)
|
||||
bar_window->scroll_y = 0;
|
||||
|
||||
|
||||
/* refresh only if scroll has changed (X and/or Y) */
|
||||
if ((old_scroll_x != bar_window->scroll_x)
|
||||
|| (old_scroll_y != bar_window->scroll_y))
|
||||
@@ -1390,10 +1390,10 @@ struct t_hdata *
|
||||
gui_bar_window_hdata_bar_window_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_bar_window", "next_bar_window");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1434,14 +1434,14 @@ gui_bar_window_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_infolist_item *ptr_item;
|
||||
int i, j;
|
||||
char option_name[64];
|
||||
|
||||
|
||||
if (!infolist || !bar_window)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_pointer (ptr_item, "bar", bar_window->bar))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "x", bar_window->x))
|
||||
@@ -1484,7 +1484,7 @@ gui_bar_window_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "gui_objects", bar_window->gui_objects))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1496,7 +1496,7 @@ void
|
||||
gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
||||
log_printf ("");
|
||||
log_printf (" [window bar (addr:0x%lx)]", bar_window);
|
||||
log_printf (" bar. . . . . . . . . . : 0x%lx ('%s')",
|
||||
|
||||
+139
-139
@@ -82,16 +82,16 @@ int
|
||||
gui_bar_valid (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
if (!bar)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (ptr_bar == bar)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* bar not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -106,16 +106,16 @@ int
|
||||
gui_bar_search_option (const char *option_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!option_name)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
|
||||
{
|
||||
if (string_strcasecmp (gui_bar_option_string[i], option_name) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* bar option not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -129,16 +129,16 @@ int
|
||||
gui_bar_search_type (const char *type)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!type)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_BAR_NUM_TYPES; i++)
|
||||
{
|
||||
if (string_strcasecmp (gui_bar_type_string[i], type) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* type not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -152,16 +152,16 @@ int
|
||||
gui_bar_search_position (const char *position)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!position)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_BAR_NUM_POSITIONS; i++)
|
||||
{
|
||||
if (string_strcasecmp (gui_bar_position_string[i], position) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* position not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -179,10 +179,10 @@ gui_bar_get_min_width (struct t_gui_bar *bar)
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
int min_width;
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
|
||||
return bar->bar_window->width;
|
||||
|
||||
|
||||
min_width = INT_MAX;
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -196,10 +196,10 @@ gui_bar_get_min_width (struct t_gui_bar *bar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (min_width == INT_MAX)
|
||||
return 0;
|
||||
|
||||
|
||||
return min_width;
|
||||
}
|
||||
|
||||
@@ -216,10 +216,10 @@ gui_bar_get_min_height (struct t_gui_bar *bar)
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
int min_height;
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
|
||||
return bar->bar_window->height;
|
||||
|
||||
|
||||
min_height = INT_MAX;
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -233,10 +233,10 @@ gui_bar_get_min_height (struct t_gui_bar *bar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (min_height == INT_MAX)
|
||||
return 0;
|
||||
|
||||
|
||||
return min_height;
|
||||
}
|
||||
|
||||
@@ -251,10 +251,10 @@ gui_bar_check_size_add (struct t_gui_bar *bar, int add_size)
|
||||
{
|
||||
struct t_gui_window *ptr_window;
|
||||
int sub_width, sub_height;
|
||||
|
||||
|
||||
sub_width = 0;
|
||||
sub_height = 0;
|
||||
|
||||
|
||||
switch (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION]))
|
||||
{
|
||||
case GUI_BAR_POSITION_BOTTOM:
|
||||
@@ -268,7 +268,7 @@ gui_bar_check_size_add (struct t_gui_bar *bar, int add_size)
|
||||
case GUI_BAR_NUM_POSITIONS:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
for (ptr_window = gui_windows; ptr_window;
|
||||
ptr_window = ptr_window->next_window)
|
||||
{
|
||||
@@ -280,7 +280,7 @@ gui_bar_check_size_add (struct t_gui_bar *bar, int add_size)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* new size ok */
|
||||
return 1;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ gui_bar_get_filling (struct t_gui_bar *bar)
|
||||
if ((CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION]) == GUI_BAR_POSITION_BOTTOM)
|
||||
|| (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION]) == GUI_BAR_POSITION_TOP))
|
||||
return CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM]);
|
||||
|
||||
|
||||
return CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT]);
|
||||
}
|
||||
|
||||
@@ -309,13 +309,13 @@ struct t_gui_bar *
|
||||
gui_bar_find_pos (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_PRIORITY]) >= CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_PRIORITY]))
|
||||
return ptr_bar;
|
||||
}
|
||||
|
||||
|
||||
/* bar not found, add to end of list */
|
||||
return NULL;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ void
|
||||
gui_bar_insert (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_bar *pos_bar;
|
||||
|
||||
|
||||
if (gui_bars)
|
||||
{
|
||||
pos_bar = gui_bar_find_pos (bar);
|
||||
@@ -394,7 +394,7 @@ gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call a modifier that will tell us if bar is displayed or not,
|
||||
* for example it can be used to display nicklist on some buffers
|
||||
@@ -415,7 +415,7 @@ gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
|
||||
rc = 1;
|
||||
if (str_displayed)
|
||||
free (str_displayed);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ gui_bar_root_get_size (struct t_gui_bar *bar, enum t_gui_bar_position position)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
int total_size;
|
||||
|
||||
|
||||
total_size = 0;
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
@@ -457,16 +457,16 @@ struct t_gui_bar *
|
||||
gui_bar_search (const char *name)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (strcmp (ptr_bar->name, name) == 0)
|
||||
return ptr_bar;
|
||||
}
|
||||
|
||||
|
||||
/* bar not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -481,9 +481,9 @@ gui_bar_search_with_option_name (const char *option_name)
|
||||
{
|
||||
char *bar_name, *pos_option;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
ptr_bar = NULL;
|
||||
|
||||
|
||||
pos_option = strchr (option_name, '.');
|
||||
if (pos_option)
|
||||
{
|
||||
@@ -498,7 +498,7 @@ gui_bar_search_with_option_name (const char *option_name)
|
||||
free (bar_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ptr_bar;
|
||||
}
|
||||
|
||||
@@ -511,10 +511,10 @@ gui_bar_content_build_bar_windows (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_window *ptr_window;
|
||||
struct t_gui_bar_window *ptr_bar_window;
|
||||
|
||||
|
||||
if (!bar)
|
||||
return;
|
||||
|
||||
|
||||
if (bar->bar_window)
|
||||
{
|
||||
gui_bar_window_content_build (bar->bar_window, NULL);
|
||||
@@ -552,7 +552,7 @@ void
|
||||
gui_bar_refresh (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
|
||||
gui_window_ask_refresh (1);
|
||||
else
|
||||
@@ -574,7 +574,7 @@ gui_bar_draw (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
|
||||
|
||||
if (!CONFIG_BOOLEAN(bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
{
|
||||
if (bar->bar_window)
|
||||
@@ -610,7 +610,7 @@ gui_bar_apply_current_size (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
|
||||
{
|
||||
gui_bar_window_set_current_size (bar->bar_window,
|
||||
@@ -644,7 +644,7 @@ void
|
||||
gui_bar_free_items_arrays (struct t_gui_bar *bar)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
||||
for (i = 0; i < bar->items_count; i++)
|
||||
{
|
||||
if (bar->items_array[i])
|
||||
@@ -702,9 +702,9 @@ gui_bar_set_items_array (struct t_gui_bar *bar, const char *items)
|
||||
{
|
||||
int i, j, count;
|
||||
char **tmp_array;
|
||||
|
||||
|
||||
gui_bar_free_items_arrays (bar);
|
||||
|
||||
|
||||
if (items && items[0])
|
||||
{
|
||||
tmp_array = string_split (items, ",", 0, 0, &count);
|
||||
@@ -773,10 +773,10 @@ gui_bar_config_change_hidden (void *data, struct t_config_option *option)
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_bar_window *ptr_bar_win, *next_bar_win;
|
||||
int bar_window_exists;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar)
|
||||
{
|
||||
@@ -801,7 +801,7 @@ gui_bar_config_change_hidden (void *data, struct t_config_option *option)
|
||||
while (ptr_bar_win)
|
||||
{
|
||||
next_bar_win = ptr_bar_win->next_bar_window;
|
||||
|
||||
|
||||
if (ptr_bar_win->bar == ptr_bar)
|
||||
{
|
||||
if (CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
@@ -809,7 +809,7 @@ gui_bar_config_change_hidden (void *data, struct t_config_option *option)
|
||||
else
|
||||
bar_window_exists = 1;
|
||||
}
|
||||
|
||||
|
||||
ptr_bar_win = next_bar_win;
|
||||
}
|
||||
if (!bar_window_exists
|
||||
@@ -833,10 +833,10 @@ gui_bar_config_change_priority (void *data, struct t_config_option *option)
|
||||
struct t_gui_bar *ptr_bar;
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_bar_window *bar_windows, *ptr_bar_win, *next_bar_win;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar)
|
||||
{
|
||||
@@ -855,9 +855,9 @@ gui_bar_config_change_priority (void *data, struct t_config_option *option)
|
||||
(ptr_bar->prev_bar)->next_bar = ptr_bar->next_bar;
|
||||
if (ptr_bar->next_bar)
|
||||
(ptr_bar->next_bar)->prev_bar = ptr_bar->prev_bar;
|
||||
|
||||
|
||||
gui_bar_insert (ptr_bar);
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
bar_windows = ptr_win->bar_windows;
|
||||
@@ -873,7 +873,7 @@ gui_bar_config_change_priority (void *data, struct t_config_option *option)
|
||||
ptr_bar_win = next_bar_win;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
}
|
||||
@@ -886,16 +886,16 @@ void
|
||||
gui_bar_config_change_conditions (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar)
|
||||
{
|
||||
if (ptr_bar->conditions_array)
|
||||
string_free_split (ptr_bar->conditions_array);
|
||||
|
||||
|
||||
if (CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS])
|
||||
&& CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS])[0])
|
||||
{
|
||||
@@ -909,7 +909,7 @@ gui_bar_config_change_conditions (void *data, struct t_config_option *option)
|
||||
ptr_bar->conditions_array = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
@@ -921,14 +921,14 @@ void
|
||||
gui_bar_config_change_position (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
gui_bar_refresh (ptr_bar);
|
||||
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
@@ -940,14 +940,14 @@ void
|
||||
gui_bar_config_change_filling (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
gui_bar_refresh (ptr_bar);
|
||||
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
}
|
||||
|
||||
@@ -963,10 +963,10 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
|
||||
long number;
|
||||
char *error;
|
||||
int new_value;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar)
|
||||
{
|
||||
@@ -1000,7 +1000,7 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
|
||||
}
|
||||
if (new_value < 0)
|
||||
return 0;
|
||||
|
||||
|
||||
if ((new_value > 0) &&
|
||||
((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE]) == 0)
|
||||
|| (new_value > CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE]))))
|
||||
@@ -1010,10 +1010,10 @@ gui_bar_config_check_size (void *data, struct t_config_option *option,
|
||||
new_value - CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_SIZE])))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1025,10 +1025,10 @@ void
|
||||
gui_bar_config_change_size (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
{
|
||||
@@ -1046,7 +1046,7 @@ gui_bar_config_change_size_max (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
char value[32];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
@@ -1074,10 +1074,10 @@ void
|
||||
gui_bar_config_change_color (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
gui_bar_refresh (ptr_bar);
|
||||
@@ -1091,10 +1091,10 @@ void
|
||||
gui_bar_config_change_separator (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar && !CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
gui_bar_refresh (ptr_bar);
|
||||
@@ -1108,10 +1108,10 @@ void
|
||||
gui_bar_config_change_items (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_bar = gui_bar_search_with_option_name (option->name);
|
||||
if (ptr_bar)
|
||||
{
|
||||
@@ -1131,10 +1131,10 @@ gui_bar_set_name (struct t_gui_bar *bar, const char *name)
|
||||
{
|
||||
int length;
|
||||
char *option_name;
|
||||
|
||||
|
||||
if (!name || !name[0])
|
||||
return;
|
||||
|
||||
|
||||
length = strlen (name) + 64;
|
||||
option_name = malloc (length);
|
||||
if (option_name)
|
||||
@@ -1167,11 +1167,11 @@ gui_bar_set_name (struct t_gui_bar *bar, const char *name)
|
||||
config_file_option_rename (bar->options[GUI_BAR_OPTION_SEPARATOR], option_name);
|
||||
snprintf (option_name, length, "%s.items", name);
|
||||
config_file_option_rename (bar->options[GUI_BAR_OPTION_ITEMS], option_name);
|
||||
|
||||
|
||||
if (bar->name)
|
||||
free (bar->name);
|
||||
bar->name = strdup (name);
|
||||
|
||||
|
||||
free (option_name);
|
||||
}
|
||||
}
|
||||
@@ -1186,7 +1186,7 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value)
|
||||
{
|
||||
if (!bar || !property || !value)
|
||||
return 0;
|
||||
|
||||
|
||||
if (string_strcasecmp (property, "name") == 0)
|
||||
{
|
||||
gui_bar_set_name (bar, value);
|
||||
@@ -1264,7 +1264,7 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value)
|
||||
gui_bar_draw (bar);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1280,13 +1280,13 @@ gui_bar_default_items (const char *bar_name)
|
||||
{
|
||||
int i;
|
||||
static char empty_items[1] = { '\0' };
|
||||
|
||||
|
||||
for (i = 0; gui_bar_items_default_for_bars[i][0]; i++)
|
||||
{
|
||||
if (strcmp (gui_bar_items_default_for_bars[i][0], bar_name) == 0)
|
||||
return gui_bar_items_default_for_bars[i][1];
|
||||
}
|
||||
|
||||
|
||||
/* no default items in bar */
|
||||
return empty_items;
|
||||
}
|
||||
@@ -1301,9 +1301,9 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
|
||||
struct t_config_option *ptr_option;
|
||||
int length;
|
||||
char *option_name;
|
||||
|
||||
|
||||
ptr_option = NULL;
|
||||
|
||||
|
||||
length = strlen (bar_name) + 1 +
|
||||
strlen (gui_bar_option_string[index_option]) + 1;
|
||||
option_name = malloc (length);
|
||||
@@ -1311,7 +1311,7 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
|
||||
{
|
||||
snprintf (option_name, length, "%s.%s",
|
||||
bar_name, gui_bar_option_string[index_option]);
|
||||
|
||||
|
||||
switch (index_option)
|
||||
{
|
||||
case GUI_BAR_OPTION_HIDDEN:
|
||||
@@ -1449,7 +1449,7 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
|
||||
}
|
||||
free (option_name);
|
||||
}
|
||||
|
||||
|
||||
return ptr_option;
|
||||
}
|
||||
|
||||
@@ -1463,7 +1463,7 @@ gui_bar_create_option_temp (struct t_gui_bar *temp_bar, int index_option,
|
||||
const char *value)
|
||||
{
|
||||
struct t_config_option *new_option;
|
||||
|
||||
|
||||
new_option = gui_bar_create_option (temp_bar->name,
|
||||
index_option,
|
||||
value);
|
||||
@@ -1526,7 +1526,7 @@ gui_bar_alloc (const char *name)
|
||||
{
|
||||
struct t_gui_bar *new_bar;
|
||||
int i;
|
||||
|
||||
|
||||
new_bar = malloc (sizeof (*new_bar));
|
||||
if (new_bar)
|
||||
{
|
||||
@@ -1547,7 +1547,7 @@ gui_bar_alloc (const char *name)
|
||||
new_bar->prev_bar = NULL;
|
||||
new_bar->next_bar = NULL;
|
||||
}
|
||||
|
||||
|
||||
return new_bar;
|
||||
}
|
||||
|
||||
@@ -1574,7 +1574,7 @@ gui_bar_new_with_options (const char *name,
|
||||
{
|
||||
struct t_gui_bar *new_bar;
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
/* create bar */
|
||||
new_bar = gui_bar_alloc (name);
|
||||
if (new_bar)
|
||||
@@ -1613,10 +1613,10 @@ gui_bar_new_with_options (const char *name,
|
||||
gui_bar_set_items_array (new_bar, CONFIG_STRING(items));
|
||||
new_bar->bar_window = NULL;
|
||||
new_bar->bar_refresh_needed = 1;
|
||||
|
||||
|
||||
/* add bar to bars list */
|
||||
gui_bar_insert (new_bar);
|
||||
|
||||
|
||||
/* add window bar */
|
||||
if (CONFIG_INTEGER(new_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
|
||||
{
|
||||
@@ -1634,7 +1634,7 @@ gui_bar_new_with_options (const char *name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_bar;
|
||||
}
|
||||
|
||||
@@ -1658,22 +1658,22 @@ gui_bar_new (const char *name, const char *hidden, const char *priority,
|
||||
struct t_config_option *option_color_bg, *option_separator;
|
||||
struct t_config_option *option_items;
|
||||
struct t_gui_bar *new_bar;
|
||||
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
/* it's not possible to create 2 bars with same name */
|
||||
if (gui_bar_search (name))
|
||||
return NULL;
|
||||
|
||||
|
||||
/* look for type */
|
||||
if (gui_bar_search_type (type) < 0)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* look for position */
|
||||
if (gui_bar_search_position (position) < 0)
|
||||
return NULL;
|
||||
|
||||
|
||||
option_hidden = gui_bar_create_option (name, GUI_BAR_OPTION_HIDDEN,
|
||||
hidden);
|
||||
option_priority = gui_bar_create_option (name, GUI_BAR_OPTION_PRIORITY,
|
||||
@@ -1743,7 +1743,7 @@ gui_bar_new (const char *name, const char *hidden, const char *priority,
|
||||
if (option_items)
|
||||
config_file_option_free (option_items);
|
||||
}
|
||||
|
||||
|
||||
return new_bar;
|
||||
}
|
||||
|
||||
@@ -1756,7 +1756,7 @@ gui_bar_use_temp_bars ()
|
||||
{
|
||||
struct t_gui_bar *ptr_temp_bar, *next_temp_bar;
|
||||
int i, num_options_ok;
|
||||
|
||||
|
||||
for (ptr_temp_bar = gui_temp_bars; ptr_temp_bar;
|
||||
ptr_temp_bar = ptr_temp_bar->next_bar)
|
||||
{
|
||||
@@ -1772,7 +1772,7 @@ gui_bar_use_temp_bars ()
|
||||
if (ptr_temp_bar->options[i])
|
||||
num_options_ok++;
|
||||
}
|
||||
|
||||
|
||||
if (num_options_ok == GUI_BAR_NUM_OPTIONS)
|
||||
{
|
||||
gui_bar_new_with_options (ptr_temp_bar->name,
|
||||
@@ -1803,16 +1803,16 @@ gui_bar_use_temp_bars ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* free all temp bars */
|
||||
while (gui_temp_bars)
|
||||
{
|
||||
next_temp_bar = gui_temp_bars->next_bar;
|
||||
|
||||
|
||||
if (gui_temp_bars->name)
|
||||
free (gui_temp_bars->name);
|
||||
free (gui_temp_bars);
|
||||
|
||||
|
||||
gui_temp_bars = next_temp_bar;
|
||||
}
|
||||
last_gui_temp_bar = NULL;
|
||||
@@ -1828,7 +1828,7 @@ gui_bar_create_default_input ()
|
||||
struct t_gui_bar *ptr_bar;
|
||||
int length;
|
||||
char *buf;
|
||||
|
||||
|
||||
/* search an input_text item */
|
||||
if (!gui_bar_item_used_in_a_bar (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT], 1))
|
||||
{
|
||||
@@ -1889,7 +1889,7 @@ void
|
||||
gui_bar_create_default_title ()
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* search title bar */
|
||||
ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_TITLE);
|
||||
if (!ptr_bar)
|
||||
@@ -1925,7 +1925,7 @@ void
|
||||
gui_bar_create_default_status ()
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* search status bar */
|
||||
ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_STATUS);
|
||||
if (!ptr_bar)
|
||||
@@ -1961,7 +1961,7 @@ void
|
||||
gui_bar_create_default_nicklist ()
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
/* search nicklist bar */
|
||||
ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_NICKLIST);
|
||||
if (!ptr_bar)
|
||||
@@ -2010,7 +2010,7 @@ void
|
||||
gui_bar_update (const char *name)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (!CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN])
|
||||
@@ -2034,13 +2034,13 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
long number;
|
||||
char *str, *error;
|
||||
int length, add_x, add, percent, scroll_beginning, scroll_end;
|
||||
|
||||
|
||||
if (!bar)
|
||||
return 0;
|
||||
|
||||
|
||||
if (CONFIG_BOOLEAN(bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||
return 1;
|
||||
|
||||
|
||||
add_x = 0;
|
||||
str = NULL;
|
||||
number = 0;
|
||||
@@ -2048,7 +2048,7 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
percent = 0;
|
||||
scroll_beginning = 0;
|
||||
scroll_end = 0;
|
||||
|
||||
|
||||
if ((scroll[0] == 'x') || (scroll[0] == 'X'))
|
||||
{
|
||||
add_x = 1;
|
||||
@@ -2064,7 +2064,7 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
if (gui_bar_get_filling (bar) == GUI_BAR_FILLING_HORIZONTAL)
|
||||
add_x = 1;
|
||||
}
|
||||
|
||||
|
||||
if ((scroll[0] == 'b') || (scroll[0] == 'B'))
|
||||
{
|
||||
scroll_beginning = 1;
|
||||
@@ -2086,11 +2086,11 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
|
||||
length = strlen (scroll);
|
||||
if (length == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
if (scroll[length - 1] == '%')
|
||||
{
|
||||
str = string_strndup (scroll, length - 1);
|
||||
@@ -2100,17 +2100,17 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
str = strdup (scroll);
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
|
||||
error = NULL;
|
||||
number = strtol (str, &error, 10);
|
||||
|
||||
|
||||
if (!error || error[0] || (number <= 0))
|
||||
{
|
||||
free (str);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT)
|
||||
{
|
||||
gui_bar_window_scroll (bar->bar_window, NULL,
|
||||
@@ -2130,10 +2130,10 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (str)
|
||||
free (str);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2145,10 +2145,10 @@ void
|
||||
gui_bar_free (struct t_gui_bar *bar)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!bar)
|
||||
return;
|
||||
|
||||
|
||||
/* remove bar window(s) */
|
||||
if (bar->bar_window)
|
||||
{
|
||||
@@ -2157,7 +2157,7 @@ gui_bar_free (struct t_gui_bar *bar)
|
||||
}
|
||||
else
|
||||
gui_bar_free_bar_windows (bar);
|
||||
|
||||
|
||||
/* remove bar from bars list */
|
||||
if (bar->prev_bar)
|
||||
(bar->prev_bar)->next_bar = bar->next_bar;
|
||||
@@ -2167,7 +2167,7 @@ gui_bar_free (struct t_gui_bar *bar)
|
||||
gui_bars = bar->next_bar;
|
||||
if (last_gui_bar == bar)
|
||||
last_gui_bar = bar->prev_bar;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (bar->name)
|
||||
free (bar->name);
|
||||
@@ -2179,7 +2179,7 @@ gui_bar_free (struct t_gui_bar *bar)
|
||||
if (bar->conditions_array)
|
||||
string_free_split (bar->conditions_array);
|
||||
gui_bar_free_items_arrays (bar);
|
||||
|
||||
|
||||
free (bar);
|
||||
}
|
||||
|
||||
@@ -2205,7 +2205,7 @@ gui_bar_free_bar_windows (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_bar_window *ptr_bar_win, *next_bar_win;
|
||||
|
||||
|
||||
if (bar->bar_window)
|
||||
{
|
||||
gui_bar_window_free (bar->bar_window, NULL);
|
||||
@@ -2219,10 +2219,10 @@ gui_bar_free_bar_windows (struct t_gui_bar *bar)
|
||||
while (ptr_bar_win)
|
||||
{
|
||||
next_bar_win = ptr_bar_win->next_bar_window;
|
||||
|
||||
|
||||
if (ptr_bar_win->bar == bar)
|
||||
gui_bar_window_free (ptr_bar_win, ptr_win);
|
||||
|
||||
|
||||
ptr_bar_win = next_bar_win;
|
||||
}
|
||||
}
|
||||
@@ -2237,10 +2237,10 @@ struct t_hdata *
|
||||
gui_bar_hdata_bar_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_bar", "next_bar");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -2276,10 +2276,10 @@ gui_bar_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_infolist_item *ptr_item;
|
||||
int i, j;
|
||||
char option_name[64];
|
||||
|
||||
|
||||
if (!infolist || !bar)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
@@ -2349,7 +2349,7 @@ gui_bar_add_to_infolist (struct t_infolist *infolist,
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "bar_window", bar->bar_window))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2362,7 +2362,7 @@ gui_bar_print_log ()
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
int i, j;
|
||||
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
log_printf ("");
|
||||
@@ -2418,7 +2418,7 @@ gui_bar_print_log ()
|
||||
log_printf (" bar_refresh_needed . . : %d", ptr_bar->bar_refresh_needed);
|
||||
log_printf (" prev_bar . . . . . . . : 0x%lx", ptr_bar->prev_bar);
|
||||
log_printf (" next_bar . . . . . . . : 0x%lx", ptr_bar->next_bar);
|
||||
|
||||
|
||||
if (ptr_bar->bar_window)
|
||||
gui_bar_window_print_log (ptr_bar->bar_window);
|
||||
}
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ struct t_gui_bar
|
||||
/* user choices */
|
||||
char *name; /* bar name */
|
||||
struct t_config_option *options[GUI_BAR_NUM_OPTIONS];
|
||||
|
||||
|
||||
/* internal vars */
|
||||
int conditions_count; /* number of conditions */
|
||||
char **conditions_array; /* bar conditions (after split) */
|
||||
|
||||
+254
-254
File diff suppressed because it is too large
Load Diff
+15
-15
@@ -72,7 +72,7 @@ struct t_gui_buffer
|
||||
* loaded
|
||||
*/
|
||||
char *plugin_name_for_upgrade; /* plugin name when upgrading */
|
||||
|
||||
|
||||
int number; /* buffer number (first is 1) */
|
||||
int layout_number; /* number of buffer saved in layout */
|
||||
int layout_number_merge_order; /* order in merge for layout */
|
||||
@@ -88,15 +88,15 @@ struct t_gui_buffer
|
||||
/* merged and that this one is not */
|
||||
/* selected buffer */
|
||||
int print_hooks_enabled; /* 1 if print hooks are enabled */
|
||||
|
||||
|
||||
/* close callback */
|
||||
int (*close_callback)(void *data, /* called when buffer is closed */
|
||||
struct t_gui_buffer *buffer);
|
||||
void *close_callback_data; /* data for callback */
|
||||
|
||||
|
||||
/* buffer title */
|
||||
char *title; /* buffer title */
|
||||
|
||||
|
||||
/* chat content */
|
||||
struct t_gui_lines *own_lines; /* lines (for this buffer only) */
|
||||
struct t_gui_lines *mixed_lines; /* mixed lines (if buffers merged) */
|
||||
@@ -105,7 +105,7 @@ struct t_gui_buffer
|
||||
int time_for_each_line; /* time is displayed for each line? */
|
||||
int chat_refresh_needed; /* refresh for chat is needed ? */
|
||||
/* (1=refresh, 2=erase+refresh) */
|
||||
|
||||
|
||||
/* nicklist */
|
||||
int nicklist; /* = 1 if nicklist is enabled */
|
||||
int nicklist_case_sensitive; /* nicks are case sensitive ? */
|
||||
@@ -113,7 +113,7 @@ struct t_gui_buffer
|
||||
int nicklist_max_length; /* max length for a nick */
|
||||
int nicklist_display_groups; /* display groups ? */
|
||||
int nicklist_visible_count; /* number of nicks/groups to display */
|
||||
|
||||
|
||||
/* inupt */
|
||||
int input; /* = 1 if input is enabled */
|
||||
int (*input_callback)(void *data, /* called when user send data */
|
||||
@@ -129,29 +129,29 @@ struct t_gui_buffer
|
||||
int input_buffer_length; /* number of chars in buffer */
|
||||
int input_buffer_pos; /* position into buffer */
|
||||
int input_buffer_1st_display; /* first char displayed on screen */
|
||||
|
||||
|
||||
/* undo/redo for input */
|
||||
struct t_gui_input_undo *input_undo_snap; /* snapshot of input buffer */
|
||||
struct t_gui_input_undo *input_undo; /* undo for input */
|
||||
struct t_gui_input_undo *last_input_undo; /* last undo for input */
|
||||
struct t_gui_input_undo *ptr_input_undo; /* pointer to current undo */
|
||||
int input_undo_count; /* number of undos */
|
||||
|
||||
|
||||
/* completion */
|
||||
struct t_gui_completion *completion; /* completion */
|
||||
|
||||
|
||||
/* history */
|
||||
struct t_gui_history *history; /* commands history */
|
||||
struct t_gui_history *last_history;/* last command in history */
|
||||
struct t_gui_history *ptr_history; /* current command in history */
|
||||
int num_history; /* number of commands in history */
|
||||
|
||||
|
||||
/* text search */
|
||||
int text_search; /* text search type */
|
||||
int text_search_exact; /* exact search (case sensitive) ? */
|
||||
int text_search_found; /* 1 if text found, otherwise 0 */
|
||||
char *text_search_input; /* input saved before text search */
|
||||
|
||||
|
||||
/* highlight settings for buffer */
|
||||
char *highlight_words; /* list of words to highlight */
|
||||
char *highlight_regex; /* regex for highlight */
|
||||
@@ -160,19 +160,19 @@ struct t_gui_buffer
|
||||
int highlight_tags_count; /* number of tags to highlight */
|
||||
/* (if 0, any tag is highlighted) */
|
||||
char **highlight_tags_array; /* tags to highlight */
|
||||
|
||||
|
||||
/* hotlist settings for buffer */
|
||||
struct t_hashtable *hotlist_max_level_nicks; /* max hotlist level for */
|
||||
/* some nicks */
|
||||
|
||||
|
||||
/* keys associated to buffer */
|
||||
struct t_gui_key *keys; /* keys specific to buffer */
|
||||
struct t_gui_key *last_key; /* last key for buffer */
|
||||
int keys_count; /* number of keys in buffer */
|
||||
|
||||
|
||||
/* local variables */
|
||||
struct t_hashtable *local_variables; /* local variables */
|
||||
|
||||
|
||||
/* link to previous/next buffer */
|
||||
struct t_gui_buffer *prev_buffer; /* link to previous buffer */
|
||||
struct t_gui_buffer *next_buffer; /* link to next buffer */
|
||||
|
||||
+67
-67
@@ -73,7 +73,7 @@ gui_chat_init ()
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (gui_chat_prefix_empty);
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_JOIN] = strdup (gui_chat_prefix_empty);
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_QUIT] = strdup (gui_chat_prefix_empty);
|
||||
|
||||
|
||||
/* some hsignals */
|
||||
hook_hsignal (NULL, "chat_quote_time_prefix_message",
|
||||
&gui_chat_hsignal_quote_line_cb, NULL);
|
||||
@@ -93,7 +93,7 @@ gui_chat_prefix_build ()
|
||||
{
|
||||
char prefix[128];
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_CHAT_NUM_PREFIXES; i++)
|
||||
{
|
||||
if (gui_chat_prefix[i])
|
||||
@@ -102,27 +102,27 @@ gui_chat_prefix_build ()
|
||||
gui_chat_prefix[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
snprintf (prefix, sizeof (prefix), "%s%s\t",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ERROR),
|
||||
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ERROR]));
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (prefix);
|
||||
|
||||
|
||||
snprintf (prefix, sizeof (prefix), "%s%s\t",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_NETWORK),
|
||||
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_NETWORK]));
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = strdup (prefix);
|
||||
|
||||
|
||||
snprintf (prefix, sizeof (prefix), "%s%s\t",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ACTION),
|
||||
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ACTION]));
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (prefix);
|
||||
|
||||
|
||||
snprintf (prefix, sizeof (prefix), "%s%s\t",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_JOIN),
|
||||
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_JOIN]));
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_JOIN] = strdup (prefix);
|
||||
|
||||
|
||||
snprintf (prefix, sizeof (prefix), "%s%s\t",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_QUIT),
|
||||
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_QUIT]));
|
||||
@@ -140,13 +140,13 @@ gui_chat_utf_char_valid (const char *utf_char)
|
||||
/* chars below 32 are not valid */
|
||||
if ((unsigned char)utf_char[0] < 32)
|
||||
return 0;
|
||||
|
||||
|
||||
/* 146 or 0x7F are not valid */
|
||||
if ((((unsigned char)(utf_char[0]) == 146)
|
||||
|| ((unsigned char)(utf_char[0]) == 0x7F))
|
||||
&& (!utf_char[1]))
|
||||
return 0;
|
||||
|
||||
|
||||
/* any other char is valid */
|
||||
return 1;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ int
|
||||
gui_chat_strlen_screen (const char *string)
|
||||
{
|
||||
int length, size_on_screen;
|
||||
|
||||
|
||||
length = 0;
|
||||
while (string && string[0])
|
||||
{
|
||||
@@ -209,7 +209,7 @@ char *
|
||||
gui_chat_string_add_offset_screen (const char *string, int offset_screen)
|
||||
{
|
||||
int size_on_screen;
|
||||
|
||||
|
||||
while (string && string[0] && (offset_screen > 0))
|
||||
{
|
||||
string = gui_chat_string_next_char (NULL, NULL,
|
||||
@@ -235,10 +235,10 @@ gui_chat_string_real_pos (const char *string, int pos)
|
||||
{
|
||||
const char *real_pos, *ptr_string;
|
||||
int size_on_screen;
|
||||
|
||||
|
||||
if (pos <= 0)
|
||||
return 0;
|
||||
|
||||
|
||||
real_pos = string;
|
||||
ptr_string = string;
|
||||
while (ptr_string && ptr_string[0] && (pos > 0))
|
||||
@@ -271,14 +271,14 @@ gui_chat_get_word_info (struct t_gui_window *window,
|
||||
const char *start_data;
|
||||
char *next_char, *next_char2;
|
||||
int leading_spaces, char_size;
|
||||
|
||||
|
||||
*word_start_offset = 0;
|
||||
*word_end_offset = 0;
|
||||
*word_length_with_spaces = 0;
|
||||
*word_length = 0;
|
||||
|
||||
|
||||
start_data = data;
|
||||
|
||||
|
||||
leading_spaces = 1;
|
||||
while (data && data[0])
|
||||
{
|
||||
@@ -331,17 +331,17 @@ gui_chat_get_time_string (time_t date)
|
||||
char *text_with_color;
|
||||
int i, time_first_digit, time_last_digit, last_color;
|
||||
struct tm *local_time;
|
||||
|
||||
|
||||
if (!CONFIG_STRING(config_look_buffer_time_format)
|
||||
|| !CONFIG_STRING(config_look_buffer_time_format)[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
local_time = localtime (&date);
|
||||
if (strftime (text_time, sizeof (text_time),
|
||||
CONFIG_STRING(config_look_buffer_time_format),
|
||||
local_time) == 0)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (strstr (text_time, "${"))
|
||||
{
|
||||
text_with_color = gui_color_string_replace_colors (text_time);
|
||||
@@ -352,7 +352,7 @@ gui_chat_get_time_string (time_t date)
|
||||
free (text_with_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
time_first_digit = -1;
|
||||
time_last_digit = -1;
|
||||
i = 0;
|
||||
@@ -366,7 +366,7 @@ gui_chat_get_time_string (time_t date)
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
text_time2[0] = '\0';
|
||||
text_time_char[1] = '\0';
|
||||
last_color = -1;
|
||||
@@ -419,7 +419,7 @@ gui_chat_get_time_string (time_t date)
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
return strdup (text_time2);
|
||||
}
|
||||
|
||||
@@ -434,21 +434,21 @@ gui_chat_get_time_length ()
|
||||
time_t date;
|
||||
char *text_time;
|
||||
int length;
|
||||
|
||||
|
||||
if (!CONFIG_STRING(config_look_buffer_time_format)
|
||||
|| !CONFIG_STRING(config_look_buffer_time_format)[0])
|
||||
return 0;
|
||||
|
||||
|
||||
length = 0;
|
||||
date = time (NULL);
|
||||
text_time = gui_chat_get_time_string (date);
|
||||
|
||||
|
||||
if (text_time)
|
||||
{
|
||||
length = gui_chat_strlen_screen (text_time);
|
||||
free (text_time);
|
||||
}
|
||||
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ gui_chat_build_string_prefix_message (struct t_gui_line *line)
|
||||
{
|
||||
char *string, *string_without_colors;
|
||||
int length;
|
||||
|
||||
|
||||
length = 0;
|
||||
if (line->data->prefix)
|
||||
length += strlen (line->data->prefix);
|
||||
@@ -495,7 +495,7 @@ gui_chat_build_string_prefix_message (struct t_gui_line *line)
|
||||
if (line->data->message)
|
||||
length += strlen (line->data->message);
|
||||
length++;
|
||||
|
||||
|
||||
string = malloc (length);
|
||||
if (string)
|
||||
{
|
||||
@@ -516,7 +516,7 @@ gui_chat_build_string_prefix_message (struct t_gui_line *line)
|
||||
string = string_without_colors;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ gui_chat_build_string_message_tags (struct t_gui_line *line)
|
||||
{
|
||||
int i, length;
|
||||
char *buf;
|
||||
|
||||
|
||||
length = 64 + 2;
|
||||
if (line->data->message)
|
||||
length += strlen (line->data->message);
|
||||
@@ -539,7 +539,7 @@ gui_chat_build_string_message_tags (struct t_gui_line *line)
|
||||
length += strlen (line->data->tags_array[i]) + 1;
|
||||
}
|
||||
length += 2;
|
||||
|
||||
|
||||
buf = malloc (length);
|
||||
buf[0] = '\0';
|
||||
if (line->data->message)
|
||||
@@ -555,7 +555,7 @@ gui_chat_build_string_message_tags (struct t_gui_line *line)
|
||||
}
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
strcat (buf, "]");
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -575,13 +575,13 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
char *pos, *pos_prefix, *pos_tab, *pos_end, *pos_lines;
|
||||
char *modifier_data, *new_msg, *ptr_msg, *lines_waiting;
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
|
||||
if (!gui_buffer_valid (buffer))
|
||||
return;
|
||||
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
if (!buffer)
|
||||
@@ -589,10 +589,10 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
|
||||
if (buffer->type != GUI_BUFFER_TYPE_FORMATTED)
|
||||
buffer = gui_buffers;
|
||||
|
||||
|
||||
if (buffer->type != GUI_BUFFER_TYPE_FORMATTED)
|
||||
return;
|
||||
}
|
||||
@@ -602,19 +602,19 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
|| ((gui_chat_mute == GUI_CHAT_MUTE_BUFFER)
|
||||
&& (gui_chat_mute_buffer == buffer)))
|
||||
return;
|
||||
|
||||
|
||||
weechat_va_format (message);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
|
||||
utf8_normalize (vbuffer, '?');
|
||||
|
||||
|
||||
date_printed = time (NULL);
|
||||
if (date <= 0)
|
||||
date = date_printed;
|
||||
|
||||
|
||||
at_least_one_message_printed = 0;
|
||||
|
||||
|
||||
pos = vbuffer;
|
||||
while (pos)
|
||||
{
|
||||
@@ -622,7 +622,7 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
pos_end = strchr (pos, '\n');
|
||||
if (pos_end)
|
||||
pos_end[0] = '\0';
|
||||
|
||||
|
||||
/* call modifier for message printed ("weechat_print") */
|
||||
new_msg = NULL;
|
||||
if (buffer)
|
||||
@@ -661,11 +661,11 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pos_prefix = NULL;
|
||||
display_time = 1;
|
||||
ptr_msg = (new_msg) ? new_msg : pos;
|
||||
|
||||
|
||||
/* space followed by tab => prefix ignored */
|
||||
if ((ptr_msg[0] == ' ') && (ptr_msg[1] == '\t'))
|
||||
{
|
||||
@@ -691,7 +691,7 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
ptr_line = gui_line_add (buffer, (display_time) ? date : 0,
|
||||
@@ -748,16 +748,16 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
memcpy (pos_lines, ptr_msg, strlen (ptr_msg) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (new_msg)
|
||||
free (new_msg);
|
||||
|
||||
|
||||
pos = (pos_end && pos_end[1]) ? pos_end + 1 : NULL;
|
||||
}
|
||||
|
||||
|
||||
if (gui_init_ok && at_least_one_message_printed)
|
||||
gui_buffer_ask_chat_refresh (buffer, 1);
|
||||
|
||||
|
||||
end:
|
||||
free (vbuffer);
|
||||
}
|
||||
@@ -773,25 +773,25 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
int i, num_lines_to_add;
|
||||
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
if (!buffer)
|
||||
buffer = gui_buffer_search_main ();
|
||||
|
||||
|
||||
if (buffer->type != GUI_BUFFER_TYPE_FREE)
|
||||
buffer = gui_buffers;
|
||||
|
||||
|
||||
if (buffer->type != GUI_BUFFER_TYPE_FREE)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
weechat_va_format (message);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
|
||||
utf8_normalize (vbuffer, '?');
|
||||
|
||||
|
||||
/* no message: delete line */
|
||||
if (!vbuffer[0])
|
||||
{
|
||||
@@ -840,7 +840,7 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
|
||||
else
|
||||
string_iconv_fprintf (stdout, "%s\n", vbuffer);
|
||||
}
|
||||
|
||||
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
@@ -853,7 +853,7 @@ gui_chat_print_lines_waiting_buffer ()
|
||||
{
|
||||
char **lines;
|
||||
int num_lines, i;
|
||||
|
||||
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
lines = string_split (gui_chat_lines_waiting_buffer, "\n", 0, 0,
|
||||
@@ -889,26 +889,26 @@ gui_chat_hsignal_quote_line_cb (void *data, const char *signal,
|
||||
const char *time, *prefix, *message;
|
||||
int length_time, length_prefix, length_message, length;
|
||||
char *str;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!gui_current_window->buffer->input)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
time = (strstr (signal, "time")) ?
|
||||
hashtable_get (hashtable, "_chat_line_time") : NULL;
|
||||
prefix = (strstr (signal, "prefix")) ?
|
||||
hashtable_get (hashtable, "_chat_line_prefix") : NULL;
|
||||
message = hashtable_get (hashtable, "_chat_line_message");
|
||||
|
||||
|
||||
if (!message)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
length_time = (time) ? strlen (time) : 0;
|
||||
length_prefix = (prefix) ? strlen (prefix) : 0;
|
||||
length_message = strlen (message);
|
||||
|
||||
|
||||
length = length_time + 1 + length_prefix + 1 +
|
||||
strlen (CONFIG_STRING(config_look_prefix_suffix)) + 1 +
|
||||
length_message + 1 + 1;
|
||||
@@ -928,7 +928,7 @@ gui_chat_hsignal_quote_line_cb (void *data, const char *signal,
|
||||
gui_input_text_changed_modifier_and_signal (gui_current_window->buffer, 1);
|
||||
free (str);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -940,7 +940,7 @@ void
|
||||
gui_chat_end ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* free prefixes */
|
||||
for (i = 0; i < GUI_CHAT_NUM_PREFIXES; i++)
|
||||
{
|
||||
@@ -950,7 +950,7 @@ gui_chat_end ()
|
||||
gui_chat_prefix[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* free lines waiting for buffer (should always be NULL here) */
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ enum t_gui_chat_prefix
|
||||
GUI_CHAT_PREFIX_ACTION,
|
||||
GUI_CHAT_PREFIX_JOIN,
|
||||
GUI_CHAT_PREFIX_QUIT,
|
||||
|
||||
|
||||
GUI_CHAT_NUM_PREFIXES,
|
||||
};
|
||||
|
||||
|
||||
+42
-42
@@ -62,7 +62,7 @@ const char *
|
||||
gui_color_search_config (const char *color_name)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
if (color_name)
|
||||
{
|
||||
for (ptr_option = weechat_config_section_color->options;
|
||||
@@ -79,7 +79,7 @@ gui_color_search_config (const char *color_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* color not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -94,19 +94,19 @@ gui_color_attr_get_flag (char c)
|
||||
{
|
||||
if (c == GUI_COLOR_EXTENDED_BOLD_CHAR)
|
||||
return GUI_COLOR_EXTENDED_BOLD_FLAG;
|
||||
|
||||
|
||||
if (c == GUI_COLOR_EXTENDED_REVERSE_CHAR)
|
||||
return GUI_COLOR_EXTENDED_REVERSE_FLAG;
|
||||
|
||||
|
||||
if (c == GUI_COLOR_EXTENDED_ITALIC_CHAR)
|
||||
return GUI_COLOR_EXTENDED_ITALIC_FLAG;
|
||||
|
||||
|
||||
if (c == GUI_COLOR_EXTENDED_UNDERLINE_CHAR)
|
||||
return GUI_COLOR_EXTENDED_UNDERLINE_FLAG;
|
||||
|
||||
|
||||
if (c == GUI_COLOR_EXTENDED_KEEPATTR_CHAR)
|
||||
return GUI_COLOR_EXTENDED_KEEPATTR_FLAG;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ void
|
||||
gui_color_attr_build_string (int color, char *str_attr)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
i = 0;
|
||||
|
||||
|
||||
if (color & GUI_COLOR_EXTENDED_BOLD_FLAG)
|
||||
str_attr[i++] = GUI_COLOR_EXTENDED_BOLD_CHAR;
|
||||
if (color & GUI_COLOR_EXTENDED_REVERSE_FLAG)
|
||||
@@ -133,7 +133,7 @@ gui_color_attr_build_string (int color, char *str_attr)
|
||||
str_attr[i++] = GUI_COLOR_EXTENDED_UNDERLINE_CHAR;
|
||||
if (color & GUI_COLOR_EXTENDED_KEEPATTR_FLAG)
|
||||
str_attr[i++] = GUI_COLOR_EXTENDED_KEEPATTR_CHAR;
|
||||
|
||||
|
||||
str_attr[i] = '\0';
|
||||
}
|
||||
|
||||
@@ -150,14 +150,14 @@ gui_color_get_custom (const char *color_name)
|
||||
char color_fg[32], color_bg[32];
|
||||
char *pos_delim, *str_fg, *pos_bg, *error, *color_attr;
|
||||
const char *ptr_color_name;
|
||||
|
||||
|
||||
/* attribute or other color name (GUI dependent) */
|
||||
index_color = (index_color + 1) % 32;
|
||||
color[index_color][0] = '\0';
|
||||
|
||||
|
||||
if (!color_name || !color_name[0])
|
||||
return color[index_color];
|
||||
|
||||
|
||||
if (string_strcasecmp (color_name, "reset") == 0)
|
||||
{
|
||||
snprintf (color[index_color], sizeof (color[index_color]),
|
||||
@@ -261,7 +261,7 @@ gui_color_get_custom (const char *color_name)
|
||||
color_attr = NULL;
|
||||
color_fg[0] = '\0';
|
||||
color_bg[0] = '\0';
|
||||
|
||||
|
||||
/* read extra attributes (bold, ..) */
|
||||
ptr_color_name = color_name;
|
||||
while (gui_color_attr_get_flag (ptr_color_name[0]) > 0)
|
||||
@@ -273,7 +273,7 @@ gui_color_get_custom (const char *color_name)
|
||||
color_attr = string_strndup (color_name,
|
||||
ptr_color_name - color_name);
|
||||
}
|
||||
|
||||
|
||||
pos_delim = strchr (ptr_color_name, ',');
|
||||
if (!pos_delim)
|
||||
pos_delim = strchr (ptr_color_name, ':');
|
||||
@@ -291,7 +291,7 @@ gui_color_get_custom (const char *color_name)
|
||||
str_fg = strdup (ptr_color_name);
|
||||
pos_bg = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (str_fg)
|
||||
{
|
||||
fg_term = gui_color_palette_get_alias (str_fg);
|
||||
@@ -330,7 +330,7 @@ gui_color_get_custom (const char *color_name)
|
||||
bg = gui_color_search (pos_bg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (fg_term >= 0)
|
||||
{
|
||||
snprintf (color_fg, sizeof (color_fg), "%c%s%05d",
|
||||
@@ -344,7 +344,7 @@ gui_color_get_custom (const char *color_name)
|
||||
(color_attr) ? color_attr : "",
|
||||
fg);
|
||||
}
|
||||
|
||||
|
||||
if (bg_term >= 0)
|
||||
{
|
||||
snprintf (color_bg, sizeof (color_bg), "%c%05d",
|
||||
@@ -382,13 +382,13 @@ gui_color_get_custom (const char *color_name)
|
||||
GUI_COLOR_BG_CHAR,
|
||||
color_bg);
|
||||
}
|
||||
|
||||
|
||||
if (color_attr)
|
||||
free (color_attr);
|
||||
if (str_fg)
|
||||
free (str_fg);
|
||||
}
|
||||
|
||||
|
||||
return color[index_color];
|
||||
}
|
||||
|
||||
@@ -408,15 +408,15 @@ gui_color_decode (const char *string, const char *replacement)
|
||||
const unsigned char *ptr_string;
|
||||
unsigned char *out;
|
||||
int out_length, out_pos, length;
|
||||
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
|
||||
out_length = (strlen ((char *)string) * 2) + 1;
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
out_pos = 0;
|
||||
while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
|
||||
@@ -577,7 +577,7 @@ gui_color_decode (const char *string, const char *replacement)
|
||||
}
|
||||
}
|
||||
out[out_pos] = '\0';
|
||||
|
||||
|
||||
return (char *)out;
|
||||
}
|
||||
|
||||
@@ -593,10 +593,10 @@ gui_color_string_replace_colors (const char *string)
|
||||
int length, length_color, index_string, index_result;
|
||||
char *result, *result2, *color_name;
|
||||
const char *pos_end_name, *ptr_color;
|
||||
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
||||
|
||||
length = strlen (string) + 1;
|
||||
result = malloc (length);
|
||||
if (result)
|
||||
@@ -642,7 +642,7 @@ gui_color_string_replace_colors (const char *string)
|
||||
}
|
||||
else
|
||||
result[index_result++] = string[index_string++];
|
||||
|
||||
|
||||
free (color_name);
|
||||
}
|
||||
else
|
||||
@@ -656,7 +656,7 @@ gui_color_string_replace_colors (const char *string)
|
||||
}
|
||||
result[index_result] = '\0';
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ gui_color_free (struct t_gui_color *color)
|
||||
{
|
||||
if (color->string)
|
||||
free (color->string);
|
||||
|
||||
|
||||
free (color);
|
||||
}
|
||||
}
|
||||
@@ -686,13 +686,13 @@ gui_color_palette_free_value_cb (struct t_hashtable *hashtable,
|
||||
const void *key, void *value)
|
||||
{
|
||||
struct t_gui_color_palette *color_palette;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
(void) key;
|
||||
|
||||
|
||||
color_palette = (struct t_gui_color_palette *)value;
|
||||
|
||||
|
||||
if (color_palette)
|
||||
gui_color_palette_free (color_palette);
|
||||
}
|
||||
@@ -738,14 +738,14 @@ int
|
||||
gui_color_palette_get_alias (const char *alias)
|
||||
{
|
||||
int *ptr_number;
|
||||
|
||||
|
||||
if (gui_color_hash_palette_alias)
|
||||
{
|
||||
ptr_number = hashtable_get (gui_color_hash_palette_alias, alias);
|
||||
if (ptr_number)
|
||||
return *ptr_number;
|
||||
}
|
||||
|
||||
|
||||
/* alias not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -758,7 +758,7 @@ struct t_gui_color_palette *
|
||||
gui_color_palette_get (int number)
|
||||
{
|
||||
char str_number[64];
|
||||
|
||||
|
||||
snprintf (str_number, sizeof (str_number), "%d", number);
|
||||
return hashtable_get (gui_color_hash_palette_color,
|
||||
str_number);
|
||||
@@ -773,18 +773,18 @@ gui_color_palette_add (int number, const char *value)
|
||||
{
|
||||
struct t_gui_color_palette *new_color_palette;
|
||||
char str_number[64];
|
||||
|
||||
|
||||
gui_color_palette_alloc_structs ();
|
||||
|
||||
|
||||
new_color_palette = gui_color_palette_new (number, value);
|
||||
if (!new_color_palette)
|
||||
return;
|
||||
|
||||
|
||||
snprintf (str_number, sizeof (str_number), "%d", number);
|
||||
hashtable_set (gui_color_hash_palette_color,
|
||||
str_number, new_color_palette);
|
||||
gui_color_palette_build_aliases ();
|
||||
|
||||
|
||||
if (gui_init_ok)
|
||||
gui_color_buffer_display ();
|
||||
}
|
||||
@@ -798,9 +798,9 @@ gui_color_palette_remove (int number)
|
||||
{
|
||||
struct t_gui_color_palette *ptr_color_palette;
|
||||
char str_number[64];
|
||||
|
||||
|
||||
gui_color_palette_alloc_structs ();
|
||||
|
||||
|
||||
snprintf (str_number, sizeof (str_number), "%d", number);
|
||||
ptr_color_palette = hashtable_get (gui_color_hash_palette_color,
|
||||
str_number);
|
||||
@@ -808,7 +808,7 @@ gui_color_palette_remove (int number)
|
||||
{
|
||||
hashtable_remove (gui_color_hash_palette_color, str_number);
|
||||
gui_color_palette_build_aliases ();
|
||||
|
||||
|
||||
if (gui_init_ok)
|
||||
gui_color_buffer_display ();
|
||||
}
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@
|
||||
enum t_gui_color_enum
|
||||
{
|
||||
GUI_COLOR_SEPARATOR = 0,
|
||||
|
||||
|
||||
GUI_COLOR_CHAT,
|
||||
GUI_COLOR_CHAT_TIME,
|
||||
GUI_COLOR_CHAT_TIME_DELIMITERS,
|
||||
@@ -65,7 +65,7 @@ enum t_gui_color_enum
|
||||
GUI_COLOR_CHAT_INACTIVE_WINDOW,
|
||||
GUI_COLOR_CHAT_INACTIVE_BUFFER,
|
||||
GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER,
|
||||
|
||||
|
||||
/* number of colors */
|
||||
GUI_COLOR_NUM_COLORS,
|
||||
};
|
||||
|
||||
+92
-92
@@ -68,15 +68,15 @@ gui_completion_buffer_init (struct t_gui_completion *completion,
|
||||
completion->direction = 0;
|
||||
completion->add_space = 1;
|
||||
completion->force_partial_completion = 0;
|
||||
|
||||
|
||||
completion->completion_list = weelist_new ();
|
||||
|
||||
|
||||
completion->word_found = NULL;
|
||||
completion->word_found_is_nick = 0;
|
||||
completion->position_replace = 0;
|
||||
completion->diff_size = 0;
|
||||
completion->diff_length = 0;
|
||||
|
||||
|
||||
completion->partial_completion_list = NULL;
|
||||
completion->last_partial_completion = NULL;
|
||||
}
|
||||
@@ -90,13 +90,13 @@ gui_completion_partial_list_add (struct t_gui_completion *completion,
|
||||
const char *word, int count)
|
||||
{
|
||||
struct t_gui_completion_partial *new_item;
|
||||
|
||||
|
||||
new_item = malloc (sizeof (*new_item));
|
||||
if (new_item)
|
||||
{
|
||||
new_item->word = strdup (word);
|
||||
new_item->count = count;
|
||||
|
||||
|
||||
new_item->prev_item = completion->last_partial_completion;
|
||||
if (completion->partial_completion_list)
|
||||
(completion->last_partial_completion)->next_item = new_item;
|
||||
@@ -125,11 +125,11 @@ gui_completion_partial_list_free (struct t_gui_completion *completion,
|
||||
completion->partial_completion_list = item->next_item;
|
||||
if (completion->last_partial_completion == item)
|
||||
completion->last_partial_completion = item->prev_item;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (item->word)
|
||||
free (item->word);
|
||||
|
||||
|
||||
free (item);
|
||||
}
|
||||
|
||||
@@ -157,11 +157,11 @@ gui_completion_free_data (struct t_gui_completion *completion)
|
||||
if (completion->base_command)
|
||||
free (completion->base_command);
|
||||
completion->base_command = NULL;
|
||||
|
||||
|
||||
if (completion->base_word)
|
||||
free (completion->base_word);
|
||||
completion->base_word = NULL;
|
||||
|
||||
|
||||
if (completion->args)
|
||||
free (completion->args);
|
||||
completion->args = NULL;
|
||||
@@ -171,7 +171,7 @@ gui_completion_free_data (struct t_gui_completion *completion)
|
||||
weelist_free (completion->completion_list);
|
||||
completion->completion_list = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (completion->word_found)
|
||||
free (completion->word_found);
|
||||
completion->word_found = NULL;
|
||||
@@ -218,9 +218,9 @@ gui_completion_search_command (struct t_weechat_plugin *plugin,
|
||||
const char *command)
|
||||
{
|
||||
struct t_hook *ptr_hook, *hook_for_other_plugin;
|
||||
|
||||
|
||||
hook_for_other_plugin = NULL;
|
||||
|
||||
|
||||
for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook;
|
||||
ptr_hook = ptr_hook->next_hook)
|
||||
{
|
||||
@@ -232,11 +232,11 @@ gui_completion_search_command (struct t_weechat_plugin *plugin,
|
||||
{
|
||||
if (ptr_hook->plugin == plugin)
|
||||
return ptr_hook;
|
||||
|
||||
|
||||
hook_for_other_plugin = ptr_hook;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return hook_for_other_plugin;
|
||||
}
|
||||
|
||||
@@ -250,17 +250,17 @@ gui_completion_nick_has_ignored_chars (const char *string)
|
||||
{
|
||||
int char_size;
|
||||
char utf_char[16];
|
||||
|
||||
|
||||
while (string[0])
|
||||
{
|
||||
char_size = utf8_char_size (string);
|
||||
memcpy (utf_char, string, char_size);
|
||||
utf_char[char_size] = '\0';
|
||||
|
||||
|
||||
if (strstr (CONFIG_STRING(config_completion_nick_ignore_chars),
|
||||
utf_char))
|
||||
return 1;
|
||||
|
||||
|
||||
string += char_size;
|
||||
}
|
||||
return 0;
|
||||
@@ -276,7 +276,7 @@ gui_completion_nick_strdup_ignore_chars (const char *string)
|
||||
{
|
||||
int char_size;
|
||||
char *result, *pos, utf_char[16];
|
||||
|
||||
|
||||
result = malloc (strlen (string) + 1);
|
||||
pos = result;
|
||||
while (string[0])
|
||||
@@ -284,14 +284,14 @@ gui_completion_nick_strdup_ignore_chars (const char *string)
|
||||
char_size = utf8_char_size (string);
|
||||
memcpy (utf_char, string, char_size);
|
||||
utf_char[char_size] = '\0';
|
||||
|
||||
|
||||
if (!strstr (CONFIG_STRING(config_completion_nick_ignore_chars),
|
||||
utf_char))
|
||||
{
|
||||
memcpy (pos, utf_char, char_size);
|
||||
pos += char_size;
|
||||
}
|
||||
|
||||
|
||||
string += char_size;
|
||||
}
|
||||
pos[0] = '\0';
|
||||
@@ -308,22 +308,22 @@ gui_completion_nickncmp (const char *base_word, const char *nick, int max)
|
||||
{
|
||||
char *base_word2, *nick2;
|
||||
int return_cmp;
|
||||
|
||||
|
||||
if (!CONFIG_STRING(config_completion_nick_ignore_chars)
|
||||
|| !CONFIG_STRING(config_completion_nick_ignore_chars)[0]
|
||||
|| !base_word || !nick || !base_word[0] || !nick[0]
|
||||
|| gui_completion_nick_has_ignored_chars (base_word))
|
||||
return string_strncasecmp (base_word, nick, max);
|
||||
|
||||
|
||||
base_word2 = gui_completion_nick_strdup_ignore_chars (base_word);
|
||||
nick2 = gui_completion_nick_strdup_ignore_chars (nick);
|
||||
|
||||
|
||||
return_cmp = string_strncasecmp (base_word2, nick2,
|
||||
utf8_strlen (base_word2));
|
||||
|
||||
|
||||
free (base_word2);
|
||||
free (nick2);
|
||||
|
||||
|
||||
return return_cmp;
|
||||
}
|
||||
|
||||
@@ -336,10 +336,10 @@ gui_completion_list_add (struct t_gui_completion *completion, const char *word,
|
||||
int nick_completion, const char *where)
|
||||
{
|
||||
char buffer[512];
|
||||
|
||||
|
||||
if (!word || !word[0])
|
||||
return;
|
||||
|
||||
|
||||
if (!completion->base_word || !completion->base_word[0]
|
||||
|| (nick_completion && (gui_completion_nickncmp (completion->base_word, word,
|
||||
utf8_strlen (completion->base_word)) == 0))
|
||||
@@ -388,7 +388,7 @@ gui_completion_build_list_template (struct t_gui_completion *completion,
|
||||
char *word, *custom_completion;
|
||||
const char *pos, *pos_end;
|
||||
int word_offset;
|
||||
|
||||
|
||||
word = strdup (template);
|
||||
word_offset = 0;
|
||||
pos = template;
|
||||
@@ -464,11 +464,11 @@ gui_completion_get_matching_template (struct t_gui_completion *completion,
|
||||
struct t_hook *hook_command)
|
||||
{
|
||||
int i, length;
|
||||
|
||||
|
||||
/* without at least one argument, we can't find matching template! */
|
||||
if (completion->base_command_arg_index <= 1)
|
||||
return -1;
|
||||
|
||||
|
||||
for (i = 0; i < HOOK_COMMAND(hook_command, cplt_num_templates); i++)
|
||||
{
|
||||
length = strlen (HOOK_COMMAND(hook_command, cplt_templates_static)[i]);
|
||||
@@ -479,7 +479,7 @@ gui_completion_get_matching_template (struct t_gui_completion *completion,
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ gui_completion_get_template_for_args (struct t_gui_completion *completion,
|
||||
struct t_hook *hook_command)
|
||||
{
|
||||
int matching_template;
|
||||
|
||||
|
||||
/*
|
||||
* if template refers to another command, search this command and use its
|
||||
* template
|
||||
@@ -511,11 +511,11 @@ gui_completion_get_template_for_args (struct t_gui_completion *completion,
|
||||
return strdup ("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* if only one template available, then use it */
|
||||
if (HOOK_COMMAND(hook_command, cplt_num_templates) == 1)
|
||||
return strdup (HOOK_COMMAND(hook_command, cplt_templates)[0]);
|
||||
|
||||
|
||||
/* search which template is matching arguments from user */
|
||||
matching_template = gui_completion_get_matching_template (completion,
|
||||
hook_command);
|
||||
@@ -543,9 +543,9 @@ gui_completion_build_list (struct t_gui_completion *completion)
|
||||
struct t_hook *ptr_hook;
|
||||
char *template, *pos_template, *pos_space;
|
||||
int repeat_last, i, length;
|
||||
|
||||
|
||||
repeat_last = 0;
|
||||
|
||||
|
||||
ptr_hook = gui_completion_search_command (completion->buffer->plugin,
|
||||
completion->base_command);
|
||||
if (!ptr_hook || !HOOK_COMMAND(ptr_hook, completion))
|
||||
@@ -556,24 +556,24 @@ gui_completion_build_list (struct t_gui_completion *completion)
|
||||
completion->base_command = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (strcmp (HOOK_COMMAND(ptr_hook, completion), "-") == 0)
|
||||
{
|
||||
gui_completion_stop (completion, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
template = gui_completion_get_template_for_args (completion, ptr_hook);
|
||||
if (!template)
|
||||
return;
|
||||
|
||||
|
||||
length = strlen (template);
|
||||
if (length >= 2)
|
||||
{
|
||||
if (strcmp (template + length - 2, "%*") == 0)
|
||||
repeat_last = 1;
|
||||
}
|
||||
|
||||
|
||||
i = 1;
|
||||
pos_template = template;
|
||||
while (pos_template && pos_template[0])
|
||||
@@ -619,7 +619,7 @@ gui_completion_find_context (struct t_gui_completion *completion,
|
||||
{
|
||||
int i, command, command_arg, pos_start, pos_end;
|
||||
char *prev_char;
|
||||
|
||||
|
||||
/* look for context */
|
||||
gui_completion_free_data (completion);
|
||||
gui_completion_buffer_init (completion, completion->buffer);
|
||||
@@ -657,11 +657,11 @@ gui_completion_find_context (struct t_gui_completion *completion,
|
||||
}
|
||||
else
|
||||
completion->context = GUI_COMPLETION_AUTO;
|
||||
|
||||
|
||||
/* look for word to complete (base word) */
|
||||
completion->base_word_pos = 0;
|
||||
completion->position_replace = pos;
|
||||
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
i = pos;
|
||||
@@ -699,9 +699,9 @@ gui_completion_find_context (struct t_gui_completion *completion,
|
||||
if (string_is_command_char (data + pos_start))
|
||||
pos_start += utf8_char_size (data + pos_start);
|
||||
}
|
||||
|
||||
|
||||
completion->base_word_pos = pos_start;
|
||||
|
||||
|
||||
if (pos_start <= pos_end)
|
||||
{
|
||||
completion->position_replace = pos_start;
|
||||
@@ -713,10 +713,10 @@ gui_completion_find_context (struct t_gui_completion *completion,
|
||||
completion->base_word[pos_end - pos_start + 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!completion->base_word)
|
||||
completion->base_word = strdup ("");
|
||||
|
||||
|
||||
/* find command (for command argument completion only) */
|
||||
if (completion->context == GUI_COMPLETION_COMMAND_ARG)
|
||||
{
|
||||
@@ -740,7 +740,7 @@ gui_completion_find_context (struct t_gui_completion *completion,
|
||||
prev_char = utf8_prev_char (data, data + pos_end);
|
||||
pos_end -= utf8_char_size (prev_char);
|
||||
}
|
||||
|
||||
|
||||
completion->base_command = malloc (pos_end - pos_start + 2);
|
||||
for (i = pos_start; i <= pos_end; i++)
|
||||
{
|
||||
@@ -750,7 +750,7 @@ gui_completion_find_context (struct t_gui_completion *completion,
|
||||
gui_completion_build_list (completion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* auto completion with nothing as base word is disabled,
|
||||
* in order to prevent completion when pasting messages with [tab] inside
|
||||
@@ -780,14 +780,14 @@ gui_completion_common_prefix_size (struct t_weelist *list,
|
||||
{
|
||||
struct t_weelist_item *ptr_item;
|
||||
char *ptr_first_item, *ptr_char, *next_char;
|
||||
|
||||
|
||||
ptr_first_item = list->items->data;
|
||||
ptr_char = ptr_first_item;
|
||||
|
||||
|
||||
while (ptr_char && ptr_char[0])
|
||||
{
|
||||
next_char = utf8_next_char (ptr_char);
|
||||
|
||||
|
||||
for (ptr_item = list->items->next_item; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
@@ -802,7 +802,7 @@ gui_completion_common_prefix_size (struct t_weelist *list,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_char = next_char;
|
||||
}
|
||||
return ptr_char - ptr_first_item;
|
||||
@@ -821,23 +821,23 @@ gui_completion_partial_build_list (struct t_gui_completion *completion,
|
||||
char utf_char[16], *word;
|
||||
struct t_weelist *weelist_temp;
|
||||
struct t_weelist_item *ptr_item, *next_item;
|
||||
|
||||
|
||||
gui_completion_partial_list_free_all (completion);
|
||||
|
||||
|
||||
if (!completion->completion_list || !completion->completion_list->items)
|
||||
return;
|
||||
|
||||
|
||||
weelist_temp = weelist_new ();
|
||||
if (!weelist_temp)
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_item = completion->completion_list->items; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
weelist_add (weelist_temp, ptr_item->data + common_prefix_size,
|
||||
WEECHAT_LIST_POS_END, NULL);
|
||||
}
|
||||
|
||||
|
||||
while (weelist_temp->items)
|
||||
{
|
||||
char_size = utf8_char_size (weelist_temp->items->data);
|
||||
@@ -856,13 +856,13 @@ gui_completion_partial_build_list (struct t_gui_completion *completion,
|
||||
while (ptr_item)
|
||||
{
|
||||
next_item = ptr_item->next_item;
|
||||
|
||||
|
||||
if (utf8_charcasecmp (utf_char, ptr_item->data) == 0)
|
||||
{
|
||||
weelist_remove (weelist_temp, ptr_item);
|
||||
items_count++;
|
||||
}
|
||||
|
||||
|
||||
ptr_item = next_item;
|
||||
}
|
||||
if (word)
|
||||
@@ -874,7 +874,7 @@ gui_completion_partial_build_list (struct t_gui_completion *completion,
|
||||
free (word);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
weelist_free (weelist_temp);
|
||||
}
|
||||
|
||||
@@ -888,13 +888,13 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
int length, word_found_seen, other_completion, partial_completion;
|
||||
int common_prefix_size, item_is_nick;
|
||||
struct t_weelist_item *ptr_item, *ptr_item2;
|
||||
|
||||
|
||||
length = utf8_strlen (completion->base_word);
|
||||
word_found_seen = 0;
|
||||
other_completion = 0;
|
||||
|
||||
|
||||
partial_completion = completion->force_partial_completion;
|
||||
|
||||
|
||||
if (!partial_completion)
|
||||
{
|
||||
if (completion->context == GUI_COMPLETION_COMMAND)
|
||||
@@ -908,7 +908,7 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
else
|
||||
partial_completion = CONFIG_BOOLEAN(config_completion_partial_completion_other);
|
||||
}
|
||||
|
||||
|
||||
common_prefix_size = 0;
|
||||
if (partial_completion
|
||||
&& completion->completion_list && completion->completion_list->items)
|
||||
@@ -916,7 +916,7 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
common_prefix_size = gui_completion_common_prefix_size (completion->completion_list,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
ptr_item = NULL;
|
||||
if (completion->completion_list)
|
||||
{
|
||||
@@ -925,14 +925,14 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
else
|
||||
ptr_item = completion->completion_list->items;
|
||||
}
|
||||
|
||||
|
||||
if (partial_completion
|
||||
&& completion->word_found
|
||||
&& (utf8_strlen (completion->word_found) >= common_prefix_size))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while (ptr_item)
|
||||
{
|
||||
item_is_nick = ((long)(ptr_item->user_data) == 1);
|
||||
@@ -954,7 +954,7 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
{
|
||||
completion->add_space = 0;
|
||||
}
|
||||
|
||||
|
||||
/* stop after first nick if user asked that */
|
||||
if (item_is_nick
|
||||
&& CONFIG_BOOLEAN(config_completion_nick_first_only))
|
||||
@@ -962,12 +962,12 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
gui_completion_stop (completion, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (completion->direction < 0)
|
||||
ptr_item2 = ptr_item->prev_item;
|
||||
else
|
||||
ptr_item2 = ptr_item->next_item;
|
||||
|
||||
|
||||
while (ptr_item2)
|
||||
{
|
||||
if ((item_is_nick
|
||||
@@ -981,19 +981,19 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
{
|
||||
other_completion++;
|
||||
}
|
||||
|
||||
|
||||
if (completion->direction < 0)
|
||||
ptr_item2 = ptr_item2->prev_item;
|
||||
else
|
||||
ptr_item2 = ptr_item2->next_item;
|
||||
}
|
||||
|
||||
|
||||
if (other_completion == 0)
|
||||
completion->position = -1;
|
||||
else
|
||||
if (completion->position < 0)
|
||||
completion->position = 0;
|
||||
|
||||
|
||||
/* stop after common prefix, if asked by user */
|
||||
if (partial_completion
|
||||
&& ((utf8_strlen (completion->word_found) >= common_prefix_size))
|
||||
@@ -1004,11 +1004,11 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
completion->add_space = 0;
|
||||
completion->position = -1;
|
||||
string_tolower (completion->word_found);
|
||||
|
||||
|
||||
/* alert user of partial completion */
|
||||
if (CONFIG_BOOLEAN(config_completion_partial_completion_alert))
|
||||
printf ("\a");
|
||||
|
||||
|
||||
/*
|
||||
* send "partial_completion" signal, to display possible
|
||||
* completions in bar item
|
||||
@@ -1019,9 +1019,9 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gui_completion_partial_list_free_all (completion);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
other_completion++;
|
||||
@@ -1029,13 +1029,13 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
if (completion->word_found &&
|
||||
(strcmp (ptr_item->data, completion->word_found) == 0))
|
||||
word_found_seen = 1;
|
||||
|
||||
|
||||
if (completion->direction < 0)
|
||||
ptr_item = ptr_item->prev_item;
|
||||
else
|
||||
ptr_item = ptr_item->next_item;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* if we was on last completion in list, then recomplete, starting from
|
||||
* first matching item
|
||||
@@ -1057,7 +1057,7 @@ void
|
||||
gui_completion_command (struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_hook *ptr_hook;
|
||||
|
||||
|
||||
if (!completion->completion_list->items)
|
||||
{
|
||||
for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook;
|
||||
@@ -1073,7 +1073,7 @@ gui_completion_command (struct t_gui_completion *completion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gui_completion_complete (completion);
|
||||
}
|
||||
|
||||
@@ -1093,7 +1093,7 @@ gui_completion_auto (struct t_gui_completion *completion)
|
||||
gui_completion_complete (completion);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* use default template completion */
|
||||
if (!completion->completion_list->items)
|
||||
{
|
||||
@@ -1113,9 +1113,9 @@ gui_completion_search (struct t_gui_completion *completion, int direction,
|
||||
const char *data, int size, int pos)
|
||||
{
|
||||
char *old_word_found;
|
||||
|
||||
|
||||
completion->direction = direction;
|
||||
|
||||
|
||||
/* if new completion => look for base word */
|
||||
if (pos != completion->position)
|
||||
{
|
||||
@@ -1126,7 +1126,7 @@ gui_completion_search (struct t_gui_completion *completion, int direction,
|
||||
gui_completion_find_context (completion, data, size, pos);
|
||||
completion->force_partial_completion = (direction < 0);
|
||||
}
|
||||
|
||||
|
||||
/* completion */
|
||||
old_word_found = (completion->word_found) ?
|
||||
strdup (completion->word_found) : NULL;
|
||||
@@ -1189,7 +1189,7 @@ gui_completion_get_string (struct t_gui_completion *completion,
|
||||
else if (string_strcasecmp (property, "args") == 0)
|
||||
return completion->args;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1201,10 +1201,10 @@ struct t_hdata *
|
||||
gui_completion_hdata_completion_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, NULL, NULL);
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1240,10 +1240,10 @@ struct t_hdata *
|
||||
gui_completion_hdata_completion_partial_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_item", "next_item");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1263,7 +1263,7 @@ void
|
||||
gui_completion_print_log (struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_gui_completion_partial *ptr_item;
|
||||
|
||||
|
||||
log_printf ("[completion (addr:0x%lx)]", completion);
|
||||
log_printf (" buffer. . . . . . . . . : 0x%lx", completion->buffer);
|
||||
log_printf (" context . . . . . . . . : %d", completion->context);
|
||||
|
||||
@@ -47,10 +47,10 @@ struct t_gui_completion
|
||||
int direction; /* +1=search next word, -1=previous word */
|
||||
int add_space; /* add space after completion? */
|
||||
int force_partial_completion; /* force partial completion? */
|
||||
|
||||
|
||||
/* for command argument completion */
|
||||
struct t_weelist *completion_list; /* data list for completion */
|
||||
|
||||
|
||||
/* completion found */
|
||||
char *word_found; /* word found (to replace base word) */
|
||||
int word_found_is_nick; /* word found is nick? */
|
||||
|
||||
+25
-25
@@ -55,7 +55,7 @@ void
|
||||
gui_cursor_mode_toggle ()
|
||||
{
|
||||
gui_cursor_mode ^= 1;
|
||||
|
||||
|
||||
if (gui_cursor_mode)
|
||||
{
|
||||
if (gui_cursor_debug)
|
||||
@@ -82,7 +82,7 @@ void
|
||||
gui_cursor_debug_set (int debug)
|
||||
{
|
||||
gui_cursor_debug = debug;
|
||||
|
||||
|
||||
if (gui_cursor_debug)
|
||||
{
|
||||
gui_chat_printf (NULL, _("Debug enabled for cursor mode (%s)"),
|
||||
@@ -101,10 +101,10 @@ gui_cursor_display_debug_info ()
|
||||
{
|
||||
struct t_gui_focus_info *focus_info;
|
||||
char str_info[1024];
|
||||
|
||||
|
||||
if (!gui_cursor_debug)
|
||||
return;
|
||||
|
||||
|
||||
focus_info = gui_focus_get_info (gui_cursor_x, gui_cursor_y);
|
||||
if (focus_info)
|
||||
{
|
||||
@@ -138,20 +138,20 @@ gui_cursor_move_xy (int x, int y)
|
||||
{
|
||||
if (!gui_cursor_mode)
|
||||
gui_cursor_mode_toggle ();
|
||||
|
||||
|
||||
gui_cursor_x = x;
|
||||
gui_cursor_y = y;
|
||||
|
||||
|
||||
if (gui_cursor_x < 0)
|
||||
gui_cursor_x = 0;
|
||||
else if (gui_cursor_x > gui_window_get_width () - 1)
|
||||
gui_cursor_x = gui_window_get_width () - 1;
|
||||
|
||||
|
||||
if (gui_cursor_y < 0)
|
||||
gui_cursor_y = 0;
|
||||
else if (gui_cursor_y > gui_window_get_height () - 1)
|
||||
gui_cursor_y = gui_window_get_height () - 1;
|
||||
|
||||
|
||||
gui_cursor_display_debug_info ();
|
||||
gui_window_move_cursor ();
|
||||
}
|
||||
@@ -165,20 +165,20 @@ gui_cursor_move_add_xy (int add_x, int add_y)
|
||||
{
|
||||
if (!gui_cursor_mode)
|
||||
gui_cursor_mode_toggle ();
|
||||
|
||||
|
||||
gui_cursor_x += add_x;
|
||||
gui_cursor_y += add_y;
|
||||
|
||||
|
||||
if (gui_cursor_x < 0)
|
||||
gui_cursor_x = gui_window_get_width () - 1;
|
||||
else if (gui_cursor_x > gui_window_get_width () - 1)
|
||||
gui_cursor_x = 0;
|
||||
|
||||
|
||||
if (gui_cursor_y < 0)
|
||||
gui_cursor_y = gui_window_get_height () - 1;
|
||||
else if (gui_cursor_y > gui_window_get_height () - 1)
|
||||
gui_cursor_y = 0;
|
||||
|
||||
|
||||
gui_cursor_display_debug_info ();
|
||||
gui_window_move_cursor ();
|
||||
}
|
||||
@@ -193,27 +193,27 @@ gui_cursor_move_area_add_xy (int add_x, int add_y)
|
||||
{
|
||||
int x, y, width, height, area_found;
|
||||
struct t_gui_focus_info *focus_info_old, *focus_info_new;
|
||||
|
||||
|
||||
if (!gui_cursor_mode)
|
||||
gui_cursor_mode_toggle ();
|
||||
|
||||
|
||||
area_found = 0;
|
||||
|
||||
|
||||
x = gui_cursor_x;
|
||||
y = gui_cursor_y;
|
||||
width = gui_window_get_width ();
|
||||
height = gui_window_get_height ();
|
||||
|
||||
|
||||
focus_info_old = gui_focus_get_info (x, y);
|
||||
if (!focus_info_old)
|
||||
return;
|
||||
focus_info_new = NULL;
|
||||
|
||||
|
||||
if (add_x != 0)
|
||||
x += add_x;
|
||||
else
|
||||
y += add_y;
|
||||
|
||||
|
||||
while ((x >= 0) && (x < width) && (y >= 0) && (y < height))
|
||||
{
|
||||
focus_info_new = gui_focus_get_info (x, y);
|
||||
@@ -230,13 +230,13 @@ gui_cursor_move_area_add_xy (int add_x, int add_y)
|
||||
area_found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (add_x != 0)
|
||||
x += add_x;
|
||||
else
|
||||
y += add_y;
|
||||
}
|
||||
|
||||
|
||||
if (area_found)
|
||||
{
|
||||
if (focus_info_new->window && focus_info_new->chat)
|
||||
@@ -252,7 +252,7 @@ gui_cursor_move_area_add_xy (int add_x, int add_y)
|
||||
else
|
||||
area_found = 0;
|
||||
}
|
||||
|
||||
|
||||
if (area_found)
|
||||
{
|
||||
gui_cursor_x = x;
|
||||
@@ -260,7 +260,7 @@ gui_cursor_move_area_add_xy (int add_x, int add_y)
|
||||
gui_cursor_display_debug_info ();
|
||||
gui_window_move_cursor ();
|
||||
}
|
||||
|
||||
|
||||
gui_focus_free_info (focus_info_old);
|
||||
if (focus_info_new)
|
||||
gui_focus_free_info (focus_info_new);
|
||||
@@ -276,11 +276,11 @@ gui_cursor_move_area (const char *area)
|
||||
int area_found, x, y;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
area_found = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
||||
|
||||
if (strcmp (area, "chat") == 0)
|
||||
{
|
||||
area_found = 1;
|
||||
@@ -313,7 +313,7 @@ gui_cursor_move_area (const char *area)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (area_found)
|
||||
{
|
||||
if (!gui_cursor_mode)
|
||||
|
||||
+46
-46
@@ -58,13 +58,13 @@ int
|
||||
gui_filter_line_has_tag_no_filter (struct t_gui_line *line)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < line->data->tags_count; i++)
|
||||
{
|
||||
if (strcmp (line->data->tags_array[i], GUI_FILTER_TAG_NO_FILTER) == 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* tag not found, line may be filtered */
|
||||
return 0;
|
||||
}
|
||||
@@ -79,14 +79,14 @@ gui_filter_check_line (struct t_gui_line *line, const char *buffer_full_name)
|
||||
{
|
||||
struct t_gui_filter *ptr_filter;
|
||||
int rc;
|
||||
|
||||
|
||||
/* line is always displayed if filters are disabled */
|
||||
if (!gui_filters_enabled)
|
||||
return 1;
|
||||
|
||||
|
||||
if (gui_filter_line_has_tag_no_filter (line))
|
||||
return 1;
|
||||
|
||||
|
||||
for (ptr_filter = gui_filters; ptr_filter;
|
||||
ptr_filter = ptr_filter->next_filter)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ gui_filter_check_line (struct t_gui_line *line, const char *buffer_full_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* no tag or regex matching, then line is displayed */
|
||||
return 1;
|
||||
}
|
||||
@@ -135,36 +135,36 @@ gui_filter_buffer (struct t_gui_buffer *buffer)
|
||||
struct t_gui_line *ptr_line;
|
||||
int line_displayed, lines_hidden;
|
||||
char buffer_full_name[512];
|
||||
|
||||
|
||||
lines_hidden = 0;
|
||||
|
||||
|
||||
buffer->lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min);
|
||||
|
||||
|
||||
snprintf (buffer_full_name, sizeof (buffer_full_name), "%s.%s",
|
||||
gui_buffer_get_plugin_name (buffer),
|
||||
buffer->name);
|
||||
|
||||
|
||||
for (ptr_line = buffer->lines->first_line; ptr_line;
|
||||
ptr_line = ptr_line->next_line)
|
||||
{
|
||||
line_displayed = gui_filter_check_line (ptr_line, buffer_full_name);
|
||||
|
||||
|
||||
if (line_displayed
|
||||
&& (ptr_line->data->prefix_length > buffer->lines->prefix_max_length))
|
||||
{
|
||||
buffer->lines->prefix_max_length = ptr_line->data->prefix_length;
|
||||
}
|
||||
|
||||
|
||||
/* force chat refresh if at least one line changed */
|
||||
if (ptr_line->data->displayed != line_displayed)
|
||||
gui_buffer_ask_chat_refresh (buffer, 2);
|
||||
|
||||
|
||||
ptr_line->data->displayed = line_displayed;
|
||||
|
||||
|
||||
if (!line_displayed)
|
||||
lines_hidden = 1;
|
||||
}
|
||||
|
||||
|
||||
if (buffer->lines->lines_hidden != lines_hidden)
|
||||
{
|
||||
buffer->lines->lines_hidden = lines_hidden;
|
||||
@@ -181,7 +181,7 @@ void
|
||||
gui_filter_all_buffers ()
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -257,14 +257,14 @@ struct t_gui_filter *
|
||||
gui_filter_search_by_name (const char *name)
|
||||
{
|
||||
struct t_gui_filter *ptr_filter;
|
||||
|
||||
|
||||
for (ptr_filter = gui_filters; ptr_filter;
|
||||
ptr_filter = ptr_filter->next_filter)
|
||||
{
|
||||
if (strcmp (ptr_filter->name, name) == 0)
|
||||
return ptr_filter;
|
||||
}
|
||||
|
||||
|
||||
/* filter not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -281,20 +281,20 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
|
||||
regex_t *regex1, *regex2;
|
||||
char *pos_tab, *regex_prefix;
|
||||
const char *ptr_start_regex, *pos_regex_message;
|
||||
|
||||
|
||||
if (!name || !buffer_name || !tags || !regex)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (gui_filter_search_by_name (name))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_start_regex = regex;
|
||||
if ((ptr_start_regex[0] == '!')
|
||||
|| ((ptr_start_regex[0] == '\\') && (ptr_start_regex[1] == '!')))
|
||||
{
|
||||
ptr_start_regex++;
|
||||
}
|
||||
|
||||
|
||||
regex1 = NULL;
|
||||
regex2 = NULL;
|
||||
if (strcmp (ptr_start_regex, "*") != 0)
|
||||
@@ -311,7 +311,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
|
||||
regex_prefix = NULL;
|
||||
pos_regex_message = ptr_start_regex;
|
||||
}
|
||||
|
||||
|
||||
if (regex_prefix)
|
||||
{
|
||||
regex1 = malloc (sizeof (*regex1));
|
||||
@@ -326,7 +326,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
regex2 = malloc (sizeof (*regex2));
|
||||
if (regex2)
|
||||
{
|
||||
@@ -341,11 +341,11 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (regex_prefix)
|
||||
free (regex_prefix);
|
||||
}
|
||||
|
||||
|
||||
/* create new filter */
|
||||
new_filter = malloc (sizeof (*new_filter));
|
||||
if (new_filter)
|
||||
@@ -372,7 +372,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
|
||||
new_filter->regex = strdup (regex);
|
||||
new_filter->regex_prefix = regex1;
|
||||
new_filter->regex_message = regex2;
|
||||
|
||||
|
||||
/* add filter to filters list */
|
||||
new_filter->prev_filter = last_gui_filter;
|
||||
if (gui_filters)
|
||||
@@ -381,13 +381,13 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
|
||||
gui_filters = new_filter;
|
||||
last_gui_filter = new_filter;
|
||||
new_filter->next_filter = NULL;
|
||||
|
||||
|
||||
gui_filter_all_buffers ();
|
||||
|
||||
|
||||
hook_signal_send ("filter_added",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, new_filter);
|
||||
}
|
||||
|
||||
|
||||
return new_filter;
|
||||
}
|
||||
|
||||
@@ -400,13 +400,13 @@ gui_filter_rename (struct t_gui_filter *filter, const char *new_name)
|
||||
{
|
||||
if (!filter || !new_name)
|
||||
return 0;
|
||||
|
||||
|
||||
if (gui_filter_search_by_name (new_name))
|
||||
return 0;
|
||||
|
||||
|
||||
free (filter->name);
|
||||
filter->name = strdup (new_name);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ gui_filter_free (struct t_gui_filter *filter)
|
||||
{
|
||||
hook_signal_send ("filter_removing",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, filter);
|
||||
|
||||
|
||||
/* free data */
|
||||
if (filter->name)
|
||||
free (filter->name);
|
||||
@@ -443,7 +443,7 @@ gui_filter_free (struct t_gui_filter *filter)
|
||||
regfree (filter->regex_message);
|
||||
free (filter->regex_message);
|
||||
}
|
||||
|
||||
|
||||
/* remove filter from filters list */
|
||||
if (filter->prev_filter)
|
||||
(filter->prev_filter)->next_filter = filter->next_filter;
|
||||
@@ -453,11 +453,11 @@ gui_filter_free (struct t_gui_filter *filter)
|
||||
gui_filters = filter->next_filter;
|
||||
if (last_gui_filter == filter)
|
||||
last_gui_filter = filter->prev_filter;
|
||||
|
||||
|
||||
free (filter);
|
||||
|
||||
|
||||
gui_filter_all_buffers ();
|
||||
|
||||
|
||||
hook_signal_send ("filter_removed", WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
|
||||
@@ -482,10 +482,10 @@ struct t_hdata *
|
||||
gui_filter_hdata_filter_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_filter", "next_filter");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -520,14 +520,14 @@ gui_filter_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_infolist_item *ptr_item;
|
||||
char option_name[64];
|
||||
int i;
|
||||
|
||||
|
||||
if (!infolist || !filter)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_integer (ptr_item, "enabled", filter->enabled))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "name", filter->name))
|
||||
@@ -547,7 +547,7 @@ gui_filter_add_to_infolist (struct t_infolist *infolist,
|
||||
}
|
||||
if (!infolist_new_var_string (ptr_item, "regex", filter->regex))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -560,10 +560,10 @@ gui_filter_print_log ()
|
||||
{
|
||||
struct t_gui_filter *ptr_filter;
|
||||
int i;
|
||||
|
||||
|
||||
log_printf ("");
|
||||
log_printf ("gui_filters_enabled = %d", gui_filters_enabled);
|
||||
|
||||
|
||||
for (ptr_filter = gui_filters; ptr_filter;
|
||||
ptr_filter = ptr_filter->next_filter)
|
||||
{
|
||||
|
||||
+17
-17
@@ -72,17 +72,17 @@ struct t_gui_focus_info *
|
||||
gui_focus_get_info (int x, int y)
|
||||
{
|
||||
struct t_gui_focus_info *focus_info;
|
||||
|
||||
|
||||
focus_info = malloc (sizeof (*focus_info));
|
||||
if (!focus_info)
|
||||
return NULL;
|
||||
|
||||
|
||||
focus_info->x = x;
|
||||
focus_info->y = y;
|
||||
|
||||
|
||||
/* search window */
|
||||
focus_info->window = gui_window_search_by_xy (x, y);
|
||||
|
||||
|
||||
/* fill info about chat area */
|
||||
gui_window_get_context_at_xy (focus_info->window,
|
||||
x, y,
|
||||
@@ -92,7 +92,7 @@ gui_focus_get_info (int x, int y)
|
||||
&focus_info->chat_word,
|
||||
&focus_info->chat_bol,
|
||||
&focus_info->chat_eol);
|
||||
|
||||
|
||||
/* search bar window, item, and line/col in item */
|
||||
gui_bar_window_search_by_xy (focus_info->window,
|
||||
x, y,
|
||||
@@ -100,7 +100,7 @@ gui_focus_get_info (int x, int y)
|
||||
&focus_info->bar_item,
|
||||
&focus_info->bar_item_line,
|
||||
&focus_info->bar_item_col);
|
||||
|
||||
|
||||
return focus_info;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ gui_focus_free_info (struct t_gui_focus_info *focus_info)
|
||||
free (focus_info->chat_bol);
|
||||
if (focus_info->chat_eol)
|
||||
free (focus_info->chat_eol);
|
||||
|
||||
|
||||
free (focus_info);
|
||||
}
|
||||
|
||||
@@ -131,12 +131,12 @@ gui_focus_buffer_localvar_map_cb (void *data, struct t_hashtable *hashtable,
|
||||
{
|
||||
struct t_hashtable *hashtable_focus;
|
||||
char hash_key[512];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
hashtable_focus = (struct t_hashtable *)data;
|
||||
|
||||
|
||||
if (hashtable_focus && key && value)
|
||||
{
|
||||
snprintf (hash_key, sizeof (hash_key),
|
||||
@@ -155,7 +155,7 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
struct t_hashtable *hashtable;
|
||||
char str_value[128], *str_time, *str_prefix, *str_tags, *str_message;
|
||||
const char *nick;
|
||||
|
||||
|
||||
hashtable = hashtable_new (32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -163,14 +163,14 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* key (key from keyboard or mouse event) */
|
||||
FOCUS_STR("_key", key);
|
||||
|
||||
|
||||
/* x,y */
|
||||
FOCUS_INT("_x", focus_info->x);
|
||||
FOCUS_INT("_y", focus_info->y);
|
||||
|
||||
|
||||
/* window/buffer */
|
||||
FOCUS_PTR("_window", focus_info->window);
|
||||
if (focus_info->window)
|
||||
@@ -191,7 +191,7 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
FOCUS_STR("_buffer_plugin", "");
|
||||
FOCUS_STR("_buffer_name", "");
|
||||
}
|
||||
|
||||
|
||||
/* chat area */
|
||||
FOCUS_INT("_chat", focus_info->chat);
|
||||
str_time = NULL;
|
||||
@@ -236,7 +236,7 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
FOCUS_STR_VAR("_chat_word", focus_info->chat_word);
|
||||
FOCUS_STR_VAR("_chat_bol", focus_info->chat_bol);
|
||||
FOCUS_STR_VAR("_chat_eol", focus_info->chat_eol);
|
||||
|
||||
|
||||
/* bar/item */
|
||||
if (focus_info->bar_window)
|
||||
{
|
||||
@@ -251,6 +251,6 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
FOCUS_STR_VAR("_bar_item_name", focus_info->bar_item);
|
||||
FOCUS_INT("_bar_item_line", focus_info->bar_item_line);
|
||||
FOCUS_INT("_bar_item_col", focus_info->bar_item_col);
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
+16
-16
@@ -55,10 +55,10 @@ void
|
||||
gui_history_buffer_add (struct t_gui_buffer *buffer, const char *string)
|
||||
{
|
||||
struct t_gui_history *new_history, *ptr_history;
|
||||
|
||||
|
||||
if (!string)
|
||||
return;
|
||||
|
||||
|
||||
if (!buffer->history
|
||||
|| (buffer->history
|
||||
&& (strcmp (buffer->history->text, string) != 0)))
|
||||
@@ -75,7 +75,7 @@ gui_history_buffer_add (struct t_gui_buffer *buffer, const char *string)
|
||||
new_history->prev_history = NULL;
|
||||
buffer->history = new_history;
|
||||
buffer->num_history++;
|
||||
|
||||
|
||||
/* remove one command if necessary */
|
||||
if ((CONFIG_INTEGER(config_history_max_commands) > 0)
|
||||
&& (buffer->num_history > CONFIG_INTEGER(config_history_max_commands)))
|
||||
@@ -105,7 +105,7 @@ gui_history_global_add (const char *string)
|
||||
|
||||
if (!string)
|
||||
return;
|
||||
|
||||
|
||||
if (!history_global
|
||||
|| (history_global
|
||||
&& (strcmp (history_global->text, string) != 0)))
|
||||
@@ -122,7 +122,7 @@ gui_history_global_add (const char *string)
|
||||
new_history->prev_history = NULL;
|
||||
history_global = new_history;
|
||||
num_history_global++;
|
||||
|
||||
|
||||
/* remove one command if necessary */
|
||||
if ((CONFIG_INTEGER(config_history_max_commands) > 0)
|
||||
&& (num_history_global > CONFIG_INTEGER(config_history_max_commands)))
|
||||
@@ -149,11 +149,11 @@ void
|
||||
gui_history_add (struct t_gui_buffer *buffer, const char *string)
|
||||
{
|
||||
char *string2, str_buffer[128];
|
||||
|
||||
|
||||
snprintf (str_buffer, sizeof (str_buffer),
|
||||
"0x%lx", (long unsigned int)(buffer));
|
||||
string2 = hook_modifier_exec (NULL, "history_add", str_buffer, string);
|
||||
|
||||
|
||||
/*
|
||||
* if message was NOT dropped by modifier, then we add it to buffer and
|
||||
* global history
|
||||
@@ -163,7 +163,7 @@ gui_history_add (struct t_gui_buffer *buffer, const char *string)
|
||||
gui_history_buffer_add (buffer, (string2) ? string2 : string);
|
||||
gui_history_global_add ((string2) ? string2 : string);
|
||||
}
|
||||
|
||||
|
||||
if (string2)
|
||||
free (string2);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ void
|
||||
gui_history_global_free ()
|
||||
{
|
||||
struct t_gui_history *ptr_history;
|
||||
|
||||
|
||||
while (history_global)
|
||||
{
|
||||
ptr_history = history_global->next_history;
|
||||
@@ -200,7 +200,7 @@ void
|
||||
gui_history_buffer_free (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_history *ptr_history;
|
||||
|
||||
|
||||
while (buffer->history)
|
||||
{
|
||||
ptr_history = buffer->history->next_history;
|
||||
@@ -223,10 +223,10 @@ struct t_hdata *
|
||||
gui_history_hdata_history_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_history", "next_history");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -248,16 +248,16 @@ gui_history_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_history *history)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !history)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_string (ptr_item, "text", history->text))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
+35
-35
@@ -69,7 +69,7 @@ struct t_gui_hotlist *
|
||||
gui_hotlist_search (struct t_gui_hotlist *hotlist, struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
|
||||
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
@@ -100,10 +100,10 @@ gui_hotlist_free (struct t_gui_hotlist **hotlist,
|
||||
}
|
||||
else
|
||||
new_hotlist = ptr_hotlist->next_hotlist;
|
||||
|
||||
|
||||
if (ptr_hotlist->next_hotlist)
|
||||
(ptr_hotlist->next_hotlist)->prev_hotlist = ptr_hotlist->prev_hotlist;
|
||||
|
||||
|
||||
free (ptr_hotlist);
|
||||
*hotlist = new_hotlist;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist,
|
||||
struct t_gui_hotlist *new_hotlist)
|
||||
{
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
|
||||
|
||||
switch (CONFIG_INTEGER(config_look_hotlist_sort))
|
||||
{
|
||||
case CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC:
|
||||
@@ -239,11 +239,11 @@ gui_hotlist_add_hotlist (struct t_gui_hotlist **hotlist,
|
||||
struct t_gui_hotlist *new_hotlist)
|
||||
{
|
||||
struct t_gui_hotlist *pos_hotlist;
|
||||
|
||||
|
||||
if (*hotlist)
|
||||
{
|
||||
pos_hotlist = gui_hotlist_find_pos (*hotlist, new_hotlist);
|
||||
|
||||
|
||||
if (pos_hotlist)
|
||||
{
|
||||
/* insert hotlist into the hotlist (before hotlist found) */
|
||||
@@ -288,34 +288,34 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
|
||||
struct t_gui_hotlist *new_hotlist, *ptr_hotlist;
|
||||
int i, count[GUI_HOTLIST_NUM_PRIORITIES];
|
||||
const char *away;
|
||||
|
||||
|
||||
if (!buffer || !gui_add_hotlist)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* do not add core buffer if upgrading */
|
||||
if (weechat_upgrading && (buffer == gui_buffer_search_main ()))
|
||||
return NULL;
|
||||
|
||||
|
||||
/* do not add buffer if it is displayed and away is not set */
|
||||
away = hashtable_get (buffer->local_variables, "away");
|
||||
if ((buffer->num_displayed > 0)
|
||||
&& ((!away || !away[0])
|
||||
|| !CONFIG_BOOLEAN(config_look_hotlist_add_buffer_if_away)))
|
||||
return NULL;
|
||||
|
||||
|
||||
if (priority > GUI_HOTLIST_MAX)
|
||||
priority = GUI_HOTLIST_MAX;
|
||||
|
||||
|
||||
/* check if priority is ok according to buffer notify level value */
|
||||
if (!gui_hotlist_check_buffer_notify (buffer, priority))
|
||||
return NULL;
|
||||
|
||||
|
||||
/* init count */
|
||||
for (i = 0; i < GUI_HOTLIST_NUM_PRIORITIES; i++)
|
||||
{
|
||||
count[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
ptr_hotlist = gui_hotlist_search (gui_hotlist, buffer);
|
||||
if (ptr_hotlist)
|
||||
{
|
||||
@@ -326,7 +326,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
|
||||
gui_hotlist_changed_signal ();
|
||||
return ptr_hotlist;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* if buffer is present with lower priority: save counts, remove it
|
||||
* and go on
|
||||
@@ -334,7 +334,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
|
||||
memcpy (count, ptr_hotlist->count, sizeof (ptr_hotlist->count));
|
||||
gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist);
|
||||
}
|
||||
|
||||
|
||||
new_hotlist = malloc (sizeof (*new_hotlist));
|
||||
if (!new_hotlist)
|
||||
{
|
||||
@@ -342,7 +342,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
|
||||
"hotlist"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_hotlist->priority = priority;
|
||||
if (creation_time)
|
||||
memcpy (&(new_hotlist->creation_time),
|
||||
@@ -354,11 +354,11 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
|
||||
new_hotlist->count[priority]++;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
new_hotlist->prev_hotlist = NULL;
|
||||
|
||||
|
||||
gui_hotlist_add_hotlist (&gui_hotlist, &last_gui_hotlist, new_hotlist);
|
||||
|
||||
|
||||
gui_hotlist_changed_signal ();
|
||||
|
||||
|
||||
return new_hotlist;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ struct t_gui_hotlist *
|
||||
gui_hotlist_dup (struct t_gui_hotlist *hotlist)
|
||||
{
|
||||
struct t_gui_hotlist *new_hotlist;
|
||||
|
||||
|
||||
new_hotlist = malloc (sizeof (*new_hotlist));
|
||||
if (new_hotlist)
|
||||
{
|
||||
@@ -395,7 +395,7 @@ gui_hotlist_resort ()
|
||||
{
|
||||
struct t_gui_hotlist *new_hotlist, *last_new_hotlist;
|
||||
struct t_gui_hotlist *ptr_hotlist, *element;
|
||||
|
||||
|
||||
/* copy and resort hotlist in new linked list */
|
||||
new_hotlist = NULL;
|
||||
last_new_hotlist = NULL;
|
||||
@@ -405,12 +405,12 @@ gui_hotlist_resort ()
|
||||
element = gui_hotlist_dup (ptr_hotlist);
|
||||
gui_hotlist_add_hotlist (&new_hotlist, &last_new_hotlist, element);
|
||||
}
|
||||
|
||||
|
||||
gui_hotlist_free_all (&gui_hotlist, &last_gui_hotlist);
|
||||
|
||||
|
||||
gui_hotlist = new_hotlist;
|
||||
last_gui_hotlist = last_new_hotlist;
|
||||
|
||||
|
||||
gui_hotlist_changed_signal ();
|
||||
}
|
||||
|
||||
@@ -434,26 +434,26 @@ gui_hotlist_remove_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
int hotlist_changed;
|
||||
struct t_gui_hotlist *ptr_hotlist, *next_hotlist;
|
||||
|
||||
|
||||
if (weechat_upgrading)
|
||||
return;
|
||||
|
||||
|
||||
hotlist_changed = 0;
|
||||
|
||||
|
||||
ptr_hotlist = gui_hotlist;
|
||||
while (ptr_hotlist)
|
||||
{
|
||||
next_hotlist = ptr_hotlist->next_hotlist;
|
||||
|
||||
|
||||
if (ptr_hotlist->buffer->number == buffer->number)
|
||||
{
|
||||
gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist);
|
||||
hotlist_changed = 1;
|
||||
}
|
||||
|
||||
|
||||
ptr_hotlist = next_hotlist;
|
||||
}
|
||||
|
||||
|
||||
if (hotlist_changed)
|
||||
gui_hotlist_changed_signal ();
|
||||
}
|
||||
@@ -470,14 +470,14 @@ gui_hotlist_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_infolist_item *ptr_item;
|
||||
int i;
|
||||
char option_name[64];
|
||||
|
||||
|
||||
if (!infolist || !hotlist)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_integer (ptr_item, "priority", hotlist->priority))
|
||||
return 0;
|
||||
switch (hotlist->priority)
|
||||
@@ -525,7 +525,7 @@ gui_hotlist_add_to_infolist (struct t_infolist *infolist,
|
||||
if (!infolist_new_var_integer (ptr_item, option_name, hotlist->count[i]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ gui_hotlist_print_log ()
|
||||
{
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
int i;
|
||||
|
||||
|
||||
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
|
||||
+89
-89
@@ -60,7 +60,7 @@ gui_input_optimize_size (struct t_gui_buffer *buffer)
|
||||
{
|
||||
int optimal_size;
|
||||
char *input_buffer2;
|
||||
|
||||
|
||||
if (buffer->input)
|
||||
{
|
||||
optimal_size = ((buffer->input_buffer_size / GUI_BUFFER_INPUT_BLOCK_SIZE) *
|
||||
@@ -93,27 +93,27 @@ gui_input_replace_input (struct t_gui_buffer *buffer, const char *new_input)
|
||||
{
|
||||
int size, length;
|
||||
char *input_utf8;
|
||||
|
||||
|
||||
input_utf8 = strdup (new_input);
|
||||
if (input_utf8)
|
||||
{
|
||||
utf8_normalize (input_utf8, '?');
|
||||
|
||||
|
||||
size = strlen (input_utf8);
|
||||
length = utf8_strlen (input_utf8);
|
||||
|
||||
|
||||
/* compute new buffer size */
|
||||
buffer->input_buffer_size = size;
|
||||
buffer->input_buffer_length = length;
|
||||
gui_input_optimize_size (buffer);
|
||||
|
||||
|
||||
/* copy new string to input */
|
||||
strcpy (buffer->input_buffer, input_utf8);
|
||||
|
||||
|
||||
/* move cursor to the end of new input if it is now after the end */
|
||||
if (buffer->input_buffer_pos > buffer->input_buffer_length)
|
||||
buffer->input_buffer_pos = buffer->input_buffer_length;
|
||||
|
||||
|
||||
free (input_utf8);
|
||||
}
|
||||
}
|
||||
@@ -138,12 +138,12 @@ gui_input_text_changed_modifier_and_signal (struct t_gui_buffer *buffer,
|
||||
int save_undo)
|
||||
{
|
||||
char str_buffer[128], *new_input;
|
||||
|
||||
|
||||
if (!gui_cursor_mode)
|
||||
{
|
||||
if (save_undo)
|
||||
gui_buffer_undo_add (buffer);
|
||||
|
||||
|
||||
/* send modifier, and change input if needed */
|
||||
snprintf (str_buffer, sizeof (str_buffer),
|
||||
"0x%lx", (long unsigned int)buffer);
|
||||
@@ -163,7 +163,7 @@ gui_input_text_changed_modifier_and_signal (struct t_gui_buffer *buffer,
|
||||
free (new_input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* send signal */
|
||||
hook_signal_send ("input_text_changed", WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
@@ -217,39 +217,39 @@ gui_input_insert_string (struct t_gui_buffer *buffer, const char *string,
|
||||
{
|
||||
int size, length;
|
||||
char *string_utf8, *ptr_start;
|
||||
|
||||
|
||||
if (buffer->input)
|
||||
{
|
||||
string_utf8 = strdup (string);
|
||||
if (!string_utf8)
|
||||
return 0;
|
||||
|
||||
|
||||
if (pos == -1)
|
||||
pos = buffer->input_buffer_pos;
|
||||
|
||||
|
||||
utf8_normalize (string_utf8, '?');
|
||||
|
||||
|
||||
size = strlen (string_utf8);
|
||||
length = utf8_strlen (string_utf8);
|
||||
|
||||
|
||||
/* increase buffer size */
|
||||
buffer->input_buffer_size += size;
|
||||
buffer->input_buffer_length += length;
|
||||
gui_input_optimize_size (buffer);
|
||||
buffer->input_buffer[buffer->input_buffer_size] = '\0';
|
||||
|
||||
|
||||
/* move end of string to the right */
|
||||
ptr_start = utf8_add_offset (buffer->input_buffer, pos);
|
||||
memmove (ptr_start + size, ptr_start, strlen (ptr_start));
|
||||
|
||||
|
||||
/* insert new string */
|
||||
ptr_start = utf8_add_offset (buffer->input_buffer, pos);
|
||||
strncpy (ptr_start, string_utf8, size);
|
||||
|
||||
|
||||
buffer->input_buffer_pos += length;
|
||||
|
||||
|
||||
free (string_utf8);
|
||||
|
||||
|
||||
return length;
|
||||
}
|
||||
return 0;
|
||||
@@ -265,7 +265,7 @@ gui_input_move_to_buffer (struct t_gui_buffer *from_buffer,
|
||||
struct t_gui_buffer *to_buffer)
|
||||
{
|
||||
int is_command;
|
||||
|
||||
|
||||
/*
|
||||
* move of input is allowed if:
|
||||
* - 2 buffers are different
|
||||
@@ -276,7 +276,7 @@ gui_input_move_to_buffer (struct t_gui_buffer *from_buffer,
|
||||
|| (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_NONE)
|
||||
|| !from_buffer->input_buffer || !from_buffer->input_buffer[0])
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
* if input is command and that only text is allowed,
|
||||
* or if input is text and that only command is allowed,
|
||||
@@ -286,7 +286,7 @@ gui_input_move_to_buffer (struct t_gui_buffer *from_buffer,
|
||||
if ((is_command && (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_TEXT))
|
||||
|| (!is_command && (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_COMMANDS)))
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
* if overwrite is off and that input of target buffer is not empty,
|
||||
* then do nothing
|
||||
@@ -294,7 +294,7 @@ gui_input_move_to_buffer (struct t_gui_buffer *from_buffer,
|
||||
if ((!CONFIG_BOOLEAN(config_look_input_share_overwrite))
|
||||
&& to_buffer->input_buffer && to_buffer->input_buffer[0])
|
||||
return;
|
||||
|
||||
|
||||
/* move input_buffer */
|
||||
if (to_buffer->input_buffer)
|
||||
free (to_buffer->input_buffer);
|
||||
@@ -305,7 +305,7 @@ gui_input_move_to_buffer (struct t_gui_buffer *from_buffer,
|
||||
to_buffer->input_buffer_pos = from_buffer->input_buffer_pos;
|
||||
to_buffer->input_buffer_1st_display = from_buffer->input_buffer_1st_display;
|
||||
gui_buffer_input_buffer_init (from_buffer);
|
||||
|
||||
|
||||
/* move undo data */
|
||||
gui_buffer_undo_free_all (to_buffer);
|
||||
(to_buffer->input_undo_snap)->data = (from_buffer->input_undo_snap)->data;
|
||||
@@ -331,12 +331,12 @@ gui_input_clipboard_copy (const char *buffer, int size)
|
||||
{
|
||||
if (size <= 0)
|
||||
return;
|
||||
|
||||
|
||||
if (gui_input_clipboard != NULL)
|
||||
free (gui_input_clipboard);
|
||||
|
||||
|
||||
gui_input_clipboard = malloc((size + 1) * sizeof(*gui_input_clipboard));
|
||||
|
||||
|
||||
if (gui_input_clipboard)
|
||||
{
|
||||
memcpy (gui_input_clipboard, buffer, size);
|
||||
@@ -358,7 +358,7 @@ gui_input_clipboard_paste (struct t_gui_buffer *buffer)
|
||||
gui_input_insert_string (buffer,
|
||||
gui_input_clipboard, -1);
|
||||
gui_completion_stop (buffer->completion, 1);
|
||||
|
||||
|
||||
gui_input_text_changed_modifier_and_signal (buffer, 1);
|
||||
}
|
||||
}
|
||||
@@ -372,7 +372,7 @@ gui_input_return (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
char *command;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window && window->buffer->input
|
||||
&& (window->buffer->input_buffer_size > 0))
|
||||
@@ -408,10 +408,10 @@ void
|
||||
gui_input_complete (struct t_gui_buffer *buffer)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (!buffer->completion)
|
||||
return;
|
||||
|
||||
|
||||
if (buffer->completion->word_found)
|
||||
{
|
||||
/* replace word with new completed word into input buffer */
|
||||
@@ -445,7 +445,7 @@ gui_input_complete (struct t_gui_buffer *buffer)
|
||||
gui_input_optimize_size (buffer);
|
||||
buffer->input_buffer[buffer->input_buffer_size] = '\0';
|
||||
}
|
||||
|
||||
|
||||
strncpy (buffer->input_buffer + buffer->completion->position_replace,
|
||||
buffer->completion->word_found,
|
||||
strlen (buffer->completion->word_found));
|
||||
@@ -453,7 +453,7 @@ gui_input_complete (struct t_gui_buffer *buffer)
|
||||
utf8_pos (buffer->input_buffer,
|
||||
buffer->completion->position_replace) +
|
||||
utf8_strlen (buffer->completion->word_found);
|
||||
|
||||
|
||||
/*
|
||||
* position is < 0 this means only one word was found to complete,
|
||||
* so reinit to stop completion
|
||||
@@ -461,7 +461,7 @@ gui_input_complete (struct t_gui_buffer *buffer)
|
||||
if (buffer->completion->position >= 0)
|
||||
buffer->completion->position = utf8_real_pos (buffer->input_buffer,
|
||||
buffer->input_buffer_pos);
|
||||
|
||||
|
||||
/* add space if needed after completion */
|
||||
if (buffer->completion->add_space)
|
||||
{
|
||||
@@ -531,7 +531,7 @@ void
|
||||
gui_input_search_text (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window && (window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
|
||||
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
|
||||
@@ -569,7 +569,7 @@ void
|
||||
gui_input_search_next (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window && (window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
|
||||
&& (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED))
|
||||
@@ -588,7 +588,7 @@ void
|
||||
gui_input_search_switch_case (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window && (window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
|
||||
&& (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED))
|
||||
@@ -626,7 +626,7 @@ gui_input_delete_previous_char (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *pos, *pos_last;
|
||||
int char_size, size_to_move;
|
||||
|
||||
|
||||
if (buffer->input && (buffer->input_buffer_pos > 0))
|
||||
{
|
||||
gui_buffer_undo_snap (buffer);
|
||||
@@ -655,7 +655,7 @@ gui_input_delete_next_char (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *pos, *pos_next;
|
||||
int char_size, size_to_move;
|
||||
|
||||
|
||||
if (buffer->input
|
||||
&& (buffer->input_buffer_pos < buffer->input_buffer_length))
|
||||
{
|
||||
@@ -684,7 +684,7 @@ gui_input_delete_previous_word (struct t_gui_buffer *buffer)
|
||||
{
|
||||
int length_deleted, size_deleted;
|
||||
char *start, *string;
|
||||
|
||||
|
||||
if (buffer->input && (buffer->input_buffer_pos > 0))
|
||||
{
|
||||
gui_buffer_undo_snap (buffer);
|
||||
@@ -709,19 +709,19 @@ gui_input_delete_previous_word (struct t_gui_buffer *buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (string)
|
||||
string = utf8_next_char (utf8_next_char (string));
|
||||
else
|
||||
string = buffer->input_buffer;
|
||||
|
||||
|
||||
size_deleted = utf8_next_char (start) - string;
|
||||
length_deleted = utf8_strnlen (string, size_deleted);
|
||||
|
||||
|
||||
gui_input_clipboard_copy (string, size_deleted);
|
||||
|
||||
|
||||
memmove (string, string + size_deleted, strlen (string + size_deleted));
|
||||
|
||||
|
||||
buffer->input_buffer_size -= size_deleted;
|
||||
buffer->input_buffer_length -= length_deleted;
|
||||
buffer->input_buffer[buffer->input_buffer_size] = '\0';
|
||||
@@ -741,7 +741,7 @@ gui_input_delete_next_word (struct t_gui_buffer *buffer)
|
||||
{
|
||||
int size_deleted, length_deleted;
|
||||
char *start, *string;
|
||||
|
||||
|
||||
if (buffer->input)
|
||||
{
|
||||
gui_buffer_undo_snap (buffer);
|
||||
@@ -757,11 +757,11 @@ gui_input_delete_next_word (struct t_gui_buffer *buffer)
|
||||
length_deleted++;
|
||||
}
|
||||
size_deleted = string - start;
|
||||
|
||||
|
||||
gui_input_clipboard_copy (start, size_deleted);
|
||||
|
||||
|
||||
memmove (start, string, strlen (string));
|
||||
|
||||
|
||||
buffer->input_buffer_size -= size_deleted;
|
||||
buffer->input_buffer_length -= length_deleted;
|
||||
buffer->input_buffer[buffer->input_buffer_size] = '\0';
|
||||
@@ -782,7 +782,7 @@ gui_input_delete_beginning_of_line (struct t_gui_buffer *buffer)
|
||||
{
|
||||
int length_deleted, size_deleted;
|
||||
char *start;
|
||||
|
||||
|
||||
if (buffer->input && (buffer->input_buffer_pos > 0))
|
||||
{
|
||||
gui_buffer_undo_snap (buffer);
|
||||
@@ -792,9 +792,9 @@ gui_input_delete_beginning_of_line (struct t_gui_buffer *buffer)
|
||||
length_deleted = utf8_strnlen (buffer->input_buffer, size_deleted);
|
||||
gui_input_clipboard_copy (buffer->input_buffer,
|
||||
start - buffer->input_buffer);
|
||||
|
||||
|
||||
memmove (buffer->input_buffer, start, strlen (start));
|
||||
|
||||
|
||||
buffer->input_buffer_size -= size_deleted;
|
||||
buffer->input_buffer_length -= length_deleted;
|
||||
buffer->input_buffer[buffer->input_buffer_size] = '\0';
|
||||
@@ -815,7 +815,7 @@ gui_input_delete_end_of_line (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *start;
|
||||
int size_deleted;
|
||||
|
||||
|
||||
if (buffer->input)
|
||||
{
|
||||
gui_buffer_undo_snap (buffer);
|
||||
@@ -862,29 +862,29 @@ gui_input_transpose_chars (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *start, *prev_char, saved_char[5];
|
||||
int size_prev_char, size_start_char;
|
||||
|
||||
|
||||
if (buffer->input && (buffer->input_buffer_pos > 0)
|
||||
&& (buffer->input_buffer_length > 1))
|
||||
{
|
||||
gui_buffer_undo_snap (buffer);
|
||||
|
||||
|
||||
if (buffer->input_buffer_pos == buffer->input_buffer_length)
|
||||
buffer->input_buffer_pos--;
|
||||
|
||||
|
||||
start = utf8_add_offset (buffer->input_buffer,
|
||||
buffer->input_buffer_pos);
|
||||
prev_char = utf8_prev_char (buffer->input_buffer, start);
|
||||
size_prev_char = start - prev_char;
|
||||
size_start_char = utf8_char_size (start);
|
||||
|
||||
|
||||
memcpy (saved_char, prev_char, size_prev_char);
|
||||
memcpy (prev_char, start, size_start_char);
|
||||
memcpy (prev_char + size_start_char, saved_char, size_prev_char);
|
||||
|
||||
|
||||
buffer->input_buffer_pos++;
|
||||
|
||||
|
||||
gui_completion_stop (buffer->completion, 1);
|
||||
|
||||
|
||||
gui_input_text_changed_modifier_and_signal (buffer, 1);
|
||||
}
|
||||
}
|
||||
@@ -956,7 +956,7 @@ void
|
||||
gui_input_move_previous_word (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *pos;
|
||||
|
||||
|
||||
if (buffer->input
|
||||
&& (buffer->input_buffer_pos > 0))
|
||||
{
|
||||
@@ -981,7 +981,7 @@ gui_input_move_previous_word (struct t_gui_buffer *buffer)
|
||||
}
|
||||
else
|
||||
buffer->input_buffer_pos = 0;
|
||||
|
||||
|
||||
gui_input_text_cursor_moved_signal ();
|
||||
}
|
||||
}
|
||||
@@ -995,7 +995,7 @@ void
|
||||
gui_input_move_next_word (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *pos;
|
||||
|
||||
|
||||
if (buffer->input
|
||||
&& (buffer->input_buffer_pos < buffer->input_buffer_length))
|
||||
{
|
||||
@@ -1026,7 +1026,7 @@ gui_input_move_next_word (struct t_gui_buffer *buffer)
|
||||
utf8_pos (buffer->input_buffer,
|
||||
utf8_prev_char (buffer->input_buffer, pos) - buffer->input_buffer);
|
||||
}
|
||||
|
||||
|
||||
gui_input_text_cursor_moved_signal ();
|
||||
}
|
||||
}
|
||||
@@ -1043,7 +1043,7 @@ gui_input_history_previous (struct t_gui_window *window,
|
||||
{
|
||||
if (!window->buffer->input)
|
||||
return;
|
||||
|
||||
|
||||
if (*ptr_history)
|
||||
{
|
||||
if (!(*ptr_history)->next_history)
|
||||
@@ -1052,10 +1052,10 @@ gui_input_history_previous (struct t_gui_window *window,
|
||||
}
|
||||
if (!(*ptr_history))
|
||||
*ptr_history = history;
|
||||
|
||||
|
||||
if (!(*ptr_history))
|
||||
return;
|
||||
|
||||
|
||||
/* bash/readline like use of history */
|
||||
if (window->buffer->input_buffer_size > 0)
|
||||
{
|
||||
@@ -1098,15 +1098,15 @@ gui_input_history_next (struct t_gui_window *window,
|
||||
struct t_gui_history **ptr_history)
|
||||
{
|
||||
int input_changed;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) history;
|
||||
|
||||
|
||||
input_changed = 0;
|
||||
|
||||
|
||||
if (!window->buffer->input)
|
||||
return;
|
||||
|
||||
|
||||
if (*ptr_history)
|
||||
{
|
||||
/* replace text in history with current input */
|
||||
@@ -1114,7 +1114,7 @@ gui_input_history_next (struct t_gui_window *window,
|
||||
if ((*ptr_history)->text)
|
||||
free ((*ptr_history)->text);
|
||||
(*ptr_history)->text = strdup (window->buffer->input_buffer);
|
||||
|
||||
|
||||
*ptr_history = (*ptr_history)->prev_history;
|
||||
if (*ptr_history)
|
||||
{
|
||||
@@ -1172,7 +1172,7 @@ void
|
||||
gui_input_history_local_previous (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window)
|
||||
{
|
||||
@@ -1191,7 +1191,7 @@ void
|
||||
gui_input_history_local_next (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window)
|
||||
{
|
||||
@@ -1210,7 +1210,7 @@ void
|
||||
gui_input_history_global_previous (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window)
|
||||
{
|
||||
@@ -1229,7 +1229,7 @@ void
|
||||
gui_input_history_global_next (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window)
|
||||
{
|
||||
@@ -1247,7 +1247,7 @@ void
|
||||
gui_input_jump_smart (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window
|
||||
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
|
||||
@@ -1282,7 +1282,7 @@ void
|
||||
gui_input_jump_last_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window
|
||||
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
|
||||
@@ -1304,7 +1304,7 @@ gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer)
|
||||
struct t_gui_window *window;
|
||||
int index;
|
||||
struct t_gui_buffer_visited *ptr_buffer_visited;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window
|
||||
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
|
||||
@@ -1313,7 +1313,7 @@ gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer)
|
||||
if (index >= 0)
|
||||
{
|
||||
gui_buffers_visited_index = index;
|
||||
|
||||
|
||||
ptr_buffer_visited =
|
||||
gui_buffer_visited_search_by_number (gui_buffers_visited_index);
|
||||
if (ptr_buffer_visited)
|
||||
@@ -1339,7 +1339,7 @@ gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer)
|
||||
struct t_gui_window *window;
|
||||
int index;
|
||||
struct t_gui_buffer_visited *ptr_buffer_visited;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window
|
||||
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
|
||||
@@ -1348,7 +1348,7 @@ gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer)
|
||||
if (index >= 0)
|
||||
{
|
||||
gui_buffers_visited_index = index;
|
||||
|
||||
|
||||
ptr_buffer_visited = gui_buffer_visited_search_by_number (gui_buffers_visited_index);
|
||||
if (ptr_buffer_visited)
|
||||
{
|
||||
@@ -1406,7 +1406,7 @@ void
|
||||
gui_input_scroll_unread (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
window = gui_window_search_with_buffer (buffer);
|
||||
if (window
|
||||
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
|
||||
@@ -1444,7 +1444,7 @@ void
|
||||
gui_input_set_unread ()
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* set read marker for all standard buffers */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
@@ -1474,7 +1474,7 @@ gui_input_switch_active_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
ptr_buffer = gui_buffer_get_next_active_buffer (buffer);
|
||||
if (ptr_buffer)
|
||||
{
|
||||
@@ -1496,7 +1496,7 @@ gui_input_switch_active_buffer_previous (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_window *window;
|
||||
|
||||
|
||||
ptr_buffer = gui_buffer_get_previous_active_buffer (buffer);
|
||||
if (ptr_buffer)
|
||||
{
|
||||
@@ -1516,7 +1516,7 @@ void
|
||||
gui_input_insert (struct t_gui_buffer *buffer, const char *args)
|
||||
{
|
||||
char *args2;
|
||||
|
||||
|
||||
if (args)
|
||||
{
|
||||
gui_buffer_undo_snap (buffer);
|
||||
@@ -1564,7 +1564,7 @@ gui_input_undo (struct t_gui_buffer *buffer)
|
||||
gui_buffer_undo_snap_free (buffer);
|
||||
gui_buffer_undo_add (buffer);
|
||||
}
|
||||
|
||||
|
||||
if (buffer->ptr_input_undo
|
||||
&& (buffer->ptr_input_undo)->prev_undo)
|
||||
{
|
||||
|
||||
+108
-108
@@ -96,12 +96,12 @@ void
|
||||
gui_key_init ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
gui_key_combo_buffer[0] = '\0';
|
||||
gui_key_grab = 0;
|
||||
gui_key_grab_count = 0;
|
||||
gui_key_last_activity_time = time (NULL);
|
||||
|
||||
|
||||
/* create default keys and save them in a separate list */
|
||||
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
|
||||
{
|
||||
@@ -129,13 +129,13 @@ int
|
||||
gui_key_search_context (const char *context)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
|
||||
{
|
||||
if (string_strcasecmp (gui_key_context_string[i], context) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/* context not found */
|
||||
return -1;
|
||||
}
|
||||
@@ -149,11 +149,11 @@ gui_key_get_current_context ()
|
||||
{
|
||||
if (gui_cursor_mode)
|
||||
return GUI_KEY_CONTEXT_CURSOR;
|
||||
|
||||
|
||||
if (gui_current_window
|
||||
&& (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED))
|
||||
return GUI_KEY_CONTEXT_SEARCH;
|
||||
|
||||
|
||||
return GUI_KEY_CONTEXT_DEFAULT;
|
||||
}
|
||||
|
||||
@@ -166,11 +166,11 @@ gui_key_grab_init (int grab_command, const char *delay)
|
||||
{
|
||||
long milliseconds;
|
||||
char *error;
|
||||
|
||||
|
||||
gui_key_grab = 1;
|
||||
gui_key_grab_count = 0;
|
||||
gui_key_grab_command = grab_command;
|
||||
|
||||
|
||||
gui_key_grab_delay = GUI_KEY_GRAB_DELAY_DEFAULT;
|
||||
if (delay != NULL)
|
||||
{
|
||||
@@ -194,11 +194,11 @@ gui_key_grab_end_timer_cb (void *data, int remaining_calls)
|
||||
{
|
||||
char *expanded_key, *expanded_key2;
|
||||
struct t_gui_key *ptr_key;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
/* get expanded name (for example: \x01+U => ctrl-u) */
|
||||
expanded_key = gui_key_get_expanded_name (gui_key_combo_buffer);
|
||||
if (expanded_key)
|
||||
@@ -244,13 +244,13 @@ gui_key_grab_end_timer_cb (void *data, int remaining_calls)
|
||||
}
|
||||
free (expanded_key);
|
||||
}
|
||||
|
||||
|
||||
/* end grab mode */
|
||||
gui_key_grab = 0;
|
||||
gui_key_grab_count = 0;
|
||||
gui_key_grab_command = 0;
|
||||
gui_key_combo_buffer[0] = '\0';
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -264,10 +264,10 @@ char *
|
||||
gui_key_get_internal_code (const char *key)
|
||||
{
|
||||
char *result;
|
||||
|
||||
|
||||
if ((key[0] == '@') && strchr (key, ':'))
|
||||
return strdup (key);
|
||||
|
||||
|
||||
if ((result = malloc (strlen (key) + 1)))
|
||||
{
|
||||
result[0] = '\0';
|
||||
@@ -310,10 +310,10 @@ char *
|
||||
gui_key_get_expanded_name (const char *key)
|
||||
{
|
||||
char *result;
|
||||
|
||||
|
||||
if (!key)
|
||||
return NULL;
|
||||
|
||||
|
||||
result = malloc ((strlen (key) * 5) + 1);
|
||||
if (result)
|
||||
{
|
||||
@@ -342,7 +342,7 @@ gui_key_get_expanded_name (const char *key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -355,17 +355,17 @@ int
|
||||
gui_key_score (struct t_gui_key *key)
|
||||
{
|
||||
int score, bonus, area;
|
||||
|
||||
|
||||
score = 0;
|
||||
bonus = 8;
|
||||
|
||||
|
||||
if (key->key[0] != '@')
|
||||
return score;
|
||||
|
||||
|
||||
/* basic score for key with area */
|
||||
score |= 1 << bonus;
|
||||
bonus--;
|
||||
|
||||
|
||||
/* add score for each area type */
|
||||
for (area = 0; area < 2; area++)
|
||||
{
|
||||
@@ -377,7 +377,7 @@ gui_key_score (struct t_gui_key *key)
|
||||
}
|
||||
bonus--;
|
||||
}
|
||||
|
||||
|
||||
/* add score for each area name */
|
||||
for (area = 0; area < 2; area++)
|
||||
{
|
||||
@@ -389,7 +389,7 @@ gui_key_score (struct t_gui_key *key)
|
||||
}
|
||||
bonus--;
|
||||
}
|
||||
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ gui_key_find_pos (struct t_gui_key *keys, struct t_gui_key *key)
|
||||
{
|
||||
struct t_gui_key *ptr_key;
|
||||
int score1, score2;
|
||||
|
||||
|
||||
score1 = gui_key_score (key);
|
||||
for (ptr_key = keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
@@ -427,11 +427,11 @@ gui_key_insert_sorted (struct t_gui_key **keys,
|
||||
struct t_gui_key *key)
|
||||
{
|
||||
struct t_gui_key *pos_key;
|
||||
|
||||
|
||||
if (*keys)
|
||||
{
|
||||
pos_key = gui_key_find_pos (*keys, key);
|
||||
|
||||
|
||||
if (pos_key)
|
||||
{
|
||||
/* insert key into the list (before key found) */
|
||||
@@ -460,7 +460,7 @@ gui_key_insert_sorted (struct t_gui_key **keys,
|
||||
*keys = key;
|
||||
*last_key = key;
|
||||
}
|
||||
|
||||
|
||||
(*keys_count)++;
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ gui_key_set_area_type_name (const char *area,
|
||||
{
|
||||
int focus, length;
|
||||
char *pos_end;
|
||||
|
||||
|
||||
for (focus = 0; focus < GUI_KEY_NUM_FOCUS; focus++)
|
||||
{
|
||||
length = strlen (gui_key_focus_string[focus]);
|
||||
@@ -528,20 +528,20 @@ gui_key_set_areas (struct t_gui_key *key)
|
||||
key->area_name[area] = NULL;
|
||||
}
|
||||
key->area_key = NULL;
|
||||
|
||||
|
||||
if (key->key[0] != '@')
|
||||
return;
|
||||
|
||||
|
||||
areas[0] = NULL;
|
||||
areas[1] = NULL;
|
||||
|
||||
|
||||
pos_colon = strchr (key->key + 1, ':');
|
||||
if (!pos_colon)
|
||||
return;
|
||||
pos_area2 = strchr (key->key + 1, '>');
|
||||
|
||||
|
||||
key->area_key = strdup (pos_colon + 1);
|
||||
|
||||
|
||||
if (!pos_area2 || (pos_area2 > pos_colon))
|
||||
areas[0] = string_strndup (key->key + 1, pos_colon - key->key - 1);
|
||||
else
|
||||
@@ -550,7 +550,7 @@ gui_key_set_areas (struct t_gui_key *key)
|
||||
areas[0] = string_strndup (key->key + 1, pos_area2 - key->key - 1);
|
||||
areas[1] = string_strndup (pos_area2 + 1, pos_colon - pos_area2 - 1);
|
||||
}
|
||||
|
||||
|
||||
for (area = 0; area < 2; area++)
|
||||
{
|
||||
if (!areas[area])
|
||||
@@ -562,7 +562,7 @@ gui_key_set_areas (struct t_gui_key *key)
|
||||
&(key->area_type[area]),
|
||||
&(key->area_name[area]));
|
||||
}
|
||||
|
||||
|
||||
if (areas[0])
|
||||
free (areas[0]);
|
||||
if (areas[1])
|
||||
@@ -581,10 +581,10 @@ gui_key_new (struct t_gui_buffer *buffer, int context, const char *key,
|
||||
{
|
||||
struct t_gui_key *new_key;
|
||||
char *expanded_name;
|
||||
|
||||
|
||||
if (!key || !command)
|
||||
return NULL;
|
||||
|
||||
|
||||
if ((new_key = malloc (sizeof (*new_key))))
|
||||
{
|
||||
new_key->key = gui_key_get_internal_code (key);
|
||||
@@ -603,7 +603,7 @@ gui_key_new (struct t_gui_buffer *buffer, int context, const char *key,
|
||||
return NULL;
|
||||
}
|
||||
gui_key_set_areas (new_key);
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
gui_key_insert_sorted (&buffer->keys, &buffer->last_key,
|
||||
@@ -615,12 +615,12 @@ gui_key_new (struct t_gui_buffer *buffer, int context, const char *key,
|
||||
&last_gui_key[context],
|
||||
&gui_keys_count[context], new_key);
|
||||
}
|
||||
|
||||
|
||||
expanded_name = gui_key_get_expanded_name (new_key->key);
|
||||
|
||||
|
||||
hook_signal_send ("key_bind",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, expanded_name);
|
||||
|
||||
|
||||
if (gui_key_verbose)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
@@ -637,7 +637,7 @@ gui_key_new (struct t_gui_buffer *buffer, int context, const char *key,
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
|
||||
return new_key;
|
||||
}
|
||||
|
||||
@@ -649,13 +649,13 @@ struct t_gui_key *
|
||||
gui_key_search (struct t_gui_key *keys, const char *key)
|
||||
{
|
||||
struct t_gui_key *ptr_key;
|
||||
|
||||
|
||||
for (ptr_key = keys; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
if (strcmp (ptr_key->key, key) == 0)
|
||||
return ptr_key;
|
||||
}
|
||||
|
||||
|
||||
/* key not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -668,10 +668,10 @@ int
|
||||
gui_key_cmp (const char *key, const char *search, int context)
|
||||
{
|
||||
int diff;
|
||||
|
||||
|
||||
if (context == GUI_KEY_CONTEXT_MOUSE)
|
||||
return (string_match (key, search, 1)) ? 0 : 1;
|
||||
|
||||
|
||||
while (search[0])
|
||||
{
|
||||
diff = utf8_charcmp (key, search);
|
||||
@@ -680,7 +680,7 @@ gui_key_cmp (const char *key, const char *search, int context)
|
||||
key = utf8_next_char (key);
|
||||
search = utf8_next_char (search);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -693,7 +693,7 @@ gui_key_search_part (struct t_gui_buffer *buffer, int context,
|
||||
const char *key)
|
||||
{
|
||||
struct t_gui_key *ptr_key;
|
||||
|
||||
|
||||
for (ptr_key = (buffer) ? buffer->keys : gui_keys[context]; ptr_key;
|
||||
ptr_key = ptr_key->next_key)
|
||||
{
|
||||
@@ -706,7 +706,7 @@ gui_key_search_part (struct t_gui_buffer *buffer, int context,
|
||||
return ptr_key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* key not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -725,9 +725,9 @@ gui_key_bind (struct t_gui_buffer *buffer, int context, const char *key,
|
||||
{
|
||||
if (!key || !command)
|
||||
return NULL;
|
||||
|
||||
|
||||
gui_key_unbind (buffer, context, key);
|
||||
|
||||
|
||||
return gui_key_new (buffer, context, key, command);
|
||||
}
|
||||
|
||||
@@ -743,12 +743,12 @@ gui_key_bind_plugin_hashtable_map_cb (void *data,
|
||||
int *user_data;
|
||||
struct t_gui_key *ptr_key;
|
||||
char *internal_code;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
|
||||
user_data = (int *)data;
|
||||
|
||||
|
||||
if (user_data && key && value)
|
||||
{
|
||||
internal_code = gui_key_get_internal_code (key);
|
||||
@@ -777,16 +777,16 @@ int
|
||||
gui_key_bind_plugin (const char *context, struct t_hashtable *keys)
|
||||
{
|
||||
int data[2];
|
||||
|
||||
|
||||
data[0] = gui_key_search_context (context);
|
||||
if (data[0] < 0)
|
||||
return 0;
|
||||
|
||||
|
||||
gui_key_verbose = 1;
|
||||
data[1] = 0;
|
||||
hashtable_map (keys, &gui_key_bind_plugin_hashtable_map_cb, data);
|
||||
gui_key_verbose = 0;
|
||||
|
||||
|
||||
return data[1];
|
||||
}
|
||||
|
||||
@@ -800,11 +800,11 @@ gui_key_unbind (struct t_gui_buffer *buffer, int context, const char *key)
|
||||
{
|
||||
struct t_gui_key *ptr_key;
|
||||
char *internal_code;
|
||||
|
||||
|
||||
internal_code = gui_key_get_internal_code (key);
|
||||
if (!internal_code)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_key = gui_key_search ((buffer) ? buffer->keys : gui_keys[context],
|
||||
(internal_code) ? internal_code : key);
|
||||
free (internal_code);
|
||||
@@ -831,7 +831,7 @@ gui_key_unbind (struct t_gui_buffer *buffer, int context, const char *key)
|
||||
WEECHAT_HOOK_SIGNAL_STRING, (char *)key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -847,11 +847,11 @@ gui_key_unbind_plugin (const char *context, const char *key)
|
||||
int ctxt, num_keys, area_type;
|
||||
char *area_name;
|
||||
struct t_gui_key *ptr_key;
|
||||
|
||||
|
||||
ctxt = gui_key_search_context (context);
|
||||
if (ctxt < 0)
|
||||
return 0;
|
||||
|
||||
|
||||
if (strncmp (key, "area:", 5) == 0)
|
||||
{
|
||||
num_keys = 0;
|
||||
@@ -883,7 +883,7 @@ gui_key_unbind_plugin (const char *context, const char *key)
|
||||
num_keys = gui_key_unbind (NULL, ctxt, key);
|
||||
gui_key_verbose = 0;
|
||||
}
|
||||
|
||||
|
||||
return num_keys;
|
||||
}
|
||||
|
||||
@@ -899,7 +899,7 @@ gui_key_focus_matching (struct t_gui_key *key,
|
||||
int match[2], area;
|
||||
char buffer_full_name[512];
|
||||
const char *chat, *buffer_plugin, *buffer_name, *bar_name, *bar_item_name;
|
||||
|
||||
|
||||
for (area = 0; area < 2; area++)
|
||||
{
|
||||
match[area] = 0;
|
||||
@@ -945,7 +945,7 @@ gui_key_focus_matching (struct t_gui_key *key,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return match[0] && match[1];
|
||||
}
|
||||
|
||||
@@ -964,43 +964,43 @@ gui_key_focus_command (const char *key, int context,
|
||||
struct t_hashtable *hashtable;
|
||||
struct t_weelist *list_keys;
|
||||
struct t_weelist_item *ptr_item;
|
||||
|
||||
|
||||
debug = 0;
|
||||
if (gui_cursor_debug && (context == GUI_KEY_CONTEXT_CURSOR))
|
||||
debug = gui_cursor_debug;
|
||||
else if (gui_mouse_debug && (context == GUI_KEY_CONTEXT_MOUSE))
|
||||
debug = gui_mouse_debug;
|
||||
|
||||
|
||||
for (ptr_key = gui_keys[context]; ptr_key;
|
||||
ptr_key = ptr_key->next_key)
|
||||
{
|
||||
/* ignore key if it has not area name or key for area */
|
||||
if (!ptr_key->area_name[0] || !ptr_key->area_key)
|
||||
continue;
|
||||
|
||||
|
||||
/* the special command "-" is used to ignore key */
|
||||
if (strcmp (ptr_key->command, "-") == 0)
|
||||
continue;
|
||||
|
||||
|
||||
/* ignore key if key for area is not matching */
|
||||
if (gui_key_cmp (key, ptr_key->area_key, context) != 0)
|
||||
continue;
|
||||
|
||||
|
||||
/* check if focus is matching with key */
|
||||
matching = gui_key_focus_matching (ptr_key, hashtable_focus);
|
||||
if (!matching)
|
||||
continue;
|
||||
|
||||
|
||||
hashtable = hook_focus_get_data (hashtable_focus[0],
|
||||
hashtable_focus[1]);
|
||||
if (!hashtable)
|
||||
continue;
|
||||
|
||||
|
||||
if ((context == GUI_KEY_CONTEXT_CURSOR) && gui_cursor_debug)
|
||||
{
|
||||
gui_input_delete_line (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
|
||||
if (debug > 1)
|
||||
{
|
||||
gui_chat_printf (NULL, _("Hashtable focus:"));
|
||||
@@ -1062,7 +1062,7 @@ gui_key_focus_command (const char *key, int context,
|
||||
hashtable_free (hashtable);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1078,13 +1078,13 @@ gui_key_focus (const char *key, int context)
|
||||
struct t_gui_focus_info *focus_info1, *focus_info2;
|
||||
struct t_hashtable *hashtable_focus[2];
|
||||
int rc;
|
||||
|
||||
|
||||
rc = 0;
|
||||
focus_info1 = NULL;
|
||||
focus_info2 = NULL;
|
||||
hashtable_focus[0] = NULL;
|
||||
hashtable_focus[1] = NULL;
|
||||
|
||||
|
||||
if (context == GUI_KEY_CONTEXT_MOUSE)
|
||||
{
|
||||
focus_info1 = gui_focus_get_info (gui_mouse_event_x[0],
|
||||
@@ -1122,9 +1122,9 @@ gui_key_focus (const char *key, int context)
|
||||
if (!hashtable_focus[0])
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
rc = gui_key_focus_command (key, context, hashtable_focus);
|
||||
|
||||
|
||||
end:
|
||||
if (focus_info1)
|
||||
gui_focus_free_info (focus_info1);
|
||||
@@ -1134,7 +1134,7 @@ end:
|
||||
hashtable_free (hashtable_focus[0]);
|
||||
if (hashtable_focus[1])
|
||||
hashtable_free (hashtable_focus[1]);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1150,14 +1150,14 @@ gui_key_pressed (const char *key_str)
|
||||
int i, first_key, context, length, length_key;
|
||||
struct t_gui_key *ptr_key;
|
||||
char **commands, *pos;
|
||||
|
||||
|
||||
/* add key to buffer */
|
||||
first_key = (gui_key_combo_buffer[0] == '\0');
|
||||
length = strlen (gui_key_combo_buffer);
|
||||
length_key = strlen (key_str);
|
||||
if (length + length_key + 1 <= (int)sizeof (gui_key_combo_buffer))
|
||||
strcat (gui_key_combo_buffer, key_str);
|
||||
|
||||
|
||||
/* if we are in "show mode", increase counter and return */
|
||||
if (gui_key_grab)
|
||||
{
|
||||
@@ -1169,7 +1169,7 @@ gui_key_pressed (const char *key_str)
|
||||
gui_key_grab_count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* mouse event pending */
|
||||
if (gui_mouse_event_pending)
|
||||
{
|
||||
@@ -1182,16 +1182,16 @@ gui_key_pressed (const char *key_str)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (strcmp (gui_key_combo_buffer, "\x01[[M") == 0)
|
||||
{
|
||||
gui_key_combo_buffer[0] = '\0';
|
||||
gui_mouse_event_init ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ptr_key = NULL;
|
||||
|
||||
|
||||
context = gui_key_get_current_context ();
|
||||
switch (context)
|
||||
{
|
||||
@@ -1223,7 +1223,7 @@ gui_key_pressed (const char *key_str)
|
||||
gui_key_combo_buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* if key is found, then execute action */
|
||||
if (ptr_key)
|
||||
{
|
||||
@@ -1254,7 +1254,7 @@ gui_key_pressed (const char *key_str)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gui_key_combo_buffer[0] = '\0';
|
||||
|
||||
/*
|
||||
@@ -1273,7 +1273,7 @@ gui_key_free (struct t_gui_key **keys, struct t_gui_key **last_key,
|
||||
int *keys_count, struct t_gui_key *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* free memory */
|
||||
if (key->key)
|
||||
free (key->key);
|
||||
@@ -1286,7 +1286,7 @@ gui_key_free (struct t_gui_key **keys, struct t_gui_key **last_key,
|
||||
free (key->area_key);
|
||||
if (key->command)
|
||||
free (key->command);
|
||||
|
||||
|
||||
/* remove key from keys list */
|
||||
if (key->prev_key)
|
||||
(key->prev_key)->next_key = key->next_key;
|
||||
@@ -1296,9 +1296,9 @@ gui_key_free (struct t_gui_key **keys, struct t_gui_key **last_key,
|
||||
*keys = key->next_key;
|
||||
if (*last_key == key)
|
||||
*last_key = key->prev_key;
|
||||
|
||||
|
||||
free (key);
|
||||
|
||||
|
||||
(*keys_count)--;
|
||||
}
|
||||
|
||||
@@ -1324,12 +1324,12 @@ void
|
||||
gui_key_buffer_optimize ()
|
||||
{
|
||||
int optimal_size, *gui_key_buffer2;
|
||||
|
||||
|
||||
optimal_size = (((gui_key_buffer_size * sizeof (int)) /
|
||||
GUI_KEY_BUFFER_BLOCK_SIZE) *
|
||||
GUI_KEY_BUFFER_BLOCK_SIZE) +
|
||||
GUI_KEY_BUFFER_BLOCK_SIZE;
|
||||
|
||||
|
||||
if (gui_key_buffer_alloc != optimal_size)
|
||||
{
|
||||
gui_key_buffer_alloc = optimal_size;
|
||||
@@ -1378,11 +1378,11 @@ gui_key_buffer_add (unsigned char key)
|
||||
{
|
||||
if (!gui_key_buffer)
|
||||
gui_key_buffer_reset ();
|
||||
|
||||
|
||||
gui_key_buffer_size++;
|
||||
|
||||
|
||||
gui_key_buffer_optimize ();
|
||||
|
||||
|
||||
if (gui_key_buffer)
|
||||
{
|
||||
gui_key_buffer[gui_key_buffer_size - 1] = key;
|
||||
@@ -1417,7 +1417,7 @@ gui_key_get_paste_lines ()
|
||||
{
|
||||
return gui_key_paste_lines + 1;
|
||||
}
|
||||
|
||||
|
||||
return gui_key_paste_lines;
|
||||
}
|
||||
|
||||
@@ -1452,11 +1452,11 @@ void
|
||||
gui_key_end ()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* free key buffer */
|
||||
if (gui_key_buffer)
|
||||
free (gui_key_buffer);
|
||||
|
||||
|
||||
for (i = 0; i < GUI_KEY_NUM_CONTEXTS; i++)
|
||||
{
|
||||
/* free keys */
|
||||
@@ -1478,10 +1478,10 @@ gui_key_hdata_key_cb (void *data, const char *hdata_name)
|
||||
struct t_hdata *hdata;
|
||||
int i;
|
||||
char str_list[128];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_key", "next_key");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1529,14 +1529,14 @@ gui_key_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_key_get_expanded_name (key->key);
|
||||
@@ -1558,7 +1558,7 @@ gui_key_add_to_infolist (struct t_infolist *infolist, struct t_gui_key *key)
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "command", key->command))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1570,7 +1570,7 @@ void
|
||||
gui_key_print_log_key (struct t_gui_key *key, const char *prefix)
|
||||
{
|
||||
int area;
|
||||
|
||||
|
||||
log_printf ("%s[key (addr:0x%lx)]", prefix, key);
|
||||
log_printf ("%s key. . . . . . . . : '%s'", prefix, key->key);
|
||||
for (area = 0; area < 2; area++)
|
||||
@@ -1596,7 +1596,7 @@ gui_key_print_log (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_key *ptr_key;
|
||||
int i;
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
log_printf (" keys . . . . . . . . : 0x%lx", buffer->keys);
|
||||
@@ -1617,7 +1617,7 @@ gui_key_print_log (struct t_gui_buffer *buffer)
|
||||
log_printf (" keys . . . . . . . . : 0x%lx", gui_keys[i]);
|
||||
log_printf (" last_key . . . . . . : 0x%lx", last_gui_key[i]);
|
||||
log_printf (" keys_count . . . . . : %d", gui_keys_count[i]);
|
||||
|
||||
|
||||
for (ptr_key = gui_keys[i]; ptr_key; ptr_key = ptr_key->next_key)
|
||||
{
|
||||
log_printf ("");
|
||||
|
||||
+72
-72
@@ -68,7 +68,7 @@ gui_layout_buffer_remove (struct t_gui_layout_buffer **layout_buffers,
|
||||
free (layout_buffer->plugin_name);
|
||||
if (layout_buffer->buffer_name)
|
||||
free (layout_buffer->buffer_name);
|
||||
|
||||
|
||||
/* remove layout from list */
|
||||
if (layout_buffer->prev_layout)
|
||||
(layout_buffer->prev_layout)->next_layout = layout_buffer->next_layout;
|
||||
@@ -78,7 +78,7 @@ gui_layout_buffer_remove (struct t_gui_layout_buffer **layout_buffers,
|
||||
*layout_buffers = layout_buffer->next_layout;
|
||||
if (*last_layout_buffer == layout_buffer)
|
||||
*last_layout_buffer = layout_buffer->prev_layout;
|
||||
|
||||
|
||||
free (layout_buffer);
|
||||
}
|
||||
|
||||
@@ -106,9 +106,9 @@ gui_layout_buffer_reset (struct t_gui_layout_buffer **layout_buffers,
|
||||
struct t_gui_layout_buffer **last_layout_buffer)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
gui_layout_buffer_remove_all (layout_buffers, last_layout_buffer);
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -127,7 +127,7 @@ gui_layout_buffer_add (struct t_gui_layout_buffer **layout_buffers,
|
||||
int number)
|
||||
{
|
||||
struct t_gui_layout_buffer *new_layout_buffer;
|
||||
|
||||
|
||||
new_layout_buffer = malloc (sizeof (*new_layout_buffer));
|
||||
if (new_layout_buffer)
|
||||
{
|
||||
@@ -135,7 +135,7 @@ gui_layout_buffer_add (struct t_gui_layout_buffer **layout_buffers,
|
||||
new_layout_buffer->plugin_name = strdup (plugin_name);
|
||||
new_layout_buffer->buffer_name = strdup (buffer_name);
|
||||
new_layout_buffer->number = number;
|
||||
|
||||
|
||||
/* add layout buffer to list */
|
||||
new_layout_buffer->prev_layout = *last_layout_buffer;
|
||||
if (*layout_buffers)
|
||||
@@ -145,7 +145,7 @@ gui_layout_buffer_add (struct t_gui_layout_buffer **layout_buffers,
|
||||
*last_layout_buffer = new_layout_buffer;
|
||||
new_layout_buffer->next_layout = NULL;
|
||||
}
|
||||
|
||||
|
||||
return new_layout_buffer;
|
||||
}
|
||||
|
||||
@@ -158,12 +158,12 @@ gui_layout_buffer_save (struct t_gui_layout_buffer **layout_buffers,
|
||||
struct t_gui_layout_buffer **last_layout_buffer)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
if (!layout_buffers || !last_layout_buffer)
|
||||
return;
|
||||
|
||||
|
||||
gui_layout_buffer_remove_all (layout_buffers, last_layout_buffer);
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -186,13 +186,13 @@ gui_layout_buffer_get_number (struct t_gui_layout_buffer *layout_buffers,
|
||||
{
|
||||
struct t_gui_layout_buffer *ptr_layout_buffer;
|
||||
int old_number, merge_order;
|
||||
|
||||
|
||||
*layout_number = 0;
|
||||
*layout_number_merge_order = 0;
|
||||
|
||||
|
||||
old_number = -1;
|
||||
merge_order = 0;
|
||||
|
||||
|
||||
for (ptr_layout_buffer = layout_buffers; ptr_layout_buffer;
|
||||
ptr_layout_buffer = ptr_layout_buffer->next_layout)
|
||||
{
|
||||
@@ -203,7 +203,7 @@ gui_layout_buffer_get_number (struct t_gui_layout_buffer *layout_buffers,
|
||||
}
|
||||
else
|
||||
merge_order++;
|
||||
|
||||
|
||||
if ((string_strcasecmp (ptr_layout_buffer->plugin_name, plugin_name) == 0)
|
||||
&& (string_strcasecmp (ptr_layout_buffer->buffer_name, buffer_name) == 0))
|
||||
{
|
||||
@@ -222,10 +222,10 @@ void
|
||||
gui_layout_buffer_get_number_all (struct t_gui_layout_buffer *layout_buffers)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
if (!layout_buffers)
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
@@ -246,31 +246,31 @@ gui_layout_buffer_apply (struct t_gui_layout_buffer *layout_buffers)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer, *ptr_next_buffer;
|
||||
int number, count_merged;
|
||||
|
||||
|
||||
/* get layout number for all buffers */
|
||||
gui_layout_buffer_get_number_all (layout_buffers);
|
||||
|
||||
|
||||
/* unmerge all buffers */
|
||||
gui_buffer_unmerge_all ();
|
||||
|
||||
|
||||
/* sort buffers by layout number (without merge) */
|
||||
gui_buffer_sort_by_layout_number ();
|
||||
|
||||
|
||||
/* merge buffers */
|
||||
ptr_buffer = gui_buffers->next_buffer;
|
||||
while (ptr_buffer)
|
||||
{
|
||||
ptr_next_buffer = ptr_buffer->next_buffer;
|
||||
|
||||
|
||||
if ((ptr_buffer->layout_number >= 1)
|
||||
&& (ptr_buffer->layout_number == (ptr_buffer->prev_buffer)->layout_number))
|
||||
{
|
||||
gui_buffer_merge (ptr_buffer, ptr_buffer->prev_buffer);
|
||||
}
|
||||
|
||||
|
||||
ptr_buffer = ptr_next_buffer;
|
||||
}
|
||||
|
||||
|
||||
/* set appropriate active buffers */
|
||||
number = 1;
|
||||
while (number <= last_gui_buffer->number)
|
||||
@@ -300,13 +300,13 @@ gui_layout_window_remove (struct t_gui_layout_window *layout_window)
|
||||
gui_layout_window_remove (layout_window->child1);
|
||||
if (layout_window->child2)
|
||||
gui_layout_window_remove (layout_window->child2);
|
||||
|
||||
|
||||
/* free data */
|
||||
if (layout_window->plugin_name)
|
||||
free (layout_window->plugin_name);
|
||||
if (layout_window->buffer_name)
|
||||
free (layout_window->buffer_name);
|
||||
|
||||
|
||||
free (layout_window);
|
||||
}
|
||||
|
||||
@@ -332,9 +332,9 @@ void
|
||||
gui_layout_window_reset (struct t_gui_layout_window **layout_windows)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
gui_layout_window_remove_all (layout_windows);
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->layout_plugin_name)
|
||||
@@ -360,27 +360,27 @@ gui_layout_window_search_by_id (struct t_gui_layout_window *layout_windows,
|
||||
int id)
|
||||
{
|
||||
struct t_gui_layout_window *res;
|
||||
|
||||
|
||||
if (!layout_windows)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (layout_windows->internal_id == id)
|
||||
return layout_windows;
|
||||
|
||||
|
||||
if (layout_windows->child1)
|
||||
{
|
||||
res = gui_layout_window_search_by_id (layout_windows->child1, id);
|
||||
if (res)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
if (layout_windows->child2)
|
||||
{
|
||||
res = gui_layout_window_search_by_id (layout_windows->child2, id);
|
||||
if (res)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ gui_layout_window_add (struct t_gui_layout_window **layout_windows,
|
||||
const char *plugin_name, const char *buffer_name)
|
||||
{
|
||||
struct t_gui_layout_window *new_layout_window;
|
||||
|
||||
|
||||
new_layout_window = malloc (sizeof (*new_layout_window));
|
||||
if (new_layout_window)
|
||||
{
|
||||
@@ -409,7 +409,7 @@ gui_layout_window_add (struct t_gui_layout_window **layout_windows,
|
||||
new_layout_window->child2 = NULL;
|
||||
new_layout_window->plugin_name = (plugin_name) ? strdup (plugin_name) : NULL;
|
||||
new_layout_window->buffer_name = (buffer_name) ? strdup (buffer_name) : NULL;
|
||||
|
||||
|
||||
if (parent)
|
||||
{
|
||||
/* assign this window to child1 or child2 of parent */
|
||||
@@ -424,7 +424,7 @@ gui_layout_window_add (struct t_gui_layout_window **layout_windows,
|
||||
*layout_windows = new_layout_window;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_layout_window;
|
||||
}
|
||||
|
||||
@@ -438,12 +438,12 @@ gui_layout_window_save_tree (struct t_gui_layout_window **layout_windows,
|
||||
struct t_gui_window_tree *tree)
|
||||
{
|
||||
struct t_gui_layout_window *layout_window;
|
||||
|
||||
|
||||
if (tree->window)
|
||||
{
|
||||
if (tree->window == gui_current_window)
|
||||
gui_layout_internal_id_current_window = gui_layout_internal_id;
|
||||
|
||||
|
||||
layout_window = gui_layout_window_add (layout_windows,
|
||||
gui_layout_internal_id,
|
||||
parent_layout,
|
||||
@@ -461,13 +461,13 @@ gui_layout_window_save_tree (struct t_gui_layout_window **layout_windows,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
gui_layout_internal_id++;
|
||||
|
||||
|
||||
if (tree->child1)
|
||||
gui_layout_window_save_tree (layout_windows,
|
||||
layout_window, tree->child1);
|
||||
|
||||
|
||||
if (tree->child2)
|
||||
gui_layout_window_save_tree (layout_windows,
|
||||
layout_window, tree->child2);
|
||||
@@ -482,12 +482,12 @@ int
|
||||
gui_layout_window_save (struct t_gui_layout_window **layout_windows)
|
||||
{
|
||||
gui_layout_window_remove_all (layout_windows);
|
||||
|
||||
|
||||
gui_layout_internal_id = 1;
|
||||
gui_layout_internal_id_current_window = -1;
|
||||
|
||||
|
||||
gui_layout_window_save_tree (layout_windows, NULL, gui_windows_tree);
|
||||
|
||||
|
||||
return gui_layout_internal_id_current_window;
|
||||
}
|
||||
|
||||
@@ -500,9 +500,9 @@ gui_layout_window_check_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
const char *plugin_name;
|
||||
|
||||
|
||||
plugin_name = gui_buffer_get_plugin_name (buffer);
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->layout_plugin_name && ptr_win->layout_buffer_name)
|
||||
@@ -527,7 +527,7 @@ gui_layout_window_check_all_buffers ()
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->layout_plugin_name && ptr_win->layout_buffer_name)
|
||||
@@ -556,12 +556,12 @@ gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window,
|
||||
int internal_id_current_window)
|
||||
{
|
||||
struct t_gui_window *old_window;
|
||||
|
||||
|
||||
if (layout_window->split_pct != 0)
|
||||
{
|
||||
/* node */
|
||||
old_window = gui_current_window;
|
||||
|
||||
|
||||
if (layout_window->split_horiz)
|
||||
{
|
||||
gui_window_split_horizontal (gui_current_window,
|
||||
@@ -572,14 +572,14 @@ gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window,
|
||||
gui_window_split_vertical (gui_current_window,
|
||||
layout_window->split_pct);
|
||||
}
|
||||
|
||||
|
||||
if (layout_window->child2)
|
||||
gui_layout_window_apply_tree (layout_window->child2,
|
||||
internal_id_current_window);
|
||||
|
||||
|
||||
if (old_window != gui_current_window)
|
||||
gui_window_switch (old_window);
|
||||
|
||||
|
||||
if (layout_window->child1)
|
||||
gui_layout_window_apply_tree (layout_window->child1,
|
||||
internal_id_current_window);
|
||||
@@ -589,7 +589,7 @@ gui_layout_window_apply_tree (struct t_gui_layout_window *layout_window,
|
||||
/* leaf */
|
||||
if (layout_window->internal_id == internal_id_current_window)
|
||||
gui_layout_ptr_current_window = gui_current_window;
|
||||
|
||||
|
||||
gui_window_set_layout_plugin_name (gui_current_window,
|
||||
layout_window->plugin_name);
|
||||
gui_window_set_layout_buffer_name (gui_current_window,
|
||||
@@ -606,20 +606,20 @@ gui_layout_window_apply (struct t_gui_layout_window *layout_windows,
|
||||
int internal_id_current_window)
|
||||
{
|
||||
struct t_gui_window *old_window;
|
||||
|
||||
|
||||
if (!layout_windows)
|
||||
return;
|
||||
|
||||
|
||||
gui_window_merge_all (gui_current_window);
|
||||
|
||||
|
||||
old_window = gui_current_window;
|
||||
gui_layout_ptr_current_window = NULL;
|
||||
|
||||
|
||||
gui_layout_window_apply_tree (layout_windows,
|
||||
internal_id_current_window);
|
||||
|
||||
|
||||
gui_layout_window_check_all_buffers ();
|
||||
|
||||
|
||||
gui_window_switch ((gui_layout_ptr_current_window) ?
|
||||
gui_layout_ptr_current_window : old_window);
|
||||
}
|
||||
@@ -660,21 +660,21 @@ gui_layout_buffer_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_layout_buffer *layout_buffer)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !layout_buffer)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_string (ptr_item, "plugin_name", layout_buffer->plugin_name))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "buffer_name", layout_buffer->buffer_name))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "number", layout_buffer->number))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -688,14 +688,14 @@ gui_layout_window_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_layout_window *layout_window)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !layout_window)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_integer (ptr_item, "internal_id", layout_window->internal_id))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "parent_id",
|
||||
@@ -716,7 +716,7 @@ gui_layout_window_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "buffer_name", layout_window->buffer_name))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ gui_layout_print_log_window (struct t_gui_layout_window *layout_window,
|
||||
layout_window,
|
||||
(layout_window->plugin_name) ? "leaf" : "node",
|
||||
level);
|
||||
|
||||
|
||||
log_printf (" internal_id. . . . . . : %d", layout_window->internal_id);
|
||||
log_printf (" parent_node. . . . . . : 0x%lx", layout_window->parent_node);
|
||||
log_printf (" split_pct. . . . . . . : %d", layout_window->split_pct);
|
||||
@@ -743,10 +743,10 @@ gui_layout_print_log_window (struct t_gui_layout_window *layout_window,
|
||||
log_printf (" child2 . . . . . . . . : 0x%lx", layout_window->child2);
|
||||
log_printf (" plugin_name. . . . . . : '%s'", layout_window->plugin_name);
|
||||
log_printf (" buffer_name. . . . . . : '%s'", layout_window->buffer_name);
|
||||
|
||||
|
||||
if (layout_window->child1)
|
||||
gui_layout_print_log_window (layout_window->child1, level + 1);
|
||||
|
||||
|
||||
if (layout_window->child2)
|
||||
gui_layout_print_log_window (layout_window->child2, level + 1);
|
||||
}
|
||||
@@ -759,9 +759,9 @@ void
|
||||
gui_layout_print_log ()
|
||||
{
|
||||
struct t_gui_layout_buffer *ptr_layout_buffer;
|
||||
|
||||
|
||||
log_printf ("");
|
||||
|
||||
|
||||
for (ptr_layout_buffer = gui_layout_buffers; ptr_layout_buffer;
|
||||
ptr_layout_buffer = ptr_layout_buffer->next_layout)
|
||||
{
|
||||
@@ -773,7 +773,7 @@ gui_layout_print_log ()
|
||||
log_printf (" prev_layout. . . . . . : 0x%lx", ptr_layout_buffer->prev_layout);
|
||||
log_printf (" next_layout. . . . . . : 0x%lx", ptr_layout_buffer->next_layout);
|
||||
}
|
||||
|
||||
|
||||
if (gui_layout_windows)
|
||||
gui_layout_print_log_window (gui_layout_windows, 0);
|
||||
}
|
||||
|
||||
@@ -36,13 +36,13 @@ struct t_gui_layout_window
|
||||
int internal_id; /* used to save/read layout from */
|
||||
/* config (to find parent) */
|
||||
struct t_gui_layout_window *parent_node; /* pointer to parent node */
|
||||
|
||||
|
||||
/* node info */
|
||||
int split_pct; /* % of split size (child1) */
|
||||
int split_horiz; /* 1 if horizontal, 0 if vertical */
|
||||
struct t_gui_layout_window *child1; /* first child, NULL if a leaf */
|
||||
struct t_gui_layout_window *child2; /* second child, NULL if leaf */
|
||||
|
||||
|
||||
/* leaf info */
|
||||
char *plugin_name;
|
||||
char *buffer_name;
|
||||
|
||||
+96
-96
@@ -68,7 +68,7 @@ gui_lines_alloc ()
|
||||
new_lines->buffer_max_length = 0;
|
||||
new_lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min);
|
||||
}
|
||||
|
||||
|
||||
return new_lines;
|
||||
}
|
||||
|
||||
@@ -91,14 +91,14 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
|
||||
int with_suffix, int first_line)
|
||||
{
|
||||
int length_time, length_buffer, length_suffix;
|
||||
|
||||
|
||||
/* return immediately if alignment for end of lines is "time" */
|
||||
if (!first_line
|
||||
&& (CONFIG_INTEGER(config_look_align_end_of_lines) == CONFIG_LOOK_ALIGN_END_OF_LINES_TIME))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* length of time */
|
||||
if (buffer->time_for_each_line)
|
||||
{
|
||||
@@ -106,14 +106,14 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
|
||||
}
|
||||
else
|
||||
length_time = 0;
|
||||
|
||||
|
||||
/* return immediately if alignment for end of lines is "buffer" */
|
||||
if (!first_line
|
||||
&& (CONFIG_INTEGER(config_look_align_end_of_lines) == CONFIG_LOOK_ALIGN_END_OF_LINES_BUFFER))
|
||||
{
|
||||
return length_time;
|
||||
}
|
||||
|
||||
|
||||
/* length of buffer name (when many buffers are merged) */
|
||||
if (buffer->mixed_lines)
|
||||
{
|
||||
@@ -132,20 +132,20 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
|
||||
}
|
||||
else
|
||||
length_buffer = 0;
|
||||
|
||||
|
||||
/* return immediately if alignment for end of lines is "prefix" */
|
||||
if (!first_line
|
||||
&& (CONFIG_INTEGER(config_look_align_end_of_lines) == CONFIG_LOOK_ALIGN_END_OF_LINES_PREFIX))
|
||||
{
|
||||
return length_time + length_buffer;
|
||||
}
|
||||
|
||||
|
||||
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)
|
||||
{
|
||||
return length_time + length_buffer + line->data->prefix_length
|
||||
+ ((line->data->prefix_length > 0) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
length_suffix = 0;
|
||||
if (with_suffix)
|
||||
{
|
||||
@@ -153,7 +153,7 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
|
||||
&& CONFIG_STRING(config_look_prefix_suffix)[0])
|
||||
length_suffix = gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix)) + 1;
|
||||
}
|
||||
|
||||
|
||||
return length_time + ((buffer->lines->prefix_max_length > 0) ? 1 : 0)
|
||||
+ length_buffer
|
||||
+ (((CONFIG_INTEGER(config_look_prefix_align_max) > 0)
|
||||
@@ -173,7 +173,7 @@ gui_line_is_displayed (struct t_gui_line *line)
|
||||
/* line is hidden if filters are enabled and flag "displayed" is not set */
|
||||
if (gui_filters_enabled && !line->data->displayed)
|
||||
return 0;
|
||||
|
||||
|
||||
/* in all other cases, line is displayed */
|
||||
return 1;
|
||||
}
|
||||
@@ -186,13 +186,13 @@ struct t_gui_line *
|
||||
gui_line_get_first_displayed (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
|
||||
ptr_line = buffer->lines->first_line;
|
||||
while (ptr_line && !gui_line_is_displayed (ptr_line))
|
||||
{
|
||||
ptr_line = ptr_line->next_line;
|
||||
}
|
||||
|
||||
|
||||
return ptr_line;
|
||||
}
|
||||
|
||||
@@ -204,13 +204,13 @@ struct t_gui_line *
|
||||
gui_line_get_last_displayed (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
|
||||
ptr_line = buffer->lines->last_line;
|
||||
while (ptr_line && !gui_line_is_displayed (ptr_line))
|
||||
{
|
||||
ptr_line = ptr_line->prev_line;
|
||||
}
|
||||
|
||||
|
||||
return ptr_line;
|
||||
}
|
||||
|
||||
@@ -260,12 +260,12 @@ gui_line_search_text (struct t_gui_line *line, const char *text,
|
||||
{
|
||||
char *prefix, *message;
|
||||
int rc;
|
||||
|
||||
|
||||
if (!line || !line->data->message || !text || !text[0])
|
||||
return 0;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
if (line->data->prefix)
|
||||
{
|
||||
prefix = gui_color_decode (line->data->prefix, NULL);
|
||||
@@ -277,7 +277,7 @@ gui_line_search_text (struct t_gui_line *line, const char *text,
|
||||
free (prefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!rc)
|
||||
{
|
||||
message = gui_color_decode (line->data->message, NULL);
|
||||
@@ -289,7 +289,7 @@ gui_line_search_text (struct t_gui_line *line, const char *text,
|
||||
free (message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -304,13 +304,13 @@ gui_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix,
|
||||
{
|
||||
char *prefix, *message;
|
||||
int match_prefix, match_message;
|
||||
|
||||
|
||||
if (!line || (!regex_prefix && !regex_message))
|
||||
return 0;
|
||||
|
||||
|
||||
prefix = NULL;
|
||||
message = NULL;
|
||||
|
||||
|
||||
match_prefix = 1;
|
||||
match_message = 1;
|
||||
|
||||
@@ -339,12 +339,12 @@ gui_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix,
|
||||
if (regex_message)
|
||||
match_message = 0;
|
||||
}
|
||||
|
||||
|
||||
if (prefix)
|
||||
free (prefix);
|
||||
if (message)
|
||||
free (message);
|
||||
|
||||
|
||||
return (match_prefix && match_message);
|
||||
}
|
||||
|
||||
@@ -358,13 +358,13 @@ gui_line_match_tags (struct t_gui_line *line, int tags_count,
|
||||
char **tags_array)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
||||
if (!line)
|
||||
return 0;
|
||||
|
||||
|
||||
if (line->data->tags_count == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
for (i = 0; i < tags_count; i++)
|
||||
{
|
||||
for (j = 0; j < line->data->tags_count; j++)
|
||||
@@ -376,7 +376,7 @@ gui_line_match_tags (struct t_gui_line *line, int tags_count,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ const char *
|
||||
gui_line_get_nick_tag (struct t_gui_line *line)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < line->data->tags_count; i++)
|
||||
{
|
||||
if (strncmp (line->data->tags_array[i], "nick_", 5) == 0)
|
||||
@@ -408,7 +408,7 @@ gui_line_has_highlight (struct t_gui_line *line)
|
||||
{
|
||||
int rc, i, j, no_highlight;
|
||||
char *msg_no_color, *highlight_words;
|
||||
|
||||
|
||||
/*
|
||||
* highlights are disabled on this buffer? (special value "-" means that
|
||||
* buffer does not want any highlight)
|
||||
@@ -416,7 +416,7 @@ gui_line_has_highlight (struct t_gui_line *line)
|
||||
if (line->data->buffer->highlight_words
|
||||
&& (strcmp (line->data->buffer->highlight_words, "-") == 0))
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* check if highlight is forced by a tag (with option highlight_tags) or
|
||||
* disabled for line
|
||||
@@ -438,7 +438,7 @@ gui_line_has_highlight (struct t_gui_line *line)
|
||||
}
|
||||
if (no_highlight)
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* check that line matches highlight tags, if any (if no tag is specified,
|
||||
* then any tag is allowed)
|
||||
@@ -450,12 +450,12 @@ gui_line_has_highlight (struct t_gui_line *line)
|
||||
line->data->buffer->highlight_tags_array))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* remove color codes from line message */
|
||||
msg_no_color = gui_color_decode (line->data->message, NULL);
|
||||
if (!msg_no_color)
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* there is highlight on line if one of buffer highlight words matches line
|
||||
* or one of global highlight words matches line
|
||||
@@ -467,7 +467,7 @@ gui_line_has_highlight (struct t_gui_line *line)
|
||||
highlight_words : line->data->buffer->highlight_words);
|
||||
if (highlight_words)
|
||||
free (highlight_words);
|
||||
|
||||
|
||||
if (!rc)
|
||||
{
|
||||
highlight_words = gui_buffer_string_replace_local_var (line->data->buffer,
|
||||
@@ -478,21 +478,21 @@ gui_line_has_highlight (struct t_gui_line *line)
|
||||
if (highlight_words)
|
||||
free (highlight_words);
|
||||
}
|
||||
|
||||
|
||||
if (!rc && config_highlight_regex)
|
||||
{
|
||||
rc = string_has_highlight_regex_compiled (msg_no_color,
|
||||
config_highlight_regex);
|
||||
}
|
||||
|
||||
|
||||
if (!rc && line->data->buffer->highlight_regex_compiled)
|
||||
{
|
||||
rc = string_has_highlight_regex_compiled (msg_no_color,
|
||||
line->data->buffer->highlight_regex_compiled);
|
||||
}
|
||||
|
||||
|
||||
free (msg_no_color);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ gui_line_compute_buffer_max_length (struct t_gui_buffer *buffer,
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
int length;
|
||||
const char *short_name;
|
||||
|
||||
|
||||
lines->buffer_max_length = 0;
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
@@ -532,7 +532,7 @@ void
|
||||
gui_line_compute_prefix_max_length (struct t_gui_lines *lines)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
|
||||
lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min);
|
||||
for (ptr_line = lines->first_line; ptr_line;
|
||||
ptr_line = ptr_line->next_line)
|
||||
@@ -557,10 +557,10 @@ gui_line_add_to_list (struct t_gui_lines *lines,
|
||||
line->prev_line = lines->last_line;
|
||||
line->next_line = NULL;
|
||||
lines->last_line = line;
|
||||
|
||||
|
||||
if (line->data->prefix_length > lines->prefix_max_length)
|
||||
lines->prefix_max_length = line->data->prefix_length;
|
||||
|
||||
|
||||
lines->lines_count++;
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_window_scroll *ptr_scroll;
|
||||
int i, update_prefix_max_length;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
/* reset scroll for any window scroll starting with this line */
|
||||
@@ -601,10 +601,10 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
update_prefix_max_length =
|
||||
(line->data->prefix_length == lines->prefix_max_length);
|
||||
|
||||
|
||||
/* move read marker if it was on line we are removing */
|
||||
if (lines->last_read_line == line)
|
||||
{
|
||||
@@ -612,7 +612,7 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
|
||||
lines->first_line_not_read = (lines->last_read_line) ? 0 : 1;
|
||||
gui_buffer_ask_chat_refresh (buffer, 1);
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
if (free_data)
|
||||
{
|
||||
@@ -626,7 +626,7 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
|
||||
free (line->data->message);
|
||||
free (line->data);
|
||||
}
|
||||
|
||||
|
||||
/* remove line from list */
|
||||
if (line->prev_line)
|
||||
(line->prev_line)->next_line = line->next_line;
|
||||
@@ -636,11 +636,11 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
|
||||
lines->first_line = line->next_line;
|
||||
if (lines->last_line == line)
|
||||
lines->last_line = line->prev_line;
|
||||
|
||||
|
||||
lines->lines_count--;
|
||||
|
||||
|
||||
free (line);
|
||||
|
||||
|
||||
/* compute "prefix_max_length" if needed */
|
||||
if (update_prefix_max_length)
|
||||
gui_line_compute_prefix_max_length (lines);
|
||||
@@ -655,7 +655,7 @@ gui_line_mixed_add (struct t_gui_lines *lines,
|
||||
struct t_gui_line_data *line_data)
|
||||
{
|
||||
struct t_gui_line *new_line;
|
||||
|
||||
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
if (new_line)
|
||||
{
|
||||
@@ -672,14 +672,14 @@ void
|
||||
gui_line_mixed_free_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_line *ptr_line, *ptr_next_line;
|
||||
|
||||
|
||||
if (buffer->mixed_lines)
|
||||
{
|
||||
ptr_line = buffer->mixed_lines->first_line;
|
||||
while (ptr_line)
|
||||
{
|
||||
ptr_next_line = ptr_line->next_line;
|
||||
|
||||
|
||||
if (ptr_line->data->buffer == buffer)
|
||||
{
|
||||
gui_line_remove_from_list (buffer,
|
||||
@@ -687,7 +687,7 @@ gui_line_mixed_free_buffer (struct t_gui_buffer *buffer)
|
||||
ptr_line,
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
ptr_line = ptr_next_line;
|
||||
}
|
||||
}
|
||||
@@ -720,7 +720,7 @@ void
|
||||
gui_line_free (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
|
||||
/* first remove mixed line if it exists */
|
||||
if (buffer->mixed_lines)
|
||||
{
|
||||
@@ -737,7 +737,7 @@ gui_line_free (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* remove line from lines list */
|
||||
gui_line_remove_from_list (buffer, buffer->own_lines, line, 1);
|
||||
}
|
||||
@@ -765,7 +765,7 @@ int
|
||||
gui_line_get_notify_level (struct t_gui_line *line)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < line->data->tags_count; i++)
|
||||
{
|
||||
if (string_strcasecmp (line->data->tags_array[i], "notify_none") == 0)
|
||||
@@ -795,14 +795,14 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
char *message_for_signal, buffer_full_name[512];
|
||||
const char *nick;
|
||||
int notify_level, *max_notify_level;
|
||||
|
||||
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
if (!new_line)
|
||||
{
|
||||
log_printf (_("Not enough memory for new line"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_line_data = malloc (sizeof (*(new_line->data)));
|
||||
if (!new_line_data)
|
||||
{
|
||||
@@ -811,7 +811,7 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
return NULL;
|
||||
}
|
||||
new_line->data = new_line_data;
|
||||
|
||||
|
||||
/* fill data in new line */
|
||||
new_line->data->buffer = buffer;
|
||||
new_line->data->y = -1;
|
||||
@@ -835,7 +835,7 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
new_line->data->prefix_length = (prefix) ?
|
||||
gui_chat_strlen_screen (prefix) : 0;
|
||||
new_line->data->message = (message) ? strdup (message) : strdup ("");
|
||||
|
||||
|
||||
/* get notify level and max notify level for nick in buffer */
|
||||
notify_level = gui_line_get_notify_level (new_line);
|
||||
nick = gui_line_get_nick_tag (new_line);
|
||||
@@ -845,17 +845,17 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
if (max_notify_level
|
||||
&& (*max_notify_level < notify_level))
|
||||
notify_level = *max_notify_level;
|
||||
|
||||
|
||||
if (notify_level == GUI_HOTLIST_HIGHLIGHT)
|
||||
new_line->data->highlight = 1;
|
||||
else if (max_notify_level && (*max_notify_level < GUI_HOTLIST_HIGHLIGHT))
|
||||
new_line->data->highlight = 0;
|
||||
else
|
||||
new_line->data->highlight = gui_line_has_highlight (new_line);
|
||||
|
||||
|
||||
/* add line to lines list */
|
||||
gui_line_add_to_list (buffer->own_lines, new_line);
|
||||
|
||||
|
||||
/* check if line is filtered or not */
|
||||
snprintf (buffer_full_name, sizeof (buffer_full_name), "%s.%s",
|
||||
gui_buffer_get_plugin_name (buffer),
|
||||
@@ -907,13 +907,13 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* add mixed line, if buffer is attched to at least one other buffer */
|
||||
if (buffer->mixed_lines)
|
||||
{
|
||||
gui_line_mixed_add (buffer->mixed_lines, new_line->data);
|
||||
}
|
||||
|
||||
|
||||
/* remove one line if necessary */
|
||||
if ((CONFIG_INTEGER(config_history_max_lines) > 0)
|
||||
&& (buffer->own_lines->lines_count > CONFIG_INTEGER(config_history_max_lines)))
|
||||
@@ -929,7 +929,7 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_line;
|
||||
}
|
||||
|
||||
@@ -943,7 +943,7 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
|
||||
struct t_gui_line *ptr_line, *new_line;
|
||||
struct t_gui_line_data *new_line_data;
|
||||
char buffer_full_name[512];
|
||||
|
||||
|
||||
/* search if line exists for "y" */
|
||||
for (ptr_line = buffer->own_lines->first_line; ptr_line;
|
||||
ptr_line = ptr_line->next_line)
|
||||
@@ -951,7 +951,7 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
|
||||
if (ptr_line->data->y >= y)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!ptr_line || (ptr_line->data->y > y))
|
||||
{
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
@@ -960,7 +960,7 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
|
||||
log_printf (_("Not enough memory for new line"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
new_line_data = malloc (sizeof (*(new_line->data)));
|
||||
if (!new_line_data)
|
||||
{
|
||||
@@ -969,9 +969,9 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
|
||||
return;
|
||||
}
|
||||
new_line->data = new_line_data;
|
||||
|
||||
|
||||
buffer->own_lines->lines_count++;
|
||||
|
||||
|
||||
/* fill data in new line */
|
||||
new_line->data->buffer = buffer;
|
||||
new_line->data->y = y;
|
||||
@@ -985,7 +985,7 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
|
||||
new_line->data->prefix_length = 0;
|
||||
new_line->data->message = NULL;
|
||||
new_line->data->highlight = 0;
|
||||
|
||||
|
||||
/* add line to lines list */
|
||||
if (ptr_line)
|
||||
{
|
||||
@@ -1012,12 +1012,12 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
|
||||
|
||||
ptr_line = new_line;
|
||||
}
|
||||
|
||||
|
||||
/* set message for line */
|
||||
if (ptr_line->data->message)
|
||||
free (ptr_line->data->message);
|
||||
ptr_line->data->message = (message) ? strdup (message) : strdup ("");
|
||||
|
||||
|
||||
/* check if line is filtered or not */
|
||||
snprintf (buffer_full_name, sizeof (buffer_full_name), "%s.%s",
|
||||
gui_buffer_get_plugin_name (buffer),
|
||||
@@ -1033,7 +1033,7 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_line->data->refresh_needed = 1;
|
||||
}
|
||||
|
||||
@@ -1048,7 +1048,7 @@ gui_line_clear (struct t_gui_line *line)
|
||||
if (line->data->prefix)
|
||||
free (line->data->prefix);
|
||||
line->data->prefix = strdup ("");
|
||||
|
||||
|
||||
if (line->data->message)
|
||||
free (line->data->message);
|
||||
line->data->message = strdup ("");
|
||||
@@ -1065,7 +1065,7 @@ gui_line_mix_buffers (struct t_gui_buffer *buffer)
|
||||
struct t_gui_buffer *ptr_buffer, *ptr_buffer_found;
|
||||
struct t_gui_lines *new_lines;
|
||||
struct t_gui_line *ptr_line1, *ptr_line2;
|
||||
|
||||
|
||||
/* search first other buffer with same number */
|
||||
ptr_buffer_found = NULL;
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
@@ -1079,7 +1079,7 @@ gui_line_mix_buffers (struct t_gui_buffer *buffer)
|
||||
}
|
||||
if (!ptr_buffer_found)
|
||||
return;
|
||||
|
||||
|
||||
/* mix all lines (sorting by date) to a new structure "new_lines" */
|
||||
new_lines = gui_lines_alloc ();
|
||||
if (!new_lines)
|
||||
@@ -1124,20 +1124,20 @@ gui_line_mix_buffers (struct t_gui_buffer *buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* compute "prefix_max_length" for mixed lines */
|
||||
gui_line_compute_prefix_max_length (new_lines);
|
||||
|
||||
|
||||
/* compute "buffer_max_length" for mixed lines */
|
||||
gui_line_compute_buffer_max_length (buffer, new_lines);
|
||||
|
||||
|
||||
/* free old mixed lines */
|
||||
if (ptr_buffer_found->mixed_lines)
|
||||
{
|
||||
gui_line_mixed_free_all (ptr_buffer_found);
|
||||
free (ptr_buffer_found->mixed_lines);
|
||||
}
|
||||
|
||||
|
||||
/* use new structure with mixed lines in all buffers with correct number */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
@@ -1158,10 +1158,10 @@ struct t_hdata *
|
||||
gui_line_hdata_lines_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, NULL, NULL);
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1185,10 +1185,10 @@ struct t_hdata *
|
||||
gui_line_hdata_line_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_line", "next_line");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1207,10 +1207,10 @@ struct t_hdata *
|
||||
gui_line_hdata_line_data_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, NULL, NULL);
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1244,14 +1244,14 @@ gui_line_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_infolist_item *ptr_item;
|
||||
int i, length;
|
||||
char option_name[64], *tags;
|
||||
|
||||
|
||||
if (!infolist || !line)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_integer (ptr_item, "y", line->data->y))
|
||||
return 0;
|
||||
if (!infolist_new_var_time (ptr_item, "date", line->data->date))
|
||||
@@ -1260,7 +1260,7 @@ gui_line_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "str_time", line->data->str_time))
|
||||
return 0;
|
||||
|
||||
|
||||
/* write tags */
|
||||
if (!infolist_new_var_integer (ptr_item, "tags_count", line->data->tags_count))
|
||||
return 0;
|
||||
@@ -1289,7 +1289,7 @@ gui_line_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
}
|
||||
free (tags);
|
||||
|
||||
|
||||
if (!infolist_new_var_integer (ptr_item, "displayed", line->data->displayed))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "highlight", line->data->highlight))
|
||||
@@ -1301,7 +1301,7 @@ gui_line_add_to_infolist (struct t_infolist *infolist,
|
||||
if (!infolist_new_var_integer (ptr_item, "last_read_line",
|
||||
(lines->last_read_line == line) ? 1 : 0))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+109
-109
@@ -59,7 +59,7 @@ gui_nicklist_send_signal (const char *signal, struct t_gui_buffer *buffer,
|
||||
{
|
||||
char *str_args;
|
||||
int length;
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
length = 128 + ((arguments) ? strlen (arguments) : 0) + 1 + 1;
|
||||
@@ -90,13 +90,13 @@ gui_nicklist_find_pos_group (struct t_gui_nick_group *groups,
|
||||
struct t_gui_nick_group *group)
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
for (ptr_group = groups; ptr_group; ptr_group = ptr_group->next_group)
|
||||
{
|
||||
if (string_strcasecmp (group->name, ptr_group->name) < 0)
|
||||
return ptr_group;
|
||||
}
|
||||
|
||||
|
||||
/* group will be inserted at end of list */
|
||||
return NULL;
|
||||
}
|
||||
@@ -111,11 +111,11 @@ gui_nicklist_insert_group_sorted (struct t_gui_nick_group **groups,
|
||||
struct t_gui_nick_group *group)
|
||||
{
|
||||
struct t_gui_nick_group *pos_group;
|
||||
|
||||
|
||||
if (*groups)
|
||||
{
|
||||
pos_group = gui_nicklist_find_pos_group (*groups, group);
|
||||
|
||||
|
||||
if (pos_group)
|
||||
{
|
||||
/* insert group into the list (before group found) */
|
||||
@@ -157,16 +157,16 @@ gui_nicklist_search_group_internal (struct t_gui_buffer *buffer,
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
const char *ptr_name;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!from_group)
|
||||
from_group = buffer->nicklist_root;
|
||||
|
||||
|
||||
if (!from_group)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (from_group->children)
|
||||
{
|
||||
ptr_group = gui_nicklist_search_group_internal (buffer,
|
||||
@@ -176,7 +176,7 @@ gui_nicklist_search_group_internal (struct t_gui_buffer *buffer,
|
||||
if (ptr_group)
|
||||
return ptr_group;
|
||||
}
|
||||
|
||||
|
||||
ptr_group = from_group;
|
||||
while (ptr_group)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ gui_nicklist_search_group_internal (struct t_gui_buffer *buffer,
|
||||
return ptr_group;
|
||||
ptr_group = ptr_group->next_group;
|
||||
}
|
||||
|
||||
|
||||
/* group not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -201,9 +201,9 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer,
|
||||
const char *name)
|
||||
{
|
||||
const char *ptr_name;
|
||||
|
||||
|
||||
ptr_name = gui_nicklist_get_group_start (name);
|
||||
|
||||
|
||||
return gui_nicklist_search_group_internal (buffer, from_group, name,
|
||||
(ptr_name == name) ? 1 : 0);
|
||||
}
|
||||
@@ -218,14 +218,14 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer,
|
||||
const char *color, int visible)
|
||||
{
|
||||
struct t_gui_nick_group *new_group;
|
||||
|
||||
|
||||
if (!buffer || !name || gui_nicklist_search_group (buffer, parent_group, name))
|
||||
return NULL;
|
||||
|
||||
|
||||
new_group = malloc (sizeof (*new_group));
|
||||
if (!new_group)
|
||||
return NULL;
|
||||
|
||||
|
||||
new_group->name = strdup (name);
|
||||
new_group->color = (color) ? strdup (color) : NULL;
|
||||
new_group->visible = visible;
|
||||
@@ -237,7 +237,7 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer,
|
||||
new_group->last_nick = NULL;
|
||||
new_group->prev_group = NULL;
|
||||
new_group->next_group = NULL;
|
||||
|
||||
|
||||
if (new_group->parent)
|
||||
{
|
||||
gui_nicklist_insert_group_sorted (&(new_group->parent->children),
|
||||
@@ -248,12 +248,12 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer,
|
||||
{
|
||||
buffer->nicklist_root = new_group;
|
||||
}
|
||||
|
||||
|
||||
if (buffer->nicklist_display_groups && visible)
|
||||
buffer->nicklist_visible_count++;
|
||||
|
||||
|
||||
gui_nicklist_send_signal ("nicklist_group_added", buffer, name);
|
||||
|
||||
|
||||
return new_group;
|
||||
}
|
||||
|
||||
@@ -266,16 +266,16 @@ gui_nicklist_find_pos_nick (struct t_gui_nick_group *group,
|
||||
struct t_gui_nick *nick)
|
||||
{
|
||||
struct t_gui_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!group)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_nick = group->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (string_strcasecmp (nick->name, ptr_nick->name) < 0)
|
||||
return ptr_nick;
|
||||
}
|
||||
|
||||
|
||||
/* nick will be inserted at end of list */
|
||||
return NULL;
|
||||
}
|
||||
@@ -289,11 +289,11 @@ gui_nicklist_insert_nick_sorted (struct t_gui_nick_group *group,
|
||||
struct t_gui_nick *nick)
|
||||
{
|
||||
struct t_gui_nick *pos_nick;
|
||||
|
||||
|
||||
if (group->nicks)
|
||||
{
|
||||
pos_nick = gui_nicklist_find_pos_nick (group, nick);
|
||||
|
||||
|
||||
if (pos_nick)
|
||||
{
|
||||
/* insert nick into the list (before nick found) */
|
||||
@@ -334,13 +334,13 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
|
||||
{
|
||||
struct t_gui_nick *ptr_nick;
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
if (!buffer && !from_group)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!from_group && !buffer->nicklist_root)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_nick = (from_group) ? from_group->nicks : buffer->nicklist_root->nicks;
|
||||
ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
@@ -356,7 +356,7 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
|
||||
if (ptr_nick)
|
||||
return ptr_nick;
|
||||
}
|
||||
|
||||
|
||||
/* nick not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -373,28 +373,28 @@ gui_nicklist_add_nick (struct t_gui_buffer *buffer,
|
||||
int visible)
|
||||
{
|
||||
struct t_gui_nick *new_nick;
|
||||
|
||||
|
||||
if (!buffer || !name || gui_nicklist_search_nick (buffer, NULL, name))
|
||||
return NULL;
|
||||
|
||||
|
||||
new_nick = malloc (sizeof (*new_nick));
|
||||
if (!new_nick)
|
||||
return NULL;
|
||||
|
||||
|
||||
new_nick->group = (group) ? group : buffer->nicklist_root;
|
||||
new_nick->name = strdup (name);
|
||||
new_nick->color = (color) ? strdup (color) : NULL;
|
||||
new_nick->prefix = (prefix) ? strdup (prefix) : NULL;
|
||||
new_nick->prefix_color = (prefix_color) ? strdup (prefix_color) : NULL;
|
||||
new_nick->visible = visible;
|
||||
|
||||
|
||||
gui_nicklist_insert_nick_sorted (new_nick->group, new_nick);
|
||||
|
||||
|
||||
if (visible)
|
||||
buffer->nicklist_visible_count++;
|
||||
|
||||
|
||||
gui_nicklist_send_signal ("nicklist_nick_added", buffer, name);
|
||||
|
||||
|
||||
return new_nick;
|
||||
}
|
||||
|
||||
@@ -407,12 +407,12 @@ gui_nicklist_remove_nick (struct t_gui_buffer *buffer,
|
||||
struct t_gui_nick *nick)
|
||||
{
|
||||
char *nick_removed;
|
||||
|
||||
|
||||
if (!buffer || !nick)
|
||||
return;
|
||||
|
||||
|
||||
nick_removed = (nick->name) ? strdup (nick->name) : NULL;
|
||||
|
||||
|
||||
/* remove nick from list */
|
||||
if (nick->prev_nick)
|
||||
(nick->prev_nick)->next_nick = nick->next_nick;
|
||||
@@ -422,7 +422,7 @@ gui_nicklist_remove_nick (struct t_gui_buffer *buffer,
|
||||
(nick->group)->nicks = nick->next_nick;
|
||||
if ((nick->group)->last_nick == nick)
|
||||
(nick->group)->last_nick = nick->prev_nick;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (nick->name)
|
||||
free (nick->name);
|
||||
@@ -432,17 +432,17 @@ gui_nicklist_remove_nick (struct t_gui_buffer *buffer,
|
||||
free (nick->prefix);
|
||||
if (nick->prefix_color)
|
||||
free (nick->prefix_color);
|
||||
|
||||
|
||||
if (nick->visible)
|
||||
{
|
||||
if (buffer->nicklist_visible_count > 0)
|
||||
buffer->nicklist_visible_count--;
|
||||
}
|
||||
|
||||
|
||||
free (nick);
|
||||
|
||||
|
||||
gui_nicklist_send_signal ("nicklist_nick_removed", buffer, nick_removed);
|
||||
|
||||
|
||||
if (nick_removed)
|
||||
free (nick_removed);
|
||||
}
|
||||
@@ -456,24 +456,24 @@ gui_nicklist_remove_group (struct t_gui_buffer *buffer,
|
||||
struct t_gui_nick_group *group)
|
||||
{
|
||||
char *group_removed;
|
||||
|
||||
|
||||
if (!buffer || !group)
|
||||
return;
|
||||
|
||||
|
||||
group_removed = (group->name) ? strdup (group->name) : NULL;
|
||||
|
||||
|
||||
/* remove children first */
|
||||
while (group->children)
|
||||
{
|
||||
gui_nicklist_remove_group (buffer, group->children);
|
||||
}
|
||||
|
||||
|
||||
/* remove nicks from group */
|
||||
while (group->nicks)
|
||||
{
|
||||
gui_nicklist_remove_nick (buffer, group->nicks);
|
||||
}
|
||||
|
||||
|
||||
if (group->parent)
|
||||
{
|
||||
/* remove group from list */
|
||||
@@ -490,24 +490,24 @@ gui_nicklist_remove_group (struct t_gui_buffer *buffer,
|
||||
{
|
||||
buffer->nicklist_root = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
if (group->name)
|
||||
free (group->name);
|
||||
if (group->color)
|
||||
free (group->color);
|
||||
|
||||
|
||||
if (group->visible)
|
||||
{
|
||||
if (buffer->nicklist_display_groups
|
||||
&& (buffer->nicklist_visible_count > 0))
|
||||
buffer->nicklist_visible_count--;
|
||||
}
|
||||
|
||||
|
||||
free (group);
|
||||
|
||||
|
||||
gui_nicklist_send_signal ("nicklist_group_removed", buffer, group_removed);
|
||||
|
||||
|
||||
if (group_removed)
|
||||
free (group_removed);
|
||||
}
|
||||
@@ -539,24 +539,24 @@ gui_nicklist_get_next_item (struct t_gui_buffer *buffer,
|
||||
struct t_gui_nick **nick)
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
|
||||
/* root group */
|
||||
if (!*group && !*nick)
|
||||
{
|
||||
*group = buffer->nicklist_root;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* next nick */
|
||||
if (*nick && (*nick)->next_nick)
|
||||
{
|
||||
*nick = (*nick)->next_nick;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (*group && !*nick)
|
||||
{
|
||||
/* first child */
|
||||
@@ -577,17 +577,17 @@ gui_nicklist_get_next_item (struct t_gui_buffer *buffer,
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*nick = NULL;
|
||||
ptr_group = (*group) ? *group : buffer->nicklist_root;
|
||||
|
||||
|
||||
/* next group */
|
||||
if (ptr_group->next_group)
|
||||
{
|
||||
*group = ptr_group->next_group;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* find next group by parents */
|
||||
while ((ptr_group = ptr_group->parent))
|
||||
{
|
||||
@@ -597,7 +597,7 @@ gui_nicklist_get_next_item (struct t_gui_buffer *buffer,
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* nothing found */
|
||||
*group = NULL;
|
||||
}
|
||||
@@ -613,7 +613,7 @@ const char *
|
||||
gui_nicklist_get_group_start (const char *name)
|
||||
{
|
||||
const char *ptr_name;
|
||||
|
||||
|
||||
ptr_name = name;
|
||||
while (isdigit ((unsigned char)ptr_name[0]))
|
||||
{
|
||||
@@ -638,10 +638,10 @@ gui_nicklist_get_max_length (struct t_gui_buffer *buffer,
|
||||
int length, max_length;
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
struct t_gui_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
|
||||
max_length = 0;
|
||||
for (ptr_group = (group) ? group : buffer->nicklist_root;
|
||||
ptr_group; ptr_group = ptr_group->next_group)
|
||||
@@ -687,21 +687,21 @@ gui_nicklist_compute_visible_count (struct t_gui_buffer *buffer,
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
struct t_gui_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!buffer || !group)
|
||||
return;
|
||||
|
||||
|
||||
/* count for children */
|
||||
for (ptr_group = group->children; ptr_group;
|
||||
ptr_group = ptr_group->next_group)
|
||||
{
|
||||
gui_nicklist_compute_visible_count (buffer, ptr_group);
|
||||
}
|
||||
|
||||
|
||||
/* count current group */
|
||||
if (buffer->nicklist_display_groups && group->visible)
|
||||
buffer->nicklist_visible_count++;
|
||||
|
||||
|
||||
/* count nicks in group */
|
||||
for (ptr_nick = group->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
@@ -720,7 +720,7 @@ gui_nicklist_group_get_integer (struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (group && property)
|
||||
{
|
||||
if (string_strcasecmp (property, "visible") == 0)
|
||||
@@ -728,7 +728,7 @@ gui_nicklist_group_get_integer (struct t_gui_buffer *buffer,
|
||||
else if (string_strcasecmp (property, "level") == 0)
|
||||
return group->level;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ gui_nicklist_group_get_string (struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (group && property)
|
||||
{
|
||||
if (string_strcasecmp (property, "name") == 0)
|
||||
@@ -751,7 +751,7 @@ gui_nicklist_group_get_string (struct t_gui_buffer *buffer,
|
||||
else if (string_strcasecmp (property, "color") == 0)
|
||||
return group->color;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -766,13 +766,13 @@ gui_nicklist_group_get_pointer (struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (group && property)
|
||||
{
|
||||
if (string_strcasecmp (property, "parent") == 0)
|
||||
return group->parent;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -788,12 +788,12 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer,
|
||||
long number;
|
||||
char *error;
|
||||
int group_changed;
|
||||
|
||||
|
||||
if (!buffer || !group || !property || !value)
|
||||
return;
|
||||
|
||||
|
||||
group_changed = 0;
|
||||
|
||||
|
||||
if (string_strcasecmp (property, "color") == 0)
|
||||
{
|
||||
if (group->color)
|
||||
@@ -809,7 +809,7 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer,
|
||||
group->visible = (number) ? 1 : 0;
|
||||
group_changed = 1;
|
||||
}
|
||||
|
||||
|
||||
if (group_changed)
|
||||
{
|
||||
gui_nicklist_send_signal ("nicklist_group_changed", buffer,
|
||||
@@ -828,13 +828,13 @@ gui_nicklist_nick_get_integer (struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (nick && property)
|
||||
{
|
||||
if (string_strcasecmp (property, "visible") == 0)
|
||||
return nick->visible;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -849,7 +849,7 @@ gui_nicklist_nick_get_string (struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (nick && property)
|
||||
{
|
||||
if (string_strcasecmp (property, "name") == 0)
|
||||
@@ -861,7 +861,7 @@ gui_nicklist_nick_get_string (struct t_gui_buffer *buffer,
|
||||
else if (string_strcasecmp (property, "prefix_color") == 0)
|
||||
return nick->prefix_color;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -876,13 +876,13 @@ gui_nicklist_nick_get_pointer (struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (nick && property)
|
||||
{
|
||||
if (string_strcasecmp (property, "group") == 0)
|
||||
return nick->group;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -898,12 +898,12 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
|
||||
long number;
|
||||
char *error;
|
||||
int nick_changed;
|
||||
|
||||
|
||||
if (!buffer || !nick || !property || !value)
|
||||
return;
|
||||
|
||||
|
||||
nick_changed = 0;
|
||||
|
||||
|
||||
if (string_strcasecmp (property, "color") == 0)
|
||||
{
|
||||
if (nick->color)
|
||||
@@ -933,7 +933,7 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
|
||||
nick->visible = (number) ? 1 : 0;
|
||||
nick_changed = 1;
|
||||
}
|
||||
|
||||
|
||||
if (nick_changed)
|
||||
{
|
||||
gui_nicklist_send_signal ("nicklist_nick_changed", buffer,
|
||||
@@ -949,10 +949,10 @@ struct t_hdata *
|
||||
gui_nicklist_hdata_nick_group_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_group", "next_group");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -979,10 +979,10 @@ struct t_hdata *
|
||||
gui_nicklist_hdata_nick_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_nick", "next_nick");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1008,14 +1008,14 @@ gui_nicklist_add_group_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_nick_group *group)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !group)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_string (ptr_item, "type", "group"))
|
||||
return 0;
|
||||
if (group->parent)
|
||||
@@ -1031,7 +1031,7 @@ gui_nicklist_add_group_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "level", group->level))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1045,14 +1045,14 @@ gui_nicklist_add_nick_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_nick *nick)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !nick)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_string (ptr_item, "type", "nick"))
|
||||
return 0;
|
||||
if (nick->group)
|
||||
@@ -1070,7 +1070,7 @@ gui_nicklist_add_nick_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "visible", nick->visible))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1086,10 +1086,10 @@ gui_nicklist_add_to_infolist (struct t_infolist *infolist,
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
struct t_gui_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!infolist || !buffer)
|
||||
return 0;
|
||||
|
||||
|
||||
/* add only one nick if asked */
|
||||
if (name && (strncmp (name, "nick_", 5) == 0))
|
||||
{
|
||||
@@ -1098,7 +1098,7 @@ gui_nicklist_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
return gui_nicklist_add_nick_to_infolist (infolist, ptr_nick);
|
||||
}
|
||||
|
||||
|
||||
/* add only one group if asked */
|
||||
if (name && (strncmp (name, "group_", 6) == 0))
|
||||
{
|
||||
@@ -1107,7 +1107,7 @@ gui_nicklist_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
return gui_nicklist_add_group_to_infolist (infolist, ptr_group);
|
||||
}
|
||||
|
||||
|
||||
ptr_group = NULL;
|
||||
ptr_nick = NULL;
|
||||
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
|
||||
@@ -1117,10 +1117,10 @@ gui_nicklist_add_to_infolist (struct t_infolist *infolist,
|
||||
gui_nicklist_add_nick_to_infolist (infolist, ptr_nick);
|
||||
else
|
||||
gui_nicklist_add_group_to_infolist (infolist, ptr_group);
|
||||
|
||||
|
||||
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1134,7 +1134,7 @@ gui_nicklist_print_log (struct t_gui_nick_group *group, int indent)
|
||||
char format[128];
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
struct t_gui_nick *ptr_nick;
|
||||
|
||||
|
||||
snprintf (format, sizeof (format),
|
||||
"%%-%ds=> group (addr:0x%%lx)",
|
||||
(indent * 2) + 4);
|
||||
@@ -1179,7 +1179,7 @@ gui_nicklist_print_log (struct t_gui_nick_group *group, int indent)
|
||||
"%%-%dsnext_group. : 0x%%lx",
|
||||
(indent * 2) + 6);
|
||||
log_printf (format, " ", group->next_group);
|
||||
|
||||
|
||||
/* display child groups first */
|
||||
if (group->children)
|
||||
{
|
||||
|
||||
+108
-108
@@ -84,13 +84,13 @@ struct t_gui_window *
|
||||
gui_window_search_by_number (int number)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->number == number)
|
||||
return ptr_win;
|
||||
}
|
||||
|
||||
|
||||
/* window not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ struct t_gui_window *
|
||||
gui_window_search_by_xy (int x, int y)
|
||||
{
|
||||
struct t_gui_window *ptr_window;
|
||||
|
||||
|
||||
for (ptr_window = gui_windows; ptr_window;
|
||||
ptr_window = ptr_window->next_window)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ gui_window_search_by_xy (int x, int y)
|
||||
return ptr_window;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* no window at this location */
|
||||
return NULL;
|
||||
}
|
||||
@@ -143,18 +143,18 @@ gui_window_get_context_at_xy (struct t_gui_window *window,
|
||||
int win_x, win_y;
|
||||
char *ptr_data, *data_next_line, *str_temp;
|
||||
char *word_start, *word_end, *last_space;
|
||||
|
||||
|
||||
*chat = 0;
|
||||
*line = NULL;
|
||||
*line_x = -1;
|
||||
*word = NULL;
|
||||
*beginning = NULL;
|
||||
*end = NULL;
|
||||
|
||||
|
||||
/* not in a window? */
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
|
||||
/* in window, but not in chat area? */
|
||||
win_x = x - window->win_chat_x;
|
||||
win_y = y - window->win_chat_y;
|
||||
@@ -165,25 +165,25 @@ gui_window_get_context_at_xy (struct t_gui_window *window,
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* add horizontal scroll (buffers with free content) */
|
||||
if (window->scroll->start_col > 0)
|
||||
win_x += window->scroll->start_col;
|
||||
|
||||
|
||||
*line_x = win_x;
|
||||
|
||||
|
||||
/* we are in chat area */
|
||||
*chat = 1;
|
||||
|
||||
|
||||
/* get line */
|
||||
*line = window->coords[win_y].line;
|
||||
if (!*line)
|
||||
return;
|
||||
|
||||
|
||||
/* no data for line? */
|
||||
if (!window->coords[win_y].data)
|
||||
return;
|
||||
|
||||
|
||||
if (win_x < window->coords_x_message)
|
||||
{
|
||||
/* X is before message (time/buffer/prefix) */
|
||||
@@ -348,17 +348,17 @@ gui_window_scroll_search (struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window_scroll *ptr_scroll;
|
||||
|
||||
|
||||
if (!window || !buffer)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_scroll = window->scroll; ptr_scroll;
|
||||
ptr_scroll = ptr_scroll->next_scroll)
|
||||
{
|
||||
if (ptr_scroll->buffer == buffer)
|
||||
return ptr_scroll;
|
||||
}
|
||||
|
||||
|
||||
/* scroll not found for buffer */
|
||||
return NULL;
|
||||
}
|
||||
@@ -397,7 +397,7 @@ gui_window_scroll_free (struct t_gui_window *window,
|
||||
(scroll->next_scroll)->prev_scroll = scroll->prev_scroll;
|
||||
if (window->scroll == scroll)
|
||||
window->scroll = scroll->next_scroll;
|
||||
|
||||
|
||||
free (scroll);
|
||||
}
|
||||
|
||||
@@ -426,14 +426,14 @@ void
|
||||
gui_window_scroll_remove_not_scrolled (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window_scroll *ptr_scroll, *next_scroll;
|
||||
|
||||
|
||||
if (window)
|
||||
{
|
||||
ptr_scroll = window->scroll->next_scroll;
|
||||
while (ptr_scroll)
|
||||
{
|
||||
next_scroll = ptr_scroll->next_scroll;
|
||||
|
||||
|
||||
if ((ptr_scroll->first_line_displayed == 0)
|
||||
&& (ptr_scroll->start_line == NULL)
|
||||
&& (ptr_scroll->start_line_pos == 0)
|
||||
@@ -444,7 +444,7 @@ gui_window_scroll_remove_not_scrolled (struct t_gui_window *window)
|
||||
{
|
||||
gui_window_scroll_free (window, ptr_scroll);
|
||||
}
|
||||
|
||||
|
||||
ptr_scroll = next_scroll;
|
||||
}
|
||||
}
|
||||
@@ -459,15 +459,15 @@ gui_window_scroll_switch (struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window_scroll *ptr_scroll, *new_scroll;
|
||||
|
||||
|
||||
if (window && buffer)
|
||||
{
|
||||
ptr_scroll = gui_window_scroll_search (window, buffer);
|
||||
|
||||
|
||||
/* scroll is already selected (first in list)? */
|
||||
if (ptr_scroll && (ptr_scroll == window->scroll))
|
||||
return;
|
||||
|
||||
|
||||
if (ptr_scroll)
|
||||
{
|
||||
/* scroll found, move it in first position */
|
||||
@@ -492,7 +492,7 @@ gui_window_scroll_switch (struct t_gui_window *window,
|
||||
window->scroll = new_scroll;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gui_window_scroll_remove_not_scrolled (window);
|
||||
}
|
||||
}
|
||||
@@ -506,7 +506,7 @@ gui_window_scroll_remove_buffer (struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window_scroll *ptr_scroll;
|
||||
|
||||
|
||||
if (window && buffer)
|
||||
{
|
||||
ptr_scroll = gui_window_scroll_search (window, buffer);
|
||||
@@ -527,7 +527,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
struct t_gui_window *new_window;
|
||||
struct t_gui_window_tree *ptr_tree, *child1, *child2, *ptr_leaf;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
|
||||
if (parent_window)
|
||||
{
|
||||
child1 = malloc (sizeof (*child1));
|
||||
@@ -540,7 +540,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
return NULL;
|
||||
}
|
||||
ptr_tree = parent_window->ptr_tree;
|
||||
|
||||
|
||||
if (width_pct == 100)
|
||||
{
|
||||
ptr_tree->split_horizontal = 1;
|
||||
@@ -551,27 +551,27 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
ptr_tree->split_horizontal = 0;
|
||||
ptr_tree->split_pct = width_pct;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* parent window leaf becomes node and we add 2 leafs below
|
||||
* (#1 is parent win, #2 is new win)
|
||||
*/
|
||||
|
||||
|
||||
parent_window->ptr_tree = child1;
|
||||
child1->parent_node = ptr_tree;
|
||||
child1->child1 = NULL;
|
||||
child1->child2 = NULL;
|
||||
child1->window = ptr_tree->window;
|
||||
|
||||
|
||||
child2->parent_node = ptr_tree;
|
||||
child2->child1 = NULL;
|
||||
child2->child2 = NULL;
|
||||
child2->window = NULL; /* will be assigned by new window below */
|
||||
|
||||
|
||||
ptr_tree->child1 = child1;
|
||||
ptr_tree->child2 = child2;
|
||||
ptr_tree->window = NULL; /* leaf becomes node */
|
||||
|
||||
|
||||
ptr_leaf = child2;
|
||||
}
|
||||
else
|
||||
@@ -580,7 +580,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
return NULL;
|
||||
ptr_leaf = gui_windows_tree;
|
||||
}
|
||||
|
||||
|
||||
if ((new_window = (malloc (sizeof (*new_window)))))
|
||||
{
|
||||
/* create scroll structure */
|
||||
@@ -590,7 +590,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
free (new_window);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* create window objects */
|
||||
if (!gui_window_objects_init (new_window))
|
||||
{
|
||||
@@ -598,10 +598,10 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
free (new_window);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* number */
|
||||
new_window->number = (last_gui_window) ? last_gui_window->number + 1 : 1;
|
||||
|
||||
|
||||
/* position & size */
|
||||
new_window->win_x = x;
|
||||
new_window->win_y = y;
|
||||
@@ -609,7 +609,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
new_window->win_height = height;
|
||||
new_window->win_width_pct = width_pct;
|
||||
new_window->win_height_pct = height_pct;
|
||||
|
||||
|
||||
/* chat window */
|
||||
new_window->win_chat_x = 0;
|
||||
new_window->win_chat_y = 0;
|
||||
@@ -621,27 +621,27 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
/* bar windows */
|
||||
new_window->bar_windows = NULL;
|
||||
new_window->last_bar_window = NULL;
|
||||
|
||||
|
||||
/* refresh */
|
||||
new_window->refresh_needed = 0;
|
||||
|
||||
|
||||
/* buffer and layout infos */
|
||||
new_window->buffer = buffer;
|
||||
new_window->layout_plugin_name = NULL;
|
||||
new_window->layout_buffer_name = NULL;
|
||||
|
||||
|
||||
/* scroll */
|
||||
gui_window_scroll_init (new_window->scroll, buffer);
|
||||
|
||||
|
||||
/* coordinates */
|
||||
new_window->coords_size = 0;
|
||||
new_window->coords = NULL;
|
||||
new_window->coords_x_message = 0;
|
||||
|
||||
|
||||
/* tree */
|
||||
new_window->ptr_tree = ptr_leaf;
|
||||
ptr_leaf->window = new_window;
|
||||
|
||||
|
||||
/* add window to windows queue */
|
||||
new_window->prev_window = last_gui_window;
|
||||
if (gui_windows)
|
||||
@@ -650,7 +650,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
gui_windows = new_window;
|
||||
last_gui_window = new_window;
|
||||
new_window->next_window = NULL;
|
||||
|
||||
|
||||
/* create bar windows */
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
@@ -660,7 +660,7 @@ gui_window_new (struct t_gui_window *parent_window, struct t_gui_buffer *buffer,
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
|
||||
return new_window;
|
||||
}
|
||||
|
||||
@@ -674,17 +674,17 @@ int
|
||||
gui_window_valid (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_window;
|
||||
|
||||
|
||||
if (!window)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_window = gui_windows; ptr_window;
|
||||
ptr_window = ptr_window->next_window)
|
||||
{
|
||||
if (ptr_window == window)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* window not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -703,20 +703,20 @@ struct t_gui_window *
|
||||
gui_window_search_with_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_gui_window *ptr_window;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (gui_current_window->buffer == buffer)
|
||||
return gui_current_window;
|
||||
|
||||
|
||||
for (ptr_window = gui_windows; ptr_window;
|
||||
ptr_window = ptr_window->next_window)
|
||||
{
|
||||
if (ptr_window->buffer == buffer)
|
||||
return ptr_window;
|
||||
}
|
||||
|
||||
|
||||
/* no window displaying buffer */
|
||||
return NULL;
|
||||
}
|
||||
@@ -759,7 +759,7 @@ gui_window_get_integer (struct t_gui_window *window, const char *property)
|
||||
if (string_strcasecmp (property, "lines_after") == 0)
|
||||
return window->scroll->lines_after;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ gui_window_get_string (struct t_gui_window *window, const char *property)
|
||||
if (window && property)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -788,14 +788,14 @@ gui_window_get_pointer (struct t_gui_window *window, const char *property)
|
||||
{
|
||||
if (string_strcasecmp (property, "current") == 0)
|
||||
return gui_current_window;
|
||||
|
||||
|
||||
if (window)
|
||||
{
|
||||
if (string_strcasecmp (property, "buffer") == 0)
|
||||
return window->buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -812,7 +812,7 @@ gui_window_set_layout_plugin_name (struct t_gui_window *window,
|
||||
free (window->layout_plugin_name);
|
||||
window->layout_plugin_name = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (plugin_name)
|
||||
window->layout_plugin_name = strdup (plugin_name);
|
||||
}
|
||||
@@ -830,7 +830,7 @@ gui_window_set_layout_buffer_name (struct t_gui_window *window,
|
||||
free (window->layout_buffer_name);
|
||||
window->layout_buffer_name = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (buffer_name)
|
||||
window->layout_buffer_name = strdup (buffer_name);
|
||||
}
|
||||
@@ -844,7 +844,7 @@ gui_window_coords_init_line (struct t_gui_window *window, int line)
|
||||
{
|
||||
if (!window->coords || (line < 0) || (line >= window->coords_size))
|
||||
return;
|
||||
|
||||
|
||||
window->coords[line].line = NULL;
|
||||
window->coords[line].data = NULL;
|
||||
window->coords[line].time_x1 = -1;
|
||||
@@ -863,7 +863,7 @@ void
|
||||
gui_window_coords_alloc (struct t_gui_window *window)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (window->coords && (window->coords_size != window->win_chat_height))
|
||||
{
|
||||
free (window->coords);
|
||||
@@ -891,38 +891,38 @@ gui_window_free (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
int i;
|
||||
|
||||
|
||||
hook_signal_send ("window_closing", WEECHAT_HOOK_SIGNAL_POINTER, window);
|
||||
|
||||
|
||||
if (window->buffer)
|
||||
gui_buffer_add_value_num_displayed (window->buffer, -1);
|
||||
|
||||
|
||||
/* free data */
|
||||
if (window->gui_objects)
|
||||
{
|
||||
gui_window_objects_free (window, 1);
|
||||
free (window->gui_objects);
|
||||
}
|
||||
|
||||
|
||||
/* remove bar windows */
|
||||
while (window->bar_windows)
|
||||
{
|
||||
gui_bar_window_free (window->bar_windows, window);
|
||||
}
|
||||
|
||||
|
||||
/* free other data */
|
||||
if (window->layout_plugin_name)
|
||||
free (window->layout_plugin_name);
|
||||
if (window->layout_buffer_name)
|
||||
free (window->layout_buffer_name);
|
||||
|
||||
|
||||
/* remove scroll list */
|
||||
gui_window_scroll_free_all (window);
|
||||
|
||||
|
||||
/* free coords */
|
||||
if (window->coords)
|
||||
free (window->coords);
|
||||
|
||||
|
||||
/* remove window from windows list */
|
||||
if (window->prev_window)
|
||||
(window->prev_window)->next_window = window->next_window;
|
||||
@@ -935,16 +935,16 @@ gui_window_free (struct t_gui_window *window)
|
||||
|
||||
if (gui_current_window == window)
|
||||
gui_current_window = gui_windows;
|
||||
|
||||
|
||||
i = 1;
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
ptr_win->number = i;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
hook_signal_send ("window_closed", WEECHAT_HOOK_SIGNAL_POINTER, window);
|
||||
|
||||
|
||||
free (window);
|
||||
}
|
||||
|
||||
@@ -957,7 +957,7 @@ gui_window_switch_previous (struct t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
gui_window_switch ((window->prev_window) ?
|
||||
window->prev_window : last_gui_window);
|
||||
}
|
||||
@@ -971,7 +971,7 @@ gui_window_switch_next (struct t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
gui_window_switch ((window->next_window) ?
|
||||
window->next_window : gui_windows);
|
||||
}
|
||||
@@ -984,10 +984,10 @@ void
|
||||
gui_window_switch_by_number (int number)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
ptr_win = gui_window_search_by_number (number);
|
||||
if (ptr_win)
|
||||
gui_window_switch (ptr_win);
|
||||
@@ -1001,10 +1001,10 @@ void
|
||||
gui_window_switch_by_buffer (struct t_gui_window *window, int buffer_number)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
ptr_win = (window->next_window) ? window->next_window : gui_windows;
|
||||
while (ptr_win != window)
|
||||
{
|
||||
@@ -1031,13 +1031,13 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
|
||||
long number;
|
||||
struct t_gui_line *ptr_line;
|
||||
struct tm *date_tmp, line_date, old_line_date;
|
||||
|
||||
|
||||
if (window->buffer->lines->first_line)
|
||||
{
|
||||
direction = 1;
|
||||
number = 0;
|
||||
time_letter = ' ';
|
||||
|
||||
|
||||
/* search direction */
|
||||
if (scroll[0] == '-')
|
||||
{
|
||||
@@ -1049,7 +1049,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
|
||||
direction = +1;
|
||||
scroll++;
|
||||
}
|
||||
|
||||
|
||||
/* search number and letter */
|
||||
pos = scroll;
|
||||
while (pos && pos[0] && isdigit ((unsigned char)pos[0]))
|
||||
@@ -1076,11 +1076,11 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
|
||||
pos[0] = saved_char;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* at least number or letter has to he given */
|
||||
if ((number == 0) && (time_letter == ' '))
|
||||
return;
|
||||
|
||||
|
||||
/* do the scroll! */
|
||||
stop = 0;
|
||||
count_msg = 0;
|
||||
@@ -1115,12 +1115,12 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
|
||||
date_tmp = localtime (&old_date);
|
||||
memcpy (&old_line_date, date_tmp, sizeof (struct tm));
|
||||
}
|
||||
|
||||
|
||||
while (ptr_line)
|
||||
{
|
||||
ptr_line = (direction < 0) ?
|
||||
gui_line_get_prev_displayed (ptr_line) : gui_line_get_next_displayed (ptr_line);
|
||||
|
||||
|
||||
if (ptr_line
|
||||
&& ((window->buffer->type != GUI_BUFFER_TYPE_FORMATTED)
|
||||
|| (ptr_line->data->date != 0)))
|
||||
@@ -1258,13 +1258,13 @@ gui_window_scroll_horiz (struct t_gui_window *window, char *scroll)
|
||||
int direction, percentage, start_col;
|
||||
char saved_char, *pos, *error;
|
||||
long number;
|
||||
|
||||
|
||||
if (window->buffer->lines->first_line)
|
||||
{
|
||||
direction = 1;
|
||||
number = 0;
|
||||
percentage = 0;
|
||||
|
||||
|
||||
/* search direction */
|
||||
if (scroll[0] == '-')
|
||||
{
|
||||
@@ -1276,7 +1276,7 @@ gui_window_scroll_horiz (struct t_gui_window *window, char *scroll)
|
||||
direction = +1;
|
||||
scroll++;
|
||||
}
|
||||
|
||||
|
||||
/* search number and percentage */
|
||||
pos = scroll;
|
||||
while (pos && pos[0] && isdigit ((unsigned char)pos[0]))
|
||||
@@ -1294,17 +1294,17 @@ gui_window_scroll_horiz (struct t_gui_window *window, char *scroll)
|
||||
number = 0;
|
||||
pos[0] = saved_char;
|
||||
}
|
||||
|
||||
|
||||
/* for percentage, compute number of columns */
|
||||
if (percentage)
|
||||
{
|
||||
number = (window->win_chat_width * number) / 100;
|
||||
}
|
||||
|
||||
|
||||
/* number must be different from 0 */
|
||||
if (number == 0)
|
||||
return;
|
||||
|
||||
|
||||
/* do the horizontal scroll! */
|
||||
start_col = window->scroll->start_col + (number * direction);
|
||||
if (start_col < 0)
|
||||
@@ -1325,7 +1325,7 @@ void
|
||||
gui_window_scroll_previous_highlight (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
|
||||
if ((window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
|
||||
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
|
||||
{
|
||||
@@ -1358,7 +1358,7 @@ void
|
||||
gui_window_scroll_next_highlight (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
|
||||
if ((window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
|
||||
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
|
||||
{
|
||||
@@ -1392,7 +1392,7 @@ int
|
||||
gui_window_search_text (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
|
||||
if (window->buffer->text_search == GUI_TEXT_SEARCH_BACKWARD)
|
||||
{
|
||||
if (window->buffer->lines->first_line
|
||||
@@ -1526,7 +1526,7 @@ gui_window_zoom (struct t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
|
||||
if (gui_window_layout_before_zoom)
|
||||
{
|
||||
/* restore layout as it was before zooming a window */
|
||||
@@ -1560,10 +1560,10 @@ struct t_hdata *
|
||||
gui_window_hdata_window_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_window", "next_window");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1606,10 +1606,10 @@ struct t_hdata *
|
||||
gui_window_hdata_window_scroll_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_scroll", "next_scroll");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1635,10 +1635,10 @@ struct t_hdata *
|
||||
gui_window_hdata_window_tree_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, NULL, NULL);
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1663,14 +1663,14 @@ gui_window_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_window *window)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !window)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!infolist_new_var_pointer (ptr_item, "pointer", window))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "current_window",
|
||||
@@ -1705,7 +1705,7 @@ gui_window_add_to_infolist (struct t_infolist *infolist,
|
||||
&& (window->scroll->start_line)) ?
|
||||
window->scroll->start_line->data->y : 0))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1719,14 +1719,14 @@ gui_window_print_log ()
|
||||
struct t_gui_window *ptr_window;
|
||||
struct t_gui_window_scroll *ptr_scroll;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
|
||||
|
||||
log_printf ("");
|
||||
log_printf ("gui_windows . . . . . . . . . : 0x%lx", gui_windows);
|
||||
log_printf ("last_gui_window . . . . . . . : 0x%lx", last_gui_window);
|
||||
log_printf ("gui_current window. . . . . . : 0x%lx", gui_current_window);
|
||||
log_printf ("gui_windows_tree. . . . . . . : 0x%lx", gui_windows_tree);
|
||||
log_printf ("gui_window_layout_before_zoom : 0x%lx", gui_window_layout_before_zoom);
|
||||
|
||||
|
||||
for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window)
|
||||
{
|
||||
log_printf ("");
|
||||
@@ -1757,7 +1757,7 @@ gui_window_print_log ()
|
||||
log_printf (" ptr_tree. . . . . . : 0x%lx", ptr_window->ptr_tree);
|
||||
log_printf (" prev_window . . . . : 0x%lx", ptr_window->prev_window);
|
||||
log_printf (" next_window . . . . : 0x%lx", ptr_window->next_window);
|
||||
|
||||
|
||||
for (ptr_scroll = ptr_window->scroll; ptr_scroll;
|
||||
ptr_scroll = ptr_scroll->next_scroll)
|
||||
{
|
||||
@@ -1774,7 +1774,7 @@ gui_window_print_log ()
|
||||
log_printf (" prev_scroll . . . . : 0x%lx", ptr_scroll->prev_scroll);
|
||||
log_printf (" next_scroll . . . . : 0x%lx", ptr_scroll->next_scroll);
|
||||
}
|
||||
|
||||
|
||||
for (ptr_bar_win = ptr_window->bar_windows; ptr_bar_win;
|
||||
ptr_bar_win = ptr_bar_win->next_bar_window)
|
||||
{
|
||||
|
||||
+12
-12
@@ -51,49 +51,49 @@ struct t_gui_window_coords
|
||||
struct t_gui_window
|
||||
{
|
||||
int number; /* window number (first is 1) */
|
||||
|
||||
|
||||
/* global position & size */
|
||||
int win_x, win_y; /* position of window */
|
||||
int win_width, win_height; /* window geometry */
|
||||
int win_width_pct; /* % of width (compared to win size) */
|
||||
int win_height_pct; /* % of height (compared to win size)*/
|
||||
|
||||
|
||||
/* chat window settings */
|
||||
int win_chat_x, win_chat_y; /* chat window position */
|
||||
int win_chat_width; /* width of chat window */
|
||||
int win_chat_height; /* height of chat window */
|
||||
int win_chat_cursor_x; /* position of cursor in chat window */
|
||||
int win_chat_cursor_y; /* position of cursor in chat window */
|
||||
|
||||
|
||||
/* bar windows */
|
||||
struct t_gui_bar_window *bar_windows; /* bar windows */
|
||||
struct t_gui_bar_window *last_bar_window; /* last bar window */
|
||||
|
||||
|
||||
/* refresh */
|
||||
int refresh_needed; /* 1 if refresh needed for window */
|
||||
|
||||
|
||||
/* GUI specific objects */
|
||||
void *gui_objects; /* pointer to a GUI specific struct */
|
||||
|
||||
|
||||
/* buffer and layout infos */
|
||||
struct t_gui_buffer *buffer; /* buffer currently displayed */
|
||||
char *layout_plugin_name; /* plugin and buffer that should be */
|
||||
char *layout_buffer_name; /* displayed in this window (even if */
|
||||
/* buffer does not exist yet, it will*/
|
||||
/* be assigned later) */
|
||||
|
||||
|
||||
/* scroll */
|
||||
struct t_gui_window_scroll *scroll; /* scroll infos for each buffer */
|
||||
/* scrolled in this window */
|
||||
|
||||
|
||||
/* coordinates (for focus) */
|
||||
int coords_size; /* size of coords (number of lines) */
|
||||
struct t_gui_window_coords *coords;/* coords for window */
|
||||
int coords_x_message; /* start X for messages */
|
||||
|
||||
|
||||
/* tree */
|
||||
struct t_gui_window_tree *ptr_tree;/* pointer to leaf in windows tree */
|
||||
|
||||
|
||||
struct t_gui_window *prev_window; /* link to previous window */
|
||||
struct t_gui_window *next_window; /* link to next window */
|
||||
};
|
||||
@@ -118,13 +118,13 @@ struct t_gui_window_scroll
|
||||
struct t_gui_window_tree
|
||||
{
|
||||
struct t_gui_window_tree *parent_node; /* pointer to parent node */
|
||||
|
||||
|
||||
/* node info */
|
||||
int split_pct; /* % of split size (child1) */
|
||||
int split_horizontal; /* 1 if horizontal, 0 if vertical */
|
||||
struct t_gui_window_tree *child1; /* first child, NULL if a leaf */
|
||||
struct t_gui_window_tree *child2; /* second child, NULL if a leaf */
|
||||
|
||||
|
||||
/* leaf info */
|
||||
struct t_gui_window *window; /* pointer to window, NULL if a node */
|
||||
};
|
||||
|
||||
@@ -77,14 +77,14 @@ void
|
||||
alias_config_cmd_change_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_config_option *ptr_option_completion;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_option_completion = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_completion,
|
||||
weechat_config_option_get_pointer (option, "name"));
|
||||
|
||||
|
||||
alias_new (weechat_config_option_get_pointer (option, "name"),
|
||||
weechat_config_option_get_pointer (option, "value"),
|
||||
(ptr_option_completion) ?
|
||||
@@ -101,18 +101,18 @@ alias_config_cmd_delete_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_config_option *ptr_option_completion;
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_option_completion = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_completion,
|
||||
weechat_config_option_get_pointer (option, "name"));
|
||||
|
||||
|
||||
ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
|
||||
if (ptr_alias)
|
||||
alias_free (ptr_alias);
|
||||
|
||||
|
||||
if (ptr_option_completion)
|
||||
weechat_config_option_free (ptr_option_completion);
|
||||
}
|
||||
@@ -126,10 +126,10 @@ void
|
||||
alias_config_completion_change_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
|
||||
if (ptr_alias && ptr_alias->hook)
|
||||
{
|
||||
@@ -147,10 +147,10 @@ void
|
||||
alias_config_completion_delete_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
ptr_alias = alias_search (weechat_config_option_get_pointer (option, "name"));
|
||||
if (ptr_alias && ptr_alias->hook && ptr_alias->completion)
|
||||
{
|
||||
@@ -167,11 +167,11 @@ alias_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_config_section_free_options (alias_config_section_cmd);
|
||||
weechat_config_section_free_options (alias_config_section_completion);
|
||||
alias_free_all ();
|
||||
|
||||
|
||||
return weechat_config_reload (config_file);
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@ alias_config_cmd_write_default_cb (void *data,
|
||||
const char *section_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
@@ -200,7 +200,7 @@ alias_config_cmd_write_default_cb (void *data,
|
||||
"\"%s\"", alias_default_list[i][1]))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -232,15 +232,15 @@ alias_config_cmd_create_option_cb (void *data,
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
/* create config option */
|
||||
alias_config_cmd_new_option (option_name, value);
|
||||
|
||||
|
||||
/* create alias */
|
||||
ptr_alias = alias_search (option_name);
|
||||
if (ptr_alias)
|
||||
@@ -250,7 +250,7 @@ alias_config_cmd_create_option_cb (void *data,
|
||||
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
else
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -258,7 +258,7 @@ alias_config_cmd_create_option_cb (void *data,
|
||||
weechat_prefix ("error"), ALIAS_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -291,12 +291,12 @@ alias_config_completion_create_option_cb (void *data,
|
||||
const char *value)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
ptr_alias = alias_search (option_name);
|
||||
if (!ptr_alias)
|
||||
{
|
||||
@@ -307,13 +307,13 @@ alias_config_completion_create_option_cb (void *data,
|
||||
option_name);
|
||||
return WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* create config option */
|
||||
alias_config_completion_new_option (option_name, value);
|
||||
|
||||
|
||||
/* create/update completion in alias */
|
||||
alias_update_completion (ptr_alias, value);
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
|
||||
@@ -326,12 +326,12 @@ int
|
||||
alias_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
alias_config_file = weechat_config_new (ALIAS_CONFIG_NAME,
|
||||
&alias_config_reload, NULL);
|
||||
if (!alias_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* cmd */
|
||||
ptr_section = weechat_config_new_section (alias_config_file, "cmd",
|
||||
1, 1,
|
||||
@@ -346,7 +346,7 @@ alias_config_init ()
|
||||
return 0;
|
||||
}
|
||||
alias_config_section_cmd = ptr_section;
|
||||
|
||||
|
||||
/* completion */
|
||||
ptr_section = weechat_config_new_section (alias_config_file, "completion",
|
||||
1, 1,
|
||||
@@ -361,7 +361,7 @@ alias_config_init ()
|
||||
return 0;
|
||||
}
|
||||
alias_config_section_completion = ptr_section;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ alias_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, ALIAS_PLUGIN_NAME) == 0)
|
||||
{
|
||||
if (pointer && !alias_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ alias_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+79
-79
@@ -56,17 +56,17 @@ int
|
||||
alias_valid (struct t_alias *alias)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
if (!alias)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_alias = alias_list; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
if (ptr_alias == alias)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* alias not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ struct t_alias *
|
||||
alias_search (const char *alias_name)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
for (ptr_alias = alias_list; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
@@ -98,14 +98,14 @@ alias_string_add_word (char **alias, int *length, const char *word)
|
||||
{
|
||||
int length_word;
|
||||
char *alias2;
|
||||
|
||||
|
||||
if (!word)
|
||||
return;
|
||||
|
||||
|
||||
length_word = strlen (word);
|
||||
if (length_word == 0)
|
||||
return;
|
||||
|
||||
|
||||
if (*alias == NULL)
|
||||
{
|
||||
*alias = malloc (length_word + 1);
|
||||
@@ -139,7 +139,7 @@ alias_string_add_word_range (char **alias, int *length, const char *start,
|
||||
const char *end)
|
||||
{
|
||||
char *word;
|
||||
|
||||
|
||||
word = weechat_strndup (start, end - start);
|
||||
if (word)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ alias_string_add_arguments (char **alias, int *length, char **argv, int start,
|
||||
int end)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = start; i <= end; i++)
|
||||
{
|
||||
if (i != start)
|
||||
@@ -185,9 +185,9 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
char **argv, *res;
|
||||
const char *start, *pos;
|
||||
int n, m, argc, length_res, args_count, offset;
|
||||
|
||||
|
||||
argv = weechat_string_split (user_args, " ", 0, 0, &argc);
|
||||
|
||||
|
||||
res = NULL;
|
||||
length_res = 0;
|
||||
args_count = 0;
|
||||
@@ -196,7 +196,7 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
while (pos && pos[0])
|
||||
{
|
||||
offset = 0;
|
||||
|
||||
|
||||
if ((pos[0] == '\\') && (pos[1] == '$'))
|
||||
{
|
||||
offset = 2;
|
||||
@@ -278,7 +278,7 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (offset != 0)
|
||||
{
|
||||
pos += offset;
|
||||
@@ -287,13 +287,13 @@ alias_replace_args (const char *alias_args, const char *user_args)
|
||||
else
|
||||
pos++;
|
||||
}
|
||||
|
||||
|
||||
if (pos > start)
|
||||
alias_string_add_word (&res, &length_res, start);
|
||||
|
||||
|
||||
if (argv)
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -307,20 +307,20 @@ alias_run_command (struct t_gui_buffer **buffer, const char *command)
|
||||
{
|
||||
char *string;
|
||||
struct t_gui_buffer *old_current_buffer, *new_current_buffer;
|
||||
|
||||
|
||||
/* save current buffer pointer */
|
||||
old_current_buffer = weechat_current_buffer();
|
||||
|
||||
|
||||
/* execute command */
|
||||
string = weechat_buffer_string_replace_local_var (*buffer, command);
|
||||
weechat_command (*buffer,
|
||||
(string) ? string : command);
|
||||
if (string)
|
||||
free (string);
|
||||
|
||||
|
||||
/* get new current buffer */
|
||||
new_current_buffer = weechat_current_buffer();
|
||||
|
||||
|
||||
/*
|
||||
* if current buffer was changed by command, then we'll use this one for
|
||||
* next commands in alias
|
||||
@@ -341,12 +341,12 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
char **commands, **ptr_cmd, **ptr_next_cmd;
|
||||
char *args_replaced, *alias_command;
|
||||
int some_args_replaced, length1, length2;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argv;
|
||||
|
||||
|
||||
ptr_alias = (struct t_alias *)data;
|
||||
|
||||
|
||||
if (ptr_alias->running)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -368,12 +368,12 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
{
|
||||
ptr_next_cmd = ptr_cmd;
|
||||
ptr_next_cmd++;
|
||||
|
||||
|
||||
args_replaced = alias_replace_args (*ptr_cmd,
|
||||
(argc > 1) ? argv_eol[1] : "");
|
||||
if (args_replaced && (strcmp (args_replaced, *ptr_cmd) != 0))
|
||||
some_args_replaced = 1;
|
||||
|
||||
|
||||
/*
|
||||
* if alias has arguments, they are now
|
||||
* arguments of the last command in the list (if no $1,$2,..$*)
|
||||
@@ -383,7 +383,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
{
|
||||
length1 = strlen (*ptr_cmd);
|
||||
length2 = strlen (argv_eol[1]);
|
||||
|
||||
|
||||
alias_command = malloc (1 + length1 + 1 + length2 + 1);
|
||||
if (alias_command)
|
||||
{
|
||||
@@ -391,11 +391,11 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
strcpy (alias_command, "/");
|
||||
else
|
||||
alias_command[0] = '\0';
|
||||
|
||||
|
||||
strcat (alias_command, *ptr_cmd);
|
||||
strcat (alias_command, " ");
|
||||
strcat (alias_command, argv_eol[1]);
|
||||
|
||||
|
||||
alias_run_command (&buffer,
|
||||
alias_command);
|
||||
free (alias_command);
|
||||
@@ -421,7 +421,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (args_replaced)
|
||||
free (args_replaced);
|
||||
}
|
||||
@@ -440,7 +440,7 @@ void
|
||||
alias_free (struct t_alias *alias)
|
||||
{
|
||||
struct t_alias *new_alias_list;
|
||||
|
||||
|
||||
/* remove alias from list */
|
||||
if (last_alias == alias)
|
||||
last_alias = alias->prev_alias;
|
||||
@@ -464,7 +464,7 @@ alias_free (struct t_alias *alias)
|
||||
if (alias->completion)
|
||||
free (alias->completion);
|
||||
free (alias);
|
||||
|
||||
|
||||
alias_list = new_alias_list;
|
||||
}
|
||||
|
||||
@@ -489,13 +489,13 @@ struct t_alias *
|
||||
alias_find_pos (const char *name)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
for (ptr_alias = alias_list; ptr_alias; ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
if (weechat_strcasecmp (name, ptr_alias->name) < 0)
|
||||
return ptr_alias;
|
||||
}
|
||||
|
||||
|
||||
/* position not found (we will add to the end of list) */
|
||||
return NULL;
|
||||
}
|
||||
@@ -510,9 +510,9 @@ alias_hook_command (struct t_alias *alias)
|
||||
{
|
||||
char *str_completion;
|
||||
int length;
|
||||
|
||||
|
||||
str_completion = NULL;
|
||||
|
||||
|
||||
if (!alias->completion)
|
||||
{
|
||||
/*
|
||||
@@ -529,12 +529,12 @@ alias_hook_command (struct t_alias *alias)
|
||||
weechat_utf8_next_char (alias->command) : alias->command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
alias->hook = weechat_hook_command (alias->name, alias->command,
|
||||
NULL, NULL,
|
||||
(str_completion) ? str_completion : alias->completion,
|
||||
&alias_cb, alias);
|
||||
|
||||
|
||||
if (str_completion)
|
||||
free (str_completion);
|
||||
}
|
||||
@@ -550,7 +550,7 @@ alias_update_completion (struct t_alias *alias, const char *completion)
|
||||
if (alias->completion)
|
||||
free (alias->completion);
|
||||
alias->completion = (completion) ? strdup (completion) : NULL;
|
||||
|
||||
|
||||
/* unhook and hook again command, with new completion */
|
||||
weechat_unhook (alias->hook);
|
||||
alias->hook = NULL;
|
||||
@@ -565,19 +565,19 @@ struct t_alias *
|
||||
alias_new (const char *name, const char *command, const char *completion)
|
||||
{
|
||||
struct t_alias *new_alias, *ptr_alias, *pos_alias;
|
||||
|
||||
|
||||
if (!name || !name[0] || !command || !command[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
while (weechat_string_is_command_char (name))
|
||||
{
|
||||
name = weechat_utf8_next_char (name);
|
||||
}
|
||||
|
||||
|
||||
ptr_alias = alias_search (name);
|
||||
if (ptr_alias)
|
||||
alias_free (ptr_alias);
|
||||
|
||||
|
||||
new_alias = malloc (sizeof (*new_alias));
|
||||
if (new_alias)
|
||||
{
|
||||
@@ -586,9 +586,9 @@ alias_new (const char *name, const char *command, const char *completion)
|
||||
new_alias->command = strdup (command);
|
||||
new_alias->completion = (completion) ? strdup (completion) : NULL;
|
||||
new_alias->running = 0;
|
||||
|
||||
|
||||
alias_hook_command (new_alias);
|
||||
|
||||
|
||||
if (alias_list)
|
||||
{
|
||||
pos_alias = alias_find_pos (name);
|
||||
@@ -620,7 +620,7 @@ alias_new (const char *name, const char *command, const char *completion)
|
||||
last_alias = new_alias;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_alias;
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ alias_get_final_command (struct t_alias *alias)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
char *result;
|
||||
|
||||
|
||||
if (alias->running)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -643,7 +643,7 @@ alias_get_final_command (struct t_alias *alias)
|
||||
alias->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ptr_alias = alias_search ((weechat_string_is_command_char (alias->command)) ?
|
||||
weechat_utf8_next_char (alias->command) : alias->command);
|
||||
if (ptr_alias)
|
||||
@@ -669,11 +669,11 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
struct t_alias *ptr_alias;
|
||||
struct t_config_option *ptr_option;
|
||||
int alias_found;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (argc > 2)
|
||||
@@ -695,7 +695,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_utf8_next_char (argv[1]) : argv[1];
|
||||
ptr_command = argv_eol[2];
|
||||
}
|
||||
|
||||
|
||||
/* define new alias */
|
||||
if (!alias_new (ptr_alias_name, ptr_command, ptr_completion))
|
||||
{
|
||||
@@ -706,7 +706,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
ptr_alias_name, ptr_command);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
/* create config option for command */
|
||||
ptr_option = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_cmd,
|
||||
@@ -714,7 +714,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
if (ptr_option)
|
||||
weechat_config_option_free (ptr_option);
|
||||
alias_config_cmd_new_option (ptr_alias_name, ptr_command);
|
||||
|
||||
|
||||
/* create config option for completion */
|
||||
ptr_option = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_completion,
|
||||
@@ -723,7 +723,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_config_option_free (ptr_option);
|
||||
if (ptr_completion)
|
||||
alias_config_completion_new_option (ptr_alias_name, ptr_completion);
|
||||
|
||||
|
||||
/* display message */
|
||||
weechat_printf (NULL,
|
||||
_("Alias \"%s\" => \"%s\" created"),
|
||||
@@ -734,7 +734,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* get pointer to alias name */
|
||||
ptr_alias_name = (weechat_string_is_command_char (argv[1])) ?
|
||||
weechat_utf8_next_char (argv[1]) : argv[1];
|
||||
|
||||
|
||||
/* display list of aliases */
|
||||
alias_found = 0;
|
||||
for (ptr_alias = alias_list; ptr_alias;
|
||||
@@ -783,7 +783,7 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
else
|
||||
weechat_printf (NULL, _("No alias defined"));
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -799,12 +799,12 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char *alias_name;
|
||||
struct t_alias *ptr_alias;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) argv_eol;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
@@ -823,7 +823,7 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
/* remove alias */
|
||||
alias_free (ptr_alias);
|
||||
|
||||
|
||||
/* remove options */
|
||||
ptr_option = weechat_config_search_option (alias_config_file,
|
||||
alias_config_section_cmd,
|
||||
@@ -835,7 +835,7 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
alias_name);
|
||||
if (ptr_option)
|
||||
weechat_config_option_free (ptr_option);
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("Alias \"%s\" removed"),
|
||||
alias_name);
|
||||
@@ -855,19 +855,19 @@ alias_completion_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_alias = alias_list; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_alias->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -883,12 +883,12 @@ alias_value_completion_cb (void *data, const char *completion_item,
|
||||
const char *args;
|
||||
char *pos, *alias_name;
|
||||
struct t_alias *ptr_alias;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
args = weechat_hook_completion_get_string (completion, "args");
|
||||
if (args)
|
||||
{
|
||||
@@ -897,7 +897,7 @@ alias_value_completion_cb (void *data, const char *completion_item,
|
||||
alias_name = weechat_strndup (args, pos - args);
|
||||
else
|
||||
alias_name = strdup (args);
|
||||
|
||||
|
||||
if (alias_name)
|
||||
{
|
||||
ptr_alias = alias_search (alias_name);
|
||||
@@ -911,7 +911,7 @@ alias_value_completion_cb (void *data, const char *completion_item,
|
||||
free (alias_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -924,14 +924,14 @@ int
|
||||
alias_add_to_infolist (struct t_infolist *infolist, struct t_alias *alias)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !alias)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_pointer (ptr_item, "hook", alias->hook))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "name", alias->name))
|
||||
@@ -942,7 +942,7 @@ alias_add_to_infolist (struct t_infolist *infolist, struct t_alias *alias)
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "running", alias->running))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -956,9 +956,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
if (!alias_config_init ())
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -967,7 +967,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
alias_config_read ();
|
||||
|
||||
|
||||
weechat_hook_command ("alias",
|
||||
N_("create an alias for a command"),
|
||||
N_("[-completion <completion>] <alias> [<command> "
|
||||
@@ -1006,20 +1006,20 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
" /alias -completion %%sajoin forcejoin /quote forcejoin"),
|
||||
"%(alias)|-completion %(commands)|%(alias_value)",
|
||||
&alias_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_command ("unalias", N_("remove aliases"),
|
||||
N_("<alias> [<alias>...]"),
|
||||
N_("alias: name of alias to remove"),
|
||||
"%(alias)|%*",
|
||||
&unalias_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_completion ("alias", N_("list of aliases"),
|
||||
&alias_completion_cb, NULL);
|
||||
weechat_hook_completion ("alias_value", N_("value of alias"),
|
||||
&alias_value_completion_cb, NULL);
|
||||
|
||||
|
||||
alias_info_init ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1032,10 +1032,10 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
alias_config_write ();
|
||||
alias_free_all ();
|
||||
weechat_config_free (alias_config_file);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ weechat_aspell_config_change_commands (void *data,
|
||||
{
|
||||
const char *value;
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (weechat_aspell_commands_to_check)
|
||||
{
|
||||
weechat_string_free_split (weechat_aspell_commands_to_check);
|
||||
@@ -80,7 +80,7 @@ weechat_aspell_config_change_commands (void *data,
|
||||
free (weechat_aspell_length_commands_to_check);
|
||||
weechat_aspell_length_commands_to_check = NULL;
|
||||
}
|
||||
|
||||
|
||||
value = weechat_config_string (option);
|
||||
if (value && value[0])
|
||||
{
|
||||
@@ -111,7 +111,7 @@ weechat_aspell_config_change_default_dict (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ weechat_aspell_config_dict_change (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
}
|
||||
|
||||
@@ -144,11 +144,11 @@ weechat_aspell_config_dict_delete_option (void *data,
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
weechat_config_option_free (option);
|
||||
|
||||
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -165,15 +165,15 @@ weechat_aspell_config_dict_create_option (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (value && value[0])
|
||||
weechat_aspell_speller_check_dictionaries (value);
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -207,7 +207,7 @@ weechat_aspell_config_dict_create_option (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -217,7 +217,7 @@ weechat_aspell_config_dict_create_option (void *data,
|
||||
}
|
||||
else
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ weechat_aspell_config_option_change (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_aspell_speller_free_all ();
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
}
|
||||
@@ -251,12 +251,12 @@ weechat_aspell_config_option_delete_option (void *data,
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
weechat_config_option_free (option);
|
||||
|
||||
|
||||
weechat_aspell_speller_free_all ();
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
|
||||
}
|
||||
|
||||
@@ -273,12 +273,12 @@ weechat_aspell_config_option_create_option (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -313,7 +313,7 @@ weechat_aspell_config_option_create_option (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -326,7 +326,7 @@ weechat_aspell_config_option_create_option (void *data,
|
||||
weechat_aspell_speller_free_all ();
|
||||
weechat_aspell_create_spellers (weechat_current_buffer ());
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -365,12 +365,12 @@ int
|
||||
weechat_aspell_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
weechat_aspell_config_file = weechat_config_new (ASPELL_CONFIG_NAME,
|
||||
NULL, NULL);
|
||||
if (!weechat_aspell_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "look",
|
||||
0, 0,
|
||||
@@ -382,13 +382,13 @@ weechat_aspell_config_init ()
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_aspell_config_look_color = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"color", "color",
|
||||
N_("color used for misspelled words"),
|
||||
NULL, 0, 0, "lightred", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* check */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "check",
|
||||
0, 0,
|
||||
@@ -400,7 +400,7 @@ weechat_aspell_config_init ()
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_aspell_config_check_commands = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"commands", "string",
|
||||
@@ -435,7 +435,7 @@ weechat_aspell_config_init ()
|
||||
N_("minimum length for a word to be spell checked (use 0 to check all "
|
||||
"words)"),
|
||||
NULL, 0, INT_MAX, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* dict */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "dict",
|
||||
1, 1,
|
||||
@@ -449,9 +449,9 @@ weechat_aspell_config_init ()
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
weechat_aspell_config_section_dict = ptr_section;
|
||||
|
||||
|
||||
/* option */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "option",
|
||||
1, 1,
|
||||
@@ -465,7 +465,7 @@ weechat_aspell_config_init ()
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -477,14 +477,14 @@ int
|
||||
weechat_aspell_config_read ()
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
rc = weechat_config_read (weechat_aspell_config_file);
|
||||
if (rc == WEECHAT_CONFIG_READ_OK)
|
||||
{
|
||||
weechat_aspell_config_change_commands (NULL,
|
||||
weechat_aspell_config_check_commands);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ void
|
||||
weechat_aspell_config_free ()
|
||||
{
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
|
||||
|
||||
if (weechat_aspell_commands_to_check)
|
||||
weechat_string_free_split (weechat_aspell_commands_to_check);
|
||||
if (weechat_aspell_length_commands_to_check)
|
||||
|
||||
@@ -47,13 +47,13 @@ weechat_aspell_speller_exists (const char *lang)
|
||||
AspellDictInfoEnumeration *el;
|
||||
const AspellDictInfo *dict;
|
||||
int rc;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
config = new_aspell_config ();
|
||||
list = get_aspell_dict_info_list (config);
|
||||
el = aspell_dict_info_list_elements (list);
|
||||
|
||||
|
||||
while ((dict = aspell_dict_info_enumeration_next (el)))
|
||||
{
|
||||
if (strcmp (dict->name, lang) == 0)
|
||||
@@ -62,10 +62,10 @@ weechat_aspell_speller_exists (const char *lang)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delete_aspell_dict_info_enumeration (el);
|
||||
delete_aspell_config (config);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ weechat_aspell_speller_check_dictionaries (const char *dict_list)
|
||||
{
|
||||
char **argv;
|
||||
int argc, i;
|
||||
|
||||
|
||||
if (dict_list)
|
||||
{
|
||||
argv = weechat_string_split (dict_list, ",", 0, 0, &argc);
|
||||
@@ -109,14 +109,14 @@ struct t_aspell_speller *
|
||||
weechat_aspell_speller_search (const char *lang)
|
||||
{
|
||||
struct t_aspell_speller *ptr_speller;
|
||||
|
||||
|
||||
for (ptr_speller = weechat_aspell_spellers; ptr_speller;
|
||||
ptr_speller = ptr_speller->next_speller)
|
||||
{
|
||||
if (strcmp (ptr_speller->lang, lang) == 0)
|
||||
return ptr_speller;
|
||||
}
|
||||
|
||||
|
||||
/* no speller found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -132,17 +132,17 @@ weechat_aspell_speller_new (const char *lang)
|
||||
AspellConfig *config;
|
||||
AspellCanHaveError *ret;
|
||||
struct t_infolist *infolist;
|
||||
|
||||
|
||||
if (!lang)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_aspell_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: creating new speller for lang \"%s\"",
|
||||
ASPELL_PLUGIN_NAME, lang);
|
||||
}
|
||||
|
||||
|
||||
/* create a speller instance for the newly created cell */
|
||||
config = new_aspell_config();
|
||||
aspell_config_replace (config, "lang", lang);
|
||||
@@ -159,9 +159,9 @@ weechat_aspell_speller_new (const char *lang)
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
ret = new_aspell_speller (config);
|
||||
|
||||
|
||||
if (aspell_error (ret) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -172,7 +172,7 @@ weechat_aspell_speller_new (const char *lang)
|
||||
delete_aspell_can_have_error (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* create and add a new speller cell */
|
||||
new_speller = malloc (sizeof (*new_speller));
|
||||
if (!new_speller)
|
||||
@@ -182,7 +182,7 @@ weechat_aspell_speller_new (const char *lang)
|
||||
weechat_prefix ("error"), ASPELL_PLUGIN_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_speller->speller = to_aspell_speller (ret);
|
||||
new_speller->lang = strdup (lang);
|
||||
|
||||
@@ -194,10 +194,10 @@ weechat_aspell_speller_new (const char *lang)
|
||||
else
|
||||
weechat_aspell_spellers = new_speller;
|
||||
last_weechat_aspell_speller = new_speller;
|
||||
|
||||
|
||||
/* free config */
|
||||
delete_aspell_config (config);
|
||||
|
||||
|
||||
return new_speller;
|
||||
}
|
||||
|
||||
@@ -210,14 +210,14 @@ weechat_aspell_speller_free (struct t_aspell_speller *speller)
|
||||
{
|
||||
if (!speller)
|
||||
return;
|
||||
|
||||
|
||||
if (weechat_aspell_plugin->debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: removing speller for lang \"%s\"",
|
||||
ASPELL_PLUGIN_NAME, speller->lang);
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
if (speller->speller)
|
||||
{
|
||||
@@ -236,7 +236,7 @@ weechat_aspell_speller_free (struct t_aspell_speller *speller)
|
||||
weechat_aspell_spellers = speller->next_speller;
|
||||
if (last_weechat_aspell_speller == speller)
|
||||
last_weechat_aspell_speller = speller->prev_speller;
|
||||
|
||||
|
||||
free (speller);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ struct t_aspell_speller
|
||||
{
|
||||
AspellSpeller *speller; /* aspell speller */
|
||||
char *lang; /* language */
|
||||
|
||||
|
||||
struct t_aspell_speller *prev_speller; /* pointer to next speller */
|
||||
struct t_aspell_speller *next_speller; /* pointer to previous speller */
|
||||
};
|
||||
|
||||
@@ -166,20 +166,20 @@ weechat_aspell_build_option_name (struct t_gui_buffer *buffer)
|
||||
const char *plugin_name, *name;
|
||||
char *option_name;
|
||||
int length;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
|
||||
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
||||
name = weechat_buffer_get_string (buffer, "name");
|
||||
|
||||
|
||||
length = strlen (plugin_name) + 1 + strlen (name) + 1;
|
||||
option_name = malloc (length);
|
||||
if (!option_name)
|
||||
return NULL;
|
||||
|
||||
|
||||
snprintf (option_name, length, "%s.%s", plugin_name, name);
|
||||
|
||||
|
||||
return option_name;
|
||||
}
|
||||
|
||||
@@ -194,11 +194,11 @@ weechat_aspell_get_dict (struct t_gui_buffer *buffer)
|
||||
{
|
||||
char *name, *option_name, *ptr_end;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
name = weechat_aspell_build_option_name (buffer);
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
||||
option_name = strdup (name);
|
||||
if (option_name)
|
||||
{
|
||||
@@ -221,21 +221,21 @@ weechat_aspell_get_dict (struct t_gui_buffer *buffer)
|
||||
ptr_end[0] = '\0';
|
||||
}
|
||||
ptr_option = weechat_aspell_config_get_dict (option_name);
|
||||
|
||||
|
||||
free (option_name);
|
||||
free (name);
|
||||
|
||||
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
}
|
||||
else
|
||||
free (name);
|
||||
|
||||
|
||||
/* nothing found => return default dictionary (if set) */
|
||||
if (weechat_config_string (weechat_aspell_config_check_default_dict)
|
||||
&& weechat_config_string (weechat_aspell_config_check_default_dict)[0])
|
||||
return weechat_config_string (weechat_aspell_config_check_default_dict);
|
||||
|
||||
|
||||
/* no default dictionary set */
|
||||
return NULL;
|
||||
}
|
||||
@@ -248,11 +248,11 @@ void
|
||||
weechat_aspell_set_dict (struct t_gui_buffer *buffer, const char *value)
|
||||
{
|
||||
char *name;
|
||||
|
||||
|
||||
name = weechat_aspell_build_option_name (buffer);
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
|
||||
if (weechat_aspell_config_set_dict (name, value) > 0)
|
||||
{
|
||||
if (value && value[0])
|
||||
@@ -262,7 +262,7 @@ weechat_aspell_set_dict (struct t_gui_buffer *buffer, const char *value)
|
||||
weechat_printf (NULL, _("%s: \"%s\" removed"),
|
||||
ASPELL_PLUGIN_NAME, name);
|
||||
}
|
||||
|
||||
|
||||
free (name);
|
||||
}
|
||||
|
||||
@@ -278,15 +278,15 @@ weechat_aspell_spellers_already_ok (const char *dict_list)
|
||||
char **argv;
|
||||
int argc, rc, i;
|
||||
struct t_aspell_speller *ptr_speller;
|
||||
|
||||
|
||||
if (!dict_list && !weechat_aspell_spellers)
|
||||
return 1;
|
||||
|
||||
|
||||
if (!dict_list || !weechat_aspell_spellers)
|
||||
return 0;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
argv = weechat_string_split (dict_list, ",", 0, 0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
@@ -302,7 +302,7 @@ weechat_aspell_spellers_already_ok (const char *dict_list)
|
||||
}
|
||||
weechat_string_free_split (argv);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ weechat_aspell_create_spellers (struct t_gui_buffer *buffer)
|
||||
const char *dict_list;
|
||||
char **argv;
|
||||
int argc, i;
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
dict_list = weechat_aspell_get_dict (buffer);
|
||||
@@ -349,13 +349,13 @@ char *
|
||||
weechat_aspell_iso_to_lang (const char *code)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; langs_avail[i].code; i++)
|
||||
{
|
||||
if (strcmp (langs_avail[i].code, code) == 0)
|
||||
return strdup (langs_avail[i].name);
|
||||
}
|
||||
|
||||
|
||||
/* lang code not found */
|
||||
return strdup ("Unknown");
|
||||
}
|
||||
@@ -370,13 +370,13 @@ char *
|
||||
weechat_aspell_iso_to_country (const char *code)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; countries_avail[i].code; i++)
|
||||
{
|
||||
if (strcmp (countries_avail[i].code, code) == 0)
|
||||
return strdup (countries_avail[i].name);
|
||||
}
|
||||
|
||||
|
||||
/* country code not found */
|
||||
return strdup ("Unknown");
|
||||
}
|
||||
@@ -395,22 +395,22 @@ weechat_aspell_speller_list_dicts ()
|
||||
AspellDictInfoList *list;
|
||||
AspellDictInfoEnumeration *el;
|
||||
const AspellDictInfo *dict;
|
||||
|
||||
|
||||
config = new_aspell_config();
|
||||
list = get_aspell_dict_info_list (config);
|
||||
el = aspell_dict_info_list_elements (list);
|
||||
|
||||
|
||||
weechat_printf (NULL, "");
|
||||
weechat_printf (NULL,
|
||||
/* TRANSLATORS: "%s" is "aspell" */
|
||||
_( "%s dictionaries list:"),
|
||||
ASPELL_PLUGIN_NAME);
|
||||
|
||||
|
||||
while ((dict = aspell_dict_info_enumeration_next (el)))
|
||||
{
|
||||
country = NULL;
|
||||
pos = strchr (dict->code, '_');
|
||||
|
||||
|
||||
if (pos)
|
||||
{
|
||||
pos[0] = '\0';
|
||||
@@ -420,7 +420,7 @@ weechat_aspell_speller_list_dicts ()
|
||||
}
|
||||
else
|
||||
lang = weechat_aspell_iso_to_lang ((char*)dict->code);
|
||||
|
||||
|
||||
if (strlen (dict->jargon) == 0)
|
||||
{
|
||||
if (pos)
|
||||
@@ -447,15 +447,15 @@ weechat_aspell_speller_list_dicts ()
|
||||
dict->name, lang, dict->jargon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
weechat_printf (NULL, " %s", buffer);
|
||||
|
||||
|
||||
if (lang)
|
||||
free (lang);
|
||||
if (country)
|
||||
free (country);
|
||||
}
|
||||
|
||||
|
||||
delete_aspell_dict_info_enumeration (el);
|
||||
delete_aspell_config (config);
|
||||
}
|
||||
@@ -502,7 +502,7 @@ weechat_aspell_add_word (const char *lang, const char *word)
|
||||
"dictionary"),
|
||||
weechat_prefix ("error"), ASPELL_PLUGIN_NAME);
|
||||
}
|
||||
|
||||
|
||||
if (new_speller)
|
||||
weechat_aspell_speller_free (new_speller);
|
||||
}
|
||||
@@ -516,12 +516,12 @@ int
|
||||
weechat_aspell_command_authorized (const char *command)
|
||||
{
|
||||
int length_command, i;
|
||||
|
||||
|
||||
if (!command)
|
||||
return 1;
|
||||
|
||||
|
||||
length_command = strlen (command);
|
||||
|
||||
|
||||
for (i = 0; i < weechat_aspell_count_commands_to_check; i++)
|
||||
{
|
||||
if ((weechat_aspell_length_commands_to_check[i] == length_command)
|
||||
@@ -532,7 +532,7 @@ weechat_aspell_command_authorized (const char *command)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* command is not authorized */
|
||||
return 0;
|
||||
}
|
||||
@@ -565,7 +565,7 @@ weechat_aspell_string_is_url (const char *word)
|
||||
|| (weechat_strncasecmp(word, "svn+ssh://", 10) == 0)
|
||||
|| (weechat_strncasecmp(word, "git://", 6) == 0))
|
||||
return 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -578,10 +578,10 @@ int
|
||||
weechat_aspell_string_is_simili_number (const char *word)
|
||||
{
|
||||
int utf8_char_int;
|
||||
|
||||
|
||||
if (!word || !word[0])
|
||||
return 0;
|
||||
|
||||
|
||||
while (word && word[0])
|
||||
{
|
||||
utf8_char_int = weechat_utf8_char_int (word);
|
||||
@@ -589,7 +589,7 @@ weechat_aspell_string_is_simili_number (const char *word)
|
||||
return 0;
|
||||
word = weechat_utf8_next_char (word);
|
||||
}
|
||||
|
||||
|
||||
/* there's only digit or punctuation */
|
||||
return 1;
|
||||
}
|
||||
@@ -604,9 +604,9 @@ weechat_aspell_check_word (struct t_gui_buffer *buffer, const char *word)
|
||||
{
|
||||
struct t_aspell_speller *ptr_speller;
|
||||
int rc;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
|
||||
/* word too small? then do not check word */
|
||||
if ((weechat_config_integer (weechat_aspell_config_check_word_min_length) > 0)
|
||||
&& ((int)strlen (word) < weechat_config_integer (weechat_aspell_config_check_word_min_length)))
|
||||
@@ -642,7 +642,7 @@ weechat_aspell_check_word (struct t_gui_buffer *buffer, const char *word)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -661,18 +661,18 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
int buffer_has_changed, utf8_char_int, char_size;
|
||||
int length, index_result, length_word, word_ok;
|
||||
int length_color_normal, length_color_error, rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) modifier;
|
||||
|
||||
|
||||
if (!string || !string[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
rc = sscanf (modifier_data, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return NULL;
|
||||
|
||||
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
buffer_has_changed = 0;
|
||||
@@ -682,15 +682,15 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
aspell_buffer_spellers = buffer;
|
||||
buffer_has_changed = 1;
|
||||
}
|
||||
|
||||
|
||||
if (!weechat_aspell_spellers)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* check text search only if option is enabled */
|
||||
if (weechat_buffer_get_integer (buffer, "text_search")
|
||||
&& !weechat_config_boolean (weechat_aspell_config_check_during_search))
|
||||
return NULL;
|
||||
|
||||
|
||||
/*
|
||||
* for performance: return last stirng built if input string is the
|
||||
* same (for example user just change cursor position, or input text is
|
||||
@@ -703,7 +703,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
return (aspell_last_modifier_result) ?
|
||||
strdup (aspell_last_modifier_result) : NULL;
|
||||
}
|
||||
|
||||
|
||||
/* free last modifier string and result */
|
||||
if (aspell_last_modifier_string)
|
||||
{
|
||||
@@ -715,25 +715,25 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
free (aspell_last_modifier_result);
|
||||
aspell_last_modifier_result = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* save last modifier string received */
|
||||
aspell_last_modifier_string = strdup (string);
|
||||
|
||||
|
||||
color_normal = weechat_color ("bar_fg");
|
||||
length_color_normal = strlen (color_normal);
|
||||
color_error = weechat_color (weechat_config_string (weechat_aspell_config_look_color));
|
||||
length_color_error = strlen (color_error);
|
||||
|
||||
|
||||
length = strlen (string);
|
||||
result = malloc (length + (length * length_color_error) + 1);
|
||||
|
||||
|
||||
if (result)
|
||||
{
|
||||
result[0] = '\0';
|
||||
|
||||
|
||||
ptr_string = aspell_last_modifier_string;
|
||||
index_result = 0;
|
||||
|
||||
|
||||
/* check if string is a command */
|
||||
if (!weechat_string_input_for_buffer (ptr_string))
|
||||
{
|
||||
@@ -749,9 +749,9 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
free (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pos_space[0] = '\0';
|
||||
|
||||
|
||||
/* exit if command is not authorized for spell checking */
|
||||
if (!weechat_aspell_command_authorized (ptr_string))
|
||||
{
|
||||
@@ -762,11 +762,11 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
index_result += char_size;
|
||||
strcpy (result + index_result, ptr_string);
|
||||
index_result += strlen (ptr_string);
|
||||
|
||||
|
||||
pos_space[0] = ' ';
|
||||
ptr_string = pos_space;
|
||||
}
|
||||
|
||||
|
||||
while (ptr_string[0])
|
||||
{
|
||||
/* find start of word */
|
||||
@@ -785,7 +785,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
}
|
||||
if (!ptr_string[0])
|
||||
break;
|
||||
|
||||
|
||||
ptr_end = weechat_utf8_next_char (ptr_string);
|
||||
utf8_char_int = weechat_utf8_char_int (ptr_end);
|
||||
while (iswalnum (utf8_char_int) || (utf8_char_int == '\'')
|
||||
@@ -799,44 +799,44 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
save_end = ptr_end[0];
|
||||
ptr_end[0] = '\0';
|
||||
length_word = ptr_end - ptr_string;
|
||||
|
||||
|
||||
if ((save_end != '\0')
|
||||
|| (weechat_config_integer (weechat_aspell_config_check_real_time)))
|
||||
word_ok = weechat_aspell_check_word (buffer, ptr_string);
|
||||
else
|
||||
word_ok = 1;
|
||||
|
||||
|
||||
/* add error color */
|
||||
if (!word_ok)
|
||||
{
|
||||
strcpy (result + index_result, color_error);
|
||||
index_result += length_color_error;
|
||||
}
|
||||
|
||||
|
||||
/* add word */
|
||||
strcpy (result + index_result, ptr_string);
|
||||
index_result += length_word;
|
||||
|
||||
|
||||
/* add normal color (after misspelled word) */
|
||||
if (!word_ok)
|
||||
{
|
||||
strcpy (result + index_result, color_normal);
|
||||
index_result += length_color_normal;
|
||||
}
|
||||
|
||||
|
||||
if (save_end == '\0')
|
||||
break;
|
||||
|
||||
ptr_end[0] = save_end;
|
||||
ptr_string = ptr_end;
|
||||
}
|
||||
|
||||
|
||||
result[index_result] = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
|
||||
aspell_last_modifier_result = strdup (result);
|
||||
return result;
|
||||
}
|
||||
@@ -850,10 +850,10 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *dicts;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "dictlist") == 0)
|
||||
@@ -907,7 +907,7 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
@@ -921,18 +921,18 @@ weechat_aspell_completion_langs_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (i = 0; langs_avail[i].code; i++)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, langs_avail[i].code,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -946,15 +946,15 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
if (!weechat_aspell_config_init ())
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
if (weechat_aspell_config_read () < 0)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
/* command /aspell */
|
||||
weechat_hook_command ("aspell",
|
||||
N_("aspell plugin configuration"),
|
||||
@@ -978,7 +978,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
weechat_hook_completion ("aspell_langs",
|
||||
N_("list of supported langs for aspell"),
|
||||
&weechat_aspell_completion_langs_cb, NULL);
|
||||
|
||||
|
||||
/*
|
||||
* callback for spell checking input text
|
||||
* we use a low priority here, so that other modifiers "input_text_display"
|
||||
@@ -986,7 +986,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
*/
|
||||
weechat_hook_modifier ("500|input_text_display",
|
||||
&weechat_aspell_modifier_cb, NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -999,17 +999,17 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
weechat_aspell_config_write ();
|
||||
|
||||
|
||||
weechat_aspell_speller_free_all ();
|
||||
|
||||
|
||||
if (aspell_last_modifier_string)
|
||||
free (aspell_last_modifier_string);
|
||||
if (aspell_last_modifier_result)
|
||||
free (aspell_last_modifier_result);
|
||||
|
||||
|
||||
weechat_aspell_config_free ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -65,11 +65,11 @@ charset_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
/* free all decode/encode charsets */
|
||||
weechat_config_section_free_options (charset_config_section_decode);
|
||||
weechat_config_section_free_options (charset_config_section_encode);
|
||||
|
||||
|
||||
return weechat_config_reload (config_file);
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -120,7 +120,7 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -128,7 +128,7 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
|
||||
weechat_prefix ("error"), CHARSET_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -141,12 +141,12 @@ int
|
||||
charset_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
charset_config_file = weechat_config_new (CHARSET_CONFIG_NAME,
|
||||
&charset_config_reload, NULL);
|
||||
if (!charset_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (charset_config_file, "default",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -157,7 +157,7 @@ charset_config_init ()
|
||||
weechat_config_free (charset_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
charset_default_decode = weechat_config_new_option (
|
||||
charset_config_file, ptr_section,
|
||||
"decode", "string",
|
||||
@@ -174,7 +174,7 @@ charset_config_init ()
|
||||
N_("global encoding charset"),
|
||||
NULL, 0, 0, "", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (charset_config_file, "decode",
|
||||
1, 1,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -186,9 +186,9 @@ charset_config_init ()
|
||||
weechat_config_free (charset_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
charset_config_section_decode = ptr_section;
|
||||
|
||||
|
||||
ptr_section = weechat_config_new_section (charset_config_file, "encode",
|
||||
1, 1,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -200,9 +200,9 @@ charset_config_init ()
|
||||
weechat_config_free (charset_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
charset_config_section_encode = ptr_section;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -235,14 +235,14 @@ int
|
||||
charset_check (const char *charset)
|
||||
{
|
||||
iconv_t cd;
|
||||
|
||||
|
||||
if (!charset || !charset[0])
|
||||
return 0;
|
||||
|
||||
|
||||
cd = iconv_open (charset, charset_internal);
|
||||
if (cd == (iconv_t)(-1))
|
||||
return 0;
|
||||
|
||||
|
||||
iconv_close (cd);
|
||||
return 1;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ charset_get (struct t_config_section *section, const char *name,
|
||||
{
|
||||
char *option_name, *ptr_end;
|
||||
struct t_config_option *ptr_option;
|
||||
|
||||
|
||||
option_name = strdup (name);
|
||||
if (option_name)
|
||||
{
|
||||
@@ -285,18 +285,18 @@ charset_get (struct t_config_section *section, const char *name,
|
||||
ptr_option = weechat_config_search_option (charset_config_file,
|
||||
section,
|
||||
option_name);
|
||||
|
||||
|
||||
free (option_name);
|
||||
|
||||
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
}
|
||||
|
||||
|
||||
/* nothing found => return default decode/encode charset (if set) */
|
||||
if (weechat_config_string (default_charset)
|
||||
&& weechat_config_string (default_charset)[0])
|
||||
return weechat_config_string (default_charset);
|
||||
|
||||
|
||||
/* no default charset set */
|
||||
return NULL;
|
||||
}
|
||||
@@ -310,11 +310,11 @@ charset_decode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
const char *string)
|
||||
{
|
||||
const char *charset;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) modifier;
|
||||
|
||||
|
||||
charset = charset_get (charset_config_section_decode, modifier_data,
|
||||
charset_default_decode);
|
||||
if (weechat_charset_plugin->debug)
|
||||
@@ -326,7 +326,7 @@ charset_decode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
}
|
||||
if (charset && charset[0])
|
||||
return weechat_iconv_to_internal (charset, string);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -339,11 +339,11 @@ charset_encode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
const char *string)
|
||||
{
|
||||
const char *charset;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) modifier;
|
||||
|
||||
|
||||
charset = charset_get (charset_config_section_encode, modifier_data,
|
||||
charset_default_encode);
|
||||
if (weechat_charset_plugin->debug)
|
||||
@@ -355,7 +355,7 @@ charset_encode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
}
|
||||
if (charset && charset[0])
|
||||
return weechat_iconv_from_internal (charset, string);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
int length;
|
||||
char *ptr_charset, *option_name;
|
||||
const char *plugin_name, *name, *charset_modifier;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
@@ -415,9 +415,9 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
charset_display_charsets ();
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
ptr_section = NULL;
|
||||
|
||||
|
||||
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
||||
name = weechat_buffer_get_string (buffer, "name");
|
||||
|
||||
@@ -431,10 +431,10 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
option_name = malloc (length);
|
||||
if (!option_name)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
snprintf (option_name, length, "%s.%s", plugin_name, name);
|
||||
}
|
||||
|
||||
|
||||
if ((argc > 1) && (weechat_strcasecmp (argv[1], "reset") == 0))
|
||||
{
|
||||
charset_set (charset_config_section_decode, "decode", option_name,
|
||||
@@ -469,7 +469,7 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
else
|
||||
ptr_charset = argv_eol[1];
|
||||
|
||||
|
||||
if (!charset_check (ptr_charset))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -492,9 +492,9 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
ptr_charset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free (option_name);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -508,17 +508,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
/* get terminal & internal charsets */
|
||||
charset_terminal = weechat_info_get ("charset_terminal", "");
|
||||
charset_internal = weechat_info_get ("charset_internal", "");
|
||||
|
||||
|
||||
/* display message */
|
||||
if (weechat_charset_plugin->debug >= 1)
|
||||
charset_display_charsets ();
|
||||
|
||||
|
||||
if (!charset_config_init ())
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -527,7 +527,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
charset_config_read ();
|
||||
|
||||
|
||||
/* /charset command */
|
||||
weechat_hook_command ("charset",
|
||||
N_("change charset for current buffer"),
|
||||
@@ -539,11 +539,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
" reset: reset charsets for current buffer"),
|
||||
"decode|encode|reset",
|
||||
&charset_command_cb, NULL);
|
||||
|
||||
|
||||
/* modifiers hooks */
|
||||
weechat_hook_modifier ("charset_decode", &charset_decode_cb, NULL);
|
||||
weechat_hook_modifier ("charset_encode", &charset_encode_cb, NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -556,10 +556,10 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
charset_config_write ();
|
||||
|
||||
|
||||
weechat_config_free (charset_config_file);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
+24
-24
@@ -56,7 +56,7 @@ demo_printf_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) argv;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
weechat_printf (buffer,
|
||||
"demo_printf: \"%s\"", argv_eol[1]);
|
||||
@@ -75,7 +75,7 @@ demo_printf_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_color ("chat_server"),
|
||||
weechat_color ("chat_host"));
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -89,14 +89,14 @@ demo_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
weechat_printf (buffer,
|
||||
"buffer_input_data_cb: buffer = %lx (%s), "
|
||||
"input_data = \"%s\"",
|
||||
(long unsigned int)buffer,
|
||||
weechat_buffer_get_string (buffer, "name"),
|
||||
input_data);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ demo_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
(long unsigned int)buffer,
|
||||
weechat_buffer_get_string (buffer, "name"));
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ demo_buffer_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
(void) argv_eol;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
new_buffer = weechat_buffer_new (argv[1],
|
||||
@@ -148,7 +148,7 @@ demo_buffer_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -164,10 +164,10 @@ demo_infolist_print (struct t_infolist *infolist, const char *item_name)
|
||||
void *pointer;
|
||||
int i, j, argc, size;
|
||||
time_t time;
|
||||
|
||||
|
||||
if (!infolist)
|
||||
return;
|
||||
|
||||
|
||||
i = 1;
|
||||
while (weechat_infolist_next (infolist))
|
||||
{
|
||||
@@ -234,11 +234,11 @@ demo_info_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
weechat_printf (NULL, "info \"%s\" = \"%s\"",
|
||||
argv[1],
|
||||
@@ -261,7 +261,7 @@ demo_info_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -274,11 +274,11 @@ demo_infolist_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
infolist = weechat_infolist_get (argv[1], NULL,
|
||||
@@ -306,7 +306,7 @@ demo_infolist_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ demo_signal_cb (void *data, const char *signal, const char *type_data,
|
||||
signal, type_data, (long unsigned int)signal_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -366,23 +366,23 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
weechat_hook_command ("demo_printf",
|
||||
N_("print some messages on current buffer"),
|
||||
N_("<text>"),
|
||||
N_("text: write this text"),
|
||||
"",
|
||||
&demo_printf_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_command ("demo_buffer",
|
||||
N_("open a new buffer"),
|
||||
N_("<name>"),
|
||||
"",
|
||||
"",
|
||||
&demo_buffer_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_command ("demo_info",
|
||||
N_("get and display an info"),
|
||||
N_("<info> [<arguments>]"),
|
||||
@@ -392,7 +392,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"of available infos"),
|
||||
"%(infos)",
|
||||
&demo_info_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_command ("demo_infolist",
|
||||
N_("get and display an infolist"),
|
||||
N_("<infolist> [<arguments>]"),
|
||||
@@ -402,9 +402,9 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
"of available infolists"),
|
||||
"%(infolists)",
|
||||
&demo_infolist_command_cb, NULL);
|
||||
|
||||
|
||||
weechat_hook_signal ("*", &demo_signal_cb, NULL);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -417,6 +417,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ fifo_info_get_info_cb (void *data, const char *info_name,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) arguments;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (info_name, "fifo_filename") == 0)
|
||||
{
|
||||
return fifo_filename;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+39
-39
@@ -74,17 +74,17 @@ fifo_remove_old_pipes ()
|
||||
DIR *dp;
|
||||
struct dirent *entry;
|
||||
struct stat statbuf;
|
||||
|
||||
|
||||
buf_len = PATH_MAX;
|
||||
buf = malloc (buf_len);
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
|
||||
weechat_home = weechat_info_get ("weechat_dir", "");
|
||||
dir_separator = weechat_info_get ("dir_separator", "");
|
||||
|
||||
|
||||
prefix_len = strlen (FIFO_FILENAME_PREFIX);
|
||||
|
||||
|
||||
dp = opendir (weechat_home);
|
||||
if (dp != NULL)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ fifo_remove_old_pipes ()
|
||||
}
|
||||
closedir (dp);
|
||||
}
|
||||
|
||||
|
||||
free (buf);
|
||||
}
|
||||
|
||||
@@ -121,20 +121,20 @@ fifo_create ()
|
||||
{
|
||||
int filename_length;
|
||||
const char *fifo_option, *weechat_home;
|
||||
|
||||
|
||||
fifo_option = weechat_config_get_plugin ("fifo");
|
||||
if (!fifo_option)
|
||||
{
|
||||
weechat_config_set_plugin ("fifo", "on");
|
||||
fifo_option = weechat_config_get_plugin ("fifo");
|
||||
}
|
||||
|
||||
|
||||
weechat_home = weechat_info_get ("weechat_dir", "");
|
||||
|
||||
|
||||
if (fifo_option && weechat_home)
|
||||
{
|
||||
fifo_remove_old_pipes ();
|
||||
|
||||
|
||||
if (weechat_strcasecmp (fifo_option, "on") == 0)
|
||||
{
|
||||
/*
|
||||
@@ -149,9 +149,9 @@ fifo_create ()
|
||||
"%s/%s%d",
|
||||
weechat_home, FIFO_FILENAME_PREFIX, (int) getpid());
|
||||
}
|
||||
|
||||
|
||||
fifo_fd = -1;
|
||||
|
||||
|
||||
/* create FIFO pipe, writable for user only */
|
||||
if (mkfifo (fifo_filename, 0600) == 0)
|
||||
{
|
||||
@@ -205,11 +205,11 @@ fifo_remove ()
|
||||
close (fifo_fd);
|
||||
fifo_fd = -1;
|
||||
}
|
||||
|
||||
|
||||
/* remove FIFO from disk */
|
||||
if (fifo_filename)
|
||||
unlink (fifo_filename);
|
||||
|
||||
|
||||
/* remove any unterminated message */
|
||||
if (fifo_unterminated)
|
||||
{
|
||||
@@ -223,7 +223,7 @@ fifo_remove ()
|
||||
free (fifo_filename);
|
||||
fifo_filename = NULL;
|
||||
}
|
||||
|
||||
|
||||
weechat_printf (NULL,
|
||||
_("%s: pipe closed"),
|
||||
FIFO_PLUGIN_NAME);
|
||||
@@ -238,14 +238,14 @@ fifo_exec (const char *text)
|
||||
{
|
||||
char *text2, *pos_msg, *pos_buffer;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
text2 = strdup (text);
|
||||
if (!text2)
|
||||
return;
|
||||
|
||||
|
||||
pos_msg = NULL;
|
||||
ptr_buffer = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* look for plugin + buffer name at beginning of text
|
||||
* text may be: "plugin.buffer *text" or "*text"
|
||||
@@ -268,7 +268,7 @@ fifo_exec (const char *text)
|
||||
}
|
||||
pos_msg[0] = '\0';
|
||||
pos_msg += 2;
|
||||
|
||||
|
||||
pos_buffer = strchr (text2, '.');
|
||||
if (!pos_buffer)
|
||||
{
|
||||
@@ -280,11 +280,11 @@ fifo_exec (const char *text)
|
||||
}
|
||||
pos_buffer[0] = '\0';
|
||||
pos_buffer++;
|
||||
|
||||
|
||||
if (text2[0] && pos_buffer[0])
|
||||
ptr_buffer = weechat_buffer_search (text2, pos_buffer);
|
||||
}
|
||||
|
||||
|
||||
if (!ptr_buffer)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -293,9 +293,9 @@ fifo_exec (const char *text)
|
||||
free (text2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
weechat_command (ptr_buffer, pos_msg);
|
||||
|
||||
|
||||
free (text2);
|
||||
}
|
||||
|
||||
@@ -309,12 +309,12 @@ fifo_read ()
|
||||
static char buffer[4096 + 2];
|
||||
char *buf2, *pos, *ptr_buf, *next_ptr_buf;
|
||||
int num_read;
|
||||
|
||||
|
||||
num_read = read (fifo_fd, buffer, sizeof (buffer) - 2);
|
||||
if (num_read > 0)
|
||||
{
|
||||
buffer[num_read] = '\0';
|
||||
|
||||
|
||||
buf2 = NULL;
|
||||
ptr_buf = buffer;
|
||||
if (fifo_unterminated)
|
||||
@@ -330,7 +330,7 @@ fifo_read ()
|
||||
free (fifo_unterminated);
|
||||
fifo_unterminated = NULL;
|
||||
}
|
||||
|
||||
|
||||
while (ptr_buf && ptr_buf[0])
|
||||
{
|
||||
next_ptr_buf = NULL;
|
||||
@@ -355,13 +355,13 @@ fifo_read ()
|
||||
next_ptr_buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ptr_buf)
|
||||
fifo_exec (ptr_buf);
|
||||
|
||||
|
||||
ptr_buf = next_ptr_buf;
|
||||
}
|
||||
|
||||
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
@@ -406,7 +406,7 @@ fifo_config_cb (void *data, const char *option, const char *value)
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (value, "on") == 0)
|
||||
{
|
||||
if (fifo_fd < 0)
|
||||
@@ -417,7 +417,7 @@ fifo_config_cb (void *data, const char *option, const char *value)
|
||||
if (fifo_fd >= 0)
|
||||
fifo_remove ();
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -431,19 +431,19 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
|
||||
fifo_quiet = 1;
|
||||
|
||||
|
||||
fifo_create ();
|
||||
|
||||
|
||||
weechat_hook_config ("plugins.var.fifo.fifo", &fifo_config_cb, NULL);
|
||||
|
||||
|
||||
fifo_info_init ();
|
||||
|
||||
|
||||
fifo_quiet = 0;
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -456,8 +456,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
|
||||
fifo_remove ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -47,22 +47,22 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
|
||||
struct t_irc_server *server;
|
||||
char *buf, *message;
|
||||
int length;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
buf = NULL;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, NULL);
|
||||
|
||||
|
||||
if (server && server->is_away)
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_item_away_message)
|
||||
@@ -88,7 +88,7 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -103,29 +103,29 @@ irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_buffer *buffer;
|
||||
const char *title;
|
||||
char *title_color;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
title = weechat_buffer_get_string (buffer, "title");
|
||||
if (!title)
|
||||
return NULL;
|
||||
|
||||
|
||||
title_color = irc_color_decode (title,
|
||||
(weechat_config_boolean (irc_config_look_topic_strip_colors)) ?
|
||||
0 : 1);
|
||||
|
||||
|
||||
return (title_color) ? title_color : strdup (title);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -143,16 +143,16 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
|
||||
const char *name;
|
||||
struct t_irc_server *server;
|
||||
struct t_irc_channel *channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
ptr_plugin = weechat_buffer_get_pointer (buffer, "plugin");
|
||||
@@ -180,7 +180,7 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
|
||||
}
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -198,21 +198,21 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_server *server;
|
||||
struct t_irc_channel *channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buf_name[0] = '\0';
|
||||
modes[0] = '\0';
|
||||
|
||||
|
||||
display_server = (weechat_config_integer (irc_config_look_item_display_server) == IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME);
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, &channel);
|
||||
@@ -282,14 +282,14 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
if (name)
|
||||
snprintf (buf_name, sizeof (buf_name), "%s", name);
|
||||
}
|
||||
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s%s%s",
|
||||
(server && server->ssl_connected) ? IRC_COLOR_STATUS_NAME_SSL : IRC_COLOR_STATUS_NAME,
|
||||
buf_name,
|
||||
modes);
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -307,21 +307,21 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_server *server;
|
||||
struct t_irc_channel *channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buf_name[0] = '\0';
|
||||
modes[0] = '\0';
|
||||
|
||||
|
||||
display_server = (weechat_config_integer (irc_config_look_item_display_server) == IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME);
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, &channel);
|
||||
@@ -363,14 +363,14 @@ irc_bar_item_channel (void *data, struct t_gui_bar_item *item,
|
||||
if (name)
|
||||
snprintf (buf_name, sizeof (buf_name), "%s", name);
|
||||
}
|
||||
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s%s%s",
|
||||
IRC_COLOR_STATUS_NAME,
|
||||
buf_name,
|
||||
modes);
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -385,20 +385,20 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item,
|
||||
char buf[128];
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_server *server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, NULL);
|
||||
|
||||
|
||||
if (server
|
||||
&& (server->lag >= weechat_config_integer (irc_config_network_lag_min_show)))
|
||||
{
|
||||
@@ -430,22 +430,22 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
|
||||
struct t_irc_nick *ptr_nick;
|
||||
char *buf, str_prefix[64];
|
||||
int length;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window ();
|
||||
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_and_channel (buffer, &server, &channel);
|
||||
if (!server || !server->nick)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* build prefix */
|
||||
str_prefix[0] = '\0';
|
||||
if (weechat_config_boolean (irc_config_look_item_nick_prefix)
|
||||
@@ -463,11 +463,11 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* build bar item */
|
||||
length = 64 + strlen (server->nick) + 64 +
|
||||
((server->nick_modes) ? strlen (server->nick_modes) : 0) + 64 + 1;
|
||||
|
||||
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
@@ -491,10 +491,10 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
|
||||
server->nick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -511,22 +511,22 @@ irc_bar_item_focus_buffer_nicklist (void *data,
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
const char *str_buffer, *nick;
|
||||
|
||||
|
||||
str_buffer = weechat_hashtable_get (info, "_buffer");
|
||||
if (!str_buffer || !str_buffer[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
rc = sscanf (str_buffer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return NULL;
|
||||
|
||||
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (ptr_server && ptr_channel)
|
||||
{
|
||||
nick = weechat_hashtable_get (info, "nick");
|
||||
@@ -540,7 +540,7 @@ irc_bar_item_focus_buffer_nicklist (void *data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -558,14 +558,14 @@ irc_bar_item_buffer_switch (void *data, const char *signal,
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
|
||||
weechat_bar_item_update ("away");
|
||||
weechat_bar_item_update ("buffer_title");
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
weechat_bar_item_update ("irc_channel");
|
||||
weechat_bar_item_update ("lag");
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,15 +49,15 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
if (server)
|
||||
*server = NULL;
|
||||
if (channel)
|
||||
*channel = NULL;
|
||||
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
|
||||
/* look for a server or channel using this buffer */
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
@@ -68,7 +68,7 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
|
||||
*server = ptr_server;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* no server or channel found */
|
||||
}
|
||||
|
||||
@@ -94,18 +94,18 @@ char *
|
||||
irc_buffer_build_name (const char *server, const char *channel)
|
||||
{
|
||||
static char buffer[128];
|
||||
|
||||
|
||||
buffer[0] = '\0';
|
||||
|
||||
|
||||
if (!server && !channel)
|
||||
return buffer;
|
||||
|
||||
|
||||
if (server && channel)
|
||||
snprintf (buffer, sizeof (buffer), "%s.%s", server, channel);
|
||||
else
|
||||
snprintf (buffer, sizeof (buffer), "%s",
|
||||
(server) ? server : channel);
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ int
|
||||
irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct t_irc_channel *next_channel;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (buffer == irc_raw_buffer)
|
||||
{
|
||||
irc_raw_buffer = NULL;
|
||||
@@ -156,7 +156,7 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -172,10 +172,10 @@ irc_buffer_search_first_for_all_servers ()
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_irc_server *ptr_server;
|
||||
int number, number_found;
|
||||
|
||||
|
||||
ptr_buffer = NULL;
|
||||
number_found = INT_MAX;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
|
||||
@@ -50,17 +50,17 @@ int
|
||||
irc_channel_valid (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
if (!server)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel == channel)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* channel not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -77,12 +77,12 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
|
||||
int number_found;
|
||||
char str_number[32];
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
number = weechat_buffer_get_integer (buffer, "number");
|
||||
number_last_channel = 0;
|
||||
number_last_private = 0;
|
||||
number_found = 0;
|
||||
|
||||
|
||||
if (server->channels)
|
||||
{
|
||||
/* search last channel/pv number for server */
|
||||
@@ -106,7 +106,7 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* use last channel/pv number + 1 */
|
||||
switch (channel_type)
|
||||
{
|
||||
@@ -130,7 +130,7 @@ irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
|
||||
number_found = weechat_buffer_get_integer (server->buffer, "number") + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* switch to number found */
|
||||
if ((number_found >= 1) && (number_found != number))
|
||||
{
|
||||
@@ -154,7 +154,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
int i, buffer_created, current_buffer_number, buffer_position, manual_join;
|
||||
char *buffer_name, str_number[32], str_group[32], *channel_name_lower;
|
||||
const char *prefix_modes;
|
||||
|
||||
|
||||
/* alloc memory for new channel */
|
||||
if ((new_channel = malloc (sizeof (*new_channel))) == NULL)
|
||||
{
|
||||
@@ -163,7 +163,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* create buffer for channel (or use existing one) */
|
||||
buffer_created = 0;
|
||||
buffer_name = irc_buffer_build_name (server->name, channel_name);
|
||||
@@ -206,7 +206,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
}
|
||||
buffer_created = 1;
|
||||
}
|
||||
|
||||
|
||||
if (buffer_created)
|
||||
{
|
||||
if (!weechat_buffer_get_integer (new_buffer, "short_name_is_set"))
|
||||
@@ -227,7 +227,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
weechat_buffer_set (new_buffer, "nicklist", "1");
|
||||
weechat_buffer_set (new_buffer, "nicklist_display_groups", "0");
|
||||
}
|
||||
|
||||
|
||||
/* set highlights settings on channel buffer */
|
||||
weechat_buffer_set(new_buffer, "highlight_words_add", "$nick");
|
||||
if (weechat_config_string (irc_config_look_highlight_tags)
|
||||
@@ -237,7 +237,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
weechat_config_string (irc_config_look_highlight_tags));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
prefix_modes = irc_server_get_prefix_modes (server);
|
||||
@@ -253,7 +253,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
weechat_nicklist_add_group (new_buffer, NULL, str_group,
|
||||
"weechat.color.nicklist_group", 1);
|
||||
}
|
||||
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->name = strdup (channel_name);
|
||||
@@ -279,7 +279,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
new_channel->last_nick_speaking_time = NULL;
|
||||
new_channel->buffer = new_buffer;
|
||||
new_channel->buffer_as_string = NULL;
|
||||
|
||||
|
||||
/* add new channel to channels list */
|
||||
new_channel->prev_channel = server->last_channel;
|
||||
new_channel->next_channel = NULL;
|
||||
@@ -288,7 +288,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
else
|
||||
server->channels = new_channel;
|
||||
server->last_channel = new_channel;
|
||||
|
||||
|
||||
manual_join = 0;
|
||||
channel_name_lower = NULL;
|
||||
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
@@ -301,7 +301,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
channel_name_lower);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_to_channel)
|
||||
{
|
||||
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
@@ -310,23 +310,23 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
|| (!manual_join && !weechat_config_boolean (irc_config_look_buffer_switch_autojoin)))
|
||||
switch_to_channel = 0;
|
||||
}
|
||||
|
||||
|
||||
if (switch_to_channel)
|
||||
{
|
||||
weechat_buffer_set (new_buffer, "display",
|
||||
(auto_switch) ? "auto" : "1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (manual_join)
|
||||
weechat_hashtable_remove (server->manual_joins, channel_name_lower);
|
||||
if (channel_name_lower)
|
||||
free (channel_name_lower);
|
||||
|
||||
|
||||
weechat_hook_signal_send ((channel_type == IRC_CHANNEL_TYPE_CHANNEL) ?
|
||||
"irc_channel_opened" : "irc_pv_opened",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, new_buffer);
|
||||
|
||||
|
||||
/* all is ok, return address of new channel */
|
||||
return new_channel;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ irc_channel_set_topic (struct t_irc_channel *channel, const char *topic)
|
||||
{
|
||||
if (channel->topic)
|
||||
free (channel->topic);
|
||||
|
||||
|
||||
channel->topic = (topic) ? strdup (topic) : NULL;
|
||||
weechat_buffer_set (channel->buffer, "title",
|
||||
(channel->topic) ? channel->topic : "");
|
||||
@@ -354,10 +354,10 @@ struct t_irc_channel *
|
||||
irc_channel_search (struct t_irc_server *server, const char *channel_name)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -375,10 +375,10 @@ int
|
||||
irc_channel_is_channel (const char *string)
|
||||
{
|
||||
char first_char[2];
|
||||
|
||||
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
|
||||
first_char[0] = string[0];
|
||||
first_char[1] = '\0';
|
||||
return (strpbrk (first_char, IRC_CHANNEL_PREFIX)) ? 1 : 0;
|
||||
@@ -393,7 +393,7 @@ irc_channel_remove_away (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
@@ -436,7 +436,7 @@ irc_channel_set_away (struct t_irc_server *server,
|
||||
int is_away)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
ptr_nick = irc_nick_search (channel, nick_name);
|
||||
@@ -456,21 +456,21 @@ irc_channel_nick_speaking_add_to_list (struct t_irc_channel *channel,
|
||||
{
|
||||
int size, to_remove, i;
|
||||
struct t_weelist_item *ptr_item;
|
||||
|
||||
|
||||
/* create list if it does not exist */
|
||||
if (!channel->nicks_speaking[highlight])
|
||||
channel->nicks_speaking[highlight] = weechat_list_new ();
|
||||
|
||||
|
||||
/* remove item if it was already in list */
|
||||
ptr_item = weechat_list_casesearch (channel->nicks_speaking[highlight],
|
||||
nick_name);
|
||||
if (ptr_item)
|
||||
weechat_list_remove (channel->nicks_speaking[highlight], ptr_item);
|
||||
|
||||
|
||||
/* add nick in list */
|
||||
weechat_list_add (channel->nicks_speaking[highlight], nick_name,
|
||||
WEECHAT_LIST_POS_END, NULL);
|
||||
|
||||
|
||||
/* reduce list size if it's too big */
|
||||
size = weechat_list_size (channel->nicks_speaking[highlight]);
|
||||
if (size > IRC_CHANNEL_NICKS_SPEAKING_LIMIT)
|
||||
@@ -498,7 +498,7 @@ irc_channel_nick_speaking_add (struct t_irc_channel *channel,
|
||||
highlight = 1;
|
||||
if (highlight)
|
||||
irc_channel_nick_speaking_add_to_list (channel, nick_name, 1);
|
||||
|
||||
|
||||
irc_channel_nick_speaking_add_to_list (channel, nick_name, 0);
|
||||
}
|
||||
|
||||
@@ -537,10 +537,10 @@ irc_channel_nick_speaking_time_search (struct t_irc_channel *channel,
|
||||
{
|
||||
struct t_irc_channel_speaking *ptr_nick;
|
||||
time_t time_limit;
|
||||
|
||||
|
||||
time_limit = time (NULL) -
|
||||
(weechat_config_integer (irc_config_look_smart_filter_delay) * 60);
|
||||
|
||||
|
||||
for (ptr_nick = channel->nicks_speaking_time; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
@@ -551,7 +551,7 @@ irc_channel_nick_speaking_time_search (struct t_irc_channel *channel,
|
||||
return ptr_nick;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* nick speaking time not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -567,7 +567,7 @@ irc_channel_nick_speaking_time_free (struct t_irc_channel *channel,
|
||||
/* free data */
|
||||
if (nick_speaking->nick)
|
||||
free (nick_speaking->nick);
|
||||
|
||||
|
||||
/* remove nick from list */
|
||||
if (nick_speaking->prev_nick)
|
||||
(nick_speaking->prev_nick)->next_nick = nick_speaking->next_nick;
|
||||
@@ -577,7 +577,7 @@ irc_channel_nick_speaking_time_free (struct t_irc_channel *channel,
|
||||
channel->nicks_speaking_time = nick_speaking->next_nick;
|
||||
if (channel->last_nick_speaking_time == nick_speaking)
|
||||
channel->last_nick_speaking_time = nick_speaking->prev_nick;
|
||||
|
||||
|
||||
free (nick_speaking);
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ void
|
||||
irc_channel_nick_speaking_time_remove_old (struct t_irc_channel *channel)
|
||||
{
|
||||
time_t time_limit;
|
||||
|
||||
|
||||
time_limit = time (NULL) -
|
||||
(weechat_config_integer (irc_config_look_smart_filter_delay) * 60);
|
||||
|
||||
@@ -611,7 +611,7 @@ irc_channel_nick_speaking_time_remove_old (struct t_irc_channel *channel)
|
||||
{
|
||||
if (channel->last_nick_speaking_time->time_last_message >= time_limit)
|
||||
break;
|
||||
|
||||
|
||||
irc_channel_nick_speaking_time_free (channel,
|
||||
channel->last_nick_speaking_time);
|
||||
}
|
||||
@@ -627,17 +627,17 @@ irc_channel_nick_speaking_time_add (struct t_irc_channel *channel,
|
||||
time_t time_last_message)
|
||||
{
|
||||
struct t_irc_channel_speaking *ptr_nick, *new_nick;
|
||||
|
||||
|
||||
ptr_nick = irc_channel_nick_speaking_time_search (channel, nick_name, 0);
|
||||
if (ptr_nick)
|
||||
irc_channel_nick_speaking_time_free (channel, ptr_nick);
|
||||
|
||||
|
||||
new_nick = malloc (sizeof (*new_nick));
|
||||
if (new_nick)
|
||||
{
|
||||
new_nick->nick = strdup (nick_name);
|
||||
new_nick->time_last_message = time_last_message;
|
||||
|
||||
|
||||
/* insert nick at beginning of list */
|
||||
new_nick->prev_nick = NULL;
|
||||
new_nick->next_nick = channel->nicks_speaking_time;
|
||||
@@ -660,7 +660,7 @@ irc_channel_nick_speaking_time_rename (struct t_irc_channel *channel,
|
||||
const char *new_nick)
|
||||
{
|
||||
struct t_irc_channel_speaking *ptr_nick;
|
||||
|
||||
|
||||
if (channel->nicks_speaking_time)
|
||||
{
|
||||
ptr_nick = irc_channel_nick_speaking_time_search (channel, old_nick, 0);
|
||||
@@ -680,12 +680,12 @@ void
|
||||
irc_channel_rejoin (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
{
|
||||
char join_args[256];
|
||||
|
||||
|
||||
snprintf (join_args, sizeof (join_args), "%s%s%s",
|
||||
channel->name,
|
||||
(channel->key) ? " " : "",
|
||||
(channel->key) ? channel->key : "");
|
||||
|
||||
|
||||
irc_command_join_server (server, join_args, 0);
|
||||
}
|
||||
|
||||
@@ -698,12 +698,12 @@ irc_channel_autorejoin_cb (void *data, int remaining_calls)
|
||||
{
|
||||
struct t_irc_server *ptr_server, *ptr_server_found;
|
||||
struct t_irc_channel *ptr_channel_arg, *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
ptr_channel_arg = (struct t_irc_channel *)data;
|
||||
|
||||
|
||||
ptr_server_found = NULL;
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
@@ -718,13 +718,13 @@ irc_channel_autorejoin_cb (void *data, int remaining_calls)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ptr_server_found && (ptr_channel_arg->hook_autorejoin))
|
||||
{
|
||||
irc_channel_rejoin (ptr_server_found, ptr_channel_arg);
|
||||
ptr_channel_arg->hook_autorejoin = NULL;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -740,10 +740,10 @@ irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
|
||||
const char *nickname)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
if (!server || (!nick && !nickname))
|
||||
return;
|
||||
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -777,10 +777,10 @@ void
|
||||
irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
{
|
||||
struct t_irc_channel *new_channels;
|
||||
|
||||
|
||||
if (!server || !channel)
|
||||
return;
|
||||
|
||||
|
||||
/* remove channel from channels list */
|
||||
if (server->last_channel == channel)
|
||||
server->last_channel = channel->prev_channel;
|
||||
@@ -791,10 +791,10 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
}
|
||||
else
|
||||
new_channels = channel->next_channel;
|
||||
|
||||
|
||||
if (channel->next_channel)
|
||||
(channel->next_channel)->prev_channel = channel->prev_channel;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (channel->name)
|
||||
free (channel->name);
|
||||
@@ -818,9 +818,9 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
irc_channel_nick_speaking_time_free_all (channel);
|
||||
if (channel->buffer_as_string)
|
||||
free (channel->buffer_as_string);
|
||||
|
||||
|
||||
free (channel);
|
||||
|
||||
|
||||
server->channels = new_channels;
|
||||
}
|
||||
|
||||
@@ -845,10 +845,10 @@ struct t_hdata *
|
||||
irc_channel_hdata_channel_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_channel", "next_channel");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -889,10 +889,10 @@ struct t_hdata *
|
||||
irc_channel_hdata_channel_speaking_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -918,14 +918,14 @@ irc_channel_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_channel_speaking *ptr_nick;
|
||||
char option_name[64];
|
||||
int i, index;
|
||||
|
||||
|
||||
if (!infolist || !channel)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_pointer (ptr_item, "buffer", channel->buffer))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "buffer_name",
|
||||
@@ -1003,7 +1003,7 @@ irc_channel_add_to_infolist (struct t_infolist *infolist,
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1018,7 +1018,7 @@ irc_channel_print_log (struct t_irc_channel *channel)
|
||||
struct t_irc_channel_speaking *ptr_nick_speaking;
|
||||
int i, index;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf (" => channel %s (addr:0x%lx):", channel->name, channel);
|
||||
weechat_log_printf (" type . . . . . . . . . . : %d", channel->type);
|
||||
|
||||
+17
-17
@@ -66,17 +66,17 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
int out_length, length, out_pos;
|
||||
char str_fg[3], str_bg[3], str_color[128];
|
||||
int fg, bg, bold, reverse, italic, underline, rc;
|
||||
|
||||
|
||||
out_length = (strlen (string) * 2) + 1;
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
||||
bold = 0;
|
||||
reverse = 0;
|
||||
italic = 0;
|
||||
underline = 0;
|
||||
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
out[0] = '\0';
|
||||
while (ptr_string && ptr_string[0])
|
||||
@@ -197,7 +197,7 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (char *)out;
|
||||
}
|
||||
|
||||
@@ -212,12 +212,12 @@ irc_color_decode_for_user_entry (const char *string)
|
||||
{
|
||||
unsigned char *out, *ptr_string;
|
||||
int out_length, out_pos, length;
|
||||
|
||||
|
||||
out_length = (strlen (string) * 2) + 1;
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
out_pos = 0;
|
||||
while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
|
||||
@@ -261,9 +261,9 @@ irc_color_decode_for_user_entry (const char *string)
|
||||
ptr_string += length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out[out_pos] = '\0';
|
||||
|
||||
|
||||
return (char *)out;
|
||||
}
|
||||
|
||||
@@ -280,12 +280,12 @@ irc_color_encode (const char *string, int keep_colors)
|
||||
{
|
||||
unsigned char *out, *ptr_string;
|
||||
int out_length, out_pos, length;
|
||||
|
||||
|
||||
out_length = (strlen (string) * 2) + 1;
|
||||
out = malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_string = (unsigned char *)string;
|
||||
out_pos = 0;
|
||||
while (ptr_string && ptr_string[0] && (out_pos < out_length - 1))
|
||||
@@ -356,9 +356,9 @@ irc_color_encode (const char *string, int keep_colors)
|
||||
ptr_string += length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out[out_pos] = '\0';
|
||||
|
||||
|
||||
return (char *)out;
|
||||
}
|
||||
|
||||
@@ -374,18 +374,18 @@ irc_color_modifier_cb (void *data, const char *modifier,
|
||||
const char *modifier_data, const char *string)
|
||||
{
|
||||
int keep_colors;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
keep_colors = (modifier_data && (strcmp (modifier_data, "1") == 0)) ? 1 : 0;
|
||||
|
||||
|
||||
if (strcmp (modifier, "irc_color_decode") == 0)
|
||||
return irc_color_decode (string, keep_colors);
|
||||
|
||||
|
||||
if (strcmp (modifier, "irc_color_encode") == 0)
|
||||
return irc_color_encode (string, keep_colors);
|
||||
|
||||
|
||||
/* unknown modifier */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+370
-370
File diff suppressed because it is too large
Load Diff
@@ -48,17 +48,17 @@ irc_completion_server_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_server->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -73,17 +73,17 @@ irc_completion_server_nick_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server && ptr_server->nick)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_server->nick,
|
||||
1, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ irc_completion_server_channels_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
@@ -118,7 +118,7 @@ irc_completion_server_channels_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -133,14 +133,14 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
@@ -153,7 +153,7 @@ irc_completion_server_privates_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -169,13 +169,13 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_irc_channel *ptr_channel2;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
for (ptr_channel2 = ptr_server->channels; ptr_channel2;
|
||||
@@ -191,12 +191,12 @@ irc_completion_server_nicks_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* add self nick at the end */
|
||||
weechat_hook_completion_list_add (completion, ptr_server->nick,
|
||||
1, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -210,19 +210,19 @@ irc_completion_servers_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_server->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -236,17 +236,17 @@ irc_completion_channel_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
weechat_hook_completion_list_add (completion, ptr_channel->name,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ irc_completion_channel_nicks_add_speakers (struct t_gui_completion *completion,
|
||||
{
|
||||
int list_size, i;
|
||||
const char *nick;
|
||||
|
||||
|
||||
if (channel->nicks_speaking[highlight])
|
||||
{
|
||||
list_size = weechat_list_size (channel->nicks_speaking[highlight]);
|
||||
@@ -291,13 +291,13 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
switch (ptr_channel->type)
|
||||
@@ -342,7 +342,7 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
|
||||
}
|
||||
ptr_channel->nick_completion_reset = 0;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -359,13 +359,13 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
|
||||
struct t_irc_nick *ptr_nick;
|
||||
char *buf;
|
||||
int length;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
switch (ptr_channel->type)
|
||||
@@ -404,7 +404,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, const char *completion_item,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -420,13 +420,13 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
|
||||
{
|
||||
char *topic, *topic_color;
|
||||
int length;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_channel && ptr_channel->topic && ptr_channel->topic[0])
|
||||
{
|
||||
if (weechat_strncasecmp (ptr_channel->topic, ptr_channel->name,
|
||||
@@ -449,7 +449,7 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
|
||||
}
|
||||
else
|
||||
topic = strdup (ptr_channel->topic);
|
||||
|
||||
|
||||
topic_color = irc_color_decode_for_user_entry ((topic) ? topic : ptr_channel->topic);
|
||||
weechat_hook_completion_list_add (completion,
|
||||
(topic_color) ? topic_color : ((topic) ? topic : ptr_channel->topic),
|
||||
@@ -459,7 +459,7 @@ irc_completion_channel_topic_cb (void *data, const char *completion_item,
|
||||
if (topic)
|
||||
free (topic);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -475,12 +475,12 @@ irc_completion_channels_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -494,7 +494,7 @@ irc_completion_channels_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -510,12 +510,12 @@ irc_completion_privates_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -529,7 +529,7 @@ irc_completion_privates_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -543,13 +543,13 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
const char *msg_part;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
msg_part = IRC_SERVER_OPTION_STRING(ptr_server,
|
||||
@@ -560,7 +560,7 @@ irc_completion_msg_part_cb (void *data, const char *completion_item,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -576,12 +576,12 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
char str_number[32];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
@@ -589,7 +589,7 @@ irc_completion_ignores_numbers_cb (void *data, const char *completion_item,
|
||||
weechat_hook_completion_list_add (completion, str_number,
|
||||
0, WEECHAT_LIST_POS_END);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -604,13 +604,13 @@ irc_completion_notify_nicks_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
|
||||
|
||||
if (ptr_server)
|
||||
{
|
||||
for (ptr_notify = ptr_server->notify_list; ptr_notify;
|
||||
@@ -633,7 +633,7 @@ irc_completion_notify_nicks_cb (void *data, const char *completion_item,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
+118
-118
@@ -144,9 +144,9 @@ irc_config_get_server_from_option_name (const char *name)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
char *pos_option, *server_name;
|
||||
|
||||
|
||||
ptr_server = NULL;
|
||||
|
||||
|
||||
if (name)
|
||||
{
|
||||
pos_option = strrchr (name, '.');
|
||||
@@ -160,7 +160,7 @@ irc_config_get_server_from_option_name (const char *name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ptr_server;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ irc_config_compute_nick_colors ()
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -199,7 +199,7 @@ irc_config_compute_nick_colors ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* if colors are displayed for nicks in nicklist, refresh them */
|
||||
if (weechat_config_boolean(irc_config_look_color_nicks_in_nicklist))
|
||||
irc_nick_nicklist_set_color_all ();
|
||||
@@ -219,7 +219,7 @@ irc_config_set_nick_colors ()
|
||||
irc_config_nick_colors = NULL;
|
||||
irc_config_num_nick_colors = 0;
|
||||
}
|
||||
|
||||
|
||||
irc_config_nick_colors =
|
||||
weechat_string_split (weechat_config_string (weechat_config_get ("weechat.color.chat_nick_colors")),
|
||||
",", 0, 0,
|
||||
@@ -239,10 +239,10 @@ irc_config_change_nick_colors_cb (void *data, const char *option,
|
||||
(void) data;
|
||||
(void) option;
|
||||
(void) value;
|
||||
|
||||
|
||||
irc_config_set_nick_colors ();
|
||||
irc_config_compute_nick_colors ();
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ irc_config_change_look_color_nicks_in_nicklist (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
irc_nick_nicklist_set_color_all ();
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ irc_config_change_look_server_buffer (void *data,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
@@ -297,7 +297,7 @@ irc_config_change_look_server_buffer (void *data,
|
||||
(weechat_config_integer (irc_config_look_server_buffer) ==
|
||||
IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE) ?
|
||||
weechat_buffer_search_main () : irc_buffer_search_first_for_all_servers ();
|
||||
|
||||
|
||||
if (ptr_buffer)
|
||||
{
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
@@ -322,7 +322,7 @@ irc_config_change_look_item_away_message (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("away");
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ irc_config_change_look_item_channel_modes (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ irc_config_change_look_item_channel_modes_hide_key (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ irc_config_change_look_item_nick_modes (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ irc_config_change_look_item_nick_prefix (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
|
||||
@@ -403,11 +403,11 @@ irc_config_change_look_highlight_tags (void *data,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -439,7 +439,7 @@ irc_config_change_look_nick_color_force (void *data,
|
||||
{
|
||||
char **items, *pos;
|
||||
int num_items, i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
@@ -454,7 +454,7 @@ irc_config_change_look_nick_color_force (void *data,
|
||||
}
|
||||
else
|
||||
weechat_hashtable_remove_all (irc_config_hashtable_nick_color_force);
|
||||
|
||||
|
||||
items = weechat_string_split (weechat_config_string (irc_config_look_nick_color_force),
|
||||
";", 0, 0, &num_items);
|
||||
if (items)
|
||||
@@ -472,7 +472,7 @@ irc_config_change_look_nick_color_force (void *data,
|
||||
}
|
||||
weechat_string_free_split (items);
|
||||
}
|
||||
|
||||
|
||||
irc_config_compute_nick_colors ();
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ irc_config_change_look_nick_color_stop_chars (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
irc_config_compute_nick_colors ();
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ irc_config_change_look_topic_strip_colors (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_title");
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ irc_config_change_color_input_nick (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ irc_config_change_color_item_away (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("away");
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ irc_config_change_color_item_buffer_name (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ irc_config_change_color_item_lag (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("lag");
|
||||
}
|
||||
|
||||
@@ -601,11 +601,11 @@ irc_config_change_color_nick_prefixes (void *data,
|
||||
{
|
||||
char **items, *pos;
|
||||
int num_items, i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (!irc_config_hashtable_nick_prefixes)
|
||||
{
|
||||
irc_config_hashtable_nick_prefixes = weechat_hashtable_new (8,
|
||||
@@ -616,7 +616,7 @@ irc_config_change_color_nick_prefixes (void *data,
|
||||
}
|
||||
else
|
||||
weechat_hashtable_remove_all (irc_config_hashtable_nick_prefixes);
|
||||
|
||||
|
||||
items = weechat_string_split (weechat_config_string (irc_config_color_nick_prefixes),
|
||||
";", 0, 0, &num_items);
|
||||
if (items)
|
||||
@@ -634,9 +634,9 @@ irc_config_change_color_nick_prefixes (void *data,
|
||||
}
|
||||
weechat_string_free_split (items);
|
||||
}
|
||||
|
||||
|
||||
irc_nick_nicklist_set_prefix_color_all ();
|
||||
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
weechat_bar_item_update ("nicklist");
|
||||
}
|
||||
@@ -651,14 +651,14 @@ irc_config_change_network_lag_check (void *data,
|
||||
{
|
||||
time_t time_next_check;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
time_next_check = (weechat_config_integer (irc_config_network_lag_check) > 0) ?
|
||||
time (NULL) : 0;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -678,7 +678,7 @@ irc_config_change_network_lag_min_show (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
weechat_bar_item_update ("lag");
|
||||
}
|
||||
|
||||
@@ -694,7 +694,7 @@ irc_config_change_network_notify_check_ison (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
irc_notify_hook_timer_ison ();
|
||||
}
|
||||
|
||||
@@ -710,7 +710,7 @@ irc_config_change_network_notify_check_whois (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
irc_notify_hook_timer_whois ();
|
||||
}
|
||||
|
||||
@@ -726,15 +726,15 @@ irc_config_change_network_send_unknown_commands (void *data,
|
||||
char value[2];
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
strcpy (value,
|
||||
(weechat_config_boolean (irc_config_network_send_unknown_commands)) ?
|
||||
"1" : "0");
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -744,7 +744,7 @@ irc_config_change_network_send_unknown_commands (void *data,
|
||||
"input_get_unknown_commands", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -770,7 +770,7 @@ irc_config_server_default_change_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
int index_option;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
index_option = irc_server_search_option (data);
|
||||
if (index_option >= 0)
|
||||
{
|
||||
@@ -820,7 +820,7 @@ irc_config_check_gnutls_priorities (const char *priorities)
|
||||
gnutls_priority_t priority_cache;
|
||||
const char *pos_error;
|
||||
int rc;
|
||||
|
||||
|
||||
if (!priorities || !priorities[0])
|
||||
return NULL;
|
||||
|
||||
@@ -850,10 +850,10 @@ irc_config_server_check_value_cb (void *data,
|
||||
{
|
||||
int index_option;
|
||||
const char *pos_error;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) option;
|
||||
|
||||
|
||||
index_option = irc_server_search_option (data);
|
||||
if (index_option >= 0)
|
||||
{
|
||||
@@ -873,7 +873,7 @@ irc_config_server_check_value_cb (void *data,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -887,7 +887,7 @@ irc_config_server_change_cb (void *data, struct t_config_option *option)
|
||||
int index_option;
|
||||
char *name;
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
index_option = irc_server_search_option (data);
|
||||
if (index_option >= 0)
|
||||
{
|
||||
@@ -938,10 +938,10 @@ irc_config_server_default_check_notify (void *data,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
|
||||
if (value && value[0])
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -954,26 +954,26 @@ irc_config_reload (void *data, struct t_config_file *config_file)
|
||||
{
|
||||
int rc;
|
||||
struct t_irc_server *ptr_server, *next_server;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
ptr_server->reloading_from_config = 1;
|
||||
ptr_server->reloaded_from_config = 0;
|
||||
}
|
||||
|
||||
|
||||
irc_ignore_free_all ();
|
||||
|
||||
|
||||
rc = weechat_config_reload (config_file);
|
||||
|
||||
|
||||
ptr_server = irc_servers;
|
||||
while (ptr_server)
|
||||
{
|
||||
next_server = ptr_server->next_server;
|
||||
|
||||
|
||||
if (!ptr_server->reloaded_from_config)
|
||||
{
|
||||
if (ptr_server->is_connected)
|
||||
@@ -988,10 +988,10 @@ irc_config_reload (void *data, struct t_config_file *config_file)
|
||||
else
|
||||
irc_server_free (ptr_server);
|
||||
}
|
||||
|
||||
|
||||
ptr_server = next_server;
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1007,12 +1007,12 @@ irc_config_msgbuffer_create_option (void *data,
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -1045,7 +1045,7 @@ irc_config_msgbuffer_create_option (void *data,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1053,7 +1053,7 @@ irc_config_msgbuffer_create_option (void *data,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1071,12 +1071,12 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
const char *default_value;
|
||||
static char empty_value[1] = { '\0' };
|
||||
const char *pos_name;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
@@ -1097,11 +1097,11 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
pos_name = strchr (option_name, '.');
|
||||
pos_name = (pos_name) ? pos_name + 1 : option_name;
|
||||
|
||||
|
||||
default_value = irc_ctcp_get_default_reply (pos_name);
|
||||
if (!default_value)
|
||||
default_value = empty_value;
|
||||
|
||||
|
||||
ptr_option = weechat_config_new_option (
|
||||
config_file, section,
|
||||
option_name, "string",
|
||||
@@ -1124,7 +1124,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1132,7 +1132,7 @@ irc_config_ctcp_create_option (void *data, struct t_config_file *config_file,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1149,12 +1149,12 @@ irc_config_ignore_read_cb (void *data,
|
||||
{
|
||||
char **argv, **argv_eol;
|
||||
int argc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
if (value && value[0])
|
||||
@@ -1171,7 +1171,7 @@ irc_config_ignore_read_cb (void *data,
|
||||
weechat_string_free_split (argv_eol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1184,13 +1184,13 @@ irc_config_ignore_write_cb (void *data, struct t_config_file *config_file,
|
||||
const char *section_name)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
@@ -1202,7 +1202,7 @@ irc_config_ignore_write_cb (void *data, struct t_config_file *config_file,
|
||||
ptr_ignore->mask))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1218,13 +1218,13 @@ irc_config_server_write_default_cb (void *data,
|
||||
{
|
||||
int i;
|
||||
char option_name[128];
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
|
||||
{
|
||||
snprintf (option_name, sizeof (option_name),
|
||||
@@ -1246,7 +1246,7 @@ irc_config_server_write_default_cb (void *data,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1271,9 +1271,9 @@ irc_config_server_new_option (struct t_config_file *config_file,
|
||||
void *callback_change_data)
|
||||
{
|
||||
struct t_config_option *new_option;
|
||||
|
||||
|
||||
new_option = NULL;
|
||||
|
||||
|
||||
switch (index_option)
|
||||
{
|
||||
case IRC_SERVER_OPTION_ADDRESSES:
|
||||
@@ -1701,7 +1701,7 @@ irc_config_server_new_option (struct t_config_file *config_file,
|
||||
case IRC_SERVER_NUM_OPTIONS:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return new_option;
|
||||
}
|
||||
|
||||
@@ -1717,14 +1717,14 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
|
||||
struct t_irc_server *ptr_server;
|
||||
int index_option, rc, i;
|
||||
char *pos_option, *server_name;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
(void) section;
|
||||
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
pos_option = strrchr (option_name, '.');
|
||||
@@ -1769,7 +1769,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1777,7 +1777,7 @@ irc_config_server_read_cb (void *data, struct t_config_file *config_file,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
option_name);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1791,13 +1791,13 @@ irc_config_server_write_cb (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
int i;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!weechat_config_write_line (config_file, section_name, NULL))
|
||||
return WEECHAT_CONFIG_WRITE_ERROR;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -1811,7 +1811,7 @@ irc_config_server_write_cb (void *data, struct t_config_file *config_file,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_CONFIG_WRITE_OK;
|
||||
}
|
||||
|
||||
@@ -1825,11 +1825,11 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
int i, length;
|
||||
char *nicks, *username, *realname, *default_value;
|
||||
struct passwd *my_passwd;
|
||||
|
||||
|
||||
nicks = NULL;
|
||||
username = NULL;
|
||||
realname = strdup ("");
|
||||
|
||||
|
||||
/* Get the user's name from /etc/passwd */
|
||||
if ((my_passwd = getpwuid (geteuid ())) != NULL)
|
||||
{
|
||||
@@ -1852,7 +1852,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
nicks = strdup (IRC_SERVER_DEFAULT_NICKS);
|
||||
username = strdup ("weechat");
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
|
||||
{
|
||||
default_value = NULL;
|
||||
@@ -1870,7 +1870,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
}
|
||||
if (!default_value)
|
||||
default_value = irc_server_option_default[i];
|
||||
|
||||
|
||||
irc_config_server_default[i] = irc_config_server_new_option (
|
||||
irc_config_file,
|
||||
section,
|
||||
@@ -1884,7 +1884,7 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
&irc_config_server_default_change_cb,
|
||||
irc_server_option_string[i]);
|
||||
}
|
||||
|
||||
|
||||
if (nicks)
|
||||
free (nicks);
|
||||
if (username)
|
||||
@@ -1902,7 +1902,7 @@ int
|
||||
irc_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
|
||||
irc_config_hashtable_nick_color_force = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -1913,12 +1913,12 @@ irc_config_init ()
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
||||
irc_config_file = weechat_config_new (IRC_CONFIG_NAME,
|
||||
&irc_config_reload, NULL);
|
||||
if (!irc_config_file)
|
||||
return 0;
|
||||
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "look",
|
||||
0, 0,
|
||||
@@ -2216,7 +2216,7 @@ irc_config_init ()
|
||||
N_("strip colors in topic (used only when displaying buffer title)"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
|
||||
&irc_config_change_look_topic_strip_colors, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* color */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "color",
|
||||
0, 0,
|
||||
@@ -2228,7 +2228,7 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
irc_config_color_message_join = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"message_join", "color",
|
||||
@@ -2321,7 +2321,7 @@ irc_config_init ()
|
||||
N_("color for new channel topic (when topic is changed)"),
|
||||
NULL, -1, 0, "white", NULL, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* network */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "network",
|
||||
0, 0,
|
||||
@@ -2333,7 +2333,7 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
irc_config_network_autoreconnect_delay_growing = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"autoreconnect_delay_growing", "integer",
|
||||
@@ -2404,7 +2404,7 @@ irc_config_init ()
|
||||
"(in minutes)"),
|
||||
NULL, 1, 60 * 24 * 7, "5", NULL, 0, NULL, NULL,
|
||||
&irc_config_change_network_notify_check_whois, NULL, NULL, NULL);
|
||||
|
||||
|
||||
/* msgbuffer */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "msgbuffer",
|
||||
1, 1,
|
||||
@@ -2418,7 +2418,7 @@ irc_config_init ()
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_msgbuffer = ptr_section;
|
||||
|
||||
|
||||
/* CTCP */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "ctcp",
|
||||
1, 1,
|
||||
@@ -2432,7 +2432,7 @@ irc_config_init ()
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_ctcp = ptr_section;
|
||||
|
||||
|
||||
/* ignore */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "ignore",
|
||||
0, 0,
|
||||
@@ -2445,7 +2445,7 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* server_default */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "server_default",
|
||||
0, 0,
|
||||
@@ -2458,9 +2458,9 @@ irc_config_init ()
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_server_default = ptr_section;
|
||||
|
||||
|
||||
irc_config_server_create_default_options (ptr_section);
|
||||
|
||||
|
||||
/* server */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "server",
|
||||
0, 0,
|
||||
@@ -2475,10 +2475,10 @@ irc_config_init ()
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_server = ptr_section;
|
||||
|
||||
|
||||
irc_config_hook_config_nick_colors = weechat_hook_config ("weechat.color.chat_nick_colors",
|
||||
&irc_config_change_nick_colors_cb, NULL);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2490,7 +2490,7 @@ int
|
||||
irc_config_read ()
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
rc = weechat_config_read (irc_config_file);
|
||||
if (rc == WEECHAT_CONFIG_READ_OK)
|
||||
{
|
||||
@@ -2511,7 +2511,7 @@ int
|
||||
irc_config_write (int write_temp_servers)
|
||||
{
|
||||
irc_config_write_temp_servers = write_temp_servers;
|
||||
|
||||
|
||||
return weechat_config_write (irc_config_file);
|
||||
}
|
||||
|
||||
@@ -2523,7 +2523,7 @@ void
|
||||
irc_config_free ()
|
||||
{
|
||||
weechat_config_free (irc_config_file);
|
||||
|
||||
|
||||
if (irc_config_hook_config_nick_colors)
|
||||
{
|
||||
weechat_unhook (irc_config_hook_config_nick_colors);
|
||||
@@ -2535,13 +2535,13 @@ irc_config_free ()
|
||||
irc_config_nick_colors = NULL;
|
||||
irc_config_num_nick_colors = 0;
|
||||
}
|
||||
|
||||
|
||||
if (irc_config_hashtable_nick_color_force)
|
||||
{
|
||||
weechat_hashtable_free (irc_config_hashtable_nick_color_force);
|
||||
irc_config_hashtable_nick_color_force = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (irc_config_hashtable_nick_prefixes)
|
||||
{
|
||||
weechat_hashtable_free (irc_config_hashtable_nick_prefixes);
|
||||
|
||||
+78
-78
@@ -59,13 +59,13 @@ const char *
|
||||
irc_ctcp_get_default_reply (const char *ctcp)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; irc_ctcp_default_reply[i].name; i++)
|
||||
{
|
||||
if (weechat_strcasecmp (irc_ctcp_default_reply[i].name, ctcp) == 0)
|
||||
return irc_ctcp_default_reply[i].reply;
|
||||
}
|
||||
|
||||
|
||||
/* unknown CTCP */
|
||||
return NULL;
|
||||
}
|
||||
@@ -81,21 +81,21 @@ irc_ctcp_get_reply (struct t_irc_server *server, const char *ctcp)
|
||||
char option_name[512];
|
||||
|
||||
snprintf (option_name, sizeof (option_name), "%s.%s", server->name, ctcp);
|
||||
|
||||
|
||||
/* search for CTCP in config file, for server */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_ctcp,
|
||||
option_name);
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
|
||||
|
||||
/* search for CTCP in config file */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_ctcp,
|
||||
ctcp);
|
||||
if (ptr_option)
|
||||
return weechat_config_string (ptr_option);
|
||||
|
||||
|
||||
/*
|
||||
* no CTCP reply found in config, then return default reply, or NULL
|
||||
* for unknown CTCP
|
||||
@@ -119,7 +119,7 @@ irc_ctcp_display_request (struct t_irc_server *server,
|
||||
if (reply && !reply[0]
|
||||
&& !weechat_config_boolean (irc_config_look_display_ctcp_blocked))
|
||||
return;
|
||||
|
||||
|
||||
weechat_printf_tags ((channel) ? channel->buffer : server->buffer,
|
||||
irc_protocol_tags (command, "irc_ctcp", NULL),
|
||||
_("%sCTCP requested by %s%s%s: %s%s%s%s%s%s"),
|
||||
@@ -147,13 +147,13 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
char *pos_end, *pos_space, *pos_args, *pos_usec;
|
||||
struct timeval tv;
|
||||
long sec1, usec1, sec2, usec2, difftime;
|
||||
|
||||
|
||||
while (arguments && arguments[0])
|
||||
{
|
||||
pos_end = strchr (arguments + 1, '\01');
|
||||
if (pos_end)
|
||||
pos_end[0] = '\0';
|
||||
|
||||
|
||||
pos_space = strchr (arguments + 1, ' ');
|
||||
if (pos_space)
|
||||
{
|
||||
@@ -169,16 +169,16 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
if (pos_usec)
|
||||
{
|
||||
pos_usec[0] = '\0';
|
||||
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
sec1 = atol (pos_args);
|
||||
usec1 = atol (pos_usec + 1);
|
||||
sec2 = tv.tv_sec;
|
||||
usec2 = tv.tv_usec;
|
||||
|
||||
|
||||
difftime = ((sec2 * 1000000) + usec2) -
|
||||
((sec1 * 1000000) + usec1);
|
||||
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
irc_protocol_tags (command,
|
||||
"irc_ctcp",
|
||||
@@ -196,7 +196,7 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
(difftime % 1000000) / 1000,
|
||||
(NG_("second", "seconds",
|
||||
(difftime / 1000000))));
|
||||
|
||||
|
||||
pos_usec[0] = ' ';
|
||||
}
|
||||
}
|
||||
@@ -234,10 +234,10 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
"",
|
||||
"");
|
||||
}
|
||||
|
||||
|
||||
if (pos_end)
|
||||
pos_end[0] = '\01';
|
||||
|
||||
|
||||
arguments = (pos_end) ? pos_end + 1 : NULL;
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
|
||||
int number;
|
||||
char hash_key[32];
|
||||
const char *str_args;
|
||||
|
||||
|
||||
hashtable = irc_server_sendf (server,
|
||||
IRC_SERVER_SEND_OUTQ_PRIO_LOW | IRC_SERVER_SEND_RETURN_HASHTABLE,
|
||||
NULL,
|
||||
@@ -265,7 +265,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
|
||||
nick, ctcp,
|
||||
(arguments) ? " " : "",
|
||||
(arguments) ? arguments : "");
|
||||
|
||||
|
||||
if (hashtable)
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_display_ctcp_reply))
|
||||
@@ -311,7 +311,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
time_t now;
|
||||
char buf[1024];
|
||||
struct utsname *buf_uname;
|
||||
|
||||
|
||||
/* clientinfo */
|
||||
temp = weechat_string_replace (format, "$clientinfo",
|
||||
"ACTION DCC CLIENTINFO FINGER PING SOURCE "
|
||||
@@ -319,7 +319,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* version */
|
||||
info = weechat_info_get ("version", "");
|
||||
temp = weechat_string_replace (res, "$version", info);
|
||||
@@ -327,7 +327,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* compilation date */
|
||||
info = weechat_info_get ("date", "");
|
||||
temp = weechat_string_replace (res, "$compilation", info);
|
||||
@@ -335,7 +335,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* info about OS */
|
||||
buf_uname = (struct utsname *)malloc (sizeof (struct utsname));
|
||||
if (buf_uname && (uname (buf_uname) >= 0))
|
||||
@@ -350,7 +350,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
return NULL;
|
||||
res = temp;
|
||||
}
|
||||
|
||||
|
||||
/* site */
|
||||
info = weechat_info_get ("weechat_site", "");
|
||||
temp = weechat_string_replace (res, "$site", info);
|
||||
@@ -358,7 +358,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* site (download page) */
|
||||
info = weechat_info_get ("weechat_site_download", "");
|
||||
temp = weechat_string_replace (res, "$download", info);
|
||||
@@ -366,7 +366,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* time */
|
||||
now = time (NULL);
|
||||
snprintf (buf, sizeof (buf), "%s", ctime (&now));
|
||||
@@ -376,7 +376,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* username */
|
||||
temp = weechat_string_replace (res, "$username",
|
||||
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME));
|
||||
@@ -384,7 +384,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* realname */
|
||||
temp = weechat_string_replace (res, "$realname",
|
||||
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME));
|
||||
@@ -392,7 +392,7 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* return result */
|
||||
return res;
|
||||
}
|
||||
@@ -429,10 +429,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
struct t_infolist *infolist;
|
||||
struct t_infolist_item *item;
|
||||
char charset_modifier[256];
|
||||
|
||||
|
||||
if (!arguments || !arguments[0])
|
||||
return;
|
||||
|
||||
|
||||
if (strncmp (arguments, "SEND ", 5) == 0)
|
||||
{
|
||||
arguments += 5;
|
||||
@@ -441,7 +441,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
arguments++;
|
||||
}
|
||||
dcc_args = strdup (arguments);
|
||||
|
||||
|
||||
if (!dcc_args)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -451,14 +451,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
IRC_PLUGIN_NAME, "privmsg");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* DCC filename */
|
||||
pos_file = dcc_args;
|
||||
while (pos_file[0] == ' ')
|
||||
{
|
||||
pos_file++;
|
||||
}
|
||||
|
||||
|
||||
/* look for file size */
|
||||
pos_size = strrchr (pos_file, ' ');
|
||||
if (!pos_size)
|
||||
@@ -470,7 +470,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
free (dcc_args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pos = pos_size;
|
||||
pos_size++;
|
||||
while (pos[0] == ' ')
|
||||
@@ -478,7 +478,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* look for DCC port */
|
||||
pos_port = strrchr (pos_file, ' ');
|
||||
if (!pos_port)
|
||||
@@ -490,7 +490,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
free (dcc_args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pos = pos_port;
|
||||
pos_port++;
|
||||
while (pos[0] == ' ')
|
||||
@@ -498,7 +498,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* look for DCC IP address */
|
||||
pos_addr = strrchr (pos_file, ' ');
|
||||
if (!pos_addr)
|
||||
@@ -510,7 +510,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
free (dcc_args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pos = pos_addr;
|
||||
pos_addr++;
|
||||
while (pos[0] == ' ')
|
||||
@@ -518,10 +518,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* remove double quotes around filename */
|
||||
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
|
||||
|
||||
|
||||
/* add DCC file via xfer plugin */
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
@@ -548,14 +548,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_dcc",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
if (filename)
|
||||
free (filename);
|
||||
|
||||
|
||||
free (dcc_args);
|
||||
}
|
||||
else if (strncmp (arguments, "RESUME ", 7) == 0)
|
||||
@@ -566,7 +566,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
arguments++;
|
||||
}
|
||||
dcc_args = strdup (arguments);
|
||||
|
||||
|
||||
if (!dcc_args)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -576,14 +576,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
IRC_PLUGIN_NAME, "privmsg");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* DCC filename */
|
||||
pos_file = dcc_args;
|
||||
while (pos_file[0] == ' ')
|
||||
{
|
||||
pos_file++;
|
||||
}
|
||||
|
||||
|
||||
/* look for resume start position */
|
||||
pos_start_resume = strrchr (pos_file, ' ');
|
||||
if (!pos_start_resume)
|
||||
@@ -602,7 +602,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* look for DCC port */
|
||||
pos_port = strrchr (pos_file, ' ');
|
||||
if (!pos_port)
|
||||
@@ -621,10 +621,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* remove double quotes around filename */
|
||||
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
|
||||
|
||||
|
||||
/* accept resume via xfer plugin */
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
@@ -645,14 +645,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_dcc",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
if (filename)
|
||||
free (filename);
|
||||
|
||||
|
||||
free (dcc_args);
|
||||
}
|
||||
else if (strncmp (arguments, "ACCEPT ", 7) == 0)
|
||||
@@ -663,7 +663,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
arguments++;
|
||||
}
|
||||
dcc_args = strdup (arguments);
|
||||
|
||||
|
||||
if (!dcc_args)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -673,14 +673,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
"privmsg");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* DCC filename */
|
||||
pos_file = dcc_args;
|
||||
while (pos_file[0] == ' ')
|
||||
{
|
||||
pos_file++;
|
||||
}
|
||||
|
||||
|
||||
/* look for resume start position */
|
||||
pos_start_resume = strrchr (pos_file, ' ');
|
||||
if (!pos_start_resume)
|
||||
@@ -699,7 +699,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* look for DCC port */
|
||||
pos_port = strrchr (pos_file, ' ');
|
||||
if (!pos_port)
|
||||
@@ -718,10 +718,10 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
pos--;
|
||||
}
|
||||
pos[1] = '\0';
|
||||
|
||||
|
||||
/* remove double quotes around filename */
|
||||
filename = irc_ctcp_dcc_filename_without_quotes (pos_file);
|
||||
|
||||
|
||||
/* resume file via xfer plugin */
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
@@ -742,14 +742,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_dcc",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
if (filename)
|
||||
free (filename);
|
||||
|
||||
|
||||
free (dcc_args);
|
||||
}
|
||||
else if (strncmp (arguments, "CHAT ", 5) == 0)
|
||||
@@ -760,7 +760,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
arguments++;
|
||||
}
|
||||
dcc_args = strdup (arguments);
|
||||
|
||||
|
||||
if (!dcc_args)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -770,14 +770,14 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
"privmsg");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* CHAT type */
|
||||
pos_file = dcc_args;
|
||||
while (pos_file[0] == ' ')
|
||||
{
|
||||
pos_file++;
|
||||
}
|
||||
|
||||
|
||||
/* DCC IP address */
|
||||
pos_addr = strchr (pos_file, ' ');
|
||||
if (!pos_addr)
|
||||
@@ -795,7 +795,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
{
|
||||
pos_addr++;
|
||||
}
|
||||
|
||||
|
||||
/* look for DCC port */
|
||||
pos_port = strchr (pos_addr, ' ');
|
||||
if (!pos_port)
|
||||
@@ -813,7 +813,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
{
|
||||
pos_port++;
|
||||
}
|
||||
|
||||
|
||||
if (weechat_strcasecmp (pos_file, "chat") != 0)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
@@ -828,7 +828,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
free (dcc_args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* add DCC chat via xfer plugin */
|
||||
infolist = weechat_infolist_new ();
|
||||
if (infolist)
|
||||
@@ -854,11 +854,11 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
}
|
||||
weechat_infolist_free (infolist);
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_dcc",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
free (dcc_args);
|
||||
}
|
||||
}
|
||||
@@ -879,13 +879,13 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
int nick_is_me;
|
||||
|
||||
|
||||
while (arguments && arguments[0])
|
||||
{
|
||||
pos_end = strrchr (arguments + 1, '\01');
|
||||
if (pos_end)
|
||||
pos_end[0] = '\0';
|
||||
|
||||
|
||||
pos_args = NULL;
|
||||
pos_space = strchr (arguments + 1, ' ');
|
||||
if (pos_space)
|
||||
@@ -897,14 +897,14 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
pos_args++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* CTCP ACTION */
|
||||
if (strcmp (arguments + 1, "ACTION") == 0)
|
||||
{
|
||||
if (channel)
|
||||
{
|
||||
ptr_nick = irc_nick_search (channel, nick);
|
||||
|
||||
|
||||
irc_channel_nick_speaking_add (channel,
|
||||
nick,
|
||||
(pos_args) ?
|
||||
@@ -913,7 +913,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
irc_channel_nick_speaking_time_remove_old (channel);
|
||||
irc_channel_nick_speaking_time_add (channel, nick,
|
||||
time (NULL));
|
||||
|
||||
|
||||
weechat_printf_tags (channel->buffer,
|
||||
irc_protocol_tags (command,
|
||||
"irc_action,notify_message",
|
||||
@@ -948,7 +948,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
{
|
||||
if (!ptr_channel->topic)
|
||||
irc_channel_set_topic (ptr_channel, address);
|
||||
|
||||
|
||||
weechat_printf_tags (ptr_channel->buffer,
|
||||
irc_protocol_tags (command,
|
||||
(nick_is_me) ?
|
||||
@@ -994,7 +994,7 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
{
|
||||
irc_ctcp_display_request (server, command, channel, nick,
|
||||
arguments + 1, pos_args, reply);
|
||||
|
||||
|
||||
if (reply[0])
|
||||
{
|
||||
decoded_reply = irc_ctcp_replace_variables (server, reply);
|
||||
@@ -1028,17 +1028,17 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_ctcp",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
message);
|
||||
|
||||
|
||||
if (pos_space)
|
||||
pos_space[0] = ' ';
|
||||
|
||||
|
||||
if (pos_end)
|
||||
pos_end[0] = '\01';
|
||||
|
||||
|
||||
arguments = (pos_end) ? pos_end + 1 : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,23 +44,23 @@ irc_debug_signal_debug_dump_cb (void *data, const char *signal,
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, IRC_PLUGIN_NAME) == 0))
|
||||
{
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
|
||||
|
||||
irc_server_print_log ();
|
||||
irc_ignore_print_log ();
|
||||
irc_redirect_pattern_print_log ();
|
||||
|
||||
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
|
||||
weechat_plugin->name);
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ irc_display_hide_password (char *string, int look_for_nickserv)
|
||||
{
|
||||
char *pos_nickserv, *pos, *pos_pwd, *pos_space;
|
||||
int char_size;
|
||||
|
||||
|
||||
pos = string;
|
||||
while (pos)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ irc_display_hide_password (char *string, int look_for_nickserv)
|
||||
{
|
||||
pos_pwd++;
|
||||
}
|
||||
|
||||
|
||||
while (pos_pwd && pos_pwd[0] && (pos_pwd[0] != ' '))
|
||||
{
|
||||
char_size = weechat_utf8_char_size (pos_pwd);
|
||||
@@ -132,7 +132,7 @@ irc_display_away (struct t_irc_server *server, const char *string1,
|
||||
const char *string2)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
|
||||
@@ -46,17 +46,17 @@ int
|
||||
irc_ignore_valid (struct t_irc_ignore *ignore)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
if (!ignore)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
if (ptr_ignore == ignore)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* ignore not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -70,12 +70,12 @@ irc_ignore_search (const char *mask, const char *server, const char *channel)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
char any[2] = "*";
|
||||
|
||||
|
||||
if (!server)
|
||||
server = any;
|
||||
if (!channel)
|
||||
channel = any;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ irc_ignore_search (const char *mask, const char *server, const char *channel)
|
||||
return ptr_ignore;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ignore not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -99,14 +99,14 @@ struct t_irc_ignore *
|
||||
irc_ignore_search_by_number (int number)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
if (ptr_ignore->number == number)
|
||||
return ptr_ignore;
|
||||
}
|
||||
|
||||
|
||||
/* ignore not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -121,14 +121,14 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
struct t_irc_ignore *new_ignore;
|
||||
regex_t *regex;
|
||||
char *complete_mask;
|
||||
|
||||
|
||||
if (!mask || !mask[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
complete_mask = malloc (1 + strlen (mask) + 1 + 1);
|
||||
if (!complete_mask)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (mask[0] == '^')
|
||||
strcpy (complete_mask, mask);
|
||||
else
|
||||
@@ -145,14 +145,14 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
free (complete_mask);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (regcomp (regex, complete_mask, REG_NOSUB | REG_ICASE) != 0)
|
||||
{
|
||||
free (regex);
|
||||
free (complete_mask);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_ignore = malloc (sizeof (*new_ignore));
|
||||
if (new_ignore)
|
||||
{
|
||||
@@ -161,7 +161,7 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
new_ignore->regex_mask = regex;
|
||||
new_ignore->server = (server) ? strdup (server) : strdup ("*");
|
||||
new_ignore->channel = (channel) ? strdup (channel) : strdup ("*");
|
||||
|
||||
|
||||
/* add ignore to ignore list */
|
||||
new_ignore->prev_ignore = last_irc_ignore;
|
||||
if (irc_ignore_list)
|
||||
@@ -171,9 +171,9 @@ irc_ignore_new (const char *mask, const char *server, const char *channel)
|
||||
last_irc_ignore = new_ignore;
|
||||
new_ignore->next_ignore = NULL;
|
||||
}
|
||||
|
||||
|
||||
free (complete_mask);
|
||||
|
||||
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
@@ -190,29 +190,29 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
int server_match, channel_match;
|
||||
|
||||
|
||||
if (!server)
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* if nick is the same as server, then we will not ignore
|
||||
* (it is possible when connected to an irc proxy)
|
||||
*/
|
||||
if (nick && server->nick && (strcmp (server->nick, nick) == 0))
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
server_match = 0;
|
||||
channel_match = 0;
|
||||
|
||||
|
||||
if (!server || (strcmp (ptr_ignore->server, "*") == 0))
|
||||
server_match = 1;
|
||||
else
|
||||
server_match = (weechat_strcasecmp (ptr_ignore->server,
|
||||
server->name) == 0);
|
||||
|
||||
|
||||
if (!channel || (strcmp (ptr_ignore->channel, "*") == 0))
|
||||
channel_match = 1;
|
||||
else
|
||||
@@ -228,7 +228,7 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
|
||||
nick) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (server_match && channel_match)
|
||||
{
|
||||
if (nick && (regexec (ptr_ignore->regex_mask, nick, 0, NULL, 0) == 0))
|
||||
@@ -237,7 +237,7 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -249,17 +249,17 @@ void
|
||||
irc_ignore_free (struct t_irc_ignore *ignore)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_ignore_removing",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, ignore);
|
||||
|
||||
|
||||
/* decrement number for all ignore after this one */
|
||||
for (ptr_ignore = ignore->next_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
ptr_ignore->number--;
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
if (ignore->mask)
|
||||
free (ignore->mask);
|
||||
@@ -272,7 +272,7 @@ irc_ignore_free (struct t_irc_ignore *ignore)
|
||||
free (ignore->server);
|
||||
if (ignore->channel)
|
||||
free (ignore->channel);
|
||||
|
||||
|
||||
/* remove ignore from list */
|
||||
if (ignore->prev_ignore)
|
||||
(ignore->prev_ignore)->next_ignore = ignore->next_ignore;
|
||||
@@ -282,9 +282,9 @@ irc_ignore_free (struct t_irc_ignore *ignore)
|
||||
irc_ignore_list = ignore->next_ignore;
|
||||
if (last_irc_ignore == ignore)
|
||||
last_irc_ignore = ignore->prev_ignore;
|
||||
|
||||
|
||||
free (ignore);
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_ignore_removed",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
@@ -310,10 +310,10 @@ struct t_hdata *
|
||||
irc_ignore_hdata_ignore_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_ignore", "next_ignore");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -340,21 +340,21 @@ irc_ignore_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_ignore *ignore)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !ignore)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "mask", ignore->mask))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "server", ignore->server))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "channel", ignore->channel))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ void
|
||||
irc_ignore_print_log ()
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
|
||||
|
||||
for (ptr_ignore = irc_ignore_list; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
|
||||
@@ -56,5 +56,5 @@ extern struct t_hdata *irc_ignore_hdata_ignore_cb (void *data,
|
||||
extern int irc_ignore_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_ignore *ignore);
|
||||
extern void irc_ignore_print_log ();
|
||||
|
||||
|
||||
#endif /* __WEECHAT_IRC_IGNORE_H */
|
||||
|
||||
+24
-24
@@ -74,10 +74,10 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
static char str_true[2] = "1";
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (info_name, "irc_is_channel") == 0)
|
||||
{
|
||||
if (irc_channel_is_channel (arguments))
|
||||
@@ -118,7 +118,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
host = NULL;
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
|
||||
|
||||
pos_comma = strchr (arguments, ',');
|
||||
if (pos_comma)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
else
|
||||
server = strdup (arguments);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* replace channel by nick in host if channel is not a channel
|
||||
* (private ?)
|
||||
@@ -154,10 +154,10 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
nick = irc_message_get_nick_from_host (host);
|
||||
if (nick)
|
||||
channel = strdup (nick);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* search for server or channel buffer */
|
||||
if (server)
|
||||
{
|
||||
@@ -165,14 +165,14 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
if (ptr_server && channel)
|
||||
ptr_channel = irc_channel_search (ptr_server, channel);
|
||||
}
|
||||
|
||||
|
||||
if (server)
|
||||
free (server);
|
||||
if (channel)
|
||||
free (channel);
|
||||
if (host)
|
||||
free (host);
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
irc_info_create_string_with_pointer (&ptr_channel->buffer_as_string,
|
||||
@@ -227,7 +227,7 @@ irc_info_get_info_cb (void *data, const char *info_name,
|
||||
}
|
||||
return isupport_value;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -243,13 +243,13 @@ irc_info_get_info_hashtable_cb (void *data, const char *info_name,
|
||||
const char *server, *message;
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_hashtable *value;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (info_name, "irc_message_parse") == 0)
|
||||
{
|
||||
message = weechat_hashtable_get (hashtable, "message");
|
||||
@@ -270,7 +270,7 @@ irc_info_get_info_hashtable_cb (void *data, const char *info_name,
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -290,18 +290,18 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
struct t_irc_notify *ptr_notify;
|
||||
char **argv;
|
||||
int argc;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "irc_server") == 0)
|
||||
{
|
||||
if (pointer && !irc_server_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -367,7 +367,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (pointer && !irc_channel_valid (ptr_server, pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -441,7 +441,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (pointer && !irc_nick_valid (ptr_channel, pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -480,7 +480,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (pointer && !irc_ignore_valid (pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -514,7 +514,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (pointer && !irc_notify_valid (NULL, pointer))
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
@@ -553,7 +553,7 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ irc_info_init ()
|
||||
N_("value of feature, if supported by server (from IRC message 005)"),
|
||||
N_("server,feature"),
|
||||
&irc_info_get_info_cb, NULL);
|
||||
|
||||
|
||||
/* info_hashtable hooks */
|
||||
weechat_hook_info_hashtable ("irc_message_parse",
|
||||
N_("parse an IRC message"),
|
||||
@@ -622,7 +622,7 @@ irc_info_init ()
|
||||
"messages, "
|
||||
"\"count\": number of messages"),
|
||||
&irc_info_get_info_hashtable_cb, NULL);
|
||||
|
||||
|
||||
/* infolist hooks */
|
||||
weechat_hook_infolist ("irc_server",
|
||||
N_("list of IRC servers"),
|
||||
|
||||
+26
-26
@@ -46,19 +46,19 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
char *text_decoded;
|
||||
|
||||
|
||||
text_decoded = irc_color_decode (text,
|
||||
weechat_config_boolean (irc_config_network_colors_send));
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
ptr_nick = irc_nick_search (ptr_channel, ptr_server->nick);
|
||||
else
|
||||
ptr_nick = NULL;
|
||||
|
||||
|
||||
weechat_printf_tags (buffer,
|
||||
irc_protocol_tags ("privmsg",
|
||||
"notify_none,no_highlight",
|
||||
@@ -70,7 +70,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
|
||||
IRC_COLOR_CHAT_NICK_SELF),
|
||||
(text_decoded) ? text_decoded : text);
|
||||
}
|
||||
|
||||
|
||||
if (text_decoded)
|
||||
free (text_decoded);
|
||||
}
|
||||
@@ -89,12 +89,12 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
|
||||
int number;
|
||||
char hash_key[32], *str_args;
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
if (!ptr_server || !ptr_channel || !message || !message[0])
|
||||
return;
|
||||
|
||||
|
||||
if (!ptr_server->is_connected)
|
||||
{
|
||||
weechat_printf (buffer,
|
||||
@@ -132,9 +132,9 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
|
||||
{
|
||||
const char *ptr_data;
|
||||
char *data_with_colors, *msg;
|
||||
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
|
||||
if (buffer == irc_raw_buffer)
|
||||
{
|
||||
if (weechat_strcasecmp (input_data, "q") == 0)
|
||||
@@ -156,7 +156,7 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
ptr_data = weechat_string_input_for_buffer (input_data);
|
||||
@@ -164,14 +164,14 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
|
||||
ptr_data = input_data;
|
||||
data_with_colors = irc_color_encode (ptr_data,
|
||||
weechat_config_boolean (irc_config_network_colors_send));
|
||||
|
||||
|
||||
msg = strdup ((data_with_colors) ? data_with_colors : ptr_data);
|
||||
if (msg)
|
||||
{
|
||||
irc_input_send_user_message (buffer, flags, NULL, msg);
|
||||
free (msg);
|
||||
}
|
||||
|
||||
|
||||
if (data_with_colors)
|
||||
free (data_with_colors);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags)
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
return irc_input_data (buffer, input_data, IRC_SERVER_SEND_OUTQ_PRIO_HIGH);
|
||||
}
|
||||
|
||||
@@ -226,14 +226,14 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
|
||||
ptr_string = (const char *)signal_data;
|
||||
|
||||
|
||||
server = NULL;
|
||||
channel = NULL;
|
||||
flags = NULL;
|
||||
@@ -241,7 +241,7 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
ptr_message = NULL;
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
|
||||
|
||||
pos_semicol1 = strchr (ptr_string, ';');
|
||||
if (pos_semicol1)
|
||||
{
|
||||
@@ -278,7 +278,7 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
|
||||
if (flags)
|
||||
{
|
||||
@@ -287,7 +287,7 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
if (flags_value < 0)
|
||||
flags_value = IRC_SERVER_SEND_OUTQ_PRIO_HIGH;
|
||||
}
|
||||
|
||||
|
||||
if (server && ptr_message)
|
||||
{
|
||||
ptr_server = irc_server_search (server);
|
||||
@@ -300,10 +300,10 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
if (ptr_channel)
|
||||
ptr_buffer = ptr_channel->buffer;
|
||||
}
|
||||
|
||||
|
||||
/* set tags to use by default */
|
||||
irc_server_set_send_default_tags (tags);
|
||||
|
||||
|
||||
/* send text to buffer, or execute command */
|
||||
if (weechat_string_input_for_buffer (ptr_message))
|
||||
{
|
||||
@@ -320,12 +320,12 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
if (data_with_colors)
|
||||
free (data_with_colors);
|
||||
}
|
||||
|
||||
|
||||
/* reset tags to use by default */
|
||||
irc_server_set_send_default_tags (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (server)
|
||||
free (server);
|
||||
if (channel)
|
||||
@@ -334,6 +334,6 @@ irc_input_send_cb (void *data, const char *signal,
|
||||
free (flags);
|
||||
if (tags)
|
||||
free (tags);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ irc_message_parse (const char *message, char **nick, char **host,
|
||||
char **command, char **channel, char **arguments)
|
||||
{
|
||||
const char *pos, *pos2, *pos3, *pos4, *pos5;
|
||||
|
||||
|
||||
if (nick)
|
||||
*nick = NULL;
|
||||
if (host)
|
||||
@@ -52,10 +52,10 @@ irc_message_parse (const char *message, char **nick, char **host,
|
||||
*channel = NULL;
|
||||
if (arguments)
|
||||
*arguments = NULL;
|
||||
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
* we will use this message as example:
|
||||
* :FlashCode!n=FlashCod@host.com PRIVMSG #channel :hello!
|
||||
@@ -177,9 +177,9 @@ irc_message_parse_to_hashtable (const char *message)
|
||||
char *nick, *host, *command, *channel, *arguments;
|
||||
char empty_str[1] = { '\0' };
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
irc_message_parse (message, &nick, &host, &command, &channel, &arguments);
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -187,13 +187,13 @@ irc_message_parse_to_hashtable (const char *message)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
weechat_hashtable_set (hashtable, "nick", (nick) ? nick : empty_str);
|
||||
weechat_hashtable_set (hashtable, "host", (host) ? host : empty_str);
|
||||
weechat_hashtable_set (hashtable, "command", (command) ? command : empty_str);
|
||||
weechat_hashtable_set (hashtable, "channel", (channel) ? channel : empty_str);
|
||||
weechat_hashtable_set (hashtable, "arguments", (arguments) ? arguments : empty_str);
|
||||
|
||||
|
||||
if (nick)
|
||||
free (nick);
|
||||
if (host)
|
||||
@@ -204,7 +204,7 @@ irc_message_parse_to_hashtable (const char *message)
|
||||
free (channel);
|
||||
if (arguments)
|
||||
free (arguments);
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -218,10 +218,10 @@ irc_message_get_nick_from_host (const char *host)
|
||||
static char nick[128];
|
||||
char host2[128], *pos_space, *pos;
|
||||
const char *ptr_host;
|
||||
|
||||
|
||||
if (!host)
|
||||
return NULL;
|
||||
|
||||
|
||||
nick[0] = '\0';
|
||||
if (host)
|
||||
{
|
||||
@@ -238,10 +238,10 @@ irc_message_get_nick_from_host (const char *host)
|
||||
snprintf (host2, sizeof (host2), "%s", host);
|
||||
ptr_host = host2;
|
||||
}
|
||||
|
||||
|
||||
if (ptr_host[0] == ':')
|
||||
ptr_host++;
|
||||
|
||||
|
||||
pos = strchr (ptr_host, '!');
|
||||
if (pos && (pos - ptr_host < (int)sizeof (nick)))
|
||||
{
|
||||
@@ -253,7 +253,7 @@ irc_message_get_nick_from_host (const char *host)
|
||||
snprintf (nick, sizeof (nick), "%s", ptr_host);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nick;
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ irc_message_get_address_from_host (const char *host)
|
||||
static char address[256];
|
||||
char host2[256], *pos_space, *pos;
|
||||
const char *ptr_host;
|
||||
|
||||
|
||||
address[0] = '\0';
|
||||
if (host)
|
||||
{
|
||||
@@ -284,7 +284,7 @@ irc_message_get_address_from_host (const char *host)
|
||||
snprintf (host2, sizeof (host2), "%s", host);
|
||||
ptr_host = host2;
|
||||
}
|
||||
|
||||
|
||||
if (ptr_host[0] == ':')
|
||||
ptr_host++;
|
||||
pos = strchr (ptr_host, '!');
|
||||
@@ -293,7 +293,7 @@ irc_message_get_address_from_host (const char *host)
|
||||
else
|
||||
snprintf (address, sizeof (address), "%s", ptr_host);
|
||||
}
|
||||
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
@@ -310,31 +310,31 @@ irc_message_replace_vars (struct t_irc_server *server,
|
||||
char *var_nick, *var_channel, *var_server;
|
||||
char empty_string[1] = { '\0' };
|
||||
char *res, *temp;
|
||||
|
||||
|
||||
var_nick = (server && server->nick) ? server->nick : empty_string;
|
||||
var_channel = (channel) ? channel->name : empty_string;
|
||||
var_server = (server) ? server->name : empty_string;
|
||||
|
||||
|
||||
/* replace nick */
|
||||
temp = weechat_string_replace (string, "$nick", var_nick);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* replace channel */
|
||||
temp = weechat_string_replace (res, "$channel", var_channel);
|
||||
free (res);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* replace server */
|
||||
temp = weechat_string_replace (res, "$server", var_server);
|
||||
free (res);
|
||||
if (!temp)
|
||||
return NULL;
|
||||
res = temp;
|
||||
|
||||
|
||||
/* return result */
|
||||
return res;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ irc_message_split_add (struct t_hashtable *hashtable, int number,
|
||||
const char *message, const char *arguments)
|
||||
{
|
||||
char key[32], value[32];
|
||||
|
||||
|
||||
if (message)
|
||||
{
|
||||
snprintf (key, sizeof (key), "msg%d", number);
|
||||
@@ -398,7 +398,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
const char *pos, *pos_max, *pos_next, *pos_last_delim;
|
||||
char message[1024], *dup_arguments;
|
||||
int max_length, number;
|
||||
|
||||
|
||||
/*
|
||||
* Examples of arguments for this function:
|
||||
*
|
||||
@@ -420,7 +420,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
* arguments: "is eating"
|
||||
* suffix : "\01"
|
||||
*/
|
||||
|
||||
|
||||
max_length = 510;
|
||||
if (max_length_host >= 0)
|
||||
max_length -= max_length_host;
|
||||
@@ -433,10 +433,10 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
max_length -= strlen (prefix);
|
||||
if (suffix)
|
||||
max_length -= strlen (suffix);
|
||||
|
||||
|
||||
if (max_length < 2)
|
||||
return 0;
|
||||
|
||||
|
||||
/* debug message */
|
||||
if (weechat_irc_plugin->debug >= 2)
|
||||
{
|
||||
@@ -447,9 +447,9 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
host, command, target, prefix, arguments, suffix,
|
||||
max_length);
|
||||
}
|
||||
|
||||
|
||||
number = 1;
|
||||
|
||||
|
||||
if (!arguments || !arguments[0])
|
||||
{
|
||||
snprintf (message, sizeof (message), "%s%s%s %s%s%s%s",
|
||||
@@ -463,7 +463,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
irc_message_split_add (hashtable, 1, message, "");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
while (arguments && arguments[0])
|
||||
{
|
||||
pos = arguments;
|
||||
@@ -498,7 +498,7 @@ irc_message_split_string (struct t_hashtable *hashtable,
|
||||
}
|
||||
arguments = (pos == pos_last_delim) ? pos + 1 : pos;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -516,14 +516,14 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
int length_to_add, index_channel;
|
||||
char **channels, **keys, *pos, *str;
|
||||
char msg_to_send[2048], keys_to_add[2048];
|
||||
|
||||
|
||||
number = 1;
|
||||
|
||||
|
||||
channels = NULL;
|
||||
channels_count = 0;
|
||||
keys = NULL;
|
||||
keys_count = 0;
|
||||
|
||||
|
||||
pos = strchr (arguments, ' ');
|
||||
if (pos)
|
||||
{
|
||||
@@ -543,7 +543,7 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
{
|
||||
channels = weechat_string_split (arguments, ",", 0, 0, &channels_count);
|
||||
}
|
||||
|
||||
|
||||
snprintf (msg_to_send, sizeof (msg_to_send), "%s%sJOIN",
|
||||
(host) ? host : "",
|
||||
(host) ? " " : "");
|
||||
@@ -589,7 +589,7 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
keys_to_add[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (length > length_no_channel)
|
||||
{
|
||||
strcat (msg_to_send, keys_to_add);
|
||||
@@ -597,12 +597,12 @@ irc_message_split_join (struct t_hashtable *hashtable,
|
||||
msg_to_send,
|
||||
msg_to_send + length_no_channel + 1);
|
||||
}
|
||||
|
||||
|
||||
if (channels)
|
||||
weechat_string_free_split (channels);
|
||||
if (keys)
|
||||
weechat_string_free_split (keys);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
|
||||
{
|
||||
char prefix[512], suffix[2], *pos, saved_char;
|
||||
int length, rc;
|
||||
|
||||
|
||||
/*
|
||||
* message sent looks like:
|
||||
* PRIVMSG #channel :hello world!
|
||||
@@ -628,7 +628,7 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
|
||||
* when IRC server sends message to other people, message looks like:
|
||||
* :nick!user@host.com PRIVMSG #channel :hello world!
|
||||
*/
|
||||
|
||||
|
||||
/* for CTCP, prefix will be ":\01xxxx " and suffix "\01" */
|
||||
prefix[0] = '\0';
|
||||
suffix[0] = '\0';
|
||||
@@ -652,11 +652,11 @@ irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
|
||||
}
|
||||
if (!prefix[0])
|
||||
strcpy (prefix, ":");
|
||||
|
||||
|
||||
rc = irc_message_split_string (hashtable, host, command, target,
|
||||
prefix, arguments, suffix,
|
||||
' ', max_length_host);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -670,7 +670,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
|
||||
char *host, char *command, char *target, char *arguments)
|
||||
{
|
||||
char *pos, suffix[512];
|
||||
|
||||
|
||||
/*
|
||||
* 005 message looks like:
|
||||
* :server 005 mynick MODES=4 CHANLIMIT=#:20 NICKLEN=16 USERLEN=10
|
||||
@@ -678,7 +678,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
|
||||
* CHANTYPES=# PREFIX=(ov)@+ CASEMAPPING=ascii CAPAB IRCD=dancer
|
||||
* :are available on this server
|
||||
*/
|
||||
|
||||
|
||||
/* search suffix */
|
||||
suffix[0] = '\0';
|
||||
pos = strstr (arguments, " :");
|
||||
@@ -687,7 +687,7 @@ irc_message_split_005 (struct t_hashtable *hashtable,
|
||||
snprintf (suffix, sizeof (suffix), "%s", pos);
|
||||
pos[0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
return irc_message_split_string (hashtable, host, command, target,
|
||||
NULL, arguments, suffix, ' ', -1);
|
||||
}
|
||||
@@ -713,7 +713,7 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
struct t_hashtable *hashtable;
|
||||
char **argv, **argv_eol, *host, *command, *arguments, target[512];
|
||||
int split_ok, argc, index_args, max_length_nick, max_length_host;
|
||||
|
||||
|
||||
split_ok = 0;
|
||||
host = NULL;
|
||||
command = NULL;
|
||||
@@ -721,11 +721,11 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
index_args = 0;
|
||||
argv = NULL;
|
||||
argv_eol = NULL;
|
||||
|
||||
|
||||
/* debug message */
|
||||
if (weechat_irc_plugin->debug >= 2)
|
||||
weechat_printf (NULL, "irc_message_split: message='%s'", message);
|
||||
|
||||
|
||||
hashtable = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
@@ -733,16 +733,16 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!message || !message[0])
|
||||
goto end;
|
||||
|
||||
|
||||
argv = weechat_string_split (message, " ", 0, 0, &argc);
|
||||
argv_eol = weechat_string_split (message, " ", 2, 0, NULL);
|
||||
|
||||
|
||||
if (argc < 2)
|
||||
goto end;
|
||||
|
||||
|
||||
if (argv[0][0] == ':')
|
||||
{
|
||||
if (argc < 3)
|
||||
@@ -758,7 +758,7 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
arguments = argv_eol[1];
|
||||
index_args = 1;
|
||||
}
|
||||
|
||||
|
||||
max_length_nick = (server && (server->nick_max_length > 0)) ?
|
||||
server->nick_max_length : 16;
|
||||
max_length_host = 1 + /* ":" */
|
||||
@@ -841,18 +841,18 @@ irc_message_split (struct t_irc_server *server, const char *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (!split_ok
|
||||
|| (weechat_hashtable_get_integer (hashtable, "items_count") == 0))
|
||||
{
|
||||
irc_message_split_add (hashtable, 1, message, arguments);
|
||||
}
|
||||
|
||||
|
||||
if (argv)
|
||||
weechat_string_free_split (argv);
|
||||
if (argv_eol)
|
||||
weechat_string_free_split (argv_eol);
|
||||
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ irc_mode_channel_set (struct t_irc_server *server,
|
||||
char *pos_args, *str_modes, set_flag, **argv, *pos, *ptr_arg;
|
||||
int modes_count, channel_modes_updated, argc, current_arg;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!server || !channel || !modes)
|
||||
return 0;
|
||||
|
||||
|
||||
channel_modes_updated = 0;
|
||||
|
||||
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
pos_args = strchr (modes, ' ');
|
||||
@@ -85,7 +85,7 @@ irc_mode_channel_set (struct t_irc_server *server,
|
||||
pos++;
|
||||
}
|
||||
current_arg = argc - modes_count;
|
||||
|
||||
|
||||
if (str_modes && str_modes[0])
|
||||
{
|
||||
set_flag = '+';
|
||||
@@ -158,14 +158,14 @@ irc_mode_channel_set (struct t_irc_server *server,
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (str_modes)
|
||||
free (str_modes);
|
||||
if (argv)
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
|
||||
|
||||
return channel_modes_updated;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
|
||||
|
||||
str_mode[0] = mode;
|
||||
str_mode[1] = '\0';
|
||||
|
||||
|
||||
if (server->nick_modes)
|
||||
{
|
||||
if (!strchr (server->nick_modes, mode))
|
||||
@@ -218,7 +218,7 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
|
||||
{
|
||||
char *pos, *nick_modes2;
|
||||
int new_size;
|
||||
|
||||
|
||||
if (server->nick_modes)
|
||||
{
|
||||
pos = strchr (server->nick_modes, mode);
|
||||
|
||||
@@ -50,7 +50,7 @@ irc_msgbuffer_get_option (struct t_irc_server *server, const char *message)
|
||||
{
|
||||
snprintf (option_name, sizeof (option_name),
|
||||
"%s.%s", server->name, message);
|
||||
|
||||
|
||||
/* search for msgbuffer in config file, for server */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_msgbuffer,
|
||||
@@ -58,14 +58,14 @@ irc_msgbuffer_get_option (struct t_irc_server *server, const char *message)
|
||||
if (ptr_option)
|
||||
return ptr_option;
|
||||
}
|
||||
|
||||
|
||||
/* search for msgbuffer in config file */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_msgbuffer,
|
||||
message);
|
||||
if (ptr_option)
|
||||
return ptr_option;
|
||||
|
||||
|
||||
/* no msgbuffer found in config */
|
||||
return NULL;
|
||||
}
|
||||
@@ -92,18 +92,18 @@ irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick,
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_weechat_plugin *buffer_plugin;
|
||||
|
||||
|
||||
ptr_option = irc_msgbuffer_get_option (server, message);
|
||||
if (!ptr_option && alias && alias[0])
|
||||
ptr_option = irc_msgbuffer_get_option (server, alias);
|
||||
|
||||
|
||||
if (!ptr_option)
|
||||
{
|
||||
if (default_buffer)
|
||||
return default_buffer;
|
||||
return (server) ? server->buffer : NULL;
|
||||
}
|
||||
|
||||
|
||||
target = weechat_config_integer (ptr_option);
|
||||
switch (target)
|
||||
{
|
||||
@@ -129,11 +129,11 @@ irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick,
|
||||
return (server) ? server->buffer : NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
ptr_buffer = weechat_current_buffer ();
|
||||
buffer_plugin = weechat_buffer_get_pointer (ptr_buffer, "plugin");
|
||||
if (buffer_plugin == weechat_irc_plugin)
|
||||
return ptr_buffer;
|
||||
|
||||
|
||||
return (server) ? server->buffer : NULL;
|
||||
}
|
||||
|
||||
+92
-92
@@ -47,16 +47,16 @@ int
|
||||
irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!channel)
|
||||
return 0;
|
||||
|
||||
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (ptr_nick == nick)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* nick not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -71,22 +71,22 @@ int
|
||||
irc_nick_is_nick (const char *string)
|
||||
{
|
||||
const char *ptr;
|
||||
|
||||
|
||||
if (!string || !string[0])
|
||||
return 0;
|
||||
|
||||
|
||||
/* first char must not be a number or hyphen */
|
||||
ptr = string;
|
||||
if (strchr ("0123456789-", *ptr))
|
||||
return 0;
|
||||
|
||||
|
||||
while (ptr && ptr[0])
|
||||
{
|
||||
if (!strchr (IRC_NICK_VALID_CHARS, *ptr))
|
||||
return 0;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ irc_nick_strdup_for_color (const char *nickname)
|
||||
{
|
||||
int char_size, other_char_seen;
|
||||
char *result, *pos, utf_char[16];
|
||||
|
||||
|
||||
result = malloc (strlen (nickname) + 1);
|
||||
pos = result;
|
||||
other_char_seen = 0;
|
||||
@@ -109,7 +109,7 @@ irc_nick_strdup_for_color (const char *nickname)
|
||||
char_size = weechat_utf8_char_size (nickname);
|
||||
memcpy (utf_char, nickname, char_size);
|
||||
utf_char[char_size] = '\0';
|
||||
|
||||
|
||||
if (strstr (weechat_config_string (irc_config_look_nick_color_stop_chars),
|
||||
utf_char))
|
||||
{
|
||||
@@ -125,7 +125,7 @@ irc_nick_strdup_for_color (const char *nickname)
|
||||
}
|
||||
memcpy (pos, utf_char, char_size);
|
||||
pos += char_size;
|
||||
|
||||
|
||||
nickname += char_size;
|
||||
}
|
||||
pos[0] = '\0';
|
||||
@@ -141,13 +141,13 @@ irc_nick_hash_color (const char *nickname)
|
||||
{
|
||||
int color;
|
||||
const char *ptr_nick;
|
||||
|
||||
|
||||
if (!irc_config_nick_colors)
|
||||
irc_config_set_nick_colors ();
|
||||
|
||||
|
||||
if (irc_config_num_nick_colors == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
color = 0;
|
||||
ptr_nick = nickname;
|
||||
while (ptr_nick && ptr_nick[0])
|
||||
@@ -155,7 +155,7 @@ irc_nick_hash_color (const char *nickname)
|
||||
color += weechat_utf8_char_int (ptr_nick);
|
||||
ptr_nick = weechat_utf8_next_char (ptr_nick);
|
||||
}
|
||||
|
||||
|
||||
return (color % irc_config_num_nick_colors);
|
||||
}
|
||||
|
||||
@@ -170,15 +170,15 @@ irc_nick_find_color (const char *nickname)
|
||||
int color;
|
||||
char *nickname2;
|
||||
const char *forced_color, *str_color;
|
||||
|
||||
|
||||
if (!irc_config_nick_colors)
|
||||
irc_config_set_nick_colors ();
|
||||
|
||||
|
||||
if (irc_config_num_nick_colors == 0)
|
||||
return weechat_color ("default");
|
||||
|
||||
|
||||
nickname2 = irc_nick_strdup_for_color (nickname);
|
||||
|
||||
|
||||
/* look if color is forced */
|
||||
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
|
||||
(nickname2) ? nickname2 : nickname);
|
||||
@@ -192,12 +192,12 @@ irc_nick_find_color (const char *nickname)
|
||||
return forced_color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* hash nickname to get color */
|
||||
color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
|
||||
if (nickname2)
|
||||
free (nickname2);
|
||||
|
||||
|
||||
/* return color */
|
||||
str_color = weechat_color (irc_config_nick_colors[color]);
|
||||
return (str_color[0]) ? str_color : weechat_color("default");
|
||||
@@ -215,15 +215,15 @@ irc_nick_find_color_name (const char *nickname)
|
||||
char *nickname2;
|
||||
const char *forced_color;
|
||||
static char *default_color = "default";
|
||||
|
||||
|
||||
if (!irc_config_nick_colors)
|
||||
irc_config_set_nick_colors ();
|
||||
|
||||
|
||||
if (irc_config_num_nick_colors == 0)
|
||||
return default_color;
|
||||
|
||||
|
||||
nickname2 = irc_nick_strdup_for_color (nickname);
|
||||
|
||||
|
||||
/* look if color is forced */
|
||||
forced_color = weechat_hashtable_get (irc_config_hashtable_nick_color_force,
|
||||
(nickname2) ? nickname2 : nickname);
|
||||
@@ -233,12 +233,12 @@ irc_nick_find_color_name (const char *nickname)
|
||||
free (nickname2);
|
||||
return forced_color;
|
||||
}
|
||||
|
||||
|
||||
/* hash nickname to get color */
|
||||
color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname);
|
||||
if (nickname2)
|
||||
free (nickname2);
|
||||
|
||||
|
||||
/* return color name */
|
||||
return irc_config_nick_colors[color];
|
||||
}
|
||||
@@ -252,7 +252,7 @@ void
|
||||
irc_nick_set_current_prefix (struct t_irc_nick *nick)
|
||||
{
|
||||
char *ptr_prefixes;
|
||||
|
||||
|
||||
nick->prefix[0] = ' ';
|
||||
for (ptr_prefixes = nick->prefixes; ptr_prefixes[0]; ptr_prefixes++)
|
||||
{
|
||||
@@ -275,7 +275,7 @@ irc_nick_set_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
int set, char prefix)
|
||||
{
|
||||
int index;
|
||||
|
||||
|
||||
index = irc_server_get_prefix_char_index (server, prefix);
|
||||
if (index >= 0)
|
||||
{
|
||||
@@ -293,10 +293,10 @@ irc_nick_set_prefixes (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
const char *prefixes)
|
||||
{
|
||||
const char *ptr_prefixes;
|
||||
|
||||
|
||||
/* reset all prefixes in nick */
|
||||
memset (nick->prefixes, ' ', strlen (nick->prefixes));
|
||||
|
||||
|
||||
/* add prefixes in nick */
|
||||
if (prefixes)
|
||||
{
|
||||
@@ -305,7 +305,7 @@ irc_nick_set_prefixes (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
irc_nick_set_prefix (server, nick, 1, ptr_prefixes[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* set current prefix */
|
||||
irc_nick_set_current_prefix (nick);
|
||||
}
|
||||
@@ -319,14 +319,14 @@ int
|
||||
irc_nick_is_op (struct t_irc_server *server, struct t_irc_nick *nick)
|
||||
{
|
||||
int index;
|
||||
|
||||
|
||||
if (nick->prefix[0] == ' ')
|
||||
return 0;
|
||||
|
||||
|
||||
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
|
||||
if (index < 0)
|
||||
return 0;
|
||||
|
||||
|
||||
return (index <= irc_server_get_prefix_mode_index (server, 'o')) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -342,11 +342,11 @@ irc_nick_has_prefix_mode (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
char prefix_mode)
|
||||
{
|
||||
char prefix_char;
|
||||
|
||||
|
||||
prefix_char = irc_server_get_prefix_char_for_mode (server, prefix_mode);
|
||||
if (prefix_char == ' ')
|
||||
return 0;
|
||||
|
||||
|
||||
return (strchr (nick->prefixes, prefix_char)) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -363,10 +363,10 @@ irc_nick_get_nicklist_group (struct t_irc_server *server,
|
||||
char str_group[2];
|
||||
const char *prefix_modes;
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
if (!server || !buffer || !nick)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr_group = NULL;
|
||||
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
|
||||
if (index < 0)
|
||||
@@ -381,7 +381,7 @@ irc_nick_get_nicklist_group (struct t_irc_server *server,
|
||||
str_group[1] = '\0';
|
||||
ptr_group = weechat_nicklist_search_group (buffer, NULL, str_group);
|
||||
}
|
||||
|
||||
|
||||
return ptr_group;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ irc_nick_get_prefix_color_name (struct t_irc_server *server,
|
||||
const char *prefix_modes, *color;
|
||||
char mode[2];
|
||||
int i, index;
|
||||
|
||||
|
||||
if (irc_config_hashtable_nick_prefixes)
|
||||
{
|
||||
index = irc_server_get_prefix_char_index (server, nick->prefix[0]);
|
||||
@@ -425,7 +425,7 @@ irc_nick_get_prefix_color_name (struct t_irc_server *server,
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* no color by default */
|
||||
return default_color;
|
||||
}
|
||||
@@ -441,10 +441,10 @@ irc_nick_get_color_for_nicklist (struct t_irc_server *server,
|
||||
static char *nick_color_bar_fg = "bar_fg";
|
||||
static char *nick_color_self = "weechat.color.chat_nick_self";
|
||||
static char *nick_color_away = "weechat.color.nicklist_away";
|
||||
|
||||
|
||||
if (nick->away)
|
||||
return nick_color_away;
|
||||
|
||||
|
||||
if (weechat_config_boolean(irc_config_look_color_nicks_in_nicklist))
|
||||
{
|
||||
if (weechat_strcasecmp (nick->name, server->nick) == 0)
|
||||
@@ -452,7 +452,7 @@ irc_nick_get_color_for_nicklist (struct t_irc_server *server,
|
||||
else
|
||||
return irc_nick_find_color_name (nick->name);
|
||||
}
|
||||
|
||||
|
||||
return nick_color_bar_fg;
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ irc_nick_nicklist_add (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick);
|
||||
weechat_nicklist_add_nick (channel->buffer, ptr_group,
|
||||
nick->name,
|
||||
@@ -486,7 +486,7 @@ irc_nick_nicklist_remove (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_gui_nick_group *ptr_group;
|
||||
|
||||
|
||||
ptr_group = irc_nick_get_nicklist_group (server, channel->buffer, nick);
|
||||
weechat_nicklist_remove_nick (channel->buffer,
|
||||
weechat_nicklist_search_nick (channel->buffer,
|
||||
@@ -523,7 +523,7 @@ irc_nick_nicklist_set_prefix_color_all ()
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -552,7 +552,7 @@ irc_nick_nicklist_set_color_all ()
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -580,28 +580,28 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
{
|
||||
struct t_irc_nick *new_nick, *ptr_nick;
|
||||
int length;
|
||||
|
||||
|
||||
/* nick already exists on this channel? */
|
||||
ptr_nick = irc_nick_search (channel, nickname);
|
||||
if (ptr_nick)
|
||||
{
|
||||
/* remove old nick from nicklist */
|
||||
irc_nick_nicklist_remove (server, channel, ptr_nick);
|
||||
|
||||
|
||||
/* update nick */
|
||||
irc_nick_set_prefixes (server, ptr_nick, prefixes);
|
||||
ptr_nick->away = away;
|
||||
|
||||
|
||||
/* add new nick in nicklist */
|
||||
irc_nick_nicklist_add (server, channel, ptr_nick);
|
||||
|
||||
|
||||
return ptr_nick;
|
||||
}
|
||||
|
||||
|
||||
/* alloc memory for new nick */
|
||||
if ((new_nick = malloc (sizeof (*new_nick))) == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* initialize new nick */
|
||||
new_nick->name = strdup (nickname);
|
||||
new_nick->host = NULL;
|
||||
@@ -620,7 +620,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
new_nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
|
||||
else
|
||||
new_nick->color = strdup (irc_nick_find_color (new_nick->name));
|
||||
|
||||
|
||||
/* add nick to end of list */
|
||||
new_nick->prev_nick = channel->last_nick;
|
||||
if (channel->nicks)
|
||||
@@ -629,14 +629,14 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
channel->nicks = new_nick;
|
||||
channel->last_nick = new_nick;
|
||||
new_nick->next_nick = NULL;
|
||||
|
||||
|
||||
channel->nicks_count++;
|
||||
|
||||
|
||||
channel->nick_completion_reset = 1;
|
||||
|
||||
|
||||
/* add nick to buffer nicklist */
|
||||
irc_nick_nicklist_add (server, channel, new_nick);
|
||||
|
||||
|
||||
/* all is ok, return address of new nick */
|
||||
return new_nick;
|
||||
}
|
||||
@@ -650,15 +650,15 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick, const char *new_nick)
|
||||
{
|
||||
int nick_is_me;
|
||||
|
||||
|
||||
/* remove nick from nicklist */
|
||||
irc_nick_nicklist_remove (server, channel, nick);
|
||||
|
||||
|
||||
/* update nicks speaking */
|
||||
nick_is_me = (strcmp (nick->name, server->nick) == 0) ? 1 : 0;
|
||||
if (!nick_is_me)
|
||||
irc_channel_nick_speaking_rename (channel, nick->name, new_nick);
|
||||
|
||||
|
||||
/* change nickname */
|
||||
if (nick->name)
|
||||
free (nick->name);
|
||||
@@ -669,7 +669,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
nick->color = strdup (IRC_COLOR_CHAT_NICK_SELF);
|
||||
else
|
||||
nick->color = strdup (irc_nick_find_color (nick->name));
|
||||
|
||||
|
||||
/* add nick in nicklist */
|
||||
irc_nick_nicklist_add (server, channel, nick);
|
||||
}
|
||||
@@ -684,21 +684,21 @@ irc_nick_set_mode (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
{
|
||||
int index;
|
||||
const char *prefix_chars;
|
||||
|
||||
|
||||
index = irc_server_get_prefix_mode_index (server, mode);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
|
||||
/* remove nick from nicklist */
|
||||
irc_nick_nicklist_remove (server, channel, nick);
|
||||
|
||||
|
||||
/* set flag */
|
||||
prefix_chars = irc_server_get_prefix_chars (server);
|
||||
irc_nick_set_prefix (server, nick, set, prefix_chars[index]);
|
||||
|
||||
|
||||
/* add nick in nicklist */
|
||||
irc_nick_nicklist_add (server, channel, nick);
|
||||
|
||||
|
||||
if (strcmp (nick->name, server->nick) == 0)
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
@@ -712,13 +712,13 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_irc_nick *new_nicks;
|
||||
|
||||
|
||||
if (!channel || !nick)
|
||||
return;
|
||||
|
||||
|
||||
/* remove nick from nicklist */
|
||||
irc_nick_nicklist_remove (server, channel, nick);
|
||||
|
||||
|
||||
/* remove nick */
|
||||
if (channel->last_nick == nick)
|
||||
channel->last_nick = nick->prev_nick;
|
||||
@@ -729,12 +729,12 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
}
|
||||
else
|
||||
new_nicks = nick->next_nick;
|
||||
|
||||
|
||||
if (nick->next_nick)
|
||||
(nick->next_nick)->prev_nick = nick->prev_nick;
|
||||
|
||||
|
||||
channel->nicks_count--;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (nick->name)
|
||||
free (nick->name);
|
||||
@@ -744,9 +744,9 @@ irc_nick_free (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
free (nick->prefixes);
|
||||
if (nick->color)
|
||||
free (nick->color);
|
||||
|
||||
|
||||
free (nick);
|
||||
|
||||
|
||||
channel->nicks = new_nicks;
|
||||
channel->nick_completion_reset = 1;
|
||||
}
|
||||
@@ -760,13 +760,13 @@ irc_nick_free_all (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
{
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
|
||||
/* remove all nicks for the channel */
|
||||
while (channel->nicks)
|
||||
{
|
||||
irc_nick_free (server, channel, channel->nicks);
|
||||
}
|
||||
|
||||
|
||||
/* sould be zero, but prevent any bug :D */
|
||||
channel->nicks_count = 0;
|
||||
}
|
||||
@@ -779,17 +779,17 @@ struct t_irc_nick *
|
||||
irc_nick_search (struct t_irc_channel *channel, const char *nickname)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
if (!channel || !nickname)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_nick = channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (weechat_strcasecmp (ptr_nick->name, nickname) == 0)
|
||||
return ptr_nick;
|
||||
}
|
||||
|
||||
|
||||
/* nick not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -804,7 +804,7 @@ irc_nick_count (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
int *count_normal)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
|
||||
(*total) = 0;
|
||||
(*count_op) = 0;
|
||||
(*count_halfop) = 0;
|
||||
@@ -865,7 +865,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
static char result[256];
|
||||
char prefix[2];
|
||||
const char *str_prefix_color;
|
||||
|
||||
|
||||
prefix[0] = (nick) ? nick->prefix[0] : '\0';
|
||||
prefix[1] = '\0';
|
||||
if (weechat_config_boolean (weechat_config_get ("weechat.look.nickmode")))
|
||||
@@ -889,7 +889,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
prefix[0] = '\0';
|
||||
str_prefix_color = IRC_COLOR_RESET;
|
||||
}
|
||||
|
||||
|
||||
snprintf (result, sizeof (result), "%s%s%s%s%s%s%s%s\t",
|
||||
(weechat_config_string (irc_config_look_nick_prefix)
|
||||
&& weechat_config_string (irc_config_look_nick_prefix)[0]) ?
|
||||
@@ -907,7 +907,7 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
(weechat_config_string (irc_config_look_nick_suffix)
|
||||
&& weechat_config_string (irc_config_look_nick_suffix)[0]) ?
|
||||
weechat_config_string (irc_config_look_nick_suffix) : "");
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -925,7 +925,7 @@ irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname)
|
||||
if (channel->pv_remote_nick_color)
|
||||
return channel->pv_remote_nick_color;
|
||||
}
|
||||
|
||||
|
||||
return IRC_COLOR_CHAT_NICK_OTHER;
|
||||
}
|
||||
|
||||
@@ -937,10 +937,10 @@ struct t_hdata *
|
||||
irc_nick_hdata_nick_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_nick", "next_nick");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -966,14 +966,14 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_nick *nick)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !nick)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "name", nick->name))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "host", nick->host))
|
||||
@@ -986,7 +986,7 @@ irc_nick_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "color", nick->color))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ irc_notify_valid (struct t_irc_server *server, struct t_irc_notify *notify)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
if (!notify)
|
||||
return 0;
|
||||
|
||||
@@ -82,7 +82,7 @@ irc_notify_valid (struct t_irc_server *server, struct t_irc_notify *notify)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* notify not found */
|
||||
return 0;
|
||||
}
|
||||
@@ -95,17 +95,17 @@ struct t_irc_notify *
|
||||
irc_notify_search (struct t_irc_server *server, const char *nick)
|
||||
{
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
if (!server || !nick)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_notify = server->notify_list; ptr_notify;
|
||||
ptr_notify = ptr_notify->next_notify)
|
||||
{
|
||||
if (strcmp (ptr_notify->nick, nick) == 0)
|
||||
return ptr_notify;
|
||||
}
|
||||
|
||||
|
||||
/* notify not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ irc_notify_set_server_option (struct t_irc_server *server)
|
||||
char *str, *str2;
|
||||
struct t_irc_notify *ptr_notify;
|
||||
int total_length, length;
|
||||
|
||||
|
||||
if (!server)
|
||||
return;
|
||||
|
||||
@@ -183,10 +183,10 @@ struct t_irc_notify *
|
||||
irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
|
||||
{
|
||||
struct t_irc_notify *new_notify;
|
||||
|
||||
|
||||
if (!server || !nick || !nick[0])
|
||||
return NULL;
|
||||
|
||||
|
||||
new_notify = malloc (sizeof (*new_notify));
|
||||
if (new_notify)
|
||||
{
|
||||
@@ -196,7 +196,7 @@ irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
|
||||
new_notify->is_on_server = 0;
|
||||
new_notify->away_message = NULL;
|
||||
new_notify->ison_received = 0;
|
||||
|
||||
|
||||
/* add notify to notify list on server */
|
||||
new_notify->prev_notify = server->last_notify;
|
||||
if (server->notify_list)
|
||||
@@ -206,7 +206,7 @@ irc_notify_new (struct t_irc_server *server, const char *nick, int check_away)
|
||||
server->last_notify = new_notify;
|
||||
new_notify->next_notify = NULL;
|
||||
}
|
||||
|
||||
|
||||
return new_notify;
|
||||
}
|
||||
|
||||
@@ -221,14 +221,14 @@ irc_notify_new_for_server (struct t_irc_server *server)
|
||||
const char *notify;
|
||||
char **items, *pos_params, **params;
|
||||
int i, j, num_items, num_params, check_away;
|
||||
|
||||
|
||||
irc_notify_free_all (server);
|
||||
|
||||
|
||||
notify = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_NOTIFY);
|
||||
|
||||
|
||||
if (!notify || !notify[0])
|
||||
return;
|
||||
|
||||
|
||||
items = weechat_string_split (notify, ",", 0, 0, &num_items);
|
||||
|
||||
if (items)
|
||||
@@ -272,7 +272,7 @@ void
|
||||
irc_notify_new_for_all_servers ()
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -289,13 +289,13 @@ irc_notify_free (struct t_irc_server *server, struct t_irc_notify *notify)
|
||||
{
|
||||
weechat_hook_signal_send ("irc_notify_removing",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, notify);
|
||||
|
||||
|
||||
/* free data */
|
||||
if (notify->nick)
|
||||
free (notify->nick);
|
||||
if (notify->away_message)
|
||||
free (notify->away_message);
|
||||
|
||||
|
||||
/* remove notify from list */
|
||||
if (notify->prev_notify)
|
||||
(notify->prev_notify)->next_notify = notify->next_notify;
|
||||
@@ -305,9 +305,9 @@ irc_notify_free (struct t_irc_server *server, struct t_irc_notify *notify)
|
||||
server->notify_list = notify->next_notify;
|
||||
if (server->last_notify == notify)
|
||||
server->last_notify = notify->prev_notify;
|
||||
|
||||
|
||||
free (notify);
|
||||
|
||||
|
||||
weechat_hook_signal_send ("irc_notify_removed",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
@@ -436,13 +436,13 @@ irc_notify_get_tags (struct t_config_option *option)
|
||||
{
|
||||
static char string[1024];
|
||||
const char *tags;
|
||||
|
||||
|
||||
tags = weechat_config_string (option);
|
||||
|
||||
|
||||
snprintf (string, sizeof (string), "irc_notify%s%s",
|
||||
(tags && tags[0]) ? "," : "",
|
||||
(tags && tags[0]) ? tags : "");
|
||||
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -457,11 +457,11 @@ irc_notify_set_is_on_server (struct t_irc_notify *notify,
|
||||
{
|
||||
if (!notify)
|
||||
return;
|
||||
|
||||
|
||||
/* same status, then do nothing */
|
||||
if (notify->is_on_server == is_on_server)
|
||||
return;
|
||||
|
||||
|
||||
notify->is_on_server = is_on_server;
|
||||
|
||||
weechat_printf_tags (notify->server->buffer,
|
||||
@@ -489,13 +489,13 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
|
||||
{
|
||||
if (!notify)
|
||||
return;
|
||||
|
||||
|
||||
/* same away message, then do nothing */
|
||||
if ((!notify->away_message && !away_message)
|
||||
|| (notify->away_message && away_message
|
||||
&& (strcmp (notify->away_message, away_message) == 0)))
|
||||
return;
|
||||
|
||||
|
||||
if (!notify->away_message && away_message)
|
||||
{
|
||||
weechat_printf_tags (notify->server->buffer,
|
||||
@@ -528,7 +528,7 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
|
||||
IRC_COLOR_RESET,
|
||||
away_message);
|
||||
}
|
||||
|
||||
|
||||
if (notify->away_message)
|
||||
free (notify->away_message);
|
||||
notify->away_message = (away_message) ? strdup (away_message) : NULL;
|
||||
@@ -550,30 +550,30 @@ irc_notify_hsignal_cb (void *data, const char *signal,
|
||||
int away_message_updated, no_such_nick;
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
|
||||
error = weechat_hashtable_get (hashtable, "error");
|
||||
server = weechat_hashtable_get (hashtable, "server");
|
||||
pattern = weechat_hashtable_get (hashtable, "pattern");
|
||||
command = weechat_hashtable_get (hashtable, "command");
|
||||
output = weechat_hashtable_get (hashtable, "output");
|
||||
|
||||
|
||||
/* if there is an error on redirection, just ignore result */
|
||||
if (error && error[0])
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* missing things in redirection */
|
||||
if (!server || !pattern || !command || !output)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* search server */
|
||||
ptr_server = irc_server_search (server);
|
||||
if (!ptr_server)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* search for start of arguments in command sent to server */
|
||||
ptr_args = strchr (command, ' ');
|
||||
if (!ptr_args)
|
||||
@@ -585,7 +585,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
|
||||
}
|
||||
if (!ptr_args[0])
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
|
||||
/* read output of command */
|
||||
if (strcmp (pattern, "ison") == 0)
|
||||
{
|
||||
@@ -663,7 +663,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
|
||||
irc_notify_set_is_on_server (ptr_notify, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
weechat_string_free_split (messages);
|
||||
}
|
||||
@@ -716,7 +716,7 @@ irc_notify_hsignal_cb (void *data, const char *signal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -733,11 +733,11 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_notify *ptr_notify, *ptr_next_notify;
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -746,16 +746,16 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
|
||||
message = malloc (7);
|
||||
if (!message)
|
||||
continue;
|
||||
|
||||
|
||||
snprintf (message, 7, "ISON :");
|
||||
total_length = 7;
|
||||
nicks_added = 0;
|
||||
|
||||
|
||||
ptr_notify = ptr_server->notify_list;
|
||||
while (ptr_notify)
|
||||
{
|
||||
ptr_next_notify = ptr_notify->next_notify;
|
||||
|
||||
|
||||
length = strlen (ptr_notify->nick);
|
||||
total_length += length + 1;
|
||||
message2 = realloc (message, total_length);
|
||||
@@ -771,10 +771,10 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
|
||||
strcat (message, " ");
|
||||
strcat (message, ptr_notify->nick);
|
||||
nicks_added++;
|
||||
|
||||
|
||||
ptr_notify = ptr_next_notify;
|
||||
}
|
||||
|
||||
|
||||
if (message && (nicks_added > 0))
|
||||
{
|
||||
hashtable = irc_message_split (ptr_server, message);
|
||||
@@ -798,12 +798,12 @@ irc_notify_timer_ison_cb (void *data, int remaining_calls)
|
||||
weechat_hashtable_free (hashtable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (message)
|
||||
free (message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -816,11 +816,11 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_notify *ptr_notify, *ptr_next_notify;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
@@ -830,7 +830,7 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
|
||||
while (ptr_notify)
|
||||
{
|
||||
ptr_next_notify = ptr_notify->next_notify;
|
||||
|
||||
|
||||
if (ptr_notify->check_away)
|
||||
{
|
||||
/*
|
||||
@@ -844,12 +844,12 @@ irc_notify_timer_whois_cb (void *data, int remaining_calls)
|
||||
IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
|
||||
"WHOIS :%s", ptr_notify->nick);
|
||||
}
|
||||
|
||||
|
||||
ptr_notify = ptr_next_notify;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -861,10 +861,10 @@ struct t_hdata *
|
||||
irc_notify_hdata_notify_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_notify", "next_notify");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -890,10 +890,10 @@ irc_notify_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_notify *notify)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !notify)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
@@ -910,7 +910,7 @@ irc_notify_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "away_message", notify->away_message))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -922,7 +922,7 @@ void
|
||||
irc_notify_print_log (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_notify *ptr_notify;
|
||||
|
||||
|
||||
for (ptr_notify = server->notify_list; ptr_notify;
|
||||
ptr_notify = ptr_notify->next_notify)
|
||||
{
|
||||
@@ -948,7 +948,7 @@ irc_notify_hook_timer_ison ()
|
||||
{
|
||||
if (irc_notify_timer_ison)
|
||||
weechat_unhook (irc_notify_timer_ison);
|
||||
|
||||
|
||||
irc_notify_timer_ison = weechat_hook_timer (
|
||||
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_ison),
|
||||
0, 0, &irc_notify_timer_ison_cb, NULL);
|
||||
@@ -963,7 +963,7 @@ irc_notify_hook_timer_whois ()
|
||||
{
|
||||
if (irc_notify_timer_whois)
|
||||
weechat_unhook (irc_notify_timer_whois);
|
||||
|
||||
|
||||
irc_notify_timer_whois = weechat_hook_timer (
|
||||
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_whois),
|
||||
0, 0, &irc_notify_timer_whois_cb, NULL);
|
||||
@@ -978,7 +978,7 @@ irc_notify_init ()
|
||||
{
|
||||
irc_notify_hook_timer_ison ();
|
||||
irc_notify_hook_timer_whois ();
|
||||
|
||||
|
||||
irc_notify_hsignal = weechat_hook_hsignal ("irc_redirection_notify_*",
|
||||
&irc_notify_hsignal_cb,
|
||||
NULL);
|
||||
|
||||
@@ -64,5 +64,5 @@ extern void irc_notify_hook_timer_ison ();
|
||||
extern void irc_notify_hook_timer_whois ();
|
||||
extern void irc_notify_init ();
|
||||
extern void irc_notify_end ();
|
||||
|
||||
|
||||
#endif /* __WEECHAT_IRC_NOTIFY_H */
|
||||
|
||||
+384
-384
File diff suppressed because it is too large
Load Diff
+30
-30
@@ -67,7 +67,7 @@ void
|
||||
irc_raw_open (int switch_to_buffer)
|
||||
{
|
||||
struct t_irc_raw_message *ptr_raw_message;
|
||||
|
||||
|
||||
if (!irc_raw_buffer)
|
||||
{
|
||||
irc_raw_buffer = weechat_buffer_search (IRC_PLUGIN_NAME,
|
||||
@@ -77,14 +77,14 @@ irc_raw_open (int switch_to_buffer)
|
||||
irc_raw_buffer = weechat_buffer_new (IRC_RAW_BUFFER_NAME,
|
||||
&irc_input_data_cb, NULL,
|
||||
&irc_buffer_close_cb, NULL);
|
||||
|
||||
|
||||
/* failed to create buffer ? then return */
|
||||
if (!irc_raw_buffer)
|
||||
return;
|
||||
|
||||
|
||||
weechat_buffer_set (irc_raw_buffer,
|
||||
"title", _("IRC raw messages"));
|
||||
|
||||
|
||||
if (!weechat_buffer_get_integer (irc_raw_buffer, "short_name_is_set"))
|
||||
{
|
||||
weechat_buffer_set (irc_raw_buffer, "short_name",
|
||||
@@ -94,7 +94,7 @@ irc_raw_open (int switch_to_buffer)
|
||||
weechat_buffer_set (irc_raw_buffer, "localvar_set_server", IRC_RAW_BUFFER_NAME);
|
||||
weechat_buffer_set (irc_raw_buffer, "localvar_set_channel", IRC_RAW_BUFFER_NAME);
|
||||
weechat_buffer_set (irc_raw_buffer, "localvar_set_no_log", "1");
|
||||
|
||||
|
||||
/* disable all highlights on this buffer */
|
||||
weechat_buffer_set (irc_raw_buffer, "highlight_words", "-");
|
||||
|
||||
@@ -106,7 +106,7 @@ irc_raw_open (int switch_to_buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (irc_raw_buffer && switch_to_buffer)
|
||||
weechat_buffer_set (irc_raw_buffer, "display", "1");
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void
|
||||
irc_raw_message_free (struct t_irc_raw_message *raw_message)
|
||||
{
|
||||
struct t_irc_raw_message *new_raw_messages;
|
||||
|
||||
|
||||
/* remove message from raw messages list */
|
||||
if (last_irc_raw_message == raw_message)
|
||||
last_irc_raw_message = raw_message->prev_message;
|
||||
@@ -130,20 +130,20 @@ irc_raw_message_free (struct t_irc_raw_message *raw_message)
|
||||
}
|
||||
else
|
||||
new_raw_messages = raw_message->next_message;
|
||||
|
||||
|
||||
if (raw_message->next_message)
|
||||
(raw_message->next_message)->prev_message = raw_message->prev_message;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (raw_message->prefix)
|
||||
free (raw_message->prefix);
|
||||
if (raw_message->message)
|
||||
free (raw_message->message);
|
||||
|
||||
|
||||
free (raw_message);
|
||||
|
||||
|
||||
irc_raw_messages = new_raw_messages;
|
||||
|
||||
|
||||
irc_raw_messages_count--;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ void
|
||||
irc_raw_message_remove_old ()
|
||||
{
|
||||
int max_messages;
|
||||
|
||||
|
||||
max_messages = weechat_config_integer (irc_config_look_raw_messages);
|
||||
while (irc_raw_messages && (irc_raw_messages_count >= max_messages))
|
||||
{
|
||||
@@ -185,19 +185,19 @@ irc_raw_message_add_to_list (time_t date, const char *prefix,
|
||||
const char *message)
|
||||
{
|
||||
struct t_irc_raw_message *new_raw_message;
|
||||
|
||||
|
||||
if (!prefix || !message)
|
||||
return NULL;
|
||||
|
||||
|
||||
irc_raw_message_remove_old ();
|
||||
|
||||
|
||||
new_raw_message = malloc (sizeof (*new_raw_message));
|
||||
if (new_raw_message)
|
||||
{
|
||||
new_raw_message->date = date;
|
||||
new_raw_message->prefix = strdup (prefix);
|
||||
new_raw_message->message = strdup (message);
|
||||
|
||||
|
||||
/* add message to list */
|
||||
new_raw_message->prev_message = last_irc_raw_message;
|
||||
new_raw_message->next_message = NULL;
|
||||
@@ -206,10 +206,10 @@ irc_raw_message_add_to_list (time_t date, const char *prefix,
|
||||
else
|
||||
irc_raw_messages = new_raw_message;
|
||||
last_irc_raw_message = new_raw_message;
|
||||
|
||||
|
||||
irc_raw_messages_count++;
|
||||
}
|
||||
|
||||
|
||||
return new_raw_message;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
|
||||
const char *hexa = "0123456789ABCDEF";
|
||||
int pos_buf, pos_buf2, char_size, i;
|
||||
struct t_irc_raw_message *new_raw_message;
|
||||
|
||||
|
||||
buf = weechat_iconv_to_internal (NULL, message);
|
||||
buf2 = malloc ((strlen (buf) * 3) + 1);
|
||||
if (buf2)
|
||||
@@ -282,7 +282,7 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
|
||||
strcpy (prefix_arrow, IRC_RAW_PREFIX_SEND);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
snprintf (prefix, sizeof (prefix), "%s%s%s%s%s",
|
||||
(server) ? weechat_color ("chat_server") : "",
|
||||
(server) ? server->name : "",
|
||||
@@ -291,16 +291,16 @@ irc_raw_message_add (struct t_irc_server *server, int flags,
|
||||
weechat_color ("chat_prefix_quit") :
|
||||
weechat_color ("chat_prefix_join"),
|
||||
prefix_arrow);
|
||||
|
||||
|
||||
new_raw_message = irc_raw_message_add_to_list (time (NULL),
|
||||
prefix,
|
||||
(buf2) ? buf2 : ((buf) ? buf : message));
|
||||
|
||||
|
||||
if (buf)
|
||||
free (buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
|
||||
|
||||
return new_raw_message;
|
||||
}
|
||||
|
||||
@@ -313,14 +313,14 @@ irc_raw_print (struct t_irc_server *server, int flags,
|
||||
const char *message)
|
||||
{
|
||||
struct t_irc_raw_message *new_raw_message;
|
||||
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
|
||||
/* auto-open IRC raw buffer if debug for irc plugin is >= 1 */
|
||||
if (!irc_raw_buffer && (weechat_irc_plugin->debug >= 1))
|
||||
irc_raw_open (0);
|
||||
|
||||
|
||||
new_raw_message = irc_raw_message_add (server, flags, message);
|
||||
if (new_raw_message)
|
||||
{
|
||||
@@ -341,20 +341,20 @@ irc_raw_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_raw_message *raw_message)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !raw_message)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_time (ptr_item, "date", raw_message->date))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "prefix", raw_message->prefix))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "message", raw_message->message))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -249,17 +249,17 @@ struct t_irc_redirect_pattern *
|
||||
irc_redirect_pattern_search (const char *name)
|
||||
{
|
||||
struct t_irc_redirect_pattern *ptr_redirect_pattern;
|
||||
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern;
|
||||
ptr_redirect_pattern = ptr_redirect_pattern->next_redirect)
|
||||
{
|
||||
if (strcmp (ptr_redirect_pattern->name, name) == 0)
|
||||
return ptr_redirect_pattern;
|
||||
}
|
||||
|
||||
|
||||
/* redirect pattern not found */
|
||||
return NULL;
|
||||
}
|
||||
@@ -274,10 +274,10 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
const char *cmd_extra)
|
||||
{
|
||||
struct t_irc_redirect_pattern *ptr_redirect_pattern, *new_redirect_pattern;
|
||||
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (!cmd_stop || !cmd_stop[0])
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -286,7 +286,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
"cmd_stop");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* check if redirect pattern already exists */
|
||||
ptr_redirect_pattern = irc_redirect_pattern_search (name);
|
||||
if (ptr_redirect_pattern)
|
||||
@@ -297,11 +297,11 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_redirect_pattern = malloc (sizeof (*new_redirect_pattern));
|
||||
if (!new_redirect_pattern)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* initialize new redirect */
|
||||
new_redirect_pattern->name = strdup (name);
|
||||
new_redirect_pattern->temp_pattern = temp_pattern;
|
||||
@@ -309,7 +309,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
new_redirect_pattern->cmd_start = (cmd_start) ? strdup (cmd_start) : NULL;
|
||||
new_redirect_pattern->cmd_stop = strdup (cmd_stop);
|
||||
new_redirect_pattern->cmd_extra = (cmd_extra) ? strdup (cmd_extra) : NULL;
|
||||
|
||||
|
||||
/* add redirect pattern to end of list */
|
||||
new_redirect_pattern->prev_redirect = last_irc_redirect_pattern;
|
||||
if (irc_redirect_patterns)
|
||||
@@ -318,7 +318,7 @@ irc_redirect_pattern_new (const char *name, int temp_pattern, int timeout,
|
||||
irc_redirect_patterns = new_redirect_pattern;
|
||||
last_irc_redirect_pattern = new_redirect_pattern;
|
||||
new_redirect_pattern->next_redirect = NULL;
|
||||
|
||||
|
||||
return new_redirect_pattern;
|
||||
}
|
||||
|
||||
@@ -330,10 +330,10 @@ void
|
||||
irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
|
||||
{
|
||||
struct t_irc_redirect_pattern *new_redirect_patterns;
|
||||
|
||||
|
||||
if (!redirect_pattern)
|
||||
return;
|
||||
|
||||
|
||||
/* remove redirect */
|
||||
if (last_irc_redirect_pattern == redirect_pattern)
|
||||
last_irc_redirect_pattern = redirect_pattern->prev_redirect;
|
||||
@@ -344,10 +344,10 @@ irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
|
||||
}
|
||||
else
|
||||
new_redirect_patterns = redirect_pattern->next_redirect;
|
||||
|
||||
|
||||
if (redirect_pattern->next_redirect)
|
||||
(redirect_pattern->next_redirect)->prev_redirect = redirect_pattern->prev_redirect;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (redirect_pattern->name)
|
||||
free (redirect_pattern->name);
|
||||
@@ -357,9 +357,9 @@ irc_redirect_pattern_free (struct t_irc_redirect_pattern *redirect_pattern)
|
||||
free (redirect_pattern->cmd_stop);
|
||||
if (redirect_pattern->cmd_extra)
|
||||
free (redirect_pattern->cmd_extra);
|
||||
|
||||
|
||||
free (redirect_pattern);
|
||||
|
||||
|
||||
irc_redirect_patterns = new_redirect_patterns;
|
||||
}
|
||||
|
||||
@@ -396,11 +396,11 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
int i, j, num_items[4];
|
||||
long value;
|
||||
struct t_hashtable *hash_cmd[4];
|
||||
|
||||
|
||||
new_redirect = malloc (sizeof (*new_redirect));
|
||||
if (!new_redirect)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* create hashtables with commands */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -448,7 +448,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
weechat_string_free_split (items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* initialize new redirect */
|
||||
new_redirect->server = server;
|
||||
new_redirect->pattern = strdup (pattern);
|
||||
@@ -467,7 +467,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
new_redirect->cmd_filter = hash_cmd[3];
|
||||
new_redirect->output = NULL;
|
||||
new_redirect->output_size = 0;
|
||||
|
||||
|
||||
/* add redirect to end of list */
|
||||
new_redirect->prev_redirect = server->last_redirect;
|
||||
if (server->redirects)
|
||||
@@ -476,7 +476,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
server->redirects = new_redirect;
|
||||
server->last_redirect = new_redirect;
|
||||
new_redirect->next_redirect = NULL;
|
||||
|
||||
|
||||
return new_redirect;
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
{
|
||||
struct t_irc_redirect_pattern *ptr_redirect_pattern;
|
||||
struct t_irc_redirect *new_redirect;
|
||||
|
||||
|
||||
if (!server->is_connected)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -501,7 +501,7 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
server->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!pattern || !pattern[0])
|
||||
{
|
||||
weechat_printf (NULL, _("%s%s: missing argument \"%s\" for redirect"),
|
||||
@@ -514,7 +514,7 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME, "signal");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ptr_redirect_pattern = irc_redirect_pattern_search (pattern);
|
||||
if (!ptr_redirect_pattern)
|
||||
{
|
||||
@@ -523,7 +523,7 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
pattern);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
new_redirect = irc_redirect_new_with_commands (server, pattern, signal,
|
||||
count, string,
|
||||
(timeout > 0) ? timeout : ptr_redirect_pattern->timeout,
|
||||
@@ -531,14 +531,14 @@ irc_redirect_new (struct t_irc_server *server,
|
||||
ptr_redirect_pattern->cmd_stop,
|
||||
ptr_redirect_pattern->cmd_extra,
|
||||
cmd_filter);
|
||||
|
||||
|
||||
/*
|
||||
* remove redirect pattern if it is temporary (created by external
|
||||
* plugin/script)
|
||||
*/
|
||||
if (new_redirect && ptr_redirect_pattern->temp_pattern)
|
||||
irc_redirect_pattern_free (ptr_redirect_pattern);
|
||||
|
||||
|
||||
return new_redirect;
|
||||
}
|
||||
|
||||
@@ -550,17 +550,17 @@ struct t_irc_redirect *
|
||||
irc_redirect_search_available (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_redirect *ptr_redirect;
|
||||
|
||||
|
||||
if (!server)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (ptr_redirect = server->redirects; ptr_redirect;
|
||||
ptr_redirect = ptr_redirect->next_redirect)
|
||||
{
|
||||
if (ptr_redirect->start_time == 0)
|
||||
return ptr_redirect;
|
||||
}
|
||||
|
||||
|
||||
/* no redirect available */
|
||||
return NULL;
|
||||
}
|
||||
@@ -575,10 +575,10 @@ irc_redirect_init_command (struct t_irc_redirect *redirect,
|
||||
const char *command)
|
||||
{
|
||||
char *pos;
|
||||
|
||||
|
||||
if (!redirect)
|
||||
return;
|
||||
|
||||
|
||||
if (command)
|
||||
{
|
||||
pos = strchr (command, '\r');
|
||||
@@ -591,9 +591,9 @@ irc_redirect_init_command (struct t_irc_redirect *redirect,
|
||||
}
|
||||
else
|
||||
redirect->command = NULL;
|
||||
|
||||
|
||||
redirect->start_time = time (NULL);
|
||||
|
||||
|
||||
if (weechat_irc_plugin->debug >= 2)
|
||||
{
|
||||
weechat_printf (redirect->server->buffer,
|
||||
@@ -618,11 +618,11 @@ irc_redirect_message_match_hash (struct t_irc_redirect *redirect,
|
||||
struct t_hashtable *cmd_hash)
|
||||
{
|
||||
int *value;
|
||||
|
||||
|
||||
value = weechat_hashtable_get (cmd_hash, command);
|
||||
if (!value)
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* if string is in redirect and that this command requires string to
|
||||
* be in message, then search for this string
|
||||
@@ -631,11 +631,11 @@ irc_redirect_message_match_hash (struct t_irc_redirect *redirect,
|
||||
{
|
||||
if (!arguments_argv || (*value >= arguments_argc))
|
||||
return 0;
|
||||
|
||||
|
||||
if (weechat_strcasecmp (arguments_argv[*value], redirect->string) != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -648,7 +648,7 @@ irc_redirect_message_add (struct t_irc_redirect *redirect, const char *message,
|
||||
const char *command)
|
||||
{
|
||||
char *output2;
|
||||
|
||||
|
||||
/*
|
||||
* if command is not for output, then don't add message
|
||||
* (it is silently ignored)
|
||||
@@ -656,7 +656,7 @@ irc_redirect_message_add (struct t_irc_redirect *redirect, const char *message,
|
||||
if (redirect->cmd_filter
|
||||
&& !weechat_hashtable_has_key (redirect->cmd_filter, command))
|
||||
return;
|
||||
|
||||
|
||||
/* add message to output */
|
||||
if (redirect->output)
|
||||
{
|
||||
@@ -716,21 +716,21 @@ irc_redirect_stop (struct t_irc_redirect *redirect, const char *error)
|
||||
(redirect->output) ? redirect->output : "");
|
||||
snprintf (str_int, sizeof (str_int), "%d", redirect->output_size);
|
||||
weechat_hashtable_set (hashtable, "output_size", str_int);
|
||||
|
||||
|
||||
/* set some other fields with values from redirect */
|
||||
weechat_hashtable_set (hashtable, "server", redirect->server->name);
|
||||
weechat_hashtable_set (hashtable, "pattern", redirect->pattern);
|
||||
weechat_hashtable_set (hashtable, "signal", redirect->signal);
|
||||
weechat_hashtable_set (hashtable, "command", redirect->command);
|
||||
}
|
||||
|
||||
|
||||
snprintf (signal_name, sizeof (signal_name), "irc_redirection_%s_%s",
|
||||
redirect->signal, redirect->pattern);
|
||||
weechat_hook_hsignal_send (signal_name, hashtable);
|
||||
|
||||
|
||||
if (hashtable)
|
||||
weechat_hashtable_free (hashtable);
|
||||
|
||||
|
||||
irc_redirect_free (redirect);
|
||||
}
|
||||
else
|
||||
@@ -760,10 +760,10 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
|
||||
struct t_irc_redirect *ptr_redirect, *ptr_next_redirect;
|
||||
int rc, match_stop, arguments_argc;
|
||||
char **arguments_argv;
|
||||
|
||||
|
||||
if (!server || !server->redirects || !message || !command)
|
||||
return 0;
|
||||
|
||||
|
||||
rc = 0;
|
||||
|
||||
if (arguments && arguments[0])
|
||||
@@ -776,12 +776,12 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
|
||||
arguments_argv = NULL;
|
||||
arguments_argc = 0;
|
||||
}
|
||||
|
||||
|
||||
ptr_redirect = server->redirects;
|
||||
while (ptr_redirect)
|
||||
{
|
||||
ptr_next_redirect = ptr_redirect->next_redirect;
|
||||
|
||||
|
||||
if (ptr_redirect->start_time > 0)
|
||||
{
|
||||
if (ptr_redirect->cmd_stop_received)
|
||||
@@ -870,14 +870,14 @@ irc_redirect_message (struct t_irc_server *server, const char *message,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ptr_redirect = ptr_next_redirect;
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
if (arguments_argv)
|
||||
weechat_string_free_split (arguments_argv);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -892,12 +892,12 @@ irc_redirect_free (struct t_irc_redirect *redirect)
|
||||
struct t_irc_redirect *new_redirects;
|
||||
int priority;
|
||||
struct t_irc_outqueue *ptr_outqueue;
|
||||
|
||||
|
||||
if (!redirect)
|
||||
return;
|
||||
|
||||
|
||||
server = redirect->server;
|
||||
|
||||
|
||||
/* remove redirect */
|
||||
if (server->last_redirect == redirect)
|
||||
server->last_redirect = redirect->prev_redirect;
|
||||
@@ -908,10 +908,10 @@ irc_redirect_free (struct t_irc_redirect *redirect)
|
||||
}
|
||||
else
|
||||
new_redirects = redirect->next_redirect;
|
||||
|
||||
|
||||
if (redirect->next_redirect)
|
||||
(redirect->next_redirect)->prev_redirect = redirect->prev_redirect;
|
||||
|
||||
|
||||
/* remove any pointer to this redirect */
|
||||
for (priority = 0; priority < IRC_SERVER_NUM_OUTQUEUES_PRIO; priority++)
|
||||
{
|
||||
@@ -922,7 +922,7 @@ irc_redirect_free (struct t_irc_redirect *redirect)
|
||||
ptr_outqueue->redirect = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* free data */
|
||||
if (redirect->pattern)
|
||||
free (redirect->pattern);
|
||||
@@ -942,9 +942,9 @@ irc_redirect_free (struct t_irc_redirect *redirect)
|
||||
weechat_hashtable_free (redirect->cmd_filter);
|
||||
if (redirect->output)
|
||||
free (redirect->output);
|
||||
|
||||
|
||||
free (redirect);
|
||||
|
||||
|
||||
server->redirects = new_redirects;
|
||||
}
|
||||
|
||||
@@ -969,10 +969,10 @@ struct t_hdata *
|
||||
irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -998,10 +998,10 @@ struct t_hdata *
|
||||
irc_redirect_hdata_redirect_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
|
||||
hdata = weechat_hdata_new (hdata_name, "prev_redirect", "next_redirect");
|
||||
if (hdata)
|
||||
{
|
||||
@@ -1038,14 +1038,14 @@ irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_redirect_pattern *redirect_pattern)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !redirect_pattern)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "name", redirect_pattern->name))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "temp_pattern", redirect_pattern->temp_pattern))
|
||||
@@ -1058,7 +1058,7 @@ irc_redirect_pattern_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "cmd_extra", redirect_pattern->cmd_extra))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1072,14 +1072,14 @@ irc_redirect_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_irc_redirect *redirect)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
|
||||
if (!infolist || !redirect)
|
||||
return 0;
|
||||
|
||||
|
||||
ptr_item = weechat_infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!weechat_infolist_new_var_pointer (ptr_item, "server", redirect->server))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "server_name", redirect->server->name))
|
||||
@@ -1116,7 +1116,7 @@ irc_redirect_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "output_size", redirect->output_size))
|
||||
return 0;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1129,7 +1129,7 @@ void
|
||||
irc_redirect_pattern_print_log ()
|
||||
{
|
||||
struct t_irc_redirect_pattern *ptr_redirect_pattern;
|
||||
|
||||
|
||||
for (ptr_redirect_pattern = irc_redirect_patterns; ptr_redirect_pattern;
|
||||
ptr_redirect_pattern = ptr_redirect_pattern->next_redirect)
|
||||
{
|
||||
@@ -1154,7 +1154,7 @@ void
|
||||
irc_redirect_print_log (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_redirect *ptr_redirect;
|
||||
|
||||
|
||||
for (ptr_redirect = server->redirects; ptr_redirect;
|
||||
ptr_redirect = ptr_redirect->next_redirect)
|
||||
{
|
||||
@@ -1205,20 +1205,20 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
|
||||
const char *pattern, *str_timeout, *cmd_start, *cmd_stop, *cmd_extra;
|
||||
char *error;
|
||||
int number, timeout;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
pattern = weechat_hashtable_get (hashtable, "pattern");
|
||||
str_timeout = weechat_hashtable_get (hashtable, "timeout");
|
||||
cmd_start = weechat_hashtable_get (hashtable, "cmd_start");
|
||||
cmd_stop = weechat_hashtable_get (hashtable, "cmd_stop");
|
||||
cmd_extra = weechat_hashtable_get (hashtable, "cmd_extra");
|
||||
|
||||
|
||||
if (!pattern || !pattern[0])
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1236,7 +1236,7 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME, "cmd_stop");
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
timeout = 0;
|
||||
if (str_timeout && str_timeout[0])
|
||||
{
|
||||
@@ -1244,14 +1244,14 @@ irc_redirect_pattern_hsignal_cb (void *data, const char *signal,
|
||||
if (error && !error[0])
|
||||
timeout = number;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* create a temporary redirect pattern (it will be removed when a
|
||||
* redirect will use it)
|
||||
*/
|
||||
irc_redirect_pattern_new (pattern, 1, timeout,
|
||||
cmd_start, cmd_stop, cmd_extra);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1271,14 +1271,14 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
char *error;
|
||||
struct t_irc_server *ptr_server;
|
||||
int number, count, timeout;
|
||||
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
|
||||
|
||||
if (!hashtable)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
|
||||
server = weechat_hashtable_get (hashtable, "server");
|
||||
pattern = weechat_hashtable_get (hashtable, "pattern");
|
||||
redirect_signal = weechat_hashtable_get (hashtable, "signal");
|
||||
@@ -1286,7 +1286,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
string = weechat_hashtable_get (hashtable, "string");
|
||||
str_timeout = weechat_hashtable_get (hashtable, "timeout");
|
||||
cmd_filter = weechat_hashtable_get (hashtable, "cmd_filter");
|
||||
|
||||
|
||||
if (!server || !server[0])
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
@@ -1302,7 +1302,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME, server);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
count = 1;
|
||||
if (str_count && str_count[0])
|
||||
{
|
||||
@@ -1310,7 +1310,7 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
if (error && !error[0])
|
||||
count = number;
|
||||
}
|
||||
|
||||
|
||||
timeout = 0;
|
||||
if (str_timeout && str_timeout[0])
|
||||
{
|
||||
@@ -1318,10 +1318,10 @@ irc_redirect_command_hsignal_cb (void *data, const char *signal,
|
||||
if (error && !error[0])
|
||||
timeout = number;
|
||||
}
|
||||
|
||||
|
||||
irc_redirect_new (ptr_server, pattern, redirect_signal,
|
||||
count, string, timeout, cmd_filter);
|
||||
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -51,7 +51,7 @@ irc_sasl_mechanism_plain (const char *sasl_username, const char *sasl_password)
|
||||
{
|
||||
char *string, *answer_base64;
|
||||
int length_username, length;
|
||||
|
||||
|
||||
answer_base64 = NULL;
|
||||
length_username = strlen (sasl_username);
|
||||
length = ((length_username + 1) * 2) + strlen (sasl_password) + 1;
|
||||
@@ -62,14 +62,14 @@ irc_sasl_mechanism_plain (const char *sasl_username, const char *sasl_password)
|
||||
sasl_username, sasl_username, sasl_password);
|
||||
string[length_username] = '\0';
|
||||
string[(length_username * 2) + 1] = '\0';
|
||||
|
||||
|
||||
answer_base64 = malloc (length * 4);
|
||||
if (answer_base64)
|
||||
weechat_string_encode_base64 (string, length - 1, answer_base64);
|
||||
|
||||
|
||||
free (string);
|
||||
}
|
||||
|
||||
|
||||
return answer_base64;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
gcry_mpi_t data_prime_number, data_generator_number, data_server_pub_key;
|
||||
gcry_mpi_t pub_key, priv_key, secret_mpi;
|
||||
gcry_cipher_hd_t gcrypt_handle;
|
||||
|
||||
|
||||
data = NULL;
|
||||
secret_bin = NULL;
|
||||
public_bin = NULL;
|
||||
@@ -109,12 +109,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
password_crypted = NULL;
|
||||
answer = NULL;
|
||||
answer_base64 = NULL;
|
||||
|
||||
|
||||
/* decode data */
|
||||
data = malloc (strlen (data_base64) + 1);
|
||||
length_data = weechat_string_decode_base64 (data_base64, data);
|
||||
ptr_data = (unsigned char *)data;
|
||||
|
||||
|
||||
/* extract prime number */
|
||||
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
|
||||
ptr_data += 2;
|
||||
@@ -126,7 +126,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
num_bits_prime_number = gcry_mpi_get_nbits (data_prime_number);
|
||||
ptr_data += size;
|
||||
length_data -= size;
|
||||
|
||||
|
||||
/* extract generator number */
|
||||
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
|
||||
ptr_data += 2;
|
||||
@@ -137,7 +137,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
gcry_mpi_scan (&data_generator_number, GCRYMPI_FMT_USG, ptr_data, size, NULL);
|
||||
ptr_data += size;
|
||||
length_data -= size;
|
||||
|
||||
|
||||
/* extract server-generated public key */
|
||||
size = ntohs ((((unsigned int)ptr_data[1]) << 8) | ptr_data[0]);
|
||||
ptr_data += 2;
|
||||
@@ -146,14 +146,14 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
goto end;
|
||||
data_server_pub_key = gcry_mpi_new (size * 8);
|
||||
gcry_mpi_scan (&data_server_pub_key, GCRYMPI_FMT_USG, ptr_data, size, NULL);
|
||||
|
||||
|
||||
/* generate keys */
|
||||
pub_key = gcry_mpi_new (num_bits_prime_number);
|
||||
priv_key = gcry_mpi_new (num_bits_prime_number);
|
||||
gcry_mpi_randomize (priv_key, num_bits_prime_number, GCRY_STRONG_RANDOM);
|
||||
/* pub_key = (g ^ priv_key) % p */
|
||||
gcry_mpi_powm (pub_key, data_generator_number, priv_key, data_prime_number);
|
||||
|
||||
|
||||
/* compute secret_bin */
|
||||
length_key = num_bits_prime_number / 8;
|
||||
secret_bin = malloc (length_key);
|
||||
@@ -162,12 +162,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
gcry_mpi_powm (secret_mpi, data_server_pub_key, priv_key, data_prime_number);
|
||||
gcry_mpi_print (GCRYMPI_FMT_USG, secret_bin, length_key,
|
||||
&num_written, secret_mpi);
|
||||
|
||||
|
||||
/* create public_bin */
|
||||
public_bin = malloc (length_key);
|
||||
gcry_mpi_print (GCRYMPI_FMT_USG, public_bin, length_key,
|
||||
&num_written, pub_key);
|
||||
|
||||
|
||||
/* create password buffers (clear and crypted) */
|
||||
length_password = strlen (sasl_password) +
|
||||
((8 - (strlen (sasl_password) % 8)) % 8);
|
||||
@@ -176,7 +176,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
memset (password_clear, 0, length_password);
|
||||
memset (password_crypted, 0, length_password);
|
||||
memcpy (password_clear, sasl_password, strlen (sasl_password));
|
||||
|
||||
|
||||
/* crypt password using blowfish */
|
||||
if (gcry_cipher_open (&gcrypt_handle, GCRY_CIPHER_BLOWFISH,
|
||||
GCRY_CIPHER_MODE_ECB, 0) != 0)
|
||||
@@ -187,7 +187,7 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
password_crypted, length_password,
|
||||
password_clear, length_password) != 0)
|
||||
goto end;
|
||||
|
||||
|
||||
/*
|
||||
* build answer for server, it is concatenation of:
|
||||
* 1. key length (2 bytes)
|
||||
@@ -206,12 +206,12 @@ irc_sasl_mechanism_dh_blowfish (const char *data_base64,
|
||||
memcpy (ptr_answer, sasl_username, length_username + 1);
|
||||
ptr_answer += length_username + 1;
|
||||
memcpy (ptr_answer, password_crypted, length_password);
|
||||
|
||||
|
||||
/* encode answer to base64 */
|
||||
answer_base64 = malloc (length_answer * 4);
|
||||
if (answer_base64)
|
||||
weechat_string_encode_base64 (answer, length_answer, answer_base64);
|
||||
|
||||
|
||||
end:
|
||||
if (data)
|
||||
free (data);
|
||||
@@ -225,14 +225,14 @@ end:
|
||||
free (password_crypted);
|
||||
if (answer)
|
||||
free (answer);
|
||||
|
||||
|
||||
return answer_base64;
|
||||
#else
|
||||
/* make C compiler happy */
|
||||
(void) data_base64;
|
||||
(void) sasl_username;
|
||||
(void) sasl_password;
|
||||
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user