summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-06-10 12:40:05 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-06-10 12:40:05 +0200
commit8d58b81d83d9a5462f1b4aeb274a16a91ef213d1 (patch)
tree4bf0ef51ea845f54fa97012b1ebe9a85e24f1750 /src
parentfd31dbb97ec00ee49cec21c4731677c403c80564 (diff)
downloadweechat-8d58b81d83d9a5462f1b4aeb274a16a91ef213d1.zip
Add buffer merging feature, with /buffer merge/unmerge (task #7404)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c144
-rw-r--r--src/core/wee-config.c15
-rw-r--r--src/core/wee-config.h9
-rw-r--r--src/core/wee-hook.c26
-rw-r--r--src/core/wee-upgrade-file.h2
-rw-r--r--src/core/wee-upgrade.c60
-rw-r--r--src/gui/CMakeLists.txt1
-rw-r--r--src/gui/Makefile.am2
-rw-r--r--src/gui/curses/gui-curses-chat.c161
-rw-r--r--src/gui/curses/gui-curses-color.c1
-rw-r--r--src/gui/curses/gui-curses-keyboard.c5
-rw-r--r--src/gui/curses/gui-curses-window.c28
-rw-r--r--src/gui/gtk/gui-gtk-bar-window.c1
-rw-r--r--src/gui/gtk/gui-gtk-chat.c7
-rw-r--r--src/gui/gtk/gui-gtk-color.c1
-rw-r--r--src/gui/gtk/gui-gtk-window.c22
-rw-r--r--src/gui/gui-bar-item.c7
-rw-r--r--src/gui/gui-buffer.c547
-rw-r--r--src/gui/gui-buffer.h46
-rw-r--r--src/gui/gui-chat.c663
-rw-r--r--src/gui/gui-chat.h28
-rw-r--r--src/gui/gui-color.h1
-rw-r--r--src/gui/gui-filter.c34
-rw-r--r--src/gui/gui-hotlist.c9
-rw-r--r--src/gui/gui-input.c34
-rw-r--r--src/gui/gui-input.h1
-rw-r--r--src/gui/gui-line.c1068
-rw-r--r--src/gui/gui-line.h106
-rw-r--r--src/gui/gui-window.c72
-rw-r--r--src/plugins/irc/irc-bar-item.c24
-rw-r--r--src/plugins/irc/irc-buffer.c198
-rw-r--r--src/plugins/irc/irc-buffer.h9
-rw-r--r--src/plugins/irc/irc-command.c160
-rw-r--r--src/plugins/irc/irc-command.h3
-rw-r--r--src/plugins/irc/irc-config.c78
-rw-r--r--src/plugins/irc/irc-config.h9
-rw-r--r--src/plugins/irc/irc-info.c12
-rw-r--r--src/plugins/irc/irc-protocol.c248
-rw-r--r--src/plugins/irc/irc-protocol.h8
-rw-r--r--src/plugins/irc/irc-server.c320
-rw-r--r--src/plugins/irc/irc-server.h7
-rw-r--r--src/plugins/irc/irc-upgrade.c9
-rw-r--r--src/plugins/irc/irc.c2
-rw-r--r--src/plugins/plugin-api.c10
-rw-r--r--src/plugins/plugin.c3
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c104
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c85
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c95
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c106
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c104
-rw-r--r--src/plugins/weechat-plugin.h12
51 files changed, 2901 insertions, 1806 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index c7e094a27..f70c550db 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -544,9 +544,15 @@ command_buffer (void *data, struct t_gui_buffer *buffer,
number = strtol (argv[i], &error, 10);
if (error && !error[0])
{
- ptr_buffer = gui_buffer_search_by_number (number);
- if (ptr_buffer && (ptr_buffer->type == GUI_BUFFER_TYPE_FORMATTED))
- gui_buffer_clear (ptr_buffer);
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if ((ptr_buffer->number == number)
+ && (ptr_buffer->type == GUI_BUFFER_TYPE_FORMATTED))
+ {
+ gui_buffer_clear (ptr_buffer);
+ }
+ }
}
}
}
@@ -600,13 +606,77 @@ command_buffer (void *data, struct t_gui_buffer *buffer,
return WEECHAT_RC_OK;
}
+ /* merge buffer with another number in the list */
+ if (string_strcasecmp (argv[1], "merge") == 0)
+ {
+ if (argc < 3)
+ {
+ gui_chat_printf (NULL,
+ _("%sError: missing arguments for \"%s\" "
+ "command"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ "buffer");
+ return WEECHAT_RC_ERROR;
+ }
+
+ error = NULL;
+ number = strtol (argv[2], &error, 10);
+ if (error && !error[0])
+ {
+ ptr_buffer = gui_buffer_search_by_number ((int) number);
+ if (ptr_buffer)
+ gui_buffer_merge (buffer, ptr_buffer);
+ }
+ else
+ {
+ /* invalid number */
+ gui_chat_printf (NULL,
+ _("%sError: incorrect buffer number"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ return WEECHAT_RC_ERROR;
+ }
+
+ return WEECHAT_RC_OK;
+ }
+
+ /* unmerge buffer */
+ if (string_strcasecmp (argv[1], "unmerge") == 0)
+ {
+ number = -1;
+ if (argc >= 3)
+ {
+ error = NULL;
+ number = strtol (argv[2], &error, 10);
+ if (!error || error[0])
+ {
+ /* invalid number */
+ gui_chat_printf (NULL,
+ _("%sError: incorrect buffer number"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ return WEECHAT_RC_ERROR;
+ }
+ }
+ gui_buffer_unmerge (buffer, (int) number);
+
+ return WEECHAT_RC_OK;
+ }
+
/* close buffer */
if (string_strcasecmp (argv[1], "close") == 0)
{
if (argc < 3)
{
- number1 = buffer->number;
- number2 = buffer->number;
+ if (!buffer->plugin)
+ {
+ gui_chat_printf (NULL,
+ _("%sError: WeeChat main buffer can't be "
+ "closed"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ }
+ else
+ {
+ gui_buffer_close (buffer);
+ }
}
else
{
@@ -649,22 +719,26 @@ command_buffer (void *data, struct t_gui_buffer *buffer,
}
if ((number1 < 0) || (number2 < 0) || (number2 < number1))
return WEECHAT_RC_ERROR;
- }
- for (i = number2; i >= number1; i--)
- {
- ptr_buffer = gui_buffer_search_by_number (i);
- if (ptr_buffer)
+
+ for (i = number2; i >= number1; i--)
{
- if (!ptr_buffer->plugin)
- {
- gui_chat_printf (NULL,
- _("%sError: WeeChat main buffer can't be "
- "closed"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
- }
- else
+ for (ptr_buffer = last_gui_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->prev_buffer)
{
- gui_buffer_close (ptr_buffer);
+ if (ptr_buffer->number == i)
+ {
+ if (!ptr_buffer->plugin)
+ {
+ gui_chat_printf (NULL,
+ _("%sError: WeeChat main buffer "
+ "can't be closed"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ }
+ else
+ {
+ gui_buffer_close (ptr_buffer);
+ }
+ }
}
}
}
@@ -1763,6 +1837,8 @@ command_input (void *data, struct t_gui_buffer *buffer,
gui_input_set_unread ();
else if (string_strcasecmp (argv[1], "set_unread_current_buffer") == 0)
gui_input_set_unread_current_buffer ();
+ else if (string_strcasecmp (argv[1], "switch_active_buffer") == 0)
+ gui_input_switch_active_buffer ();
else if (string_strcasecmp (argv[1], "insert") == 0)
{
if (argc > 2)
@@ -3877,13 +3953,19 @@ command_init ()
&command_bar, NULL);
hook_command (NULL, "buffer",
N_("manage buffers"),
- N_("[clear [number | -all] | move number | close [n1[-n2]]| "
- "list | notify level | localvar | set property value | "
- "number | name]"),
+ N_("[clear [number | -all] | move number | merge number | "
+ "unmerge [number] | close [n1[-n2]]| list | notify level | "
+ "localvar | set property value | number | name]"),
N_(" clear: clear buffer content (-all for all buffers, "
"number for a buffer, or nothing for current buffer)\n"
" move: move buffer in the list (may be relative, for "
"example -1)\n"
+ " merge: merge current buffer to another buffer (chat "
+ "area will be mix of both buffers)\n"
+ " (by default ctrl-x switches between merged "
+ "buffers)\n"
+ " unmerge: unmerge buffer from other buffers which have "
+ "same number\n"
" close: close buffer (number/range is optional)\n"
" list: list buffers (no parameter implies this list)\n"
" notify: set notify level for current buffer: this "
@@ -3903,15 +3985,19 @@ command_init ()
"\"weechat.look.jump_current_to_previous_buffer\"\n"
" name: jump to buffer by (partial) name\n\n"
"Examples:\n"
- "clear current buffer: /buffer clear\n"
- " clear all buffers: /buffer clear -all\n"
- " move buffer: /buffer move 5\n"
- "close current buffer: /buffer close\n"
- "close buffers 5 to 7: /buffer close 5-7\n"
- " jump to #weechat: /buffer #weechat\n"
- " jump to next buffer: /buffer +1"),
+ " clear current buffer: /buffer clear\n"
+ " clear all buffers: /buffer clear -all\n"
+ " move buffer: /buffer move 5\n"
+ "merge with core buffer: /buffer merge 1\n"
+ " unmerge buffer: /buffer unmerge\n"
+ " close current buffer: /buffer close\n"
+ " close buffers 5 to 7: /buffer close 5-7\n"
+ " jump to #weechat: /buffer #weechat\n"
+ " jump to next buffer: /buffer +1"),
"clear -all|%(buffers_numbers)"
" || move %(buffers_numbers)"
+ " || merge %(buffers_numbers)"
+ " || unmerge %(buffers_numbers)"
" || close"
" || list"
" || notify reset|none|highlight|message|all"
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index a72727b85..a9f73149f 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -91,6 +91,7 @@ struct t_config_option *config_look_paste_max_lines;
struct t_config_option *config_look_prefix[GUI_CHAT_NUM_PREFIXES];
struct t_config_option *config_look_prefix_align;
struct t_config_option *config_look_prefix_align_max;
+struct t_config_option *config_look_prefix_buffer_align;
struct t_config_option *config_look_prefix_suffix;
struct t_config_option *config_look_read_marker;
struct t_config_option *config_look_save_config_on_exit;
@@ -107,6 +108,7 @@ struct t_config_option *config_color_chat;
struct t_config_option *config_color_chat_bg;
struct t_config_option *config_color_chat_time;
struct t_config_option *config_color_chat_time_delimiters;
+struct t_config_option *config_color_chat_prefix_buffer;
struct t_config_option *config_color_chat_prefix[GUI_CHAT_NUM_PREFIXES];
struct t_config_option *config_color_chat_prefix_more;
struct t_config_option *config_color_chat_prefix_suffix;
@@ -1363,6 +1365,12 @@ config_weechat_init_options ()
"prefix_align_max", "integer",
N_("max size for prefix (0 = no max size)"),
NULL, 0, 64, "0", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ config_look_prefix_buffer_align = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "prefix_buffer_align", "integer",
+ N_("prefix alignment for buffer name, when many buffers are merged "
+ "with same number (none, left, right (default))"),
+ "none|left|right", 0, 0, "right", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
config_look_prefix_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_suffix", "string",
@@ -1453,6 +1461,13 @@ config_weechat_init_options ()
N_("text color for time delimiters"),
NULL, GUI_COLOR_CHAT_TIME_DELIMITERS, 0, "brown", NULL, 0,
NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ config_color_chat_prefix_buffer = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "chat_prefix_buffer", "color",
+ N_("text color for buffer name (before prefix, when many buffers are "
+ "merged with same number)"),
+ NULL, GUI_COLOR_CHAT_PREFIX_BUFFER, 0, "brown", NULL, 0,
+ NULL, NULL, &config_change_color, NULL, NULL, NULL);
config_color_chat_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option (
weechat_config_file, ptr_section,
"chat_prefix_error", "color",
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index 5b7db86ea..720dfeb7a 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -41,6 +41,13 @@ enum t_config_look_prefix_align
CONFIG_LOOK_PREFIX_ALIGN_RIGHT,
};
+enum t_config_look_prefix_buffer_align
+{
+ CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE = 0,
+ CONFIG_LOOK_PREFIX_BUFFER_ALIGN_LEFT,
+ CONFIG_LOOK_PREFIX_BUFFER_ALIGN_RIGHT,
+};
+
enum t_config_look_hotlist_sort
{
CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC = 0,
@@ -99,6 +106,7 @@ extern struct t_config_option *config_look_paste_max_lines;
extern struct t_config_option *config_look_prefix[];
extern struct t_config_option *config_look_prefix_align;
extern struct t_config_option *config_look_prefix_align_max;
+extern struct t_config_option *config_look_prefix_buffer_align;
extern struct t_config_option *config_look_prefix_suffix;
extern struct t_config_option *config_look_read_marker;
extern struct t_config_option *config_look_save_config_on_exit;
@@ -113,6 +121,7 @@ extern struct t_config_option *config_color_chat;
extern struct t_config_option *config_color_chat_bg;
extern struct t_config_option *config_color_chat_time;
extern struct t_config_option *config_color_chat_time_delimiters;
+extern struct t_config_option *config_color_chat_prefix_buffer;
extern struct t_config_option *config_color_chat_prefix[];
extern struct t_config_option *config_color_chat_prefix_more;
extern struct t_config_option *config_color_chat_prefix_suffix;
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index 72ad4ec61..a18883c06 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -41,10 +41,10 @@
#include "wee-string.h"
#include "wee-utf8.h"
#include "wee-util.h"
-#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
#include "../gui/gui-completion.h"
+#include "../gui/gui-line.h"
#include "../plugins/plugin.h"
@@ -1542,12 +1542,13 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
char *prefix_no_color, *message_no_color;
int tags_match, tag_found, i, j;
- if (!line->message || !line->message[0])
+ if (!line->data->message || !line->data->message[0])
return;
- prefix_no_color = (line->prefix) ? gui_color_decode (line->prefix, NULL) : NULL;
+ prefix_no_color = (line->data->prefix) ?
+ gui_color_decode (line->data->prefix, NULL) : NULL;
- message_no_color = gui_color_decode (line->message, NULL);
+ message_no_color = gui_color_decode (line->data->message, NULL);
if (!message_no_color)
{
free (prefix_no_color);
@@ -1574,17 +1575,17 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
if (HOOK_PRINT(ptr_hook, tags_array))
{
/* if there are tags in message printed */
- if (line->tags_array)
+ if (line->data->tags_array)
{
tags_match = 1;
for (i = 0; i < HOOK_PRINT(ptr_hook, tags_count); i++)
{
/* search for tag in message */
tag_found = 0;
- for (j = 0; j < line->tags_count; j++)
+ for (j = 0; j < line->data->tags_count; j++)
{
if (string_strcasecmp (HOOK_PRINT(ptr_hook, tags_array)[i],
- line->tags_array[j]) != 0)
+ line->data->tags_array[j]) != 0)
{
tag_found = 1;
break;
@@ -1609,11 +1610,12 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
{
ptr_hook->running = 1;
(void) (HOOK_PRINT(ptr_hook, callback))
- (ptr_hook->callback_data, buffer, line->date,
- line->tags_count, (const char **)line->tags_array,
- (int)line->displayed, (int)line->highlight,
- (HOOK_PRINT(ptr_hook, strip_colors)) ? prefix_no_color : line->prefix,
- (HOOK_PRINT(ptr_hook, strip_colors)) ? message_no_color : line->message);
+ (ptr_hook->callback_data, buffer, line->data->date,
+ line->data->tags_count,
+ (const char **)line->data->tags_array,
+ (int)line->data->displayed, (int)line->data->highlight,
+ (HOOK_PRINT(ptr_hook, strip_colors)) ? prefix_no_color : line->data->prefix,
+ (HOOK_PRINT(ptr_hook, strip_colors)) ? message_no_color : line->data->message);
ptr_hook->running = 0;
}
}
diff --git a/src/core/wee-upgrade-file.h b/src/core/wee-upgrade-file.h
index ff865ca05..569839f2f 100644
--- a/src/core/wee-upgrade-file.h
+++ b/src/core/wee-upgrade-file.h
@@ -20,7 +20,7 @@
#ifndef __WEECHAT_UPGRADE_FILE_H
#define __WEECHAT_UPGRADE_FILE_H 1
-#define UPGRADE_SIGNATURE "===== WeeChat Upgrade file v2.1 - binary, do not edit! ====="
+#define UPGRADE_SIGNATURE "===== WeeChat Upgrade file v2.2 - binary, do not edit! ====="
#define UPGRADE_ERROR(msg1, msg2) \
upgrade_file_error(upgrade_file, msg1, msg2, __FILE__, __LINE__)
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index 849aa927e..c7fa6f425 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -36,6 +36,7 @@
#include "../gui/gui-chat.h"
#include "../gui/gui-history.h"
#include "../gui/gui-hotlist.h"
+#include "../gui/gui-line.h"
#include "../gui/gui-nicklist.h"
#include "../gui/gui-window.h"
#include "../plugins/plugin.h"
@@ -43,6 +44,7 @@
struct t_gui_buffer *upgrade_current_buffer = NULL;
struct t_gui_buffer *upgrade_set_current_buffer = NULL;
+int upgrade_last_buffer_number = 1;
int hotlist_reset = 0;
@@ -147,14 +149,15 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
}
/* save buffer lines */
- for (ptr_line = ptr_buffer->lines; ptr_line;
+ for (ptr_line = ptr_buffer->own_lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
{
ptr_infolist = infolist_new ();
if (!ptr_infolist)
return 0;
- if (!gui_buffer_line_add_to_infolist (ptr_infolist,
- ptr_buffer, ptr_line))
+ if (!gui_line_add_to_infolist (ptr_infolist,
+ ptr_buffer->own_lines,
+ ptr_line))
{
infolist_free (ptr_infolist);
return 0;
@@ -289,10 +292,11 @@ upgrade_weechat_read_cb (void *data,
int object_id,
struct t_infolist *infolist)
{
- const char *key, *var_name, *type, *name, *group_name;
+ const char *key, *var_name, *type, *name, *group_name, *plugin_name;
+ const char *buffer_name;
char option_name[64], *option_key, *option_var;
struct t_gui_nick_group *ptr_group;
- struct t_gui_buffer *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer, *ptr_buffer_for_merge;
struct t_gui_line *new_line;
struct timeval creation_time;
void *buf;
@@ -330,6 +334,7 @@ upgrade_weechat_read_cb (void *data,
{
/* create buffer if it was created by a plugin (ie not
WeeChat main buffer) */
+ ptr_buffer_for_merge = last_gui_buffer;
upgrade_current_buffer = gui_buffer_new (
NULL,
infolist_string (infolist, "name"),
@@ -341,6 +346,10 @@ upgrade_weechat_read_cb (void *data,
upgrade_set_current_buffer = upgrade_current_buffer;
upgrade_current_buffer->plugin_name_for_upgrade =
strdup (infolist_string (infolist, "plugin_name"));
+ upgrade_current_buffer->merge_for_upgrade = NULL;
+ if (infolist_integer (infolist, "number") == upgrade_last_buffer_number)
+ upgrade_current_buffer->merge_for_upgrade = ptr_buffer_for_merge;
+ upgrade_last_buffer_number = infolist_integer (infolist, "number");
upgrade_current_buffer->short_name =
(infolist_string (infolist, "short_name")) ?
strdup (infolist_string (infolist, "short_name")) :
@@ -356,7 +365,7 @@ upgrade_weechat_read_cb (void *data,
upgrade_current_buffer->title =
(infolist_string (infolist, "title")) ?
strdup (infolist_string (infolist, "title")) : NULL;
- upgrade_current_buffer->first_line_not_read =
+ upgrade_current_buffer->lines->first_line_not_read =
infolist_integer (infolist, "first_line_not_read");
upgrade_current_buffer->time_for_each_line =
infolist_integer (infolist, "time_for_each_line");
@@ -449,7 +458,7 @@ upgrade_weechat_read_cb (void *data,
/* add line to current buffer */
if (upgrade_current_buffer)
{
- new_line = gui_chat_line_add (
+ new_line = gui_line_add (
upgrade_current_buffer,
infolist_time (infolist, "date"),
infolist_time (infolist, "date_printed"),
@@ -458,10 +467,10 @@ upgrade_weechat_read_cb (void *data,
infolist_string (infolist, "message"));
if (new_line)
{
- new_line->highlight = infolist_integer (infolist, "highlight");
+ new_line->data->highlight = infolist_integer (infolist, "highlight");
}
if (infolist_integer (infolist, "last_read_line"))
- upgrade_current_buffer->last_read_line = new_line;
+ upgrade_current_buffer->lines->last_read_line = new_line;
}
break;
case UPGRADE_WEECHAT_TYPE_NICKLIST:
@@ -519,17 +528,23 @@ upgrade_weechat_read_cb (void *data,
gui_hotlist_clear ();
hotlist_reset = 1;
}
- ptr_buffer = gui_buffer_search_by_number (infolist_integer (infolist, "buffer_number"));
- if (ptr_buffer)
+ plugin_name = infolist_string (infolist, "plugin_name");
+ buffer_name = infolist_string (infolist, "plugin_name");
+ if (plugin_name && buffer_name)
{
- buf = infolist_buffer (infolist, "creation_time", &size);
- if (buf)
+ ptr_buffer = gui_buffer_search_by_name (plugin_name,
+ buffer_name);
+ if (ptr_buffer)
{
- memcpy (&creation_time, buf, size);
- gui_hotlist_add (ptr_buffer,
- infolist_integer (infolist, "priority"),
- &creation_time,
- 1);
+ buf = infolist_buffer (infolist, "creation_time", &size);
+ if (buf)
+ {
+ memcpy (&creation_time, buf, size);
+ gui_hotlist_add (ptr_buffer,
+ infolist_integer (infolist, "priority"),
+ &creation_time,
+ 1);
+ }
}
}
break;
@@ -549,12 +564,21 @@ upgrade_weechat_load ()
{
int rc;
struct t_upgrade_file *upgrade_file;
+ struct t_gui_buffer *ptr_buffer;
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 ();
+
+ /* merge buffers */
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->merge_for_upgrade)
+ gui_buffer_merge (ptr_buffer, ptr_buffer->merge_for_upgrade);
+ }
if (upgrade_set_current_buffer)
{
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index f71812928..a3c7342cd 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -28,6 +28,7 @@ gui-hotlist.c gui-hotlist.h
gui-input.c gui-input.h
gui-keyboard.c gui-keyboard.h
gui-layout.c gui-layout.h
+gui-line.c gui-line.h
gui-main.h
gui-nicklist.c gui-nicklist.h
gui-window.c gui-window.h)
diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am
index 011c543e6..92f3c4cef 100644
--- a/src/gui/Makefile.am
+++ b/src/gui/Makefile.am
@@ -44,6 +44,8 @@ lib_weechat_gui_common_a_SOURCES = gui-bar.c \
gui-keyboard.h \
gui-layout.c \
gui-layout.h \
+ gui-line.c \
+ gui-line.h \
gui-main.h \
gui-nicklist.c \
gui-nicklist.h \
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index d9c138cbc..4be162d9c 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -37,6 +37,7 @@
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-hotlist.h"
+#include "../gui-line.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-curses.h"
@@ -67,12 +68,12 @@ gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
struct t_gui_line *last_read_line;
/* marker is not set for buffer? */
- if (!buffer->last_read_line)
+ if (!buffer->lines->last_read_line)
return 0;
- last_read_line = buffer->last_read_line;
- if (!last_read_line->displayed)
- last_read_line = gui_chat_get_prev_line_displayed (last_read_line);
+ 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;
@@ -87,7 +88,7 @@ gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
if (last_read_line == line)
return 1;
- if (line->displayed)
+ if (line->data->displayed)
break;
line = line->next_line;
@@ -440,7 +441,7 @@ gui_chat_display_word (struct t_gui_window *window,
while (data && data[0])
{
/* insert spaces for align text under time/nick */
- length_align = gui_chat_get_line_align (window->buffer, line, 0);
+ length_align = gui_line_get_align (window->buffer, line, 0);
if ((length_align > 0) &&
(window->win_chat_cursor_x == 0) &&
(*lines_displayed > 0) &&
@@ -540,15 +541,17 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
int simulate)
{
char str_space[] = " ", str_plus[] = "+", *prefix_highlighted;
- int i, length_allowed, num_spaces;
+ int i, length, length_allowed, num_spaces;
+ struct t_gui_lines *mixed_lines;
/* display time */
- if (window->buffer->time_for_each_line && (line->str_time && line->str_time[0]))
+ if (window->buffer->time_for_each_line
+ && (line->data->str_time && line->data->str_time[0]))
{
if (!simulate)
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat, GUI_COLOR_CHAT);
- gui_chat_display_word (window, line, line->str_time,
+ gui_chat_display_word (window, line, line->data->str_time,
NULL, 1, num_lines, count, lines_displayed,
simulate);
gui_chat_display_word (window, line, str_space,
@@ -564,25 +567,73 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
NULL, 1, num_lines, count, lines_displayed,
simulate);
}
+
+ /* display buffer name (if many buffers are merged) */
+ mixed_lines = line->data->buffer->mixed_lines;
+ if (mixed_lines)
+ {
+ if (!simulate)
+ {
+ gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat,
+ GUI_COLOR_CHAT_PREFIX_BUFFER);
+ }
+
+ length = gui_chat_strlen_screen (line->data->buffer->short_name);
+ num_spaces = mixed_lines->buffer_max_length - length;
+
+ if (CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_RIGHT)
+ {
+ for (i = 0; i < num_spaces; i++)
+ {
+ gui_chat_display_word (window, line, str_space,
+ NULL, 1, num_lines, count,
+ lines_displayed, simulate);
+ }
+ }
+
+ gui_chat_display_word (window, line,
+ line->data->buffer->short_name,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+
+ if ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_LEFT)
+ || ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE)
+ && (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)))
+ {
+ for (i = 0; i < num_spaces; i++)
+ {
+ gui_chat_display_word (window, line, str_space,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+ }
+ }
+
+ gui_chat_display_word (window, line, str_space,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+ }
/* display prefix */
- if (line->prefix
- && (line->prefix[0]
+ if (line->data->prefix
+ && (line->data->prefix[0]
|| (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)))
{
if (!simulate)
- gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat, GUI_COLOR_CHAT);
+ {
+ gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat,
+ GUI_COLOR_CHAT);
+ }
if (CONFIG_INTEGER(config_look_prefix_align_max) > 0)
{
length_allowed =
- (window->buffer->prefix_max_length <= CONFIG_INTEGER(config_look_prefix_align_max)) ?
- window->buffer->prefix_max_length : CONFIG_INTEGER(config_look_prefix_align_max);
+ (window->buffer->lines->prefix_max_length <= CONFIG_INTEGER(config_look_prefix_align_max)) ?
+ window->buffer->lines->prefix_max_length : CONFIG_INTEGER(config_look_prefix_align_max);
}
else
- length_allowed = window->buffer->prefix_max_length;
+ length_allowed = window->buffer->lines->prefix_max_length;
- num_spaces = length_allowed - line->prefix_length;
+ num_spaces = length_allowed - line->data->prefix_length;
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_RIGHT)
{
@@ -595,9 +646,9 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
}
prefix_highlighted = NULL;
- if (line->highlight)
+ if (line->data->highlight)
{
- prefix_highlighted = gui_color_decode (line->prefix, NULL);
+ prefix_highlighted = gui_color_decode (line->data->prefix, NULL);
if (!simulate)
{
gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat,
@@ -610,19 +661,19 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
&& (num_spaces < 0))
{
gui_chat_display_word (window, line,
- (prefix_highlighted) ? prefix_highlighted : line->prefix,
+ (prefix_highlighted) ? prefix_highlighted : line->data->prefix,
(prefix_highlighted) ?
prefix_highlighted + gui_chat_string_real_pos (prefix_highlighted,
length_allowed) :
- line->prefix + gui_chat_string_real_pos (line->prefix,
- length_allowed),
+ line->data->prefix + gui_chat_string_real_pos (line->data->prefix,
+ length_allowed),
1, num_lines, count, lines_displayed,
simulate);
}
else
{
gui_chat_display_word (window, line,
- (prefix_highlighted) ? prefix_highlighted : line->prefix,
+ (prefix_highlighted) ? prefix_highlighted : line->data->prefix,
NULL, 1, num_lines, count, lines_displayed,
simulate);
}
@@ -656,7 +707,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
}
else
{
- if (window->buffer->prefix_max_length > 0)
+ if (window->buffer->lines->prefix_max_length > 0)
{
gui_chat_display_word (window, line, str_space,
NULL, 1, num_lines, count, lines_displayed,
@@ -728,8 +779,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
}
/* calculate marker position (maybe not used for this line!) */
- if (window->buffer->time_for_each_line && line->str_time)
- read_marker_x = x + gui_chat_strlen_screen (line->str_time);
+ 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;
@@ -746,14 +797,14 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
if (!simulate)
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat, GUI_COLOR_CHAT);
- if (!line->message || !line->message[0])
+ if (!line->data->message || !line->data->message[0])
{
gui_chat_display_new_line (window, num_lines, count,
&lines_displayed, simulate);
}
else
{
- ptr_data = line->message;
+ ptr_data = line->data->message;
while (ptr_data && ptr_data[0])
{
gui_chat_get_word_info (window,
@@ -767,7 +818,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
if (word_length > 0)
{
/* spaces + word too long for current line but ok for next line */
- line_align = gui_chat_get_line_align (window->buffer, line, 1);
+ line_align = gui_line_get_align (window->buffer, line, 1);
if ((window->win_chat_cursor_x + word_length_with_spaces > gui_chat_get_real_width (window))
&& (word_length <= gui_chat_get_real_width (window) - line_align))
{
@@ -830,7 +881,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
}
}
- if (marker_line && gui_chat_get_next_line_displayed (line))
+ if (marker_line && gui_line_get_next_displayed (line))
{
gui_chat_display_horizontal_line (window, simulate);
gui_chat_display_new_line (window, num_lines, count,
@@ -847,7 +898,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
/* display marker if line is matching user search */
if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
{
- if (gui_chat_line_search (line, window->buffer->input_buffer,
+ if (gui_line_search_text (line, window->buffer->input_buffer,
window->buffer->text_search_exact))
{
gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat,
@@ -861,8 +912,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
{
/* display read marker if needed */
if ((CONFIG_INTEGER(config_look_read_marker) == CONFIG_LOOK_READ_MARKER_CHAR)
- && window->buffer->last_read_line
- && (window->buffer->last_read_line == gui_chat_get_prev_line_displayed (line)))
+ && window->buffer->lines->last_read_line
+ && (window->buffer->lines->last_read_line == gui_line_get_prev_displayed (line)))
{
gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat,
GUI_COLOR_CHAT_READ_MARKER);
@@ -896,7 +947,7 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
window->win_chat_cursor_x);
wclrtoeol (GUI_WINDOW_OBJECTS(window)->win_chat);
- if (gui_chat_display_word_raw (window, line->message,
+ if (gui_chat_display_word_raw (window, line->data->message,
window->win_chat_width, 1) < window->win_chat_width)
{
gui_window_clrtoeol_with_current_bg (GUI_WINDOW_OBJECTS(window)->win_chat);
@@ -925,7 +976,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
/* if looking backward, start at last line of buffer */
if (backward)
{
- *line = gui_chat_get_last_line_displayed (window->buffer);
+ *line = gui_line_get_last_displayed (window->buffer);
if (!(*line))
return;
current_size = gui_chat_display_line (window, *line, 0, 1);
@@ -936,7 +987,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
/* if looking forward, start at first line of buffer */
else
{
- *line = gui_chat_get_first_line_displayed (window->buffer);
+ *line = gui_line_get_first_displayed (window->buffer);
if (!(*line))
return;
*line_pos = 0;
@@ -955,7 +1006,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
(*line_pos)--;
else
{
- *line = gui_chat_get_prev_line_displayed (*line);
+ *line = gui_line_get_prev_displayed (*line);
if (*line)
{
current_size = gui_chat_display_line (window, *line, 0, 1);
@@ -973,7 +1024,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
(*line_pos)++;
else
{
- *line = gui_chat_get_next_line_displayed (*line);
+ *line = gui_line_get_next_displayed (*line);
if (*line)
{
current_size = gui_chat_display_line (window, *line, 0, 1);
@@ -992,7 +1043,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
if (backward)
{
/* first line reached */
- *line = gui_chat_get_first_line_displayed (window->buffer);
+ *line = gui_line_get_first_displayed (window->buffer);
*line_pos = 0;
}
else
@@ -1020,7 +1071,7 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
- if (ptr_win->buffer == buffer)
+ if (ptr_win->buffer->number == buffer->number)
{
if (erase)
{
@@ -1069,18 +1120,18 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
ptr_line,
0, 1) -
line_pos, 0);
- ptr_line = gui_chat_get_next_line_displayed (ptr_line);
+ ptr_line = gui_line_get_next_displayed (ptr_line);
ptr_win->first_line_displayed = 0;
}
else
ptr_win->first_line_displayed =
- (ptr_line == gui_chat_get_first_line_displayed (ptr_win->buffer));
+ (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_chat_get_next_line_displayed (ptr_line);
+ ptr_line = gui_line_get_next_displayed (ptr_line);
}
old_scroll = ptr_win->scroll;
@@ -1092,13 +1143,13 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
/* if so, disable scroll indicator */
if (!ptr_line && ptr_win->scroll)
{
- if ((count == gui_chat_display_line (ptr_win, gui_chat_get_last_line_displayed (ptr_win->buffer), 0, 1))
+ if ((count == gui_chat_display_line (ptr_win, gui_line_get_last_displayed (ptr_win->buffer), 0, 1))
|| (count == ptr_win->win_chat_height))
ptr_win->scroll = 0;
}
if (!ptr_win->scroll
- && (ptr_win->start_line == gui_chat_get_first_line_displayed (ptr_win->buffer)))
+ && (ptr_win->start_line == gui_line_get_first_displayed (ptr_win->buffer)))
{
ptr_win->start_line = NULL;
ptr_win->start_line_pos = 0;
@@ -1110,7 +1161,7 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
/* count number of lines after last line displayed */
while (ptr_line)
{
- ptr_line = gui_chat_get_next_line_displayed (ptr_line);
+ ptr_line = gui_line_get_next_displayed (ptr_line);
if (ptr_line)
ptr_win->scroll_lines_after++;
}
@@ -1144,23 +1195,23 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
case GUI_BUFFER_TYPE_FREE:
/* display at position of scrolling */
ptr_line = (ptr_win->start_line) ?
- ptr_win->start_line : buffer->lines;
+ ptr_win->start_line : buffer->lines->first_line;
if (ptr_line)
{
- if (!ptr_line->displayed)
- ptr_line = gui_chat_get_next_line_displayed (ptr_line);
+ if (!ptr_line->data->displayed)
+ ptr_line = gui_line_get_next_displayed (ptr_line);
if (ptr_line)
{
- y_start = (ptr_win->start_line) ? ptr_line->y : 0;
+ y_start = (ptr_win->start_line) ? ptr_line->data->y : 0;
y_end = y_start + ptr_win->win_chat_height - 1;
- while (ptr_line && (ptr_line->y <= y_end))
+ while (ptr_line && (ptr_line->data->y <= y_end))
{
- if (ptr_line->refresh_needed || erase)
+ if (ptr_line->data->refresh_needed || erase)
{
gui_chat_display_line_y (ptr_win, ptr_line,
- ptr_line->y - y_start);
+ ptr_line->data->y - y_start);
}
- ptr_line = gui_chat_get_next_line_displayed (ptr_line);
+ ptr_line = gui_line_get_next_displayed (ptr_line);
}
}
}
@@ -1176,10 +1227,10 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
if (buffer->type == GUI_BUFFER_TYPE_FREE)
{
- for (ptr_line = buffer->lines; ptr_line;
+ for (ptr_line = buffer->lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
{
- ptr_line->refresh_needed = 0;
+ ptr_line->data->refresh_needed = 0;
}
}
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c
index 1403e5e69..914713c61 100644
--- a/src/gui/curses/gui-curses-color.c
+++ b/src/gui/curses/gui-curses-color.c
@@ -382,6 +382,7 @@ gui_color_init_weechat ()
gui_color_build (GUI_COLOR_CHAT_READ_MARKER, CONFIG_COLOR(config_color_chat_read_marker), CONFIG_COLOR(config_color_chat_read_marker_bg));
gui_color_build (GUI_COLOR_CHAT_TEXT_FOUND, CONFIG_COLOR(config_color_chat_text_found), CONFIG_COLOR(config_color_chat_text_found_bg));
gui_color_build (GUI_COLOR_CHAT_VALUE, CONFIG_COLOR(config_color_chat_value), CONFIG_COLOR(config_color_chat_bg));
+ gui_color_build (GUI_COLOR_CHAT_PREFIX_BUFFER, CONFIG_COLOR(config_color_chat_prefix_buffer), CONFIG_COLOR(config_color_chat_bg));
}
/*
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index e19365c49..d7d1e6a4e 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -86,6 +86,7 @@ gui_keyboard_default_bindings ()
gui_keyboard_default_bind (/* del */ "meta2-3~", "/input delete_next_char");
gui_keyboard_default_bind (/* ^D */ "ctrl-D", "/input delete_next_char");
gui_keyboard_default_bind (/* ^W */ "ctrl-W", "/input delete_previous_word");
+ gui_keyboard_default_bind (/* ^X */ "ctrl-X", "/input switch_active_buffer");
gui_keyboard_default_bind (/* m-d */ "meta-d", "/input delete_next_word");
gui_keyboard_default_bind (/* ^K */ "ctrl-K", "/input delete_end_of_line");
gui_keyboard_default_bind (/* m-r */ "meta-r", "/input delete_line");
@@ -114,16 +115,14 @@ gui_keyboard_default_bindings ()
gui_keyboard_default_bind (/* ^down */ "meta-Ob", "/input history_global_next");
gui_keyboard_default_bind (/* m-a */ "meta-a", "/input jump_smart");
gui_keyboard_default_bind (/* m-j,m-l */ "meta-jmeta-l", "/input jump_last_buffer");
- gui_keyboard_default_bind (/* m-j,m-p */ "meta-jmeta-p", "/input jump_previous_buffer");
gui_keyboard_default_bind (/* m-j,m-r */ "meta-jmeta-r", "/server raw");
gui_keyboard_default_bind (/* m-h */ "meta-h", "/input hotlist_clear");
gui_keyboard_default_bind (/* m-k */ "meta-k", "/input grab_key");
- gui_keyboard_default_bind (/* m-s */ "meta-s", "/server switch");
gui_keyboard_default_bind (/* m-u */ "meta-u", "/input scroll_unread");
gui_keyboard_default_bind (/* ^S^U */ "ctrl-Sctrl-U", "/input set_unread");
gui_keyboard_default_bind (/* ^Cb */ "ctrl-Cb", "/input insert \\x02");
gui_keyboard_default_bind (/* ^Cc */ "ctrl-Cc", "/input insert \\x03");
- gui_keyboard_default_bind (/* ^Cc */ "ctrl-Ci", "/input insert \\x1D");
+ gui_keyboard_default_bind (/* ^Ci */ "ctrl-Ci", "/input insert \\x1D");
gui_keyboard_default_bind (/* ^Co */ "ctrl-Co", "/input insert \\x0F");
gui_keyboard_default_bind (/* ^Cr */ "ctrl-Cr", "/input insert \\x12");
gui_keyboard_default_bind (/* ^Cu */ "ctrl-Cu", "/input insert \\x15");
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index 5bf42f16b..7c20cc1a6 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -43,6 +43,7 @@
#include "../gui-hotlist.h"
#include "../gui-input.h"
#include "../gui-main.h"
+#include "../gui-line.h"
#include "../gui-nicklist.h"
#include "gui-curses.h"
@@ -488,12 +489,11 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
if (!gui_ok)
return;
- if (window->buffer->num_displayed > 0)
- window->buffer->num_displayed--;
+ gui_buffer_add_value_num_displayed (window->buffer, -1);
old_buffer = window->buffer;
- if (window->buffer != buffer)
+ if (window->buffer->number != buffer->number)
{
window->start_line = NULL;
window->start_line_pos = 0;
@@ -506,19 +506,19 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
{
if (window->buffer->num_displayed == 0)
{
- window->buffer->last_read_line = window->buffer->last_line;
- window->buffer->first_line_not_read = 0;
+ window->buffer->lines->last_read_line = window->buffer->lines->last_line;
+ window->buffer->lines->first_line_not_read = 0;
}
- if (buffer->last_read_line == buffer->last_line)
+ if (buffer->lines->last_read_line == buffer->lines->last_line)
{
- buffer->last_read_line = NULL;
- buffer->first_line_not_read = 0;
+ buffer->lines->last_read_line = NULL;
+ buffer->lines->first_line_not_read = 0;
}
}
}
window->buffer = buffer;
- buffer->num_displayed++;
+ gui_buffer_add_value_num_displayed (buffer, 1);
gui_hotlist_remove_buffer (buffer);
@@ -558,6 +558,8 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
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)
{
@@ -812,7 +814,7 @@ gui_window_scroll_top (struct t_gui_window *window)
case GUI_BUFFER_TYPE_FORMATTED:
if (!window->first_line_displayed)
{
- window->start_line = gui_chat_get_first_line_displayed (window->buffer);
+ window->start_line = gui_line_get_first_displayed (window->buffer);
window->start_line_pos = 0;
window->scroll_reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
@@ -857,7 +859,7 @@ gui_window_scroll_bottom (struct t_gui_window *window)
break;
case GUI_BUFFER_TYPE_FREE:
window->start_line = NULL;
- if (window->buffer->lines_count > window->win_chat_height)
+ if (window->buffer->lines->lines_count > window->win_chat_height)
{
snprintf (scroll, sizeof (scroll), "-%d",
window->win_chat_height - 1);
@@ -1015,7 +1017,7 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage)
window->win_height_pct = 100 - percentage;
/* assign same buffer for new window (top window) */
- new_window->buffer->num_displayed++;
+ gui_buffer_add_value_num_displayed (new_window->buffer, 1);
window->refresh_needed = 1;
new_window->refresh_needed = 1;
@@ -1059,7 +1061,7 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
window->win_width_pct = 100 - percentage;
/* assign same buffer for new window (right window) */
- new_window->buffer->num_displayed++;
+ gui_buffer_add_value_num_displayed (new_window->buffer, 1);
window->refresh_needed = 1;
new_window->refresh_needed = 1;
diff --git a/src/gui/gtk/gui-gtk-bar-window.c b/src/gui/gtk/gui-gtk-bar-window.c
index a7eacbd4f..95a6e9850 100644
--- a/src/gui/gtk/gui-gtk-bar-window.c
+++ b/src/gui/gtk/gui-gtk-bar-window.c
@@ -30,7 +30,6 @@
#include "../../core/wee-log.h"
#include "../gui-bar.h"
#include "../gui-bar-window.h"
-#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-window.h"
#include "gui-gtk.h"
diff --git a/src/gui/gtk/gui-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c
index 7b009f83c..2cdd395a7 100644
--- a/src/gui/gtk/gui-gtk-chat.c
+++ b/src/gui/gtk/gui-gtk-chat.c
@@ -34,6 +34,7 @@
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-main.h"
+#include "../gui-line.h"
#include "../gui-window.h"
#include "gui-gtk.h"
@@ -358,7 +359,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **l
/* if looking backward, start at last line of buffer */
if (backward)
{
- *line = window->buffer->last_line;
+ *line = window->buffer->lines->last_line;
if (!(*line))
return;
current_size = gui_chat_display_line (window, *line, 0, 1);
@@ -369,7 +370,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **l
/* if looking forward, start at first line of buffer */
else
{
- *line = window->buffer->lines;
+ *line = window->buffer->lines->first_line;
if (!(*line))
return;
*line_pos = 0;
@@ -425,7 +426,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **l
if (backward)
{
/* first line reached */
- *line = window->buffer->lines;
+ *line = window->buffer->lines->first_line;
*line_pos = 0;
}
else
diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c
index c40c342aa..b25e7baed 100644
--- a/src/gui/gtk/gui-gtk-color.c
+++ b/src/gui/gtk/gui-gtk-color.c
@@ -31,7 +31,6 @@
#include "../../core/wee-config.h"
#include "../../core/wee-string.h"
#include "../gui-color.h"
-#include "../gui-chat.h"
#include "gui-gtk.h"
diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c
index ecb836257..2d64dddfe 100644
--- a/src/gui/gtk/gui-gtk-window.c
+++ b/src/gui/gtk/gui-gtk-window.c
@@ -34,6 +34,7 @@
#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-hotlist.h"
+#include "../gui-line.h"
#include "../gui-nicklist.h"
#include "../gui-main.h"
#include "gui-gtk.h"
@@ -195,8 +196,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
{
GtkTextIter start, end;
- if (window->buffer->num_displayed > 0)
- window->buffer->num_displayed--;
+ gui_buffer_add_value_num_displayed (window->buffer, -1);
if (window->buffer != buffer)
{
@@ -211,13 +211,13 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
{
if (window->buffer->num_displayed == 0)
{
- window->buffer->last_read_line = window->buffer->last_line;
- window->buffer->first_line_not_read = 0;
+ window->buffer->lines->last_read_line = window->buffer->lines->last_line;
+ window->buffer->lines->first_line_not_read = 0;
}
- if (buffer->last_read_line == buffer->last_line)
+ if (buffer->lines->last_read_line == buffer->lines->last_line)
{
- buffer->last_read_line = NULL;
- buffer->first_line_not_read = 0;
+ buffer->lines->last_read_line = NULL;
+ buffer->lines->first_line_not_read = 0;
}
}
}
@@ -245,7 +245,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
window->start_line = NULL;
window->start_line_pos = 0;
- buffer->num_displayed++;
+ gui_buffer_add_value_num_displayed (buffer, 1);
gui_hotlist_remove_buffer (buffer);
}
@@ -376,7 +376,7 @@ gui_window_scroll_top (struct t_gui_window *window)
if (!window->first_line_displayed)
{
- window->start_line = window->buffer->lines;
+ window->start_line = window->buffer->lines->first_line;
window->start_line_pos = 0;
gui_chat_draw (window->buffer, 0);
}
@@ -502,7 +502,7 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage)
window->win_height_pct = 100 - percentage;
/* assign same buffer for new window (top window) */
- new_window->buffer->num_displayed++;
+ gui_buffer_add_value_num_displayed (new_window->buffer, 1);
gui_window_switch_to_buffer (window, window->buffer, 1);
@@ -546,7 +546,7 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
window->win_width_pct = 100 - percentage;
/* assign same buffer for new window (right window) */
- new_window->buffer->num_displayed++;
+ gui_buffer_add_value_num_displayed (new_window->buffer, 1);
gui_window_switch_to_buffer (window, window->buffer, 1);
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index f78dcea16..73a233db6 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -45,6 +45,7 @@
#include "gui-filter.h"
#include "gui-hotlist.h"
#include "gui-keyboard.h"
+#include "gui-line.h"
#include "gui-nicklist.h"
#include "gui-window.h"
@@ -881,7 +882,7 @@ gui_bar_item_default_buffer_filter (void *data, struct t_gui_bar_item *item,
if (!window)
window = gui_current_window;
- if (!gui_filters_enabled || !gui_filters || !window->buffer->lines_hidden)
+ if (!gui_filters_enabled || !gui_filters || !window->buffer->lines->lines_hidden)
return NULL;
snprintf (buf, sizeof (buf),
@@ -1366,6 +1367,10 @@ gui_bar_item_init ()
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER]);
gui_bar_item_hook_signal ("buffer_moved",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER]);
+ gui_bar_item_hook_signal ("buffer_merged",
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER]);
+ gui_bar_item_hook_signal ("buffer_unmerged",
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER]);
/* buffer name */
gui_bar_item_new (NULL,
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index e933e48ef..373451276 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -49,6 +49,7 @@
#include "gui-input.h"
#include "gui-keyboard.h"
#include "gui-layout.h"
+#include "gui-line.h"
#include "gui-main.h"
#include "gui-nicklist.h"
#include "gui-window.h"
@@ -394,6 +395,8 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
/* init buffer */
new_buffer->plugin = plugin;
new_buffer->plugin_name_for_upgrade = NULL;
+ new_buffer->merge_for_upgrade = NULL;
+
/* number will be set later (when inserting buffer in list) */
new_buffer->layout_number = gui_layout_buffer_get_number (gui_layout_buffers,
plugin_get_name (plugin),
@@ -403,6 +406,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->type = GUI_BUFFER_TYPE_FORMATTED;
new_buffer->notify = CONFIG_INTEGER(config_look_buffer_notify_default);
new_buffer->num_displayed = 0;
+ new_buffer->active = 1;
new_buffer->print_hooks_enabled = 1;
/* close callback */
@@ -412,14 +416,10 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
/* title */
new_buffer->title = NULL;
- /* chat lines (formatted) */
- new_buffer->lines = NULL;
- new_buffer->last_line = NULL;
- new_buffer->last_read_line = NULL;
- new_buffer->first_line_not_read = 0;
- new_buffer->lines_count = 0;
- new_buffer->lines_hidden = 0;
- new_buffer->prefix_max_length = 0;
+ /* chat content */
+ new_buffer->own_lines = gui_lines_alloc ();
+ new_buffer->mixed_lines = NULL;
+ new_buffer->lines = new_buffer->own_lines;
new_buffer->time_for_each_line = 1;
new_buffer->chat_refresh_needed = 2;
@@ -653,9 +653,9 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property)
else if (string_strcasecmp (property, "notify") == 0)
return buffer->notify;
else if (string_strcasecmp (property, "lines_hidden") == 0)
- return buffer->lines_hidden;
+ return buffer->lines->lines_hidden;
else if (string_strcasecmp (property, "prefix_max_length") == 0)
- return buffer->prefix_max_length;
+ return buffer->lines->prefix_max_length;
else if (string_strcasecmp (property, "time_for_each_line") == 0)
return buffer->time_for_each_line;
else if (string_strcasecmp (property, "text_search") == 0)
@@ -776,7 +776,7 @@ gui_buffer_set_type (struct t_gui_buffer *buffer, enum t_gui_buffer_type type)
if (buffer->type == type)
return;
- gui_chat_line_free_all (buffer);
+ gui_line_free_all (buffer);
buffer->type = type;
gui_buffer_ask_chat_refresh (buffer, 2);
@@ -915,11 +915,11 @@ gui_buffer_set_unread (struct t_gui_buffer *buffer)
if (buffer->type == GUI_BUFFER_TYPE_FORMATTED)
{
- refresh = ((buffer->last_read_line != NULL)
- && (buffer->last_read_line != buffer->last_line));
+ refresh = ((buffer->lines->last_read_line != NULL)
+ && (buffer->lines->last_read_line != buffer->lines->last_line));
- buffer->last_read_line = buffer->last_line;
- buffer->first_line_not_read = (buffer->last_read_line) ? 0 : 1;
+ buffer->lines->last_read_line = buffer->lines->last_line;
+ buffer->lines->first_line_not_read = (buffer->lines->last_read_line) ? 0 : 1;
if (refresh)
gui_buffer_ask_chat_refresh (buffer, 2);
@@ -1116,6 +1116,28 @@ gui_buffer_set_pointer (struct t_gui_buffer *buffer, const char *property,
}
/*
+ * gui_buffer_add_value_num_displayed: add value to "num_displayed" variable
+ * for a buffer (value can be negative)
+ */
+
+void
+gui_buffer_add_value_num_displayed (struct t_gui_buffer *buffer, int value)
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->number == buffer->number)
+ {
+ ptr_buffer->num_displayed += value;
+ if (ptr_buffer->num_displayed < 0)
+ ptr_buffer->num_displayed = 0;
+ }
+ }
+}
+
+/*
* gui_buffer_search_main: get main buffer (weechat one, created at startup)
* return first buffer if not found
*/
@@ -1132,8 +1154,8 @@ gui_buffer_search_main ()
return ptr_buffer;
}
- /* buffer not found, return first buffer by default */
- return gui_buffers;
+ /* buffer not found (should never occur!) */
+ return NULL;
}
/*
@@ -1298,6 +1320,29 @@ gui_buffer_search_by_number (int number)
}
/*
+ * gui_buffer_count_merged_buffers: return number of merged buffers (buffers
+ * with same number)
+ */
+
+int
+gui_buffer_count_merged_buffers (int number)
+{
+ struct t_gui_buffer *ptr_buffer;
+ int count;
+
+ count = 0;
+
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->number == number)
+ count++;
+ }
+
+ return count;
+}
+
+/*
* gui_buffer_is_scrolled: return 1 if all windows displaying buffer are scrolled
* (user doesn't see end of buffer)
* return 0 if at least one window is NOT scrolled
@@ -1345,7 +1390,7 @@ gui_buffer_clear (struct t_gui_buffer *buffer)
return;
/* remove all lines */
- gui_chat_line_free_all (buffer);
+ gui_line_free_all (buffer);
/* remove any scroll for buffer */
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
@@ -1397,6 +1442,10 @@ gui_buffer_close (struct t_gui_buffer *buffer)
{
(void)(buffer->close_callback) (buffer->close_callback_data, buffer);
}
+
+ /* first unmerge buffer if it is merged to at least one other buffer */
+ if (gui_buffer_count_merged_buffers (buffer->number) > 1)
+ gui_buffer_unmerge (buffer, -1);
if (!weechat_quit)
{
@@ -1465,7 +1514,7 @@ gui_buffer_close (struct t_gui_buffer *buffer)
}
/* free all lines */
- gui_chat_line_free_all (buffer);
+ gui_line_free_all (buffer);
/* free some data */
if (buffer->title)
@@ -1531,7 +1580,8 @@ gui_buffer_switch_by_number (struct t_gui_window *window, int number)
/* search for buffer in the list */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
- if ((ptr_buffer != window->buffer) && (number == ptr_buffer->number))
+ if ((ptr_buffer != window->buffer) && (number == ptr_buffer->number)
+ && ptr_buffer->active)
{
gui_window_switch_to_buffer (window, ptr_buffer, 1);
return;
@@ -1540,14 +1590,60 @@ gui_buffer_switch_by_number (struct t_gui_window *window, int number)
}
/*
+ * gui_buffer_set_active_buffer: set active buffer (when many buffers are
+ * merged)
+ */
+
+void
+gui_buffer_set_active_buffer (struct t_gui_buffer *buffer)
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->number == buffer->number)
+ ptr_buffer->active = (ptr_buffer == buffer) ? 1 : 0;
+ }
+}
+
+/*
+ * gui_buffer_get_next_active_buffer: get next active buffer (when many buffers
+ * are merged)
+ */
+
+struct t_gui_buffer *
+gui_buffer_get_next_active_buffer (struct t_gui_buffer *buffer)
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ if (buffer->next_buffer
+ && (buffer->next_buffer->number == buffer->number))
+ return buffer->next_buffer;
+ else
+ {
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if ((ptr_buffer != buffer)
+ && (ptr_buffer->number == buffer->number))
+ {
+ return ptr_buffer;
+ }
+ }
+ }
+ return buffer;
+}
+
+/*
* gui_buffer_move_to_number: move a buffer to another number
*/
void
gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
{
- struct t_gui_buffer *ptr_buffer;
- int i;
+ struct t_gui_buffer *ptr_first_buffer, *ptr_last_buffer, *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer_pos;
char buf1_str[16], buf2_str[16], *argv[2] = { NULL, NULL };
/* if only one buffer then return */
@@ -1561,26 +1657,61 @@ gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
if (number == buffer->number)
return;
+ ptr_first_buffer = NULL;
+ ptr_last_buffer = NULL;
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->number == buffer->number)
+ {
+ if (!ptr_first_buffer)
+ ptr_first_buffer = ptr_buffer;
+ ptr_last_buffer = ptr_buffer;
+ }
+ }
+
+ /* error when looking for buffers */
+ if (!ptr_first_buffer || !ptr_last_buffer)
+ return;
+
+ /* if group of buffers found is all buffers, then we can't move buffers! */
+ if ((ptr_first_buffer == gui_buffers) && (ptr_last_buffer == last_gui_buffer))
+ return;
+
snprintf (buf2_str, sizeof (buf2_str) - 1, "%d", buffer->number);
- /* remove buffer from list */
- if (buffer == gui_buffers)
+ /* remove buffer(s) from list */
+ if (ptr_first_buffer == gui_buffers)
{
- gui_buffers = buffer->next_buffer;
+ gui_buffers = ptr_last_buffer->next_buffer;
gui_buffers->prev_buffer = NULL;
}
- if (buffer == last_gui_buffer)
+ else if (ptr_last_buffer == last_gui_buffer)
{
- last_gui_buffer = buffer->prev_buffer;
+ last_gui_buffer = ptr_first_buffer->prev_buffer;
last_gui_buffer->next_buffer = NULL;
}
- if (buffer->prev_buffer)
- (buffer->prev_buffer)->next_buffer = buffer->next_buffer;
- if (buffer->next_buffer)
- (buffer->next_buffer)->prev_buffer = buffer->prev_buffer;
+ if (ptr_first_buffer->prev_buffer)
+ (ptr_first_buffer->prev_buffer)->next_buffer = ptr_last_buffer->next_buffer;
+ if (ptr_last_buffer->next_buffer)
+ (ptr_last_buffer->next_buffer)->prev_buffer = ptr_first_buffer->prev_buffer;
+
+ /* compute "number - 1" for all buffers after buffer(s) */
+ for (ptr_buffer = ptr_last_buffer->next_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ ptr_buffer->number--;
+ }
if (number == 1)
{
+ for (ptr_buffer = ptr_first_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ ptr_buffer->number = 1;
+ if (ptr_buffer == ptr_last_buffer)
+ break;
+ }
gui_buffers->prev_buffer = buffer;
buffer->prev_buffer = NULL;
buffer->next_buffer = gui_buffers;
@@ -1588,43 +1719,51 @@ gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
}
else
{
- /* assign new number to all buffers */
- i = 1;
- for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
- {
- ptr_buffer->number = i++;
- }
-
/* search for new position in the list */
- for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
+ for (ptr_buffer_pos = gui_buffers; ptr_buffer_pos;
+ ptr_buffer_pos = ptr_buffer_pos->next_buffer)
{
- if (ptr_buffer->number == number)
+ if (ptr_buffer_pos->number == number)
break;
}
- if (ptr_buffer)
+ if (ptr_buffer_pos)
{
/* insert before buffer found */
- buffer->prev_buffer = ptr_buffer->prev_buffer;
- buffer->next_buffer = ptr_buffer;
- if (ptr_buffer->prev_buffer)
- (ptr_buffer->prev_buffer)->next_buffer = buffer;
- ptr_buffer->prev_buffer = buffer;
+ for (ptr_buffer = ptr_first_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ ptr_buffer->number = ptr_buffer_pos->number;
+ if (ptr_buffer == ptr_last_buffer)
+ break;
+ }
+ ptr_first_buffer->prev_buffer = ptr_buffer_pos->prev_buffer;
+ ptr_last_buffer->next_buffer = ptr_buffer_pos;
+ if (ptr_buffer_pos->prev_buffer)
+ (ptr_buffer_pos->prev_buffer)->next_buffer = ptr_first_buffer;
+ ptr_buffer_pos->prev_buffer = ptr_last_buffer;
}
else
{
/* number not found (too big)? => add to end */
- buffer->prev_buffer = last_gui_buffer;
- buffer->next_buffer = NULL;
- last_gui_buffer->next_buffer = buffer;
- last_gui_buffer = buffer;
+ for (ptr_buffer = ptr_first_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ ptr_buffer->number = last_gui_buffer->number + 1;
+ if (ptr_buffer == ptr_last_buffer)
+ break;
+ }
+ ptr_first_buffer->prev_buffer = last_gui_buffer;
+ ptr_last_buffer->next_buffer = NULL;
+ last_gui_buffer->next_buffer = ptr_first_buffer;
+ last_gui_buffer = ptr_last_buffer;
}
}
- /* assign new number to all buffers */
- i = 1;
- for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
+ /* compute "number + 1" for all buffers after buffer(s) */
+ for (ptr_buffer = ptr_last_buffer->next_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
{
- ptr_buffer->number = i++;
+ ptr_buffer->number++;
}
snprintf (buf1_str, sizeof (buf1_str) - 1, "%d", buffer->number);
@@ -1636,6 +1775,176 @@ gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
}
/*
+ * gui_buffer_merge: merge a buffer to another buffer
+ */
+
+void
+gui_buffer_merge (struct t_gui_buffer *buffer,
+ struct t_gui_buffer *target_buffer)
+{
+ struct t_gui_buffer *ptr_buffer;
+ int target_number;
+
+ /* if only one buffer then return */
+ if (gui_buffers == last_gui_buffer)
+ return;
+
+ if ((buffer == target_buffer) || (buffer->number == target_buffer->number))
+ return;
+
+ if (gui_buffer_count_merged_buffers (buffer->number) > 1)
+ gui_buffer_unmerge (buffer, -1);
+
+ /* check if current buffer and target buffers are type "formatted" */
+ if ((buffer->type != GUI_BUFFER_TYPE_FORMATTED)
+ || (target_buffer->type != GUI_BUFFER_TYPE_FORMATTED))
+ {
+ gui_chat_printf (NULL,
+ _("%sError: it is only possible to merge buffers "
+ "with formatted content"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ return;
+ }
+
+ /* move buffer immediately after number we want to merge to */
+ target_number = (buffer->number < target_buffer->number) ?
+ target_buffer->number : target_buffer->number + 1;
+ if (buffer->number != target_number)
+ gui_buffer_move_to_number (buffer, target_number);
+
+ /* change number */
+ buffer->number--;
+
+ /* mix lines */
+ gui_line_mix_buffers (buffer);
+
+ /* set buffer as active in merged buffers group */
+ gui_buffer_set_active_buffer (buffer);
+
+ /* compute "number - 1" for next buffers */
+ for (ptr_buffer = buffer->next_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ ptr_buffer->number--;
+ }
+
+ gui_window_ask_refresh (1);
+
+ hook_signal_send ("buffer_merged",
+ WEECHAT_HOOK_SIGNAL_POINTER, buffer);
+}
+
+/*
+ * gui_buffer_unmerge: unmerge a buffer from group of merged buffers
+ * if number >= 1, then buffer is moved to this number,
+ * otherwise it is moved to buffer->number + 1
+ */
+
+void
+gui_buffer_unmerge (struct t_gui_buffer *buffer, int number)
+{
+ int num_merged;
+ struct t_gui_buffer *ptr_buffer;
+
+ /* if only one buffer then return */
+ if (gui_buffers == last_gui_buffer)
+ return;
+
+ num_merged = gui_buffer_count_merged_buffers (buffer->number);
+
+ /* can't unmerge if buffer is not merged to at least one buffer */
+ if (num_merged < 2)
+ return;
+
+ /* by default, we move buffer to buffer->number + 1 */
+ if ((number < 1) || (number == buffer->number))
+ {
+ number = buffer->number + 1;
+ }
+ else
+ {
+ if (number > last_gui_buffer->number + 1)
+ number = last_gui_buffer->number + 1;
+ }
+
+ if (num_merged == 2)
+ {
+ /* only one buffer will remain, so it will not be merged any more */
+ gui_line_mixed_free_all (buffer);
+ gui_lines_free (buffer->mixed_lines);
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->number == buffer->number)
+ {
+ ptr_buffer->active = 1;
+ ptr_buffer->mixed_lines = NULL;
+ ptr_buffer->lines = ptr_buffer->own_lines;
+ }
+ }
+ }
+ else
+ {
+ /* remove this buffer from mixed_lines, but keep other buffers merged */
+ ptr_buffer = gui_buffer_get_next_active_buffer (buffer);
+ if (ptr_buffer)
+ gui_buffer_set_active_buffer (ptr_buffer);
+ gui_line_mixed_free_buffer (buffer);
+ buffer->mixed_lines = NULL;
+ buffer->lines = buffer->own_lines;
+ }
+
+ /* remove buffer from list */
+ if (buffer->prev_buffer)
+ (buffer->prev_buffer)->next_buffer = buffer->next_buffer;
+ if (buffer->next_buffer)
+ (buffer->next_buffer)->prev_buffer = buffer->prev_buffer;
+ if (gui_buffers == buffer)
+ gui_buffers = buffer->next_buffer;
+ if (last_gui_buffer == buffer)
+ last_gui_buffer = buffer->prev_buffer;
+
+ /* move buffer */
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->number >= number)
+ break;
+ }
+ if (ptr_buffer)
+ {
+ /* insert buffer into the list (before buffer found) */
+ buffer->prev_buffer = ptr_buffer->prev_buffer;
+ buffer->next_buffer = ptr_buffer;
+ if (ptr_buffer->prev_buffer)
+ (ptr_buffer->prev_buffer)->next_buffer = buffer;
+ else
+ gui_buffers = buffer;
+ ptr_buffer->prev_buffer = buffer;
+ }
+ else
+ {
+ /* add buffer to the end */
+ buffer->prev_buffer = last_gui_buffer;
+ buffer->next_buffer = NULL;
+ last_gui_buffer->next_buffer = buffer;
+ last_gui_buffer = buffer;
+ }
+ buffer->active = 1;
+ buffer->number = number;
+ for (ptr_buffer = buffer->next_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ ptr_buffer->number++;
+ }
+
+ gui_window_ask_refresh (1);
+
+ hook_signal_send ("buffer_unmerged",
+ WEECHAT_HOOK_SIGNAL_POINTER, buffer);
+}
+
+/*
* gui_buffer_visited_search: search a visited buffer in list of visited buffers
*/
@@ -1867,11 +2176,11 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "print_hooks_enabled", buffer->print_hooks_enabled))
return 0;
- if (!infolist_new_var_integer (ptr_item, "first_line_not_read", buffer->first_line_not_read))
+ if (!infolist_new_var_integer (ptr_item, "first_line_not_read", buffer->lines->first_line_not_read))
return 0;
- if (!infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines_hidden))
+ if (!infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines->lines_hidden))
return 0;
- if (!infolist_new_var_integer (ptr_item, "prefix_max_length", buffer->prefix_max_length))
+ if (!infolist_new_var_integer (ptr_item, "prefix_max_length", buffer->lines->prefix_max_length))
return 0;
if (!infolist_new_var_integer (ptr_item, "time_for_each_line", buffer->time_for_each_line))
return 0;
@@ -1939,78 +2248,6 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
}
/*
- * gui_buffer_line_add_to_infolist: add a buffer line in an infolist
- * return 1 if ok, 0 if error
- */
-
-int
-gui_buffer_line_add_to_infolist (struct t_infolist *infolist,
- struct t_gui_buffer *buffer,
- struct t_gui_line *line)
-{
- 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_time (ptr_item, "date", line->date))
- return 0;
- if (!infolist_new_var_time (ptr_item, "date_printed", line->date))
- return 0;
- if (!infolist_new_var_string (ptr_item, "str_time", line->str_time))
- return 0;
-
- /* write tags */
- if (!infolist_new_var_integer (ptr_item, "tags_count", line->tags_count))
- return 0;
- length = 0;
- for (i = 0; i < line->tags_count; i++)
- {
- snprintf (option_name, sizeof (option_name), "tag_%05d", i + 1);
- if (!infolist_new_var_string (ptr_item, option_name,
- line->tags_array[i]))
- return 0;
- length += strlen (line->tags_array[i]) + 1;
- }
- tags = malloc (length + 1);
- if (!tags)
- return 0;
- tags[0] = '\0';
- for (i = 0; i < line->tags_count; i++)
- {
- strcat (tags, line->tags_array[i]);
- if (i < line->tags_count - 1)
- strcat (tags, ",");
- }
- if (!infolist_new_var_string (ptr_item, "tags", tags))
- {
- free (tags);
- return 0;
- }
- free (tags);
-
- if (!infolist_new_var_integer (ptr_item, "displayed", line->displayed))
- return 0;
- if (!infolist_new_var_integer (ptr_item, "highlight", line->highlight))
- return 0;
- if (!infolist_new_var_string (ptr_item, "prefix", line->prefix))
- return 0;
- if (!infolist_new_var_string (ptr_item, "message", line->message))
- return 0;
- if (!infolist_new_var_integer (ptr_item, "last_read_line",
- (buffer->last_read_line == line) ? 1 : 0))
- return 0;
-
- return 1;
-}
-
-/*
* gui_buffer_dump_hexa: dump content of buffer as hexa data in log file
*/
@@ -2025,11 +2262,12 @@ gui_buffer_dump_hexa (struct t_gui_buffer *buffer)
log_printf ("[buffer dump hexa (addr:0x%lx)]", buffer);
num_line = 1;
- for (ptr_line = buffer->lines; ptr_line; ptr_line = ptr_line->next_line)
+ for (ptr_line = buffer->lines->first_line; ptr_line;
+ ptr_line = ptr_line->next_line)
{
/* display line without colors */
- message_without_colors = (ptr_line->message) ?
- gui_color_decode (ptr_line->message, NULL) : NULL;
+ message_without_colors = (ptr_line->data->message) ?
+ gui_color_decode (ptr_line->data->message, NULL) : NULL;
log_printf ("");
log_printf (" line %d: %s",
num_line,
@@ -2037,13 +2275,13 @@ gui_buffer_dump_hexa (struct t_gui_buffer *buffer)
message_without_colors : "(null)");
if (message_without_colors)
free (message_without_colors);
- tags = string_build_with_exploded ((const char **)ptr_line->tags_array, ",");
+ tags = string_build_with_exploded ((const char **)ptr_line->data->tags_array, ",");
log_printf (" tags: %s", (tags) ? tags : "(none)");
if (tags)
free (tags);
/* display raw message for line */
- if (ptr_line->message)
+ if (ptr_line->data->message)
{
log_printf ("");
log_printf (" raw data for line %d (with color codes):",
@@ -2051,15 +2289,15 @@ gui_buffer_dump_hexa (struct t_gui_buffer *buffer)
msg_pos = 0;
hexa_pos = 0;
ascii_pos = 0;
- while (ptr_line->message[msg_pos])
+ while (ptr_line->data->message[msg_pos])
{
snprintf (hexa + hexa_pos, 4, "%02X ",
- (unsigned char)(ptr_line->message[msg_pos]));
+ (unsigned char)(ptr_line->data->message[msg_pos]));
hexa_pos += 3;
snprintf (ascii + ascii_pos, 3, "%c ",
- ((((unsigned char)ptr_line->message[msg_pos]) < 32)
- || (((unsigned char)ptr_line->message[msg_pos]) > 127)) ?
- '.' : (unsigned char)(ptr_line->message[msg_pos]));
+ ((((unsigned char)ptr_line->data->message[msg_pos]) < 32)
+ || (((unsigned char)ptr_line->data->message[msg_pos]) > 127)) ?
+ '.' : (unsigned char)(ptr_line->data->message[msg_pos]));
ascii_pos += 2;
if (ascii_pos == 32)
{
@@ -2106,17 +2344,16 @@ gui_buffer_print_log ()
log_printf (" type . . . . . . . . . : %d", ptr_buffer->type);
log_printf (" notify . . . . . . . . : %d", ptr_buffer->notify);
log_printf (" num_displayed. . . . . : %d", ptr_buffer->num_displayed);
+ log_printf (" active . . . . . . . . : %d", ptr_buffer->active);
log_printf (" print_hooks_enabled. . : %d", ptr_buffer->print_hooks_enabled);
log_printf (" close_callback . . . . : 0x%lx", ptr_buffer->close_callback);
log_printf (" close_callback_data. . : 0x%lx", ptr_buffer->close_callback_data);
log_printf (" title. . . . . . . . . : '%s'", ptr_buffer->title);
+ log_printf (" own_lines. . . . . . . : 0x%lx", ptr_buffer->own_lines);
+ gui_lines_print_log (ptr_buffer->own_lines);
+ log_printf (" mixed_lines. . . . . . : 0x%lx", ptr_buffer->mixed_lines);
+ gui_lines_print_log (ptr_buffer->mixed_lines);
log_printf (" lines. . . . . . . . . : 0x%lx", ptr_buffer->lines);
- log_printf (" last_line. . . . . . . : 0x%lx", ptr_buffer->last_line);
- log_printf (" last_read_line . . . . : 0x%lx", ptr_buffer->last_read_line);
- log_printf (" first_line_not_read. . : %d", ptr_buffer->first_line_not_read);
- log_printf (" lines_count. . . . . . : %d", ptr_buffer->lines_count);
- log_printf (" lines_hidden . . . . . : %d", ptr_buffer->lines_hidden);
- log_printf (" prefix_max_length. . . : %d", ptr_buffer->prefix_max_length);
log_printf (" time_for_each_line . . : %d", ptr_buffer->time_for_each_line);
log_printf (" chat_refresh_needed. . : %d", ptr_buffer->chat_refresh_needed);
log_printf (" nicklist . . . . . . . : %d", ptr_buffer->nicklist);
@@ -2150,6 +2387,8 @@ gui_buffer_print_log ()
log_printf (" highlight_tags_array . : 0x%lx", ptr_buffer->highlight_tags_array);
log_printf (" keys . . . . . . . . . : 0x%lx", ptr_buffer->keys);
log_printf (" last_key . . . . . . . : 0x%lx", ptr_buffer->last_key);
+ log_printf (" local_variables. . . . : 0x%lx", ptr_buffer->local_variables);
+ log_printf (" last_local_var . . . . : 0x%lx", ptr_buffer->last_local_var);
log_printf (" prev_buffer. . . . . . : 0x%lx", ptr_buffer->prev_buffer);
log_printf (" next_buffer. . . . . . : 0x%lx", ptr_buffer->next_buffer);
@@ -2184,31 +2423,31 @@ gui_buffer_print_log ()
log_printf ("");
log_printf (" => last 100 lines:");
num = 0;
- ptr_line = ptr_buffer->last_line;
+ ptr_line = ptr_buffer->lines->last_line;
while (ptr_line && (num < 100))
{
num++;
ptr_line = ptr_line->prev_line;
}
if (!ptr_line)
- ptr_line = ptr_buffer->lines;
+ ptr_line = ptr_buffer->lines->first_line;
else
ptr_line = ptr_line->next_line;
while (ptr_line)
{
num--;
- tags = string_build_with_exploded ((const char **)ptr_line->tags_array, ",");
+ tags = string_build_with_exploded ((const char **)ptr_line->data->tags_array, ",");
log_printf (" line N-%05d: y:%d, str_time:'%s', tags:'%s', "
"displayed:%d, highlight:%d, refresh_needed:%d, prefix:'%s'",
- num, ptr_line->y, ptr_line->str_time,
+ num, ptr_line->data->y, ptr_line->data->str_time,
(tags) ? tags : "",
- (int)(ptr_line->displayed),
- (int) (ptr_line->highlight),
- (int)(ptr_line->refresh_needed),
- ptr_line->prefix);
+ (int)(ptr_line->data->displayed),
+ (int)(ptr_line->data->highlight),
+ (int)(ptr_line->data->refresh_needed),
+ ptr_line->data->prefix);
log_printf (" data: '%s'",
- ptr_line->message);
+ ptr_line->data->message);
if (tags)
free (tags);
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index c46033d6f..58c251d6c 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -49,24 +49,6 @@ enum t_gui_buffer_notify
/* buffer structures */
-struct t_gui_line
-{
- int y; /* line position (for free buffer) */
- time_t date; /* date/time of line (may be past) */
- time_t date_printed; /* date/time when weechat print it */
- char *str_time; /* time string (for display) */
- int tags_count; /* number of tags for line */
- char **tags_array; /* tags for line */
- char displayed; /* 1 if line is displayed */
- char highlight; /* 1 if line has highlight */
- char refresh_needed; /* 1 if refresh asked (free buffer) */
- char *prefix; /* prefix for line (may be NULL) */
- int prefix_length; /* prefix length (on screen) */
- char *message; /* line content (after prefix) */
- struct t_gui_line *prev_line; /* link to previous line */
- struct t_gui_line *next_line; /* link to next line */
-};
-
struct t_gui_buffer_local_var
{
char *name; /* variable name */
@@ -83,6 +65,10 @@ struct t_gui_buffer
to store plugin name, then restore plugin pointer when plugin is
loaded */
char *plugin_name_for_upgrade; /* plugin name when upgrading */
+ /* when upgrading, we use this pointer to remember that this buffer
+ must merge with another buffer (it's done when all buffers are
+ restored) */
+ struct t_gui_buffer *merge_for_upgrade;
int number; /* buffer number (for jump/switch) */
int layout_number; /* the number of buffer saved in */
@@ -95,6 +81,9 @@ struct t_gui_buffer
/* 2 = highlight + msg */
/* 3 = highlight + msg + join/part */
int num_displayed; /* number of windows displaying buf. */
+ int active; /* it is 0 only if buffers are */
+ /* merged and that this one is not */
+ /* selected buffer */
int print_hooks_enabled; /* 1 if print hooks are enabled */
/* close callback */
@@ -106,13 +95,10 @@ struct t_gui_buffer
char *title; /* buffer title */
/* chat content */
- struct t_gui_line *lines; /* lines of chat window */
- struct t_gui_line *last_line; /* last line of chat window */
- struct t_gui_line *last_read_line; /* last read line before jump */
- int first_line_not_read; /* if 1, marker is before first line */
- int lines_count; /* number of lines in the buffer */
- int lines_hidden; /* 1 if at least one line is hidden */
- int prefix_max_length; /* length for prefix align */
+ struct t_gui_lines *own_lines; /* lines (for this buffer only) */
+ struct t_gui_lines *mixed_lines; /* mixed lines (if buffers merged) */
+ struct t_gui_lines *lines; /* pointer to "own_lines" or */
+ /* "mixed_lines" */
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) */
@@ -230,6 +216,8 @@ extern void gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value);
extern void gui_buffer_set_pointer (struct t_gui_buffer *buffer,
const char *property, void *pointer);
+extern void gui_buffer_add_value_num_displayed (struct t_gui_buffer *buffer,
+ int value);
extern struct t_gui_buffer *gui_buffer_search_main ();
extern struct t_gui_buffer *gui_buffer_search_by_name (const char *plugin,
const char *name);
@@ -242,7 +230,12 @@ extern void gui_buffer_clear_all ();
extern void gui_buffer_close (struct t_gui_buffer *buffer);
extern void gui_buffer_switch_by_number (struct t_gui_window *window,
int number);
+extern void gui_buffer_set_active_buffer (struct t_gui_buffer *buffer);
+extern struct t_gui_buffer *gui_buffer_get_next_active_buffer (struct t_gui_buffer *buffer);
extern void gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number);
+extern void gui_buffer_merge (struct t_gui_buffer *buffer,
+ struct t_gui_buffer *target_buffer);
+extern void gui_buffer_unmerge (struct t_gui_buffer *buffer, int number);
extern struct t_gui_buffer_visited *gui_buffer_visited_search_by_number (int number);
extern void gui_buffer_visited_remove (struct t_gui_buffer_visited *buffer_visited);
extern void gui_buffer_visited_remove_by_buffer (struct t_gui_buffer *buffer);
@@ -251,9 +244,6 @@ extern int gui_buffer_visited_get_index_previous ();
extern int gui_buffer_visited_get_index_next ();
extern int gui_buffer_add_to_infolist (struct t_infolist *infolist,
struct t_gui_buffer *buffer);
-extern int gui_buffer_line_add_to_infolist (struct t_infolist *infolist,
- struct t_gui_buffer *buffer,
- struct t_gui_line *line);
extern void gui_buffer_dump_hexa (struct t_gui_buffer *buffer);
extern void gui_buffer_print_log ();
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index ab881fcb0..80f11e611 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -41,7 +41,7 @@
#include "gui-buffer.h"
#include "gui-color.h"
#include "gui-filter.h"
-#include "gui-hotlist.h"
+#include "gui-line.h"
#include "gui-main.h"
#include "gui-window.h"
@@ -359,420 +359,20 @@ gui_chat_change_time_format ()
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- for (ptr_line = ptr_buffer->lines; ptr_line;
+ for (ptr_line = ptr_buffer->lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
{
- if (ptr_line->date != 0)
+ if (ptr_line->data->date != 0)
{
- if (ptr_line->str_time)
- free (ptr_line->str_time);
- ptr_line->str_time = gui_chat_get_time_string (ptr_line->date);
+ if (ptr_line->data->str_time)
+ free (ptr_line->data->str_time);
+ ptr_line->data->str_time = gui_chat_get_time_string (ptr_line->data->date);
}
}
}
}
/*
- * gui_chat_get_line_align: get alignment for a line
- */
-
-int
-gui_chat_get_line_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
- int with_suffix)
-{
- int time_length, length_suffix;
-
- time_length = (buffer->time_for_each_line) ? gui_chat_time_length : 0;
-
- if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)
- return time_length + 1 + line->prefix_length + 2;
-
- length_suffix = 0;
- if (with_suffix)
- {
- if (CONFIG_STRING(config_look_prefix_suffix)
- && CONFIG_STRING(config_look_prefix_suffix)[0])
- length_suffix = gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix)) + 1;
- }
- return time_length + ((buffer->prefix_max_length > 0) ? 1 : 0) +
- + (((CONFIG_INTEGER(config_look_prefix_align_max) > 0)
- && (buffer->prefix_max_length > CONFIG_INTEGER(config_look_prefix_align_max))) ?
- CONFIG_INTEGER(config_look_prefix_align_max) : buffer->prefix_max_length)
- + length_suffix + 1;
-}
-
-/*
- * gui_chat_line_displayed: return 1 if line is displayed (no filter on line,
- * or filters disabled), 0 if line is hidden
- */
-
-int
-gui_chat_line_displayed (struct t_gui_line *line)
-{
- /* line is hidden if filters are enabled and flag "displayed" is not set */
- if (gui_filters_enabled && !line->displayed)
- return 0;
-
- /* in all other cases, line is displayed */
- return 1;
-}
-
-/*
- * gui_chat_get_first_line_displayed: get first line displayed of a buffer
- */
-
-struct t_gui_line *
-gui_chat_get_first_line_displayed (struct t_gui_buffer *buffer)
-{
- struct t_gui_line *ptr_line;
-
- ptr_line = buffer->lines;
- while (ptr_line && !gui_chat_line_displayed (ptr_line))
- {
- ptr_line = ptr_line->next_line;
- }
-
- return ptr_line;
-}
-
-/*
- * gui_chat_get_last_line_displayed: get last line displayed of a buffer
- */
-
-struct t_gui_line *
-gui_chat_get_last_line_displayed (struct t_gui_buffer *buffer)
-{
- struct t_gui_line *ptr_line;
-
- ptr_line = buffer->last_line;
- while (ptr_line && !gui_chat_line_displayed (ptr_line))
- {
- ptr_line = ptr_line->prev_line;
- }
-
- return ptr_line;
-}
-
-/*
- * gui_chat_get_prev_line_displayed: get previous line displayed
- */
-
-struct t_gui_line *
-gui_chat_get_prev_line_displayed (struct t_gui_line *line)
-{
- if (line)
- {
- line = line->prev_line;
- while (line && !gui_chat_line_displayed (line))
- {
- line = line->prev_line;
- }
- }
- return line;
-}
-
-/*
- * gui_chat_get_next_line_displayed: get next line displayed
- */
-
-struct t_gui_line *
-gui_chat_get_next_line_displayed (struct t_gui_line *line)
-{
- if (line)
- {
- line = line->next_line;
- while (line && !gui_chat_line_displayed (line))
- {
- line = line->next_line;
- }
- }
- return line;
-}
-
-/*
- * gui_chat_line_search: search for text in a line
- */
-
-int
-gui_chat_line_search (struct t_gui_line *line, const char *text,
- int case_sensitive)
-{
- char *prefix, *message;
- int rc;
-
- if (!line || !line->message || !text || !text[0])
- return 0;
-
- rc = 0;
-
- if (line->prefix)
- {
- prefix = gui_color_decode (line->prefix, NULL);
- if (prefix)
- {
- if ((case_sensitive && (strstr (prefix, text)))
- || (!case_sensitive && (string_strcasestr (prefix, text))))
- rc = 1;
- free (prefix);
- }
- }
-
- if (!rc)
- {
- message = gui_color_decode (line->message, NULL);
- if (message)
- {
- if ((case_sensitive && (strstr (message, text)))
- || (!case_sensitive && (string_strcasestr (message, text))))
- rc = 1;
- free (message);
- }
- }
-
- return rc;
-}
-
-/*
- * gui_chat_line_match_regex: return 1 if message matches regex
- * 0 if it doesn't match
- */
-
-int
-gui_chat_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix,
- regex_t *regex_message)
-{
- 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;
-
- if (line->prefix)
- {
- prefix = gui_color_decode (line->prefix, NULL);
- if (!prefix
- || (regex_prefix && (regexec (regex_prefix, prefix, 0, NULL, 0) != 0)))
- match_prefix = 0;
- }
- else
- {
- if (regex_prefix)
- match_prefix = 0;
- }
-
- if (line->message)
- {
- message = gui_color_decode (line->message, NULL);
- if (!message
- || (regex_message && (regexec (regex_message, message, 0, NULL, 0) != 0)))
- match_message = 0;
- }
- else
- {
- if (regex_message)
- match_message = 0;
- }
-
- if (prefix)
- free (prefix);
- if (message)
- free (message);
-
- return (match_prefix && match_message);
-}
-
-/*
- * gui_chat_line_match_tags: return 1 if line matches tags
- * 0 if it doesn't match any tag in array
- */
-
-int
-gui_chat_line_match_tags (struct t_gui_line *line, int tags_count,
- char **tags_array)
-{
- int i, j;
-
- if (!line)
- return 0;
-
- if (line->tags_count == 0)
- return 0;
-
- for (i = 0; i < tags_count; i++)
- {
- for (j = 0; j < line->tags_count; j++)
- {
- /* check tag */
- if (string_match (line->tags_array[j],
- tags_array[i],
- 0))
- return 1;
- }
- }
-
- return 0;
-}
-
-/*
- * gui_chat_line_has_highlight: return 1 if given message contains highlight (with
- * a string in global highlight or buffer highlight)
- */
-
-int
-gui_chat_line_has_highlight (struct t_gui_buffer *buffer,
- struct t_gui_line *line)
-{
- int rc, i;
- char *msg_no_color;
-
- /* highlights are disabled on this buffer? (special value "-" means that
- buffer does not want any highlight) */
- if (buffer->highlight_words && (strcmp (buffer->highlight_words, "-") == 0))
- return 0;
-
- /* check if highlight is disabled for line */
- for (i = 0; i < line->tags_count; i++)
- {
- if (strcmp (line->tags_array[i], GUI_CHAT_TAG_NO_HIGHLIGHT) == 0)
- return 0;
- }
-
- /* check that line matches highlight tags, if any (if no tag is specified,
- then any tag is allowed) */
- if (buffer->highlight_tags_count > 0)
- {
- if (!gui_chat_line_match_tags (line,
- buffer->highlight_tags_count,
- buffer->highlight_tags_array))
- return 0;
- }
-
- /* remove color codes from line message */
- msg_no_color = gui_color_decode (line->message, NULL);
- if (!msg_no_color)
- return 0;
-
- /* there is highlight on line if one of global highlight words matches line
- or one of buffer highlight words matches line */
- rc = (string_has_highlight (msg_no_color,
- CONFIG_STRING(config_look_highlight)) ||
- string_has_highlight (msg_no_color,
- buffer->highlight_words));
-
- free (msg_no_color);
-
- return rc;
-}
-
-/*
- * gui_chat_line_free: delete a formatted line from a buffer
- */
-
-void
-gui_chat_line_free (struct t_gui_buffer *buffer, struct t_gui_line *line)
-{
- int update_prefix_max_length;
- struct t_gui_line *ptr_line;
- struct t_gui_window *ptr_win;
-
- update_prefix_max_length = (line->prefix_length == buffer->prefix_max_length);
-
- /* reset scroll for any window starting with this line */
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
- {
- if (ptr_win->start_line == line)
- {
- ptr_win->start_line = ptr_win->start_line->next_line;
- ptr_win->start_line_pos = 0;
- gui_buffer_ask_chat_refresh (buffer, 2);
- }
- }
-
- /* move read marker if it was on line we are removing */
- if (buffer->last_read_line == line)
- {
- buffer->last_read_line = buffer->last_read_line->prev_line;
- buffer->first_line_not_read = (buffer->last_read_line) ? 0 : 1;
- gui_buffer_ask_chat_refresh (buffer, 1);
- }
-
- /* free data */
- if (line->str_time)
- free (line->str_time);
- if (line->tags_array)
- string_free_exploded (line->tags_array);
- if (line->prefix)
- free (line->prefix);
- if (line->message)
- free (line->message);
-
- /* remove line from lines list */
- if (line->prev_line)
- (line->prev_line)->next_line = line->next_line;
- if (line->next_line)
- (line->next_line)->prev_line = line->prev_line;
- if (buffer->lines == line)
- buffer->lines = line->next_line;
- if (buffer->last_line == line)
- buffer->last_line = line->prev_line;
-
- free (line);
-
- buffer->lines_count--;
-
- if (update_prefix_max_length)
- {
- buffer->prefix_max_length = 0;
- for (ptr_line = buffer->lines; ptr_line;
- ptr_line = ptr_line->next_line)
- {
- if (ptr_line->prefix_length > buffer->prefix_max_length)
- buffer->prefix_max_length = ptr_line->prefix_length;
- }
- }
-}
-
-/*
- * gui_chat_line_free_all: delete all formatted lines from a buffer
- */
-
-void
-gui_chat_line_free_all (struct t_gui_buffer *buffer)
-{
- while (buffer->lines)
- {
- gui_chat_line_free (buffer, buffer->lines);
- }
-}
-
-/*
- * gui_chat_line_get_notify_level: get notify level for a line
- */
-
-int
-gui_chat_line_get_notify_level (struct t_gui_line *line)
-{
- int i;
-
- for (i = 0; i < line->tags_count; i++)
- {
- if (string_strcasecmp (line->tags_array[i], "notify_highlight") == 0)
- return GUI_HOTLIST_HIGHLIGHT;
- if (string_strcasecmp (line->tags_array[i], "notify_private") == 0)
- return GUI_HOTLIST_PRIVATE;
- if (string_strcasecmp (line->tags_array[i], "notify_message") == 0)
- return GUI_HOTLIST_MESSAGE;
- }
- return GUI_HOTLIST_LOW;
-}
-
-/*
* gui_chat_build_string_prefix_message: build a string with prefix and message
*/
@@ -783,22 +383,22 @@ gui_chat_build_string_prefix_message (struct t_gui_line *line)
int length;
length = 0;
- if (line->prefix)
- length += strlen (line->prefix);
+ if (line->data->prefix)
+ length += strlen (line->data->prefix);
length++;
- if (line->message)
- length += strlen (line->message);
+ if (line->data->message)
+ length += strlen (line->data->message);
length++;
string = malloc (length);
if (string)
{
string[0] = '\0';
- if (line->prefix)
- strcat (string, line->prefix);
+ if (line->data->prefix)
+ strcat (string, line->data->prefix);
strcat (string, "\t");
- if (line->message)
- strcat (string, line->message);
+ if (line->data->message)
+ strcat (string, line->data->message);
}
if (string)
@@ -815,219 +415,6 @@ gui_chat_build_string_prefix_message (struct t_gui_line *line)
}
/*
- * gui_chat_line_add: add a new line for a buffer
- */
-
-struct t_gui_line *
-gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
- time_t date_printed, const char *tags,
- const char *prefix, const char *message)
-{
- struct t_gui_line *new_line;
- struct t_gui_window *ptr_win;
- char *message_for_signal;
- int notify_level;
-
- new_line = malloc (sizeof (*new_line));
- if (!new_line)
- {
- log_printf (_("Not enough memory for new line"));
- return NULL;
- }
-
- /* fill data in new line */
- new_line->y = 0;
- new_line->date = date;
- new_line->date_printed = date_printed;
- new_line->str_time = (date == 0) ?
- NULL : gui_chat_get_time_string (date);
- if (tags)
- {
- new_line->tags_array = string_explode (tags, ",", 0, 0,
- &new_line->tags_count);
- }
- else
- {
- new_line->tags_count = 0;
- new_line->tags_array = NULL;
- }
- new_line->refresh_needed = 0;
- new_line->prefix = (prefix) ?
- strdup (prefix) : ((date != 0) ? strdup ("") : NULL);
- new_line->prefix_length = (prefix) ?
- gui_chat_strlen_screen (prefix) : 0;
- new_line->message = (message) ? strdup (message) : strdup ("");
- new_line->highlight = gui_chat_line_has_highlight (buffer, new_line);
-
- /* add line to lines list */
- if (!buffer->lines)
- buffer->lines = new_line;
- else
- buffer->last_line->next_line = new_line;
- new_line->prev_line = buffer->last_line;
- new_line->next_line = NULL;
- buffer->last_line = new_line;
- buffer->lines_count++;
-
- /* check if line is filtered or not */
- new_line->displayed = gui_filter_check_line (buffer, new_line);
- if (new_line->displayed)
- {
- if (new_line->prefix_length > buffer->prefix_max_length)
- buffer->prefix_max_length = new_line->prefix_length;
- if (new_line->highlight)
- {
- gui_hotlist_add (buffer, GUI_HOTLIST_HIGHLIGHT, NULL, 1);
- if (!weechat_upgrading)
- {
- message_for_signal = gui_chat_build_string_prefix_message (new_line);
- if (message_for_signal)
- {
- hook_signal_send ("weechat_highlight",
- WEECHAT_HOOK_SIGNAL_STRING,
- message_for_signal);
- free (message_for_signal);
- }
- }
- }
- else
- {
- notify_level = gui_chat_line_get_notify_level (new_line);
- if (!weechat_upgrading && (notify_level == GUI_HOTLIST_PRIVATE))
- {
- message_for_signal = gui_chat_build_string_prefix_message (new_line);
- if (message_for_signal)
- {
- hook_signal_send ("weechat_pv",
- WEECHAT_HOOK_SIGNAL_STRING,
- message_for_signal);
- free (message_for_signal);
- }
- }
- gui_hotlist_add (buffer, notify_level, NULL, 1);
- }
- }
- else
- {
- if (!buffer->lines_hidden)
- {
- buffer->lines_hidden = 1;
- hook_signal_send ("buffer_lines_hidden",
- WEECHAT_HOOK_SIGNAL_POINTER, buffer);
- }
- }
-
- /* remove one line if necessary */
- if ((CONFIG_INTEGER(config_history_max_lines) > 0)
- && (buffer->lines_count > CONFIG_INTEGER(config_history_max_lines)))
- {
- gui_chat_line_free (buffer, buffer->lines);
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
- {
- if ((ptr_win->buffer == buffer)
- && (buffer->lines_count < ptr_win->win_chat_height))
- {
- gui_buffer_ask_chat_refresh (buffer, 2);
- break;
- }
- }
- }
-
- return new_line;
-}
-
-/*
- * gui_chat_line_add_y: add or update a line for a buffer with free content
- */
-
-void
-gui_chat_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
-{
- struct t_gui_line *ptr_line, *new_line;
-
- if (!message || !message[0])
- return;
-
- /* search if line exists for "y" */
- for (ptr_line = buffer->lines; ptr_line;
- ptr_line = ptr_line->next_line)
- {
- if (ptr_line->y >= y)
- break;
- }
-
- if (!ptr_line || (ptr_line->y > y))
- {
- new_line = malloc (sizeof (*new_line));
- if (!new_line)
- {
- log_printf (_("Not enough memory for new line"));
- return;
- }
-
- buffer->lines_count++;
-
- /* fill data in new line */
- new_line->y = y;
- new_line->date = 0;
- new_line->date_printed = 0;
- new_line->str_time = NULL;
- new_line->tags_count = 0;
- new_line->tags_array = NULL;
- new_line->refresh_needed = 1;
- new_line->prefix = NULL;
- new_line->prefix_length = 0;
- new_line->message = NULL;
- new_line->highlight = 0;
-
- /* add line to lines list */
- if (ptr_line)
- {
- /* add before line found */
- new_line->prev_line = ptr_line->prev_line;
- new_line->next_line = ptr_line;
- if (ptr_line->prev_line)
- (ptr_line->prev_line)->next_line = new_line;
- else
- buffer->lines = new_line;
- ptr_line->prev_line = new_line;
- }
- else
- {
- /* add at end of list */
- new_line->prev_line = buffer->last_line;
- if (buffer->lines)
- buffer->last_line->next_line = new_line;
- else
- buffer->lines = new_line;
- buffer->last_line = new_line;
- new_line->next_line = NULL;
- }
-
- ptr_line = new_line;
- }
-
- /* set message for line */
- if (ptr_line->message)
- free (ptr_line->message);
- ptr_line->message = strdup (message);
-
- /* check if line is filtered or not */
- ptr_line->displayed = gui_filter_check_line (buffer, ptr_line);
- if (!ptr_line->displayed)
- {
- if (!buffer->lines_hidden)
- {
- buffer->lines_hidden = 1;
- hook_signal_send ("buffer_lines_hidden",
- WEECHAT_HOOK_SIGNAL_POINTER, buffer);
- }
- }
-
- ptr_line->refresh_needed = 1;
-}
-
-/*
* gui_chat_printf_date_tags: display a message in a buffer with optional
* date and tags
* Info: this function works only with formatted
@@ -1082,7 +469,7 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
date = date_printed;
if (gui_init_ok)
- ptr_line = buffer->last_line;
+ ptr_line = buffer->lines->last_line;
at_least_one_message_printed = 0;
@@ -1153,12 +540,12 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
if (gui_init_ok)
{
- gui_chat_line_add (buffer, (display_time) ? date : 0,
- (display_time) ? date_printed : 0,
- tags, pos_prefix, ptr_msg);
- if (buffer->last_line && buffer->print_hooks_enabled)
+ gui_line_add (buffer, (display_time) ? date : 0,
+ (display_time) ? date_printed : 0,
+ tags, pos_prefix, ptr_msg);
+ if (buffer->lines->last_line && buffer->print_hooks_enabled)
{
- hook_print_exec (buffer, buffer->last_line);
+ hook_print_exec (buffer, buffer->lines->last_line);
}
at_least_one_message_printed = 1;
}
@@ -1219,15 +606,15 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
{
if (gui_init_ok)
{
- for (ptr_line = buffer->lines; ptr_line;
+ for (ptr_line = buffer->lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
{
- if (ptr_line->y >= y)
+ if (ptr_line->data->y >= y)
break;
}
- if (ptr_line && (ptr_line->y == y))
+ if (ptr_line && (ptr_line->data->y == y))
{
- gui_chat_line_free (buffer, ptr_line);
+ gui_line_free (buffer, ptr_line);
gui_buffer_ask_chat_refresh (buffer, 2);
}
}
@@ -1236,7 +623,7 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
{
if (gui_init_ok)
{
- gui_chat_line_add_y (buffer, y, gui_chat_buffer);
+ gui_line_add_y (buffer, y, gui_chat_buffer);
gui_buffer_ask_chat_refresh (buffer, 1);
}
else
diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h
index 12ddeb1b7..791184b17 100644
--- a/src/gui/gui-chat.h
+++ b/src/gui/gui-chat.h
@@ -20,8 +20,6 @@
#ifndef __WEECHAT_GUI_CHAT_H
#define __WEECHAT_GUI_CHAT_H 1
-#include <regex.h>
-
struct t_gui_window;
struct t_gui_buffer;
struct t_gui_line;
@@ -60,31 +58,9 @@ extern void gui_chat_get_word_info (struct t_gui_window *window,
int *word_end_offset,
int *word_length_with_spaces,
int *word_length);
+extern char *gui_chat_get_time_string (time_t date);
extern void gui_chat_change_time_format ();
-extern int gui_chat_get_line_align (struct t_gui_buffer *buffer,
- struct t_gui_line *line,
- int with_suffix);
-extern int gui_chat_line_displayed (struct t_gui_line *line);
-extern struct t_gui_line *gui_chat_get_first_line_displayed (struct t_gui_buffer *buffer);
-extern struct t_gui_line *gui_chat_get_last_line_displayed (struct t_gui_buffer *buffer);
-extern struct t_gui_line *gui_chat_get_prev_line_displayed (struct t_gui_line *line);
-extern struct t_gui_line *gui_chat_get_next_line_displayed (struct t_gui_line *line);
-extern int gui_chat_line_search (struct t_gui_line *line, const char *text,
- int case_sensitive);
-extern int gui_chat_line_match_regex (struct t_gui_line *line,
- regex_t *regex_prefix,
- regex_t *regex_message);
-extern int gui_chat_line_match_tags (struct t_gui_line *line, int tags_count,
- char **tags_array);
-extern void gui_chat_line_free (struct t_gui_buffer *buffer,
- struct t_gui_line *line);
-extern void gui_chat_line_free_all (struct t_gui_buffer *buffer);
-extern struct t_gui_line *gui_chat_line_add (struct t_gui_buffer *buffer,
- time_t date,
- time_t date_printed,
- const char *tags,
- const char *prefix,
- const char *message);
+extern char *gui_chat_build_string_prefix_message (struct t_gui_line *line);
extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
time_t date, const char *tags,
const char *message, ...);
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 50cee70d0..7feae6497 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -58,6 +58,7 @@ enum t_gui_color_enum
GUI_COLOR_CHAT_READ_MARKER,
GUI_COLOR_CHAT_TEXT_FOUND,
GUI_COLOR_CHAT_VALUE,
+ GUI_COLOR_CHAT_PREFIX_BUFFER,
/* number of colors */
GUI_COLOR_NUM_COLORS,
diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c
index 5e823e3b0..4906f7a93 100644
--- a/src/gui/gui-filter.c
+++ b/src/gui/gui-filter.c
@@ -35,7 +35,7 @@
#include "../plugins/plugin.h"
#include "gui-filter.h"
#include "gui-buffer.h"
-#include "gui-chat.h"
+#include "gui-line.h"
struct t_gui_filter *gui_filters = NULL; /* first filter */
@@ -54,9 +54,9 @@ gui_filter_line_has_tag_no_filter (struct t_gui_line *line)
{
int i;
- for (i = 0; i < line->tags_count; i++)
+ for (i = 0; i < line->data->tags_count; i++)
{
- if (strcmp (line->tags_array[i], GUI_FILTER_TAG_NO_FILTER) == 0)
+ if (strcmp (line->data->tags_array[i], GUI_FILTER_TAG_NO_FILTER) == 0)
return 1;
}
@@ -92,17 +92,17 @@ gui_filter_check_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
&& string_match (buffer->name, ptr_filter->buffer_name, 0))
{
if ((strcmp (ptr_filter->tags, "*") == 0)
- || (gui_chat_line_match_tags (line,
- ptr_filter->tags_count,
- ptr_filter->tags_array)))
+ || (gui_line_match_tags (line,
+ ptr_filter->tags_count,
+ ptr_filter->tags_array)))
{
/* check line with regex */
if (!ptr_filter->regex_prefix && !ptr_filter->regex_message)
return 0;
- if (gui_chat_line_match_regex (line,
- ptr_filter->regex_prefix,
- ptr_filter->regex_message))
+ if (gui_line_match_regex (line,
+ ptr_filter->regex_prefix,
+ ptr_filter->regex_message))
return 0;
}
}
@@ -125,32 +125,32 @@ gui_filter_buffer (struct t_gui_buffer *buffer)
lines_hidden = 0;
- buffer->prefix_max_length = 0;
+ buffer->lines->prefix_max_length = 0;
- for (ptr_line = buffer->lines; ptr_line;
+ for (ptr_line = buffer->lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
{
line_displayed = gui_filter_check_line (buffer, ptr_line);
if (line_displayed
- && (ptr_line->prefix_length > buffer->prefix_max_length))
+ && (ptr_line->data->prefix_length > buffer->lines->prefix_max_length))
{
- buffer->prefix_max_length = ptr_line->prefix_length;
+ buffer->lines->prefix_max_length = ptr_line->data->prefix_length;
}
/* force chat refresh if at least one line changed */
- if (ptr_line->displayed != line_displayed)
+ if (ptr_line->data->displayed != line_displayed)
gui_buffer_ask_chat_refresh (buffer, 2);
- ptr_line->displayed = line_displayed;
+ ptr_line->data->displayed = line_displayed;
if (!line_displayed)
lines_hidden = 1;
}
- if (buffer->lines_hidden != lines_hidden)
+ if (buffer->lines->lines_hidden != lines_hidden)
{
- buffer->lines_hidden = lines_hidden;
+ buffer->lines->lines_hidden = lines_hidden;
hook_signal_send ("buffer_lines_hidden",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index ae14bb5d3..2d8cf38fb 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -293,7 +293,8 @@ gui_hotlist_add (struct t_gui_buffer *buffer, int priority,
if (!gui_hotlist_check_buffer_notify (buffer, priority))
return;
- if ((ptr_hotlist = gui_hotlist_search (gui_hotlist, buffer)))
+ ptr_hotlist = gui_hotlist_search (gui_hotlist, buffer);
+ if (ptr_hotlist)
{
/* return if priority is greater or equal than the one to add */
if (ptr_hotlist->priority >= priority)
@@ -395,7 +396,7 @@ void
gui_hotlist_remove_buffer (struct t_gui_buffer *buffer)
{
struct t_gui_hotlist *pos_hotlist;
-
+
pos_hotlist = gui_hotlist_search (gui_hotlist, buffer);
if (pos_hotlist)
{
@@ -453,6 +454,10 @@ gui_hotlist_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "buffer_number", hotlist->buffer->number))
return 0;
+ if (!infolist_new_var_string (ptr_item, "plugin_name", plugin_get_name (hotlist->buffer->plugin)))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "buffer_name", hotlist->buffer->name))
+ return 0;
return 1;
}
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 645ac945b..2429f31eb 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -35,11 +35,11 @@
#include "../plugins/plugin.h"
#include "gui-input.h"
#include "gui-buffer.h"
-#include "gui-chat.h"
#include "gui-completion.h"
#include "gui-history.h"
#include "gui-hotlist.h"
#include "gui-keyboard.h"
+#include "gui-line.h"
#include "gui-window.h"
@@ -1239,17 +1239,17 @@ gui_input_scroll_unread ()
if (CONFIG_STRING(config_look_read_marker) &&
CONFIG_STRING(config_look_read_marker)[0] &&
(gui_current_window->buffer->type == GUI_BUFFER_TYPE_FORMATTED) &&
- (gui_current_window->buffer->first_line_not_read ||
- (gui_current_window->buffer->last_read_line &&
- gui_current_window->buffer->last_read_line != gui_current_window->buffer->last_line)))
+ (gui_current_window->buffer->lines->first_line_not_read ||
+ (gui_current_window->buffer->lines->last_read_line &&
+ gui_current_window->buffer->lines->last_read_line != gui_current_window->buffer->lines->last_line)))
{
- if (gui_current_window->buffer->first_line_not_read)
- gui_current_window->start_line = gui_current_window->buffer->lines;
+ if (gui_current_window->buffer->lines->first_line_not_read)
+ gui_current_window->start_line = gui_current_window->buffer->lines->first_line;
else
- gui_current_window->start_line = gui_current_window->buffer->last_read_line->next_line;
+ gui_current_window->start_line = gui_current_window->buffer->lines->last_read_line->next_line;
gui_current_window->start_line_pos = 0;
gui_current_window->first_line_displayed =
- (gui_current_window->start_line == gui_chat_get_first_line_displayed (gui_current_window->buffer));
+ (gui_current_window->start_line == gui_line_get_first_displayed (gui_current_window->buffer));
gui_buffer_ask_chat_refresh (gui_current_window->buffer, 2);
}
}
@@ -1285,6 +1285,24 @@ gui_input_set_unread_current_buffer ()
}
/*
+ * gui_input_switch_active_buffer: switch active buffer (when many buffers are
+ * merged)
+ */
+
+void
+gui_input_switch_active_buffer ()
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ ptr_buffer = gui_buffer_get_next_active_buffer (gui_current_window->buffer);
+ if (ptr_buffer)
+ {
+ gui_buffer_set_active_buffer (ptr_buffer);
+ gui_window_switch_to_buffer (gui_current_window, ptr_buffer, 1);
+ }
+}
+
+/*
* gui_input_insert: insert a string in command line
* (many default keys are bound to this function)
*/
diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h
index dcbcc3e67..0a1e4983d 100644
--- a/src/gui/gui-input.h
+++ b/src/gui/gui-input.h
@@ -66,6 +66,7 @@ extern void gui_input_grab_key ();
extern void gui_input_scroll_unread ();
extern void gui_input_set_unread ();
extern void gui_input_set_unread_current_buffer ();
+extern void gui_input_switch_active_buffer ();
extern void gui_input_insert ();
#endif /* gui-input.h */
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c
new file mode 100644
index 000000000..b73d75805
--- /dev/null
+++ b/src/gui/gui-line.c
@@ -0,0 +1,1068 @@
+/*
+ * Copyright (c) 2003-2009 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* gui-line.c: line functions, used by all GUI */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "../core/weechat.h"
+#include "../core/wee-config.h"
+#include "../core/wee-hook.h"
+#include "../core/wee-infolist.h"
+#include "../core/wee-log.h"
+#include "../core/wee-string.h"
+#include "../plugins/plugin.h"
+#include "gui-line.h"
+#include "gui-buffer.h"
+#include "gui-chat.h"
+#include "gui-color.h"
+#include "gui-filter.h"
+#include "gui-hotlist.h"
+#include "gui-window.h"
+
+
+/*
+ * gui_lines_alloc: alloc structure "t_gui_lines" and initialize it
+ */
+
+struct t_gui_lines *
+gui_lines_alloc ()
+{
+ struct t_gui_lines *new_lines;
+
+ new_lines = malloc (sizeof (*new_lines));
+ if (new_lines)
+ {
+ new_lines->first_line = NULL;
+ new_lines->last_line = NULL;
+ new_lines->last_read_line = NULL;
+ new_lines->lines_count = 0;
+ new_lines->first_line_not_read = 0;
+ new_lines->lines_hidden = 0;
+ new_lines->buffer_max_length = 0;
+ new_lines->prefix_max_length = 0;
+ }
+
+ return new_lines;
+}
+
+/*
+ * gui_lines_free: free a "t_gui_lines" structure
+ */
+
+void
+gui_lines_free (struct t_gui_lines *lines)
+{
+ free (lines);
+}
+
+/*
+ * gui_line_get_align: get alignment for a line
+ */
+
+int
+gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
+ int with_suffix)
+{
+ int length_time, length_buffer, length_suffix;
+
+ /* length of time */
+ length_time = (buffer->time_for_each_line) ? gui_chat_time_length : 0;
+
+ /* length of buffer name (when many buffers are merged) */
+ if (buffer->mixed_lines)
+ {
+ length_buffer = ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)
+ && (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)) ?
+ gui_chat_strlen_screen (buffer->short_name) + 1 : buffer->mixed_lines->buffer_max_length + 1;
+ }
+ else
+ length_buffer = 0;
+
+ if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)
+ return length_time + 1 + length_buffer + line->data->prefix_length + 2;
+
+ length_suffix = 0;
+ if (with_suffix)
+ {
+ if (CONFIG_STRING(config_look_prefix_suffix)
+ && 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)
+ && (buffer->lines->prefix_max_length > CONFIG_INTEGER(config_look_prefix_align_max))) ?
+ CONFIG_INTEGER(config_look_prefix_align_max) : buffer->lines->prefix_max_length)
+ + length_suffix + 1;
+}
+
+/*
+ * gui_line_is_displayed: return 1 if line is displayed (no filter on line,
+ * or filters disabled), 0 if line is hidden
+ */
+
+int
+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;
+}
+
+/*
+ * gui_line_get_first_displayed: get first line displayed of a buffer
+ */
+
+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;
+}
+
+/*
+ * gui_line_get_last_displayed: get last line displayed of a buffer
+ */
+
+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;
+}
+
+/*
+ * gui_line_get_prev_displayed: get previous line displayed
+ */
+
+struct t_gui_line *
+gui_line_get_prev_displayed (struct t_gui_line *line)
+{
+ if (line)
+ {
+ line = line->prev_line;
+ while (line && !gui_line_is_displayed (line))
+ {
+ line = line->prev_line;
+ }
+ }
+ return line;
+}
+
+/*
+ * gui_line_get_next_displayed: get next line displayed
+ */
+
+struct t_gui_line *
+gui_line_get_next_displayed (struct t_gui_line *line)
+{
+ if (line)
+ {
+ line = line->next_line;
+ while (line && !gui_line_is_displayed (line))
+ {
+ line = line->next_line;
+ }
+ }
+ return line;
+}
+
+/*
+ * gui_line_search_text: search for text in a line
+ */
+
+int
+gui_line_search_text (struct t_gui_line *line, const char *text,
+ int case_sensitive)
+{
+ 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);
+ if (prefix)
+ {
+ if ((case_sensitive && (strstr (prefix, text)))
+ || (!case_sensitive && (string_strcasestr (prefix, text))))
+ rc = 1;
+ free (prefix);
+ }
+ }
+
+ if (!rc)
+ {
+ message = gui_color_decode (line->data->message, NULL);
+ if (message)
+ {
+ if ((case_sensitive && (strstr (message, text)))
+ || (!case_sensitive && (string_strcasestr (message, text))))
+ rc = 1;
+ free (message);
+ }
+ }
+
+ return rc;
+}
+
+/*
+ * gui_line_match_regex: return 1 if message matches regex
+ * 0 if it doesn't match
+ */
+
+int
+gui_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix,
+ regex_t *regex_message)
+{
+ 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;
+
+ if (line->data->prefix)
+ {
+ prefix = gui_color_decode (line->data->prefix, NULL);
+ if (!prefix
+ || (regex_prefix && (regexec (regex_prefix, prefix, 0, NULL, 0) != 0)))
+ match_prefix = 0;
+ }
+ else
+ {
+ if (regex_prefix)
+ match_prefix = 0;
+ }
+
+ if (line->data->message)
+ {
+ message = gui_color_decode (line->data->message, NULL);
+ if (!message
+ || (regex_message && (regexec (regex_message, message, 0, NULL, 0) != 0)))
+ match_message = 0;
+ }
+ else
+ {
+ if (regex_message)
+ match_message = 0;
+ }
+
+ if (prefix)
+ free (prefix);
+ if (message)
+ free (message);
+
+ return (match_prefix && match_message);
+}
+
+/*
+ * gui_line_match_tags: return 1 if line matches tags
+ * 0 if it doesn't match any tag in array
+ */
+
+int
+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++)
+ {
+ /* check tag */
+ if (string_match (line->data->tags_array[j],
+ tags_array[i],
+ 0))
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * gui_line_has_highlight: return 1 if given message contains highlight (with
+ * a string in global highlight or buffer highlight)
+ */
+
+int
+gui_line_has_highlight (struct t_gui_line *line)
+{
+ int rc, i;
+ char *msg_no_color;
+
+ /* highlights are disabled on this buffer? (special value "-" means that
+ buffer does not want any highlight) */
+ if (line->data->buffer->highlight_words
+ && (strcmp (line->data->buffer->highlight_words, "-") == 0))
+ return 0;
+
+ /* check if highlight is disabled for line */
+ for (i = 0; i < line->data->tags_count; i++)
+ {
+ if (strcmp (line->data->tags_array[i], GUI_CHAT_TAG_NO_HIGHLIGHT) == 0)
+ return 0;
+ }
+
+ /* check that line matches highlight tags, if any (if no tag is specified,
+ then any tag is allowed) */
+ if (line->data->buffer->highlight_tags_count > 0)
+ {
+ if (!gui_line_match_tags (line,
+ line->data->buffer->highlight_tags_count,
+ 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 global highlight words matches line
+ or one of buffer highlight words matches line */
+ rc = (string_has_highlight (msg_no_color,
+ CONFIG_STRING(config_look_highlight)) ||
+ string_has_highlight (msg_no_color,
+ line->data->buffer->highlight_words));
+
+ free (msg_no_color);
+
+ return rc;
+}
+
+/*
+ * gui_line_compute_buffer_max_length: compute "buffer_max_length" for a
+ * "t_gui_lines" structure
+ */
+
+void
+gui_line_compute_buffer_max_length (struct t_gui_buffer *buffer,
+ struct t_gui_lines *lines)
+{
+ struct t_gui_buffer *ptr_buffer;
+ int length;
+
+ lines->buffer_max_length = 0;
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if ((ptr_buffer->number == buffer->number) && ptr_buffer->short_name)
+ {
+ length = gui_chat_strlen_screen (ptr_buffer->short_name);
+ if (length > lines->buffer_max_length)
+ lines->buffer_max_length = length;
+ }
+ }
+}
+
+/*
+ * gui_line_compute_prefix_max_length: compute "prefix_max_length" for a
+ * "t_gui_lines" structure
+ */
+
+void
+gui_line_compute_prefix_max_length (struct t_gui_lines *lines)
+{
+ struct t_gui_line *ptr_line;
+
+ lines->prefix_max_length = 0;
+ for (ptr_line = lines->first_line; ptr_line;
+ ptr_line = ptr_line->next_line)
+ {
+ if (ptr_line->data->prefix_length > lines->prefix_max_length)
+ lines->prefix_max_length = ptr_line->data->prefix_length;
+ }
+}
+
+/*
+ * gui_line_add_to_list: add a line to a "t_gui_lines" structure
+ */
+
+void
+gui_line_add_to_list (struct t_gui_lines *lines,
+ struct t_gui_line *line)
+{
+ if (!lines->first_line)
+ lines->first_line = line;
+ else
+ (lines->last_line)->next_line = line;
+ 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++;
+}
+
+/*
+ * gui_line_remove_from_list: remove a line from a "t_gui_lines" structure
+ */
+
+void
+gui_line_remove_from_list (struct t_gui_lines *lines,
+ struct t_gui_line *line,
+ int free_data)
+{
+ int update_prefix_max_length;
+
+ update_prefix_max_length =
+ (line->data->prefix_length == lines->prefix_max_length);
+
+ /* free data */
+ if (free_data)
+ {
+ if (line->data->str_time)
+ free (line->data->str_time);
+ if (line->data->tags_array)
+ string_free_exploded (line->data->tags_array);
+ if (line->data->prefix)
+ free (line->data->prefix);
+ if (line->data->message)
+ free (line->data->message);
+ free (line->data);
+ }
+
+ /* remove line from list */
+ if (line->prev_line)
+ (line->prev_line)->next_line = line->next_line;
+ if (line->next_line)
+ (line->next_line)->prev_line = line->prev_line;
+ if (lines->first_line == line)
+ 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);
+}
+
+/*
+ * gui_line_mixed_add: add line to mixed lines for a buffer
+ */
+
+void
+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)
+ {
+ new_line->data = line_data;
+ gui_line_add_to_list (lines, new_line);
+ }
+}
+
+/*
+ * gui_line_mixed_free_buffer: free all mixed lines matching a buffer
+ */
+
+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->mixed_lines,
+ ptr_line,
+ 0);
+ }
+
+ ptr_line = ptr_next_line;
+ }
+ }
+}
+
+/*
+ * gui_line_mixed_free_all: free all mixed lines in a buffer
+ */
+
+void
+gui_line_mixed_free_all (struct t_gui_buffer *buffer)
+{
+ if (buffer->mixed_lines)
+ {
+ while (buffer->mixed_lines->first_line)
+ {
+ gui_line_remove_from_list (buffer->mixed_lines,
+ buffer->mixed_lines->first_line,
+ 0);
+ }
+ }
+}
+
+/*
+ * gui_line_free: delete a formatted line from a buffer
+ */
+
+void
+gui_line_free (struct t_gui_buffer *buffer, struct t_gui_line *line)
+{
+ struct t_gui_line *ptr_line;
+ struct t_gui_window *ptr_win;
+
+ /* first remove mixed line if it exists */
+ if (buffer->mixed_lines)
+ {
+ for (ptr_line = buffer->mixed_lines->first_line; ptr_line;
+ ptr_line = ptr_line->next_line)
+ {
+ if (ptr_line->data == line->data)
+ {
+ gui_line_remove_from_list (buffer->mixed_lines, ptr_line, 0);
+ break;
+ }
+ }
+ }
+
+ /* reset scroll for any window starting with this line */
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ if (ptr_win->start_line == line)
+ {
+ ptr_win->start_line = ptr_win->start_line->next_line;
+ ptr_win->start_line_pos = 0;
+ gui_buffer_ask_chat_refresh (buffer, 2);
+ }
+ }
+
+ /* move read marker if it was on line we are removing */
+ if (buffer->own_lines->last_read_line == line)
+ {
+ buffer->own_lines->last_read_line = buffer->own_lines->last_read_line->prev_line;
+ buffer->own_lines->first_line_not_read = (buffer->own_lines->last_read_line) ? 0 : 1;
+ gui_buffer_ask_chat_refresh (buffer, 1);
+ }
+
+ /* remove line from lines list */
+ gui_line_remove_from_list (buffer->own_lines, line, 1);
+}
+
+/*
+ * gui_line_free_all: delete all formatted lines from a buffer
+ */
+
+void
+gui_line_free_all (struct t_gui_buffer *buffer)
+{
+ while (buffer->own_lines->first_line)
+ {
+ gui_line_free (buffer, buffer->own_lines->first_line);
+ }
+}
+
+/*
+ * gui_line_get_notify_level: get notify level for a line
+ */
+
+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_highlight") == 0)
+ return GUI_HOTLIST_HIGHLIGHT;
+ if (string_strcasecmp (line->data->tags_array[i], "notify_private") == 0)
+ return GUI_HOTLIST_PRIVATE;
+ if (string_strcasecmp (line->data->tags_array[i], "notify_message") == 0)
+ return GUI_HOTLIST_MESSAGE;
+ }
+ return GUI_HOTLIST_LOW;
+}
+
+/*
+ * gui_line_add: add a new line for a buffer
+ */
+
+struct t_gui_line *
+gui_line_add (struct t_gui_buffer *buffer, time_t date,
+ time_t date_printed, const char *tags,
+ const char *prefix, const char *message)
+{
+ struct t_gui_line *new_line;
+ struct t_gui_line_data *new_line_data;
+ struct t_gui_window *ptr_win;
+ char *message_for_signal;
+ int 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)
+ {
+ free (new_line);
+ log_printf (_("Not enough memory for new line"));
+ return NULL;
+ }
+ new_line->data = new_line_data;
+
+ /* fill data in new line */
+ new_line->data->buffer = buffer;
+ new_line->data->y = 0;
+ new_line->data->date = date;
+ new_line->data->date_printed = date_printed;
+ new_line->data->str_time = (date == 0) ?
+ NULL : gui_chat_get_time_string (date);
+ if (tags)
+ {
+ new_line->data->tags_array = string_explode (tags, ",", 0, 0,
+ &new_line->data->tags_count);
+ }
+ else
+ {
+ new_line->data->tags_count = 0;
+ new_line->data->tags_array = NULL;
+ }
+ new_line->data->refresh_needed = 0;
+ new_line->data->prefix = (prefix) ?
+ strdup (prefix) : ((date != 0) ? strdup ("") : NULL);
+ new_line->data->prefix_length = (prefix) ?
+ gui_chat_strlen_screen (prefix) : 0;
+ new_line->data->message = (message) ? strdup (message) : strdup ("");
+ 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 */
+ new_line->data->displayed = gui_filter_check_line (buffer, new_line);
+ if (new_line->data->displayed)
+ {
+ if (new_line->data->highlight)
+ {
+ gui_hotlist_add (buffer, GUI_HOTLIST_HIGHLIGHT, NULL, 1);
+ if (!weechat_upgrading)
+ {
+ message_for_signal = gui_chat_build_string_prefix_message (new_line);
+ if (message_for_signal)
+ {
+ hook_signal_send ("weechat_highlight",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ message_for_signal);
+ free (message_for_signal);
+ }
+ }
+ }
+ else
+ {
+ notify_level = gui_line_get_notify_level (new_line);
+ if (!weechat_upgrading && (notify_level == GUI_HOTLIST_PRIVATE))
+ {
+ message_for_signal = gui_chat_build_string_prefix_message (new_line);
+ if (message_for_signal)
+ {
+ hook_signal_send ("weechat_pv",
+ WEECHAT_HOOK_SIGNAL_STRING,
+ message_for_signal);
+ free (message_for_signal);
+ }
+ }
+ gui_hotlist_add (buffer, notify_level, NULL, 1);
+ }
+ }
+ else
+ {
+ if (!buffer->own_lines->lines_hidden)
+ {
+ buffer->own_lines->lines_hidden = 1;
+ if (buffer->mixed_lines)
+ buffer->mixed_lines->lines_hidden = 1;
+ hook_signal_send ("buffer_lines_hidden",
+ 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)))
+ {
+ gui_line_free (buffer, buffer->own_lines->first_line);
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ if ((ptr_win->buffer == buffer)
+ && (buffer->own_lines->lines_count < ptr_win->win_chat_height))
+ {
+ gui_buffer_ask_chat_refresh (buffer, 2);
+ break;
+ }
+ }
+ }
+
+ return new_line;
+}
+
+/*
+ * gui_line_add_y: add or update a line for a buffer with free content
+ */
+
+void
+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;
+
+ if (!message || !message[0])
+ return;
+
+ /* search if line exists for "y" */
+ for (ptr_line = buffer->own_lines->first_line; ptr_line;
+ ptr_line = ptr_line->next_line)
+ {
+ if (ptr_line->data->y >= y)
+ break;
+ }
+
+ if (!ptr_line || (ptr_line->data->y > y))
+ {
+ new_line = malloc (sizeof (*new_line));
+ if (!new_line)
+ {
+ log_printf (_("Not enough memory for new line"));
+ return;
+ }
+
+ new_line_data = malloc (sizeof (*(new_line->data)));
+ if (!new_line_data)
+ {
+ free (new_line);
+ log_printf (_("Not enough memory for new line"));
+ return;
+ }
+ new_line->data = new_line_data;
+
+ buffer->own_lines->lines_count++;
+
+ /* fill data in new line */
+ new_line->data->y = y;
+ new_line->data->date = 0;
+ new_line->data->date_printed = 0;
+ new_line->data->str_time = NULL;
+ new_line->data->tags_count = 0;
+ new_line->data->tags_array = NULL;
+ new_line->data->refresh_needed = 1;
+ new_line->data->prefix = NULL;
+ new_line->data->prefix_length = 0;
+ new_line->data->message = NULL;
+ new_line->data->highlight = 0;
+
+ /* add line to lines list */
+ if (ptr_line)
+ {
+ /* add before line found */
+ new_line->prev_line = ptr_line->prev_line;
+ new_line->next_line = ptr_line;
+ if (ptr_line->prev_line)
+ (ptr_line->prev_line)->next_line = new_line;
+ else
+ buffer->own_lines->first_line = new_line;
+ ptr_line->prev_line = new_line;
+ }
+ else
+ {
+ /* add at end of list */
+ new_line->prev_line = buffer->own_lines->last_line;
+ if (buffer->own_lines->first_line)
+ buffer->own_lines->last_line->next_line = new_line;
+ else
+ buffer->own_lines->first_line = new_line;
+ buffer->own_lines->last_line = new_line;
+ new_line->next_line = NULL;
+ }
+
+ ptr_line = new_line;
+ }
+
+ /* set message for line */
+ if (ptr_line->data->message)
+ free (ptr_line->data->message);
+ ptr_line->data->message = strdup (message);
+
+ /* check if line is filtered or not */
+ ptr_line->data->displayed = gui_filter_check_line (buffer, ptr_line);
+ if (!ptr_line->data->displayed)
+ {
+ if (!buffer->own_lines->lines_hidden)
+ {
+ buffer->own_lines->lines_hidden = 1;
+ hook_signal_send ("buffer_lines_hidden",
+ WEECHAT_HOOK_SIGNAL_POINTER, buffer);
+ }
+ }
+
+ ptr_line->data->refresh_needed = 1;
+}
+
+/*
+ * gui_line_mix_buffers: mix lines of a buffer (or group of buffers) with a new
+ * buffer
+ */
+
+void
+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;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if ((ptr_buffer != buffer) && (ptr_buffer->number == buffer->number))
+ {
+ ptr_buffer_found = ptr_buffer;
+ break;
+ }
+ }
+ 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)
+ return;
+ ptr_line1 = ptr_buffer_found->lines->first_line;
+ ptr_line2 = buffer->lines->first_line;
+ while (ptr_line1 || ptr_line2)
+ {
+ if (!ptr_line1)
+ {
+ gui_line_mixed_add (new_lines, ptr_line2->data);
+ ptr_line2 = ptr_line2->next_line;
+ }
+ else
+ {
+ if (!ptr_line2)
+ {
+ gui_line_mixed_add (new_lines, ptr_line1->data);
+ ptr_line1 = ptr_line1->next_line;
+ }
+ else
+ {
+ /* look for older line by comparing time */
+ if (ptr_line1->data->date <= ptr_line2->data->date)
+ {
+ while (ptr_line1
+ && (ptr_line1->data->date <= ptr_line2->data->date))
+ {
+ gui_line_mixed_add (new_lines, ptr_line1->data);
+ ptr_line1 = ptr_line1->next_line;
+ }
+ }
+ else
+ {
+ while (ptr_line2
+ && (ptr_line1->data->date > ptr_line2->data->date))
+ {
+ gui_line_mixed_add (new_lines, ptr_line2->data);
+ ptr_line2 = ptr_line2->next_line;
+ }
+ }
+ }
+ }
+ }
+
+ /* 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)
+ {
+ if (ptr_buffer->number == buffer->number)
+ {
+ ptr_buffer->mixed_lines = new_lines;
+ ptr_buffer->lines = ptr_buffer->mixed_lines;
+ }
+ }
+}
+
+/*
+ * gui_buffer_line_add_to_infolist: add a buffer line in an infolist
+ * return 1 if ok, 0 if error
+ */
+
+int
+gui_line_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_lines *lines,
+ struct t_gui_line *line)
+{
+ 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_time (ptr_item, "date", line->data->date))
+ return 0;
+ if (!infolist_new_var_time (ptr_item, "date_printed", line->data->date_printed))
+ 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;
+ length = 0;
+ for (i = 0; i < line->data->tags_count; i++)
+ {
+ snprintf (option_name, sizeof (option_name), "tag_%05d", i + 1);
+ if (!infolist_new_var_string (ptr_item, option_name,
+ line->data->tags_array[i]))
+ return 0;
+ length += strlen (line->data->tags_array[i]) + 1;
+ }
+ tags = malloc (length + 1);
+ if (!tags)
+ return 0;
+ tags[0] = '\0';
+ for (i = 0; i < line->data->tags_count; i++)
+ {
+ strcat (tags, line->data->tags_array[i]);
+ if (i < line->data->tags_count - 1)
+ strcat (tags, ",");
+ }
+ if (!infolist_new_var_string (ptr_item, "tags", tags))
+ {
+ free (tags);
+ 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))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "prefix", line->data->prefix))
+ return 0;
+ if (!infolist_new_var_string (ptr_item, "message", line->data->message))
+ return 0;
+ if (!infolist_new_var_integer (ptr_item, "last_read_line",
+ (lines->last_read_line == line) ? 1 : 0))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * gui_lines_print_log: print lines structure infos in log (usually for crash dump)
+ */
+
+void
+gui_lines_print_log (struct t_gui_lines *lines)
+{
+ if (lines)
+ {
+ log_printf (" first_line . . . . . : 0x%lx", lines->first_line);
+ log_printf (" last_line. . . . . . : 0x%lx", lines->last_line);
+ log_printf (" last_read_line . . . : 0x%lx", lines->last_read_line);
+ log_printf (" lines_count. . . . . . : %d", lines->lines_count);
+ log_printf (" first_line_not_read. . : %d", lines->first_line_not_read);
+ log_printf (" lines_hidden . . . . : %d", lines->lines_hidden);
+ log_printf (" buffer_max_length. . : %d", lines->buffer_max_length);
+ log_printf (" prefix_max_length. . : %d", lines->prefix_max_length);
+ }
+}
diff --git a/src/gui/gui-line.h b/src/gui/gui-line.h
new file mode 100644
index 000000000..fe92716c8
--- /dev/null
+++ b/src/gui/gui-line.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2003-2009 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_GUI_LINE_H
+#define __WEECHAT_GUI_LINE_H 1
+
+#include <regex.h>
+
+struct t_infolist;
+
+/* line structures */
+
+struct t_gui_line_data
+{
+ struct t_gui_buffer *buffer; /* pointer to buffer */
+ int y; /* line position (for free buffer) */
+ time_t date; /* date/time of line (may be past) */
+ time_t date_printed; /* date/time when weechat print it */
+ char *str_time; /* time string (for display) */
+ int tags_count; /* number of tags for line */
+ char **tags_array; /* tags for line */
+ char displayed; /* 1 if line is displayed */
+ char highlight; /* 1 if line has highlight */
+ char refresh_needed; /* 1 if refresh asked (free buffer) */
+ char *prefix; /* prefix for line (may be NULL) */
+ int prefix_length; /* prefix length (on screen) */
+ char *message; /* line content (after prefix) */
+};
+
+struct t_gui_line
+{
+ struct t_gui_line_data *data; /* pointer to line data */
+ struct t_gui_line *prev_line; /* link to previous line */
+ struct t_gui_line *next_line; /* link to next line */
+};
+
+struct t_gui_lines
+{
+ struct t_gui_line *first_line; /* pointer to first line */
+ struct t_gui_line *last_line; /* pointer to last line */
+ struct t_gui_line *last_read_line; /* last read line */
+ int lines_count; /* number of lines */
+ int first_line_not_read; /* if 1, marker is before first line */
+ int lines_hidden; /* 1 if at least one line is hidden */
+ int buffer_max_length; /* max length for buffer name (for */
+ /* mixed lines only) */
+ int prefix_max_length; /* max length for prefix align */
+};
+
+/* line functions */
+
+extern struct t_gui_lines *gui_lines_alloc ();
+extern void gui_lines_free (struct t_gui_lines *lines);
+extern int gui_line_get_align (struct t_gui_buffer *buffer,
+ struct t_gui_line *line,
+ int with_suffix);
+extern int gui_line_is_displayed (struct t_gui_line *line);
+extern struct t_gui_line *gui_line_get_first_displayed (struct t_gui_buffer *buffer);
+extern struct t_gui_line *gui_line_get_last_displayed (struct t_gui_buffer *buffer);
+extern struct t_gui_line *gui_line_get_prev_displayed (struct t_gui_line *line);
+extern struct t_gui_line *gui_line_get_next_displayed (struct t_gui_line *line);
+extern int gui_line_search_text (struct t_gui_line *line, const char *text,
+ int case_sensitive);
+extern int gui_line_match_regex (struct t_gui_line *line,
+ regex_t *regex_prefix,
+ regex_t *regex_message);
+extern int gui_line_match_tags (struct t_gui_line *line, int tags_count,
+ char **tags_array);
+extern int gui_line_has_highlight (struct t_gui_line *line);
+extern void gui_line_mixed_free_buffer (struct t_gui_buffer *buffer);
+extern void gui_line_mixed_free_all (struct t_gui_buffer *buffer);
+extern void gui_line_free (struct t_gui_buffer *buffer,
+ struct t_gui_line *line);
+extern void gui_line_free_all (struct t_gui_buffer *buffer);
+extern int gui_line_get_notify_level (struct t_gui_line *line);
+extern struct t_gui_line *gui_line_add (struct t_gui_buffer *buffer,
+ time_t date,
+ time_t date_printed,
+ const char *tags,
+ const char *prefix,
+ const char *message);
+extern void gui_line_add_y (struct t_gui_buffer *buffer, int y,
+ const char *message);
+extern void gui_line_mix_buffers (struct t_gui_buffer *buffer);
+extern int gui_line_add_to_infolist (struct t_infolist *infolist,
+ struct t_gui_lines *lines,
+ struct t_gui_line *line);
+extern void gui_lines_print_log (struct t_gui_lines *lines);
+
+#endif /* gui-line.h */
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index 91bd37146..d039c8520 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -44,11 +44,11 @@
#include "gui-bar.h"
#include "gui-bar-window.h"
#include "gui-buffer.h"
-#include "gui-chat.h"
#include "gui-filter.h"
#include "gui-input.h"
#include "gui-hotlist.h"
#include "gui-layout.h"
+#include "gui-line.h"
int gui_init_ok = 0; /* = 1 if GUI is initialized*/
@@ -419,8 +419,8 @@ gui_window_set_layout_buffer_name (struct t_gui_window *window,
void
gui_window_free (struct t_gui_window *window)
{
- if (window->buffer && (window->buffer->num_displayed > 0))
- window->buffer->num_displayed--;
+ if (window->buffer)
+ gui_buffer_add_value_num_displayed (window->buffer, -1);
/* free data */
if (window->gui_objects)
@@ -524,7 +524,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
struct t_gui_line *ptr_line;
struct tm *date_tmp, line_date, old_line_date;
- if (window->buffer->lines)
+ if (window->buffer->lines->first_line)
{
direction = 1;
number = 0;
@@ -579,8 +579,8 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
if (direction < 0)
{
ptr_line = (window->start_line) ?
- window->start_line : window->buffer->last_line;
- while (ptr_line && !gui_chat_line_displayed (ptr_line))
+ window->start_line : window->buffer->lines->last_line;
+ while (ptr_line && !gui_line_is_displayed (ptr_line))
{
ptr_line = ptr_line->prev_line;
}
@@ -588,21 +588,21 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
else
{
ptr_line = (window->start_line) ?
- window->start_line : window->buffer->lines;
- while (ptr_line && !gui_chat_line_displayed (ptr_line))
+ window->start_line : window->buffer->lines->first_line;
+ while (ptr_line && !gui_line_is_displayed (ptr_line))
{
ptr_line = ptr_line->next_line;
}
}
- old_date = ptr_line->date;
+ old_date = ptr_line->data->date;
date_tmp = localtime (&old_date);
memcpy (&old_line_date, date_tmp, sizeof (struct tm));
while (ptr_line)
{
ptr_line = (direction < 0) ?
- gui_chat_get_prev_line_displayed (ptr_line) : gui_chat_get_next_line_displayed (ptr_line);
+ gui_line_get_prev_displayed (ptr_line) : gui_line_get_next_displayed (ptr_line);
if (ptr_line)
{
@@ -614,12 +614,12 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
}
else
{
- date_tmp = localtime (&(ptr_line->date));
+ date_tmp = localtime (&(ptr_line->data->date));
memcpy (&line_date, date_tmp, sizeof (struct tm));
- if (old_date > ptr_line->date)
- diff_date = old_date - ptr_line->date;
+ if (old_date > ptr_line->data->date)
+ diff_date = old_date - ptr_line->data->date;
else
- diff_date = ptr_line->date - old_date;
+ diff_date = ptr_line->data->date - old_date;
switch (time_letter)
{
case 's': /* seconds */
@@ -709,7 +709,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
window->start_line = ptr_line;
window->start_line_pos = 0;
window->first_line_displayed =
- (window->start_line == gui_chat_get_first_line_displayed (window->buffer));
+ (window->start_line == gui_line_get_first_displayed (window->buffer));
gui_buffer_ask_chat_refresh (window->buffer, 2);
return;
}
@@ -737,18 +737,18 @@ gui_window_scroll_previous_highlight (struct t_gui_window *window)
if ((window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
- if (window->buffer->lines)
+ if (window->buffer->lines->first_line)
{
ptr_line = (window->start_line) ?
- window->start_line->prev_line : window->buffer->last_line;
+ window->start_line->prev_line : window->buffer->lines->last_line;
while (ptr_line)
{
- if (ptr_line->highlight)
+ if (ptr_line->data->highlight)
{
window->start_line = ptr_line;
window->start_line_pos = 0;
window->first_line_displayed =
- (window->start_line == window->buffer->lines);
+ (window->start_line == window->buffer->lines->first_line);
gui_buffer_ask_chat_refresh (window->buffer, 2);
return;
}
@@ -770,18 +770,18 @@ gui_window_scroll_next_highlight (struct t_gui_window *window)
if ((window->buffer->type == GUI_BUFFER_TYPE_FORMATTED)
&& (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
- if (window->buffer->lines)
+ if (window->buffer->lines->first_line)
{
ptr_line = (window->start_line) ?
- window->start_line->next_line : window->buffer->lines->next_line;
+ window->start_line->next_line : window->buffer->lines->first_line->next_line;
while (ptr_line)
{
- if (ptr_line->highlight)
+ if (ptr_line->data->highlight)
{
window->start_line = ptr_line;
window->start_line_pos = 0;
window->first_line_displayed =
- (window->start_line == window->buffer->lines);
+ (window->start_line == window->buffer->lines->first_line);
gui_buffer_ask_chat_refresh (window->buffer, 2);
return;
}
@@ -802,51 +802,51 @@ gui_window_search_text (struct t_gui_window *window)
if (window->buffer->text_search == GUI_TEXT_SEARCH_BACKWARD)
{
- if (window->buffer->lines
+ if (window->buffer->lines->first_line
&& window->buffer->input_buffer && window->buffer->input_buffer[0])
{
ptr_line = (window->start_line) ?
- gui_chat_get_prev_line_displayed (window->start_line) :
- gui_chat_get_last_line_displayed (window->buffer);
+ gui_line_get_prev_displayed (window->start_line) :
+ gui_line_get_last_displayed (window->buffer);
while (ptr_line)
{
- if (gui_chat_line_search (ptr_line,
+ if (gui_line_search_text (ptr_line,
window->buffer->input_buffer,
window->buffer->text_search_exact))
{
window->start_line = ptr_line;
window->start_line_pos = 0;
window->first_line_displayed =
- (window->start_line == gui_chat_get_first_line_displayed (window->buffer));
+ (window->start_line == gui_line_get_first_displayed (window->buffer));
gui_buffer_ask_chat_refresh (window->buffer, 2);
return 1;
}
- ptr_line = gui_chat_get_prev_line_displayed (ptr_line);
+ ptr_line = gui_line_get_prev_displayed (ptr_line);
}
}
}
else if (window->buffer->text_search == GUI_TEXT_SEARCH_FORWARD)
{
- if (window->buffer->lines
+ if (window->buffer->lines->first_line
&& window->buffer->input_buffer && window->buffer->input_buffer[0])
{
ptr_line = (window->start_line) ?
- gui_chat_get_next_line_displayed (window->start_line) :
- gui_chat_get_first_line_displayed (window->buffer);
+ gui_line_get_next_displayed (window->start_line) :
+ gui_line_get_first_displayed (window->buffer);
while (ptr_line)
{
- if (gui_chat_line_search (ptr_line,
+ if (gui_line_search_text (ptr_line,
window->buffer->input_buffer,
window->buffer->text_search_exact))
{
window->start_line = ptr_line;
window->start_line_pos = 0;
window->first_line_displayed =
- (window->start_line == window->buffer->lines);
+ (window->start_line == window->buffer->lines->first_line);
gui_buffer_ask_chat_refresh (window->buffer, 2);
return 1;
}
- ptr_line = gui_chat_get_next_line_displayed (ptr_line);
+ ptr_line = gui_line_get_next_displayed (ptr_line);
}
}
}
@@ -997,7 +997,7 @@ gui_window_add_to_infolist (struct t_infolist *infolist,
if (!infolist_new_var_integer (ptr_item, "start_line_y",
((window->buffer->type == GUI_BUFFER_TYPE_FREE)
&& (window->start_line)) ?
- window->start_line->y : 0))
+ window->start_line->data->y : 0))
return 0;
return 1;
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c
index 29d026251..2292a6edd 100644
--- a/src/plugins/irc/irc-bar-item.c
+++ b/src/plugins/irc/irc-bar-item.c
@@ -143,24 +143,12 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
{
if (server && !channel)
{
- if (weechat_config_boolean (irc_config_look_one_server_buffer))
- {
- snprintf (buf_name, sizeof (buf_name), "%s%s[<%s%s%s>]",
- _("servers"),
- IRC_COLOR_BAR_DELIM,
- IRC_COLOR_STATUS_NAME,
- (irc_current_server) ? irc_current_server->name : "-",
- IRC_COLOR_BAR_DELIM);
- }
- else
- {
- snprintf (buf_name, sizeof (buf_name), "%s%s[%s%s%s]",
- _("server"),
- IRC_COLOR_BAR_DELIM,
- IRC_COLOR_STATUS_NAME,
- server->name,
- IRC_COLOR_BAR_DELIM);
- }
+ snprintf (buf_name, sizeof (buf_name), "%s%s[%s%s%s]",
+ _("server"),
+ IRC_COLOR_BAR_DELIM,
+ IRC_COLOR_STATUS_NAME,
+ server->name,
+ IRC_COLOR_BAR_DELIM);
}
else
{
diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c
index 8d6989a09..5cd1146b3 100644
--- a/src/plugins/irc/irc-buffer.c
+++ b/src/plugins/irc/irc-buffer.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <limits.h>
#include "../weechat-plugin.h"
#include "irc.h"
@@ -33,10 +34,6 @@
#include "irc-server.h"
-/* buffer for all servers (if using one buffer for all servers) */
-struct t_gui_buffer *irc_buffer_servers = NULL;
-
-
/*
* irc_buffer_get_server_channel: get IRC server and channel pointers with a
* buffer pointer
@@ -66,12 +63,7 @@ irc_buffer_get_server_channel (struct t_gui_buffer *buffer,
if (ptr_server->buffer == buffer)
{
if (server)
- {
- if (weechat_config_boolean (irc_config_look_one_server_buffer))
- *server = irc_current_server;
- else
- *server = ptr_server;
- }
+ *server = ptr_server;
return;
}
@@ -116,156 +108,6 @@ irc_buffer_build_name (const char *server, const char *channel)
}
/*
- * irc_buffer_get_server_prefix: return prefix, with server name if server
- * buffers are displayed in only one buffer
- */
-
-char *
-irc_buffer_get_server_prefix (struct t_irc_server *server, char *prefix_code)
-{
- static char buf[256];
- const char *prefix;
-
- prefix = (prefix_code && prefix_code[0]) ?
- weechat_prefix (prefix_code) : NULL;
-
- if (weechat_config_boolean (irc_config_look_one_server_buffer) && server)
- {
- snprintf (buf, sizeof (buf), "%s%s[%s%s%s]%s ",
- (prefix) ? prefix : "",
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_SERVER,
- server->name,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT);
- }
- else
- {
- snprintf (buf, sizeof (buf), "%s",
- (prefix) ? prefix : "");
- }
- return buf;
-}
-
-/*
- * irc_buffer_merge_servers: merge server buffers in one buffer
- */
-
-void
-irc_buffer_merge_servers ()
-{
- struct t_irc_server *ptr_server;
- struct t_gui_buffer *ptr_buffer;
- int number, number_selected;
- char charset_modifier[256];
-
- irc_buffer_servers = NULL;
- irc_current_server = NULL;
-
- /* choose server buffer with lower number (should be first created) */
- number_selected = -1;
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->buffer)
- {
- number = weechat_buffer_get_integer (ptr_server->buffer, "number");
- if ((number_selected == -1) || (number < number_selected))
- {
- irc_buffer_servers = ptr_server->buffer;
- irc_current_server = ptr_server;
- number_selected = number;
- }
- }
- }
-
- if (irc_buffer_servers)
- {
- weechat_buffer_set (irc_buffer_servers,
- "name", IRC_BUFFER_ALL_SERVERS_NAME);
- weechat_buffer_set (irc_buffer_servers,
- "short_name", IRC_BUFFER_ALL_SERVERS_NAME);
- weechat_buffer_set (irc_buffer_servers,
- "localvar_set_server", IRC_BUFFER_ALL_SERVERS_NAME);
- weechat_buffer_set (irc_buffer_servers,
- "localvar_set_channel", IRC_BUFFER_ALL_SERVERS_NAME);
- snprintf (charset_modifier, sizeof (charset_modifier),
- "irc.%s", irc_current_server->name);
- weechat_buffer_set (irc_buffer_servers,
- "localvar_set_charset_modifier",
- charset_modifier);
- weechat_hook_signal_send ("logger_stop",
- WEECHAT_HOOK_SIGNAL_POINTER,
- irc_buffer_servers);
- weechat_hook_signal_send ("logger_start",
- WEECHAT_HOOK_SIGNAL_POINTER,
- irc_buffer_servers);
-
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->buffer
- && (ptr_server->buffer != irc_buffer_servers))
- {
- ptr_buffer = ptr_server->buffer;
- ptr_server->buffer = irc_buffer_servers;
- weechat_buffer_close (ptr_buffer);
- }
- }
-
- irc_server_set_buffer_title (irc_current_server);
- irc_server_buffer_set_highlight_words (irc_buffer_servers);
- }
-}
-
-/*
- * irc_buffer_split_server: split the server buffer into many buffers (one by server)
- */
-
-void
-irc_buffer_split_server ()
-{
- struct t_irc_server *ptr_server;
- char buffer_name[256], charset_modifier[256];
-
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->buffer && (ptr_server != irc_current_server))
- {
- irc_server_create_buffer (ptr_server, 0);
- }
- }
-
- if (irc_current_server)
- {
- snprintf (buffer_name, sizeof (buffer_name),
- "server.%s", irc_current_server->name);
- weechat_buffer_set (irc_current_server->buffer, "name", buffer_name);
- weechat_buffer_set (irc_current_server->buffer,
- "short_name", irc_current_server->name);
- weechat_buffer_set (irc_current_server->buffer,
- "localvar_set_server", irc_current_server->name);
- weechat_buffer_set (irc_current_server->buffer,
- "localvar_set_channel", irc_current_server->name);
- snprintf (charset_modifier, sizeof (charset_modifier),
- "irc.%s", irc_current_server->name);
- weechat_buffer_set (irc_current_server->buffer,
- "localvar_set_charset_modifier",
- charset_modifier);
- weechat_hook_signal_send ("logger_stop",
- WEECHAT_HOOK_SIGNAL_POINTER,
- irc_current_server->buffer);
- weechat_hook_signal_send ("logger_start",
- WEECHAT_HOOK_SIGNAL_POINTER,
- irc_current_server->buffer);
- }
-
- irc_buffer_servers = NULL;
- irc_current_server = NULL;
-}
-
-/*
* irc_buffer_close_cb: callback called when a buffer is closed
*/
@@ -310,12 +152,40 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
irc_server_disconnect (ptr_server, 0);
ptr_server->buffer = NULL;
}
- if (irc_buffer_servers == buffer)
- irc_buffer_servers = NULL;
- if (ptr_server && (irc_current_server == ptr_server))
- irc_current_server = NULL;
}
}
return WEECHAT_RC_OK;
}
+
+/*
+ * irc_buffer_search_first_for_all_servers: search first server buffer that
+ * will be used to merge all IRC
+ * server buffers
+ */
+
+struct t_gui_buffer *
+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)
+ {
+ if (ptr_server->buffer)
+ {
+ number = weechat_buffer_get_integer (ptr_server->buffer, "number");
+ if (number < number_found)
+ {
+ number_found = number;
+ ptr_buffer = ptr_server->buffer;
+ }
+ }
+ }
+ return ptr_buffer;
+}
diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h
index 74d97ed2b..87959a38e 100644
--- a/src/plugins/irc/irc-buffer.h
+++ b/src/plugins/irc/irc-buffer.h
@@ -20,8 +20,6 @@
#ifndef __WEECHAT_IRC_BUFFER_H
#define __WEECHAT_IRC_BUFFER_H 1
-#define IRC_BUFFER_ALL_SERVERS_NAME "servers"
-
#define IRC_BUFFER_RAW_NAME "irc_raw"
#define IRC_BUFFER_RAW_PREFIX_RECV "-->"
#define IRC_BUFFER_RAW_PREFIX_RECV_MOD "==>"
@@ -32,16 +30,11 @@ struct t_gui_buffer;
struct t_irc_server;
struct t_irc_channel;
-extern struct t_gui_buffer *irc_buffer_servers;
-
extern void irc_buffer_get_server_channel (struct t_gui_buffer *buffer,
struct t_irc_server **server,
struct t_irc_channel **channel);
extern char *irc_buffer_build_name (const char *server, const char *channel);
-extern char *irc_buffer_get_server_prefix (struct t_irc_server *server,
- char *prefix_code);
-extern void irc_buffer_merge_servers ();
-extern void irc_buffer_split_server ();
extern int irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer);
+extern struct t_gui_buffer *irc_buffer_search_first_for_all_servers ();
#endif /* irc-buffer.h */
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 2a852a806..37cf1bef9 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -232,8 +232,7 @@ irc_command_amsg (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: cannot find nick for "
"sending message"),
- irc_buffer_get_server_prefix (ptr_server,
- "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME);
}
}
@@ -296,11 +295,8 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments,
/* reset "unread" indicator on server and channels/pv buffers */
if (reset_unread_marker)
{
- if (!weechat_config_boolean (irc_config_look_one_server_buffer))
- {
- if (weechat_buffer_get_integer (server->buffer, "num_displayed") > 0)
- weechat_buffer_set (server->buffer, "unread", "");
- }
+ if (weechat_buffer_get_integer (server->buffer, "num_displayed") > 0)
+ weechat_buffer_set (server->buffer, "unread", "");
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -319,8 +315,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments,
string = irc_color_decode (arguments,
weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (server->buffer,
- _("%s%s: future away: %s"),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: future away: %s"),
IRC_PLUGIN_NAME,
(string) ? string : arguments);
if (string)
@@ -378,8 +373,7 @@ irc_command_away_server (struct t_irc_server *server, const char *arguments,
/* server not connected, remove away message but do not send
anything */
weechat_printf (server->buffer,
- _("%s%s: future away removed"),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: future away removed"),
IRC_PLUGIN_NAME);
}
}
@@ -464,8 +458,8 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "ban");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "ban");
return WEECHAT_RC_OK;
}
}
@@ -485,8 +479,7 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "ban");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "ban");
return WEECHAT_RC_OK;
}
irc_server_sendf (ptr_server, 0, "MODE %s +b", ptr_channel->name);
@@ -698,8 +691,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01PING %d %d\01",
argv[1], tv.tv_sec, tv.tv_usec);
weechat_printf (ptr_server->buffer,
- "%sCTCP%s(%s%s%s)%s: %s%s %s%d %d",
- irc_buffer_get_server_prefix (ptr_server, NULL),
+ "CTCP%s(%s%s%s)%s: %s%s %s%d %d",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[1],
@@ -717,8 +709,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01%s %s\01",
argv[1], irc_cmd, argv_eol[3]);
weechat_printf (ptr_server->buffer,
- "%sCTCP%s(%s%s%s)%s: %s%s %s%s",
- irc_buffer_get_server_prefix (ptr_server, NULL),
+ "CTCP%s(%s%s%s)%s: %s%s %s%s",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[1],
@@ -734,8 +725,7 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
irc_server_sendf (ptr_server, 1, "PRIVMSG %s :\01%s\01",
argv[1], irc_cmd);
weechat_printf (ptr_server->buffer,
- "%sCTCP%s(%s%s%s)%s: %s%s",
- irc_buffer_get_server_prefix (ptr_server, NULL),
+ "CTCP%s(%s%s%s)%s: %s%s",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[1],
@@ -800,8 +790,8 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can not be executed "
"on a server buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "cycle");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "cycle");
return WEECHAT_RC_OK;
}
@@ -821,8 +811,7 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can not be executed on "
"a server buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "part");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "part");
return WEECHAT_RC_OK;
}
@@ -953,8 +942,7 @@ irc_command_dcc (void *data, struct t_gui_buffer *buffer, int argc,
{
weechat_printf (ptr_server->buffer,
_("%s%s: wrong arguments for \"%s\" command"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "dcc");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "dcc");
return WEECHAT_RC_OK;
}
}
@@ -996,8 +984,7 @@ irc_command_dehalfop (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be executed in "
"a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "dehalfop");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "dehalfop");
return WEECHAT_RC_OK;
}
return WEECHAT_RC_OK;
@@ -1033,8 +1020,7 @@ irc_command_deop (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be executed in "
"a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "deop");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "deop");
return WEECHAT_RC_OK;
}
return WEECHAT_RC_OK;
@@ -1070,8 +1056,7 @@ irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "devoice");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "devoice");
return WEECHAT_RC_OK;
}
return WEECHAT_RC_OK;
@@ -1150,15 +1135,14 @@ irc_command_disconnect_one_server (struct t_irc_server *server)
{
weechat_printf (server->buffer,
_("%s%s: not connected to server \"%s\"!"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, server->name);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ server->name);
return 0;
}
if (server->reconnect_start > 0)
{
weechat_printf (server->buffer,
- _("%s%s: auto-reconnection is cancelled"),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: auto-reconnection is cancelled"),
IRC_PLUGIN_NAME);
}
irc_command_quit_server (server, NULL);
@@ -1261,8 +1245,7 @@ irc_command_halfop (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "halfop");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "halfop");
return WEECHAT_RC_OK;
}
return WEECHAT_RC_OK;
@@ -1506,8 +1489,8 @@ irc_command_invite (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "invite");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "invite");
return WEECHAT_RC_OK;
}
@@ -1604,8 +1587,8 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: wrong arguments for \"%s\" "
"command"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "kick");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "kick");
return WEECHAT_RC_OK;
}
pos_channel = argv[1];
@@ -1625,8 +1608,8 @@ irc_command_kick (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "kick");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "kick");
return WEECHAT_RC_OK;
}
}
@@ -1671,8 +1654,8 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: wrong arguments for \"%s\" "
"command"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "kickban");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "kickban");
return WEECHAT_RC_OK;
}
pos_channel = argv[1];
@@ -1692,8 +1675,8 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "kickban");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "kickban");
return WEECHAT_RC_OK;
}
}
@@ -1818,8 +1801,8 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" is not a valid regular "
"expression (%s)"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, argv_eol, buf);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ argv_eol, buf);
return WEECHAT_RC_OK;
}
else
@@ -1830,8 +1813,7 @@ irc_command_list (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: not enough memory for regular "
"expression"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
return WEECHAT_RC_OK;
}
}
@@ -1884,8 +1866,7 @@ irc_command_me (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can not be executed "
"on a server buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "me");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "me");
return WEECHAT_RC_OK;
}
irc_command_me_channel (ptr_server, ptr_channel,
@@ -1941,8 +1922,8 @@ irc_command_mode (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: you must specify channel for \"%s\" "
"command if you're not in a channel"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "mode");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "mode");
return WEECHAT_RC_OK;
}
irc_command_mode_server (ptr_server, ptr_channel, argv_eol[1]);
@@ -2038,8 +2019,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
_("%s%s: \"%s\" command can only be "
"executed in a channel or private "
"buffer"),
- irc_buffer_get_server_prefix (ptr_server,
- "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "msg *");
return WEECHAT_RC_OK;
}
@@ -2093,8 +2073,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_server->buffer,
"%s%s-%s%s%s- %s%s",
- irc_buffer_get_server_prefix (ptr_server,
- "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
targets[i],
@@ -2123,8 +2102,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
{
weechat_printf (ptr_server->buffer,
"%sMSG%s(%s%s%s)%s: %s",
- irc_buffer_get_server_prefix (ptr_server,
- "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
targets[i],
@@ -2173,8 +2151,8 @@ irc_command_names (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "names");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "names");
return WEECHAT_RC_OK;
}
}
@@ -2219,8 +2197,7 @@ irc_command_nick (void *data, struct t_gui_buffer *buffer, int argc,
{
weechat_printf (ptr_server->buffer,
_("%s%s: wrong arguments for \"%s\" command"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "nick");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "nick");
return WEECHAT_RC_OK;
}
for (ptr_server = irc_servers; ptr_server;
@@ -2274,8 +2251,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
string = irc_color_decode (argv_eol[arg_text],
weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_server->buffer,
- "%sNotice -> %s%s%s: %s",
- irc_buffer_get_server_prefix (ptr_server, NULL),
+ "Notice -> %s%s%s: %s",
IRC_COLOR_CHAT_NICK,
argv[arg_nick],
IRC_COLOR_CHAT,
@@ -2324,8 +2300,7 @@ irc_command_op (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "op");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "op");
return WEECHAT_RC_OK;
}
return WEECHAT_RC_OK;
@@ -2418,8 +2393,8 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
_("%s%s: \"%s\" command can only be "
"executed in a channel or "
"private buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "part");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "part");
return WEECHAT_RC_OK;
}
channel_name = ptr_channel->name;
@@ -2434,8 +2409,7 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
_("%s%s: \"%s\" command can only be "
"executed in a channel or private "
"buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "part");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "part");
return WEECHAT_RC_OK;
}
if (!ptr_channel->nicks)
@@ -2543,8 +2517,8 @@ irc_command_query (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: cannot create new private "
"buffer \"%s\""),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, argv[arg_nick]);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ argv[arg_nick]);
return WEECHAT_RC_OK;
}
}
@@ -2625,8 +2599,8 @@ irc_command_reconnect_one_server (struct t_irc_server *server, int no_join)
{
weechat_printf (server->buffer,
_("%s%s: not connected to server \"%s\"!"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, server->name);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ server->name);
return 0;
}
irc_command_quit_server (server, NULL);
@@ -3115,13 +3089,6 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
return WEECHAT_RC_OK;
}
- if (weechat_strcasecmp (argv[1], "switch") == 0)
- {
- if (weechat_config_boolean (irc_config_look_one_server_buffer))
- irc_server_switch_next ();
- return WEECHAT_RC_OK;
- }
-
weechat_printf (NULL,
_("%s%s: unknown option for \"%s\" command"),
weechat_prefix ("error"), IRC_PLUGIN_NAME, "server");
@@ -3345,8 +3312,8 @@ irc_command_topic (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "topic");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "topic");
return WEECHAT_RC_OK;
}
}
@@ -3437,8 +3404,8 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "unban");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "unban");
return WEECHAT_RC_OK;
}
}
@@ -3455,8 +3422,7 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
{
weechat_printf (ptr_server->buffer,
_("%s%s: wrong argument count for \"%s\" command"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "unban");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "unban");
return WEECHAT_RC_OK;
}
@@ -3572,8 +3538,7 @@ irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc,
weechat_printf (ptr_server->buffer,
_("%s%s: \"%s\" command can only be "
"executed in a channel buffer"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
- IRC_PLUGIN_NAME, "voice");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "voice");
return WEECHAT_RC_OK;
}
@@ -4047,7 +4012,7 @@ irc_command_init ()
"[copy servername newservername] | "
"[rename servername newservername] | "
"[keep servername] | [del servername] | "
- "[deloutq] | [raw] | [switch]"),
+ "[deloutq] | [raw]"),
N_(" list: list servers (no parameter implies "
"this list)\n"
" listfull: list servers with detailed info for "
@@ -4071,10 +4036,7 @@ irc_command_init ()
" deloutq: delete messages out queue for all "
"servers (all messages WeeChat is currently "
"sending)\n"
- " raw: open buffer with raw IRC data\n"
- " switch: switch active server (when one "
- "buffer is used for all servers, default key: "
- "alt-s on server buffer)\n\n"
+ " raw: open buffer with raw IRC data\n\n"
"Examples:\n"
" /server listfull\n"
" /server add oftc irc.oftc.net/6697 -ssl\n"
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index 12b2b526d..6bd14219d 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -26,8 +26,7 @@ struct t_irc_channel;
#define IRC_COMMAND_TOO_FEW_ARGUMENTS(__buffer, __command) \
weechat_printf (__buffer, \
_("%s%s: too few arguments for \"%s\" command"), \
- irc_buffer_get_server_prefix (ptr_server, "error"), \
- IRC_PLUGIN_NAME, \
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, \
__command); \
return WEECHAT_RC_OK;
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 6529d827f..b0fa3c072 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -43,7 +43,7 @@ struct t_config_section *irc_config_section_server = NULL;
/* IRC config, look section */
struct t_config_option *irc_config_look_color_nicks_in_server_messages;
-struct t_config_option *irc_config_look_one_server_buffer;
+struct t_config_option *irc_config_look_server_buffer;
struct t_config_option *irc_config_look_open_near_server;
struct t_config_option *irc_config_look_nick_prefix;
struct t_config_option *irc_config_look_nick_suffix;
@@ -153,22 +153,50 @@ irc_config_change_look_color_nicks_number (void *data, const char *option,
}
/*
- * irc_config_change_look_one_server_buffer: called when the "one server buffer"
- * option is changed
+ * irc_config_change_look_server_buffer: called when the "one server buffer"
+ * option is changed
*/
void
-irc_config_change_look_one_server_buffer (void *data,
- struct t_config_option *option)
+irc_config_change_look_server_buffer (void *data,
+ struct t_config_option *option)
{
+ struct t_irc_server *ptr_server;
+ struct t_gui_buffer *ptr_buffer;
+
/* make C compiler happy */
(void) data;
(void) option;
-
- if (weechat_config_boolean (irc_config_look_one_server_buffer))
- irc_buffer_merge_servers ();
- else
- irc_buffer_split_server ();
+
+ /* first unmerge all IRC server buffers */
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ if (ptr_server->buffer)
+ weechat_buffer_unmerge (ptr_server->buffer, -1);
+ }
+
+ /* merge IRC server buffers with core buffer or another buffer */
+ if ((weechat_config_integer (irc_config_look_server_buffer) ==
+ IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE)
+ || (weechat_config_integer (irc_config_look_server_buffer) ==
+ IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITHOUT_CORE))
+ {
+ ptr_buffer =
+ (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;
+ ptr_server = ptr_server->next_server)
+ {
+ if (ptr_server->buffer && (ptr_server->buffer != ptr_buffer))
+ weechat_buffer_merge (ptr_server->buffer, ptr_buffer);
+ }
+ }
+ }
}
/*
@@ -340,26 +368,15 @@ irc_config_change_network_send_unknown_commands (void *data,
(weechat_config_boolean (irc_config_network_send_unknown_commands)) ?
"1" : "0");
- if (weechat_config_boolean (irc_config_look_one_server_buffer))
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
{
- if (irc_buffer_servers)
+ if (ptr_server->buffer)
{
- weechat_buffer_set (irc_buffer_servers,
+ weechat_buffer_set (ptr_server->buffer,
"input_get_unknown_commands", value);
}
}
- else
- {
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->buffer)
- {
- weechat_buffer_set (ptr_server->buffer,
- "input_get_unknown_commands", value);
- }
- }
- }
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
@@ -1055,12 +1072,13 @@ irc_config_init ()
N_("use nick color in messages from server"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
- irc_config_look_one_server_buffer = weechat_config_new_option (
+ irc_config_look_server_buffer = weechat_config_new_option (
irc_config_file, ptr_section,
- "one_server_buffer", "boolean",
- N_("use same buffer for all servers"),
- NULL, 0, 0, "off", NULL, 0, NULL, NULL,
- &irc_config_change_look_one_server_buffer, NULL, NULL, NULL);
+ "server_buffer", "integer",
+ N_("merge server buffers"),
+ "merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core",
+ NULL, 0, NULL, NULL,
+ &irc_config_change_look_server_buffer, NULL, NULL, NULL);
irc_config_look_open_near_server = weechat_config_new_option (
irc_config_file, ptr_section,
"open_near_server", "boolean",
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index 30be39987..d79e15b7b 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -22,6 +22,13 @@
#define IRC_CONFIG_NAME "irc"
+enum t_irc_config_look_server_buffer
+{
+ IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE = 0,
+ IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITHOUT_CORE,
+ IRC_CONFIG_LOOK_SERVER_BUFFER_INDEPENDENT,
+};
+
enum t_irc_config_nick_completion
{
IRC_CONFIG_NICK_COMPLETION_SMART_OFF = 0,
@@ -41,7 +48,7 @@ extern struct t_config_section *irc_config_section_server_default;
extern struct t_config_section *irc_config_section_server;
extern struct t_config_option *irc_config_look_color_nicks_in_server_messages;
-extern struct t_config_option *irc_config_look_one_server_buffer;
+extern struct t_config_option *irc_config_look_server_buffer;
extern struct t_config_option *irc_config_look_open_near_server;
extern struct t_config_option *irc_config_look_nick_prefix;
extern struct t_config_option *irc_config_look_nick_suffix;
diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c
index de55223c9..d7a1cf400 100644
--- a/src/plugins/irc/irc-info.c
+++ b/src/plugins/irc/irc-info.c
@@ -166,14 +166,6 @@ irc_info_get_info_cb (void *data, const char *info_name,
}
}
}
- else if (weechat_strcasecmp (info_name, "irc_current_server") == 0)
- {
- if (weechat_config_boolean (irc_config_look_one_server_buffer)
- && irc_current_server)
- {
- return irc_current_server->name;
- }
- }
return NULL;
}
@@ -391,10 +383,6 @@ irc_info_init ()
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_buffer", N_("get buffer pointer for an IRC server/channel"),
&irc_info_get_info_cb, NULL);
- weechat_hook_info ("irc_current_server",
- N_("currently selected server (only if one buffer is "
- "used for all servers)"),
- &irc_info_get_info_cb, NULL);
/* infolist hooks */
weechat_hook_infolist ("irc_server", N_("list of IRC servers"),
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index c60e2ad87..17e908ee8 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -252,7 +252,7 @@ irc_protocol_cmd_error (struct t_irc_server *server, const char *command,
weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer,
irc_protocol_tags (command, "irc_error"),
"%s%s%s%s%s%s",
- (ptr_channel) ? weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
(ptr_channel && chan_nick
&& (strcmp (chan_nick, ptr_channel->name) == 0)) ?
IRC_COLOR_CHAT_CHANNEL : "",
@@ -292,7 +292,7 @@ irc_protocol_cmd_invite (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "notify_highlight"),
_("%sYou have been invited to %s%s%s by "
"%s%s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
(argv[3][0] == ':') ? argv[3] + 1 : argv[3],
IRC_COLOR_CHAT,
@@ -339,8 +339,8 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot create new channel \"%s\""),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, pos_channel);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ pos_channel);
return WEECHAT_RC_ERROR;
}
}
@@ -413,8 +413,8 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: channel \"%s\" not found for "
"\"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, argv[2], "kick");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, argv[2],
+ "kick");
return WEECHAT_RC_ERROR;
}
@@ -584,7 +584,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command,
ptr_channel->buffer : server->buffer,
irc_protocol_tags (command, NULL),
_("%sMode %s%s %s[%s%s%s]%s by %s%s"),
- (ptr_channel) ? weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
(ptr_channel) ? ptr_channel->name : argv[2],
IRC_COLOR_CHAT_DELIMITERS,
@@ -603,7 +603,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, NULL),
_("%sUser mode %s[%s%s%s]%s by %s%s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
pos_modes,
@@ -770,7 +770,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, NULL),
_("%sCTCP %sVERSION%s reply from %s%s%s: %s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
@@ -809,8 +809,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "irc_ctcp"),
_("%sCTCP %sPING%s reply from "
"%s%s%s: %ld.%ld %s"),
- irc_buffer_get_server_prefix (server,
- "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
@@ -836,8 +835,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer,
irc_protocol_tags (command, NULL),
"%sNotice%s(%s%s%s)%s: %s",
- (ptr_channel) ?
- weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
(nick && nick[0]) ? nick : "?",
@@ -870,8 +868,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: cannot create new "
"private buffer \"%s\""),
- irc_buffer_get_server_prefix (server,
- "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, nick);
return WEECHAT_RC_ERROR;
}
@@ -895,8 +892,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
irc_protocol_tags (command,
(notify_private) ? "notify_private" : NULL),
"%s%s%s %s(%s%s%s)%s: %s",
- irc_buffer_get_server_prefix (server,
- "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
nick,
IRC_COLOR_CHAT_DELIMITERS,
@@ -914,8 +910,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
irc_protocol_tags (command,
(notify_private) ? "notify_private" : NULL),
"%s%s%s%s: %s",
- irc_buffer_get_server_prefix (server,
- "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
nick,
IRC_COLOR_CHAT,
@@ -927,8 +922,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
irc_protocol_tags (command,
(notify_private) ? "notify_private" : NULL),
"%s%s",
- irc_buffer_get_server_prefix (server,
- "network"),
+ weechat_prefix ("network"),
pos_args);
}
}
@@ -1161,8 +1155,7 @@ irc_protocol_reply_version (struct t_irc_server *server,
weechat_printf (ptr_buffer,
_("%sCTCP %sVERSION%s received from %s%s%s: "
"%s"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
@@ -1174,8 +1167,7 @@ irc_protocol_reply_version (struct t_irc_server *server,
{
weechat_printf (ptr_buffer,
_("%sCTCP %sVERSION%s received from %s%s"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
@@ -1426,7 +1418,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: channel \"%s\" not found for \"%s\" "
"command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, argv[2], "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1471,8 +1463,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_ctcp"),
_("%sCTCP %sPING%s received from %s%s"),
- irc_buffer_get_server_prefix (server,
- "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_NICK,
@@ -1498,7 +1489,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1511,7 +1502,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: not enough memory for \"%s\" "
"command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1529,7 +1520,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
@@ -1548,7 +1539,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
@@ -1567,7 +1558,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
@@ -1629,7 +1620,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1642,7 +1633,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: not enough memory for \"%s\" "
"command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1660,7 +1651,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
@@ -1679,7 +1670,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
@@ -1735,8 +1726,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "privmsg");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1748,8 +1739,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: not enough memory for \"%s\" "
"command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "privmsg");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1766,8 +1757,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "privmsg");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
}
@@ -1785,8 +1776,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "privmsg");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
}
@@ -1841,8 +1832,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "privmsg");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1854,8 +1845,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: not enough memory for \"%s\" "
"command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "privmsg");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "privmsg");
return WEECHAT_RC_ERROR;
}
@@ -1872,8 +1863,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "privmsg");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
}
@@ -1890,8 +1881,8 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: cannot parse \"%s\" command"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "privmsg");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ "privmsg");
free (dcc_args);
return WEECHAT_RC_ERROR;
}
@@ -1907,7 +1898,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: unknown DCC CHAT type "
"received from %s%s%s: \"%s\""),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME,
IRC_COLOR_CHAT_NICK,
nick,
@@ -1976,8 +1967,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: cannot create new "
"private buffer \"%s\""),
- irc_buffer_get_server_prefix (server,
- "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, remote_nick);
return WEECHAT_RC_ERROR;
}
@@ -2042,8 +2032,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "irc_ctcp"),
_("%sUnknown CTCP %s%s%s "
"received from %s%s%s: %s"),
- irc_buffer_get_server_prefix (server,
- "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
pos_args,
IRC_COLOR_CHAT,
@@ -2058,8 +2047,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "irc_ctcp"),
_("%sUnknown CTCP %s%s%s "
"received from %s%s"),
- irc_buffer_get_server_prefix (server,
- "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
pos_args,
IRC_COLOR_CHAT,
@@ -2091,8 +2079,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: cannot create new "
"private buffer \"%s\""),
- irc_buffer_get_server_prefix (server,
- "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, remote_nick);
return WEECHAT_RC_ERROR;
}
@@ -2241,7 +2228,7 @@ irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, const char *co
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s: %s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
pos_mode,
(pos_args) ? pos_args : "");
@@ -2276,7 +2263,7 @@ irc_protocol_cmd_numeric (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
pos_args);
return WEECHAT_RC_OK;
@@ -2306,8 +2293,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
{
weechat_printf (server->buffer,
_("%s%s: \"%s\" command received without channel"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, "topic");
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, "topic");
return WEECHAT_RC_ERROR;
}
@@ -2333,8 +2319,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, NULL),
_("%s%s%s%s has changed topic for %s%s%s "
"from \"%s%s\" to \"%s%s\""),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
nick,
IRC_COLOR_CHAT,
@@ -2354,8 +2339,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, NULL),
_("%s%s%s%s has changed topic for %s%s%s to "
"\"%s%s\""),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
nick,
IRC_COLOR_CHAT,
@@ -2373,8 +2357,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command,
weechat_printf_tags (ptr_buffer,
irc_protocol_tags (command, NULL),
_("%s%s%s%s has unset topic for %s%s"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
nick,
IRC_COLOR_CHAT,
@@ -2409,7 +2392,7 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, NULL),
_("%sWallops from %s%s %s(%s%s%s)%s: %s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
nick,
IRC_COLOR_CHAT_DELIMITERS,
@@ -2475,11 +2458,6 @@ irc_protocol_cmd_001 (struct t_irc_server *server, const char *command,
commands = weechat_string_split_command (ptr_command, ';');
if (commands)
{
- if (weechat_config_boolean (irc_config_look_one_server_buffer)
- && (irc_current_server != server))
- {
- irc_server_set_current_server (server);
- }
for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++)
{
vars_replaced = irc_protocol_replace_vars (server, NULL,
@@ -2565,7 +2543,7 @@ irc_protocol_cmd_221 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sUser mode for %s%s%s is %s[%s%s%s]"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
argv[2],
IRC_COLOR_CHAT,
@@ -2612,8 +2590,7 @@ irc_protocol_cmd_301 (struct t_irc_server *server, const char *command,
weechat_printf_tags (ptr_buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%s%s[%s%s%s]%s is away: %s"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -2652,7 +2629,7 @@ irc_protocol_cmd_303 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sUsers online: %s%s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
(argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]);
@@ -2681,7 +2658,7 @@ irc_protocol_cmd_305 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
(argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]);
}
@@ -2715,7 +2692,7 @@ irc_protocol_cmd_306 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
(argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]);
}
@@ -2744,7 +2721,7 @@ irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, const char *comman
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -2772,7 +2749,7 @@ irc_protocol_cmd_311 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] (%s%s@%s%s)%s: %s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -2804,7 +2781,7 @@ irc_protocol_cmd_312 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s %s(%s%s%s)",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -2836,7 +2813,7 @@ irc_protocol_cmd_314 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%s%s%s %s(%s%s@%s%s)%s was %s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
argv[3],
IRC_COLOR_CHAT_DELIMITERS,
@@ -2876,7 +2853,7 @@ irc_protocol_cmd_315 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s]%s %s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
@@ -2923,7 +2900,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command,
_("%s%s[%s%s%s]%s idle: %s%d %s%s, "
"%s%02d %s%s %s%02d %s%s %s%02d "
"%s%s, signon at: %s%s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -2955,7 +2932,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command,
_("%s%s[%s%s%s]%s idle: %s%02d %s%s "
"%s%02d %s%s %s%02d %s%s, "
"signon at: %s%s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -3002,7 +2979,7 @@ irc_protocol_cmd_321 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s%s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
argv[3],
(pos_args) ? " " : "",
(pos_args) ? pos_args : "");
@@ -3035,7 +3012,7 @@ irc_protocol_cmd_322 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s%s%s(%s%s%s)%s%s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT_DELIMITERS,
@@ -3075,7 +3052,7 @@ irc_protocol_cmd_323 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
(pos_args && pos_args[0]) ? pos_args : "");
return WEECHAT_RC_OK;
@@ -3145,7 +3122,7 @@ irc_protocol_cmd_327 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s %s %s(%s%s%s)",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -3163,7 +3140,7 @@ irc_protocol_cmd_327 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s %s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -3248,7 +3225,7 @@ irc_protocol_cmd_329 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sChannel %s%s%s created on %s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT,
@@ -3275,7 +3252,7 @@ irc_protocol_cmd_330 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s %s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -3313,8 +3290,7 @@ irc_protocol_cmd_331 (struct t_irc_server *server, const char *command,
weechat_printf_tags (ptr_buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sNo topic set for channel %s%s"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3]);
@@ -3361,8 +3337,7 @@ irc_protocol_cmd_332 (struct t_irc_server *server, const char *command,
weechat_printf_tags (ptr_buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sTopic for %s%s%s is \"%s%s\""),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT,
@@ -3412,7 +3387,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sTopic for %s%s%s set by %s%s%s on %s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT,
@@ -3442,7 +3417,7 @@ irc_protocol_cmd_338 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s]%s %s %s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[3],
@@ -3475,7 +3450,7 @@ irc_protocol_cmd_341 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%s%s%s%s has invited %s%s%s on %s%s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_NICK,
argv[2],
IRC_COLOR_CHAT,
@@ -3505,7 +3480,7 @@ irc_protocol_cmd_344 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sChannel reop %s%s%s: %s%s"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT,
@@ -3532,7 +3507,7 @@ irc_protocol_cmd_345 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s%s%s: %s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT,
@@ -3573,8 +3548,7 @@ irc_protocol_cmd_348 (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "irc_numeric"),
_("%s%s[%s%s%s]%s exception %s%s%s "
"by %s%s %s(%s%s%s)%s on %s"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
@@ -3597,8 +3571,7 @@ irc_protocol_cmd_348 (struct t_irc_server *server, const char *command,
weechat_printf_tags (ptr_buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%s%s[%s%s%s]%s exception %s%s"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
@@ -3638,8 +3611,7 @@ irc_protocol_cmd_349 (struct t_irc_server *server, const char *command,
weechat_printf_tags (ptr_buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s]%s%s%s",
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
@@ -3670,7 +3642,7 @@ irc_protocol_cmd_351 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s %s (%s)",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
argv[3],
argv[4],
(argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]);
@@ -3680,7 +3652,7 @@ irc_protocol_cmd_351 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s %s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
argv[3],
argv[4]);
}
@@ -3744,7 +3716,7 @@ irc_protocol_cmd_352 (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s] %s%s%s(%s%s@%s%s)%s "
"%s%s%s%s(%s)",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
@@ -3870,7 +3842,7 @@ irc_protocol_cmd_353 (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: cannot create nick \"%s\" "
"for channel \"%s\""),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, pos_nick, ptr_channel->name);
}
}
@@ -3881,7 +3853,7 @@ irc_protocol_cmd_353 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
_("%sNicks %s%s%s: %s[%s%s%s]"),
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
pos_channel,
IRC_COLOR_CHAT,
@@ -4025,7 +3997,7 @@ irc_protocol_cmd_366 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s%s%s: %s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT,
@@ -4066,8 +4038,7 @@ irc_protocol_cmd_367 (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "irc_numeric"),
_("%s%s[%s%s%s] %s%s%s banned by "
"%s%s %s(%s%s%s)%s on %s"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
@@ -4090,8 +4061,7 @@ irc_protocol_cmd_367 (struct t_irc_server *server, const char *command,
irc_protocol_tags (command, "irc_numeric"),
_("%s%s[%s%s%s] %s%s%s banned by "
"%s%s %s(%s%s%s)"),
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
@@ -4137,8 +4107,7 @@ irc_protocol_cmd_368 (struct t_irc_server *server, const char *command,
weechat_printf_tags (ptr_buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s[%s%s%s]%s%s%s",
- (ptr_buffer == server->buffer) ?
- irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"),
+ weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
@@ -4187,7 +4156,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command,
_("%s%s: all declared nicknames are "
"already in use or invalid, closing "
"connection with server"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME);
irc_server_disconnect (server, 1);
return WEECHAT_RC_OK;
@@ -4196,7 +4165,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command,
weechat_printf (server->buffer,
_("%s%s: nickname \"%s\" is invalid, "
"trying nickname #%d (\"%s\")"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME, server->nick, nick_to_use + 1,
server->nicks_array[nick_to_use]);
@@ -4243,16 +4212,15 @@ irc_protocol_cmd_433 (struct t_irc_server *server, const char *command,
_("%s%s: all declared nicknames are "
"already in use, closing "
"connection with server"),
- irc_buffer_get_server_prefix (server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME);
irc_server_disconnect (server, 1);
return WEECHAT_RC_OK;
}
weechat_printf (server->buffer,
- _("%s%s: nickname \"%s\" is already in use, "
+ _("%s: nickname \"%s\" is already in use, "
"trying nickname #%d (\"%s\")"),
- irc_buffer_get_server_prefix (server, NULL),
IRC_PLUGIN_NAME, server->nick,
nick_to_use + 1, server->nicks_array[nick_to_use]);
@@ -4287,7 +4255,7 @@ irc_protocol_cmd_438 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s (%s => %s)",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
(argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4],
argv[2],
argv[3]);
@@ -4297,7 +4265,7 @@ irc_protocol_cmd_438 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s %s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
argv[2],
argv[3]);
}
@@ -4324,7 +4292,7 @@ irc_protocol_cmd_901 (struct t_irc_server *server, const char *command,
weechat_printf_tags (server->buffer,
irc_protocol_tags (command, "irc_numeric"),
"%s%s",
- irc_buffer_get_server_prefix (server, "network"),
+ weechat_prefix ("network"),
(argv_eol[6][0] == ':') ? argv_eol[6] + 1 : argv_eol[6]);
}
else
@@ -4522,12 +4490,11 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *entire_line,
{
weechat_printf (server->buffer,
_("%s%s: command \"%s\" not found:"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, command);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ command);
weechat_printf (server->buffer,
"%s%s",
- irc_buffer_get_server_prefix (server, "error"),
- entire_line);
+ weechat_prefix ("error"), entire_line);
return;
}
}
@@ -4561,12 +4528,11 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *entire_line,
weechat_printf (server->buffer,
_("%s%s: failed to parse command \"%s\" (please "
"report to developers):"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, command);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ command);
weechat_printf (server->buffer,
"%s%s",
- irc_buffer_get_server_prefix (server, "error"),
- entire_line);
+ weechat_prefix ("error"), entire_line);
}
/* send signal with received command */
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index db1fe18b4..0a36867e5 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -41,8 +41,8 @@
_("%s%s: too few arguments received from IRC " \
"server for command \"%s\" (received: %d " \
"arguments, expected: at least %d)"), \
- irc_buffer_get_server_prefix (server, "error"), \
- IRC_PLUGIN_NAME, command, argc, __min_args); \
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, \
+ command, argc, __min_args); \
return WEECHAT_RC_ERROR; \
}
@@ -52,8 +52,8 @@
weechat_printf (server->buffer, \
_("%s%s: \"%s\" command received without " \
"host"), \
- irc_buffer_get_server_prefix (server, "error"), \
- IRC_PLUGIN_NAME, command); \
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, \
+ command); \
return WEECHAT_RC_ERROR; \
}
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index dc18745dc..774dc8cfc 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -53,9 +53,6 @@
struct t_irc_server *irc_servers = NULL;
struct t_irc_server *last_irc_server = NULL;
-/* current server when there is one buffer for all servers */
-struct t_irc_server *irc_current_server = NULL;
-
struct t_irc_message *irc_recv_msgq = NULL;
struct t_irc_message *irc_msgq_last_msg = NULL;
@@ -220,44 +217,6 @@ irc_server_set_nicks (struct t_irc_server *server, const char *nicks)
}
/*
- * irc_server_buffer_set_highlight_words: set highlight words for buffer with
- * all servers
- */
-
-void
-irc_server_buffer_set_highlight_words (struct t_gui_buffer *buffer)
-{
- struct t_irc_server *ptr_server;
- int length;
- char *words;
-
- length = 0;
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->is_connected && ptr_server->nick)
- length += strlen (ptr_server->nick) + 1;
- }
- words = malloc (length + 1);
- if (words)
- {
- words[0] = '\0';
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->is_connected && ptr_server->nick)
- {
- if (words[0])
- strcat (words, ",");
- strcat (words, ptr_server->nick);
- }
- }
- weechat_buffer_set (buffer, "highlight_words", words);
- free (words);
- }
-}
-
-/*
* irc_server_set_nick: set nickname for a server
*/
@@ -270,10 +229,7 @@ irc_server_set_nick (struct t_irc_server *server, const char *nick)
free (server->nick);
server->nick = (nick) ? strdup (nick) : NULL;
- if (weechat_config_boolean (irc_config_look_one_server_buffer))
- irc_server_buffer_set_highlight_words (server->buffer);
- else
- weechat_buffer_set (server->buffer, "highlight_words", nick);
+ weechat_buffer_set (server->buffer, "highlight_words", nick);
/* set local variable "nick" for server and all channels/pv */
weechat_buffer_set (server->buffer, "localvar_set_nick", nick);
@@ -635,48 +591,6 @@ irc_server_outqueue_free_all (struct t_irc_server *server)
}
/*
- * irc_server_switch_next: swicth to next server
- */
-
-void
-irc_server_switch_next ()
-{
- struct t_irc_server *ptr_server;
-
- if (irc_current_server)
- {
- ptr_server = irc_current_server->next_server;
- if (!ptr_server)
- ptr_server = irc_servers;
- while (ptr_server != irc_current_server)
- {
- if (ptr_server->buffer)
- {
- irc_current_server = ptr_server;
- break;
- }
- ptr_server = ptr_server->next_server;
- if (!ptr_server)
- ptr_server = irc_servers;
- }
- }
- else
- {
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->buffer)
- {
- irc_current_server = ptr_server;
- break;
- }
- }
- }
- if (irc_current_server)
- irc_server_set_current_server (irc_current_server);
-}
-
-/*
* irc_server_free_data: free server data
*/
@@ -734,13 +648,6 @@ irc_server_free (struct t_irc_server *server)
if (!server)
return;
- if (irc_current_server == server)
- {
- irc_server_switch_next ();
- if (irc_current_server == server)
- irc_current_server = NULL;
- }
-
/* close all channels/privates */
irc_channel_free_all (server);
@@ -958,8 +865,7 @@ irc_server_send (struct t_irc_server *server, const char *buffer, int size_buf)
_("%s%s: error sending data to IRC server: empty "
"buffer (please report problem to "
"developers)"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
return 0;
}
@@ -974,8 +880,8 @@ irc_server_send (struct t_irc_server *server, const char *buffer, int size_buf)
{
weechat_printf (server->buffer,
_("%s%s: error sending data to IRC server (%s)"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, strerror (errno));
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ strerror (errno));
}
return rc;
@@ -1351,8 +1257,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, const char *msg)
{
weechat_printf (server->buffer,
_("%s%s: not enough memory for received message"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
return;
}
message->server = server;
@@ -1364,8 +1269,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, const char *msg)
{
weechat_printf (server->buffer,
_("%s%s: not enough memory for received message"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
}
else
{
@@ -1412,8 +1316,7 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, const char *strin
{
weechat_printf (server->buffer,
_("%s%s: not enough memory for received message"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
}
else
strcat (server->unterminated_message, string);
@@ -1425,8 +1328,7 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, const char *strin
{
weechat_printf (server->buffer,
_("%s%s: not enough memory for received message"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
}
}
}
@@ -1646,8 +1548,7 @@ irc_server_recv_cb (void *arg_server, int fd)
weechat_printf (server->buffer,
_("%s%s: cannot read data from socket, "
"disconnecting from server..."),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
irc_server_disconnect (server, 1);
}
@@ -1717,11 +1618,8 @@ irc_server_timer_cb (void *data, int remaining_calls)
if (diff / 1000 > weechat_config_integer (irc_config_network_lag_disconnect) * 60)
{
weechat_printf (ptr_server->buffer,
- _("%s%s: lag is high, "
- "disconnecting from "
- "server..."),
- irc_buffer_get_server_prefix (ptr_server,
- NULL),
+ _("%s: lag is high, disconnecting "
+ "from server..."),
IRC_PLUGIN_NAME);
irc_server_disconnect (ptr_server, 1);
}
@@ -1825,8 +1723,7 @@ irc_server_reconnect_schedule (struct t_irc_server *server)
server->reconnect_start = time (NULL);
delay = IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AUTORECONNECT_DELAY);
weechat_printf (server->buffer,
- _("%s%s: reconnecting to server in %d %s"),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: reconnecting to server in %d %s"),
IRC_PLUGIN_NAME,
delay,
NG_("second", "seconds", delay));
@@ -1882,8 +1779,7 @@ irc_server_switch_address (struct t_irc_server *server)
{
server->index_current_address++;
weechat_printf (server->buffer,
- _("%s%s: switching address to %s/%d"),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: switching address to %s/%d"),
IRC_PLUGIN_NAME,
server->addresses_array[server->index_current_address],
server->ports_array[server->index_current_address]);
@@ -1918,8 +1814,7 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
free (server->current_ip);
server->current_ip = (ip_address) ? strdup (ip_address) : NULL;
weechat_printf (server->buffer,
- _("%s%s: connected to %s (%s)"),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: connected to %s (%s)"),
IRC_PLUGIN_NAME,
server->addresses_array[server->index_current_address],
(server->current_ip) ? server->current_ip : "?");
@@ -1934,15 +1829,13 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
(proxy && proxy[0]) ?
_("%s%s: proxy address \"%s\" not found") :
_("%s%s: address \"%s\" not found"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
server->addresses_array[server->index_current_address]);
if (error && error[0])
{
weechat_printf (server->buffer,
_("%s%s: error: %s"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
irc_server_close_connection (server);
@@ -1953,14 +1846,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
(proxy && proxy[0]) ?
_("%s%s: proxy IP address not found") :
_("%s%s: IP address not found"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
if (error && error[0])
{
weechat_printf (server->buffer,
_("%s%s: error: %s"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
irc_server_close_connection (server);
@@ -1971,14 +1862,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
(proxy && proxy[0]) ?
_("%s%s: proxy connection refused") :
_("%s%s: connection refused"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
if (error && error[0])
{
weechat_printf (server->buffer,
_("%s%s: error: %s"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
irc_server_close_connection (server);
@@ -1991,14 +1880,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
"(check username/password if used "
"and if server address/port is allowed by "
"proxy)"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
if (error && error[0])
{
weechat_printf (server->buffer,
_("%s%s: error: %s"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
irc_server_close_connection (server);
@@ -2007,14 +1894,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
case WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR:
weechat_printf (server->buffer,
_("%s%s: unable to set local hostname/IP"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
if (error && error[0])
{
weechat_printf (server->buffer,
_("%s%s: error: %s"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
irc_server_close_connection (server);
@@ -2023,14 +1908,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
case WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR:
weechat_printf (server->buffer,
_("%s%s: TLS init error"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
if (error && error[0])
{
weechat_printf (server->buffer,
_("%s%s: error: %s"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
irc_server_close_connection (server);
@@ -2039,14 +1922,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
case WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR:
weechat_printf (server->buffer,
_("%s%s: TLS handshake failed"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
if (error && error[0])
{
weechat_printf (server->buffer,
_("%s%s: error: %s"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
irc_server_close_connection (server);
@@ -2055,14 +1936,12 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
case WEECHAT_HOOK_CONNECT_MEMORY_ERROR:
weechat_printf (server->buffer,
_("%s%s: not enough memory"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
if (error && error[0])
{
weechat_printf (server->buffer,
_("%s%s: error: %s"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME,
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
irc_server_close_connection (server);
@@ -2112,36 +1991,36 @@ irc_server_set_buffer_title (struct t_irc_server *server)
*/
struct t_gui_buffer *
-irc_server_create_buffer (struct t_irc_server *server, int all_servers)
+irc_server_create_buffer (struct t_irc_server *server)
{
char buffer_name[256], charset_modifier[256];
+ struct t_gui_buffer *ptr_buffer_for_merge;
- if (all_servers)
- {
- snprintf (buffer_name, sizeof (buffer_name),
- IRC_BUFFER_ALL_SERVERS_NAME);
- }
- else
+ ptr_buffer_for_merge = NULL;
+ switch (weechat_config_integer (irc_config_look_server_buffer))
{
- snprintf (buffer_name, sizeof (buffer_name),
- "server.%s", server->name);
+ case IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITH_CORE:
+ /* merge with WeeChat core buffer */
+ ptr_buffer_for_merge = weechat_buffer_search_main ();
+ break;
+ case IRC_CONFIG_LOOK_SERVER_BUFFER_MERGE_WITHOUT_CORE:
+ /* find buffer used to merge all IRC server buffers */
+ ptr_buffer_for_merge = irc_buffer_search_first_for_all_servers ();
+ break;
}
+
+ snprintf (buffer_name, sizeof (buffer_name),
+ "server.%s", server->name);
server->buffer = weechat_buffer_new (buffer_name,
&irc_input_data_cb, NULL,
&irc_buffer_close_cb, NULL);
if (!server->buffer)
return NULL;
- weechat_buffer_set (server->buffer, "short_name",
- (weechat_config_boolean (irc_config_look_one_server_buffer)) ?
- IRC_BUFFER_ALL_SERVERS_NAME : server->name);
+ weechat_buffer_set (server->buffer, "short_name", server->name);
weechat_buffer_set (server->buffer, "localvar_set_type", "server");
- weechat_buffer_set (server->buffer, "localvar_set_server",
- (weechat_config_boolean (irc_config_look_one_server_buffer)) ?
- IRC_BUFFER_ALL_SERVERS_NAME : server->name);
- weechat_buffer_set (server->buffer, "localvar_set_channel",
- (weechat_config_boolean (irc_config_look_one_server_buffer)) ?
- IRC_BUFFER_ALL_SERVERS_NAME : server->name);
+ weechat_buffer_set (server->buffer, "localvar_set_server", server->name);
+ weechat_buffer_set (server->buffer, "localvar_set_channel", server->name);
snprintf (charset_modifier, sizeof (charset_modifier),
"irc.%s", server->name);
weechat_buffer_set (server->buffer, "localvar_set_charset_modifier",
@@ -2165,29 +2044,11 @@ irc_server_create_buffer (struct t_irc_server *server, int all_servers)
irc_server_set_buffer_title (server);
- return server->buffer;
-}
-
-/*
- * irc_server_set_current_server: set new current server (when all servers are
- * in one buffer)
- */
-
-void
-irc_server_set_current_server (struct t_irc_server *server)
-{
- char charset_modifier[256];
-
- irc_current_server = server;
+ /* merge buffer if needed */
+ if (ptr_buffer_for_merge)
+ weechat_buffer_merge (server->buffer, ptr_buffer_for_merge);
- irc_server_set_buffer_title (irc_current_server);
- snprintf (charset_modifier, sizeof (charset_modifier),
- "irc.%s", irc_current_server->name);
- weechat_buffer_set (irc_current_server->buffer,
- "localvar_set_charset_modifier",
- charset_modifier);
- weechat_bar_item_update ("buffer_name");
- weechat_bar_item_update ("input_prompt");
+ return server->buffer;
}
/*
@@ -2200,40 +2061,16 @@ int
irc_server_connect (struct t_irc_server *server)
{
int set, length;
- char *option_name, charset_modifier[256];
+ char *option_name;
struct t_config_option *proxy_type, *proxy_ipv6, *proxy_address, *proxy_port;
const char *proxy, *str_proxy_type, *str_proxy_address;
if (!server->buffer)
{
- if (weechat_config_boolean (irc_config_look_one_server_buffer)
- && irc_buffer_servers)
- {
- server->buffer = irc_buffer_servers;
- irc_server_set_buffer_title (server);
- }
- else
- {
- if (!irc_server_create_buffer (server,
- weechat_config_boolean (irc_config_look_one_server_buffer)))
- return 0;
- }
-
- if (weechat_config_boolean (irc_config_look_one_server_buffer))
- {
- irc_current_server = server;
- if (!irc_buffer_servers)
- irc_buffer_servers = server->buffer;
-
- snprintf (charset_modifier, sizeof (charset_modifier),
- "irc.%s", irc_current_server->name);
- weechat_buffer_set (irc_buffer_servers,
- "localvar_set_charset_modifier",
- charset_modifier);
- }
+ if (!irc_server_create_buffer (server))
+ return 0;
weechat_buffer_set (server->buffer, "display", "auto");
-
weechat_bar_item_update ("buffer_name");
}
@@ -2242,8 +2079,8 @@ irc_server_connect (struct t_irc_server *server)
weechat_printf (server->buffer,
_("%s%s: addresses not defined for server \"%s\", "
"cannot connect"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, server->name);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ server->name);
return 0;
}
@@ -2263,8 +2100,7 @@ irc_server_connect (struct t_irc_server *server)
{
weechat_printf (server->buffer,
_("%s%s: not enough memory"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
return 0;
}
snprintf (option_name, length, "weechat.proxy.%s.type", proxy);
@@ -2281,8 +2117,8 @@ irc_server_connect (struct t_irc_server *server)
weechat_printf (server->buffer,
_("%s%s: proxy \"%s\" not found for server "
"\"%s\", cannot connect"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, proxy, server->name);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, proxy,
+ server->name);
return 0;
}
str_proxy_type = weechat_config_string (proxy_type);
@@ -2293,8 +2129,7 @@ irc_server_connect (struct t_irc_server *server)
weechat_printf (server->buffer,
_("%s%s: missing proxy settings, check options "
"for proxy \"%s\""),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, proxy);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME, proxy);
return 0;
}
}
@@ -2304,8 +2139,8 @@ irc_server_connect (struct t_irc_server *server)
weechat_printf (server->buffer,
_("%s%s: nicks not defined for server \"%s\", "
"cannot connect"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME, server->name);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ server->name);
return 0;
}
@@ -2315,17 +2150,15 @@ irc_server_connect (struct t_irc_server *server)
weechat_printf (server->buffer,
_("%s%s: cannot connect with SSL because WeeChat "
"was not built with GnuTLS support"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
return 0;
}
#endif
if (proxy_type)
{
weechat_printf (server->buffer,
- _("%s%s: connecting to server %s/%d%s%s via %s "
+ _("%s: connecting to server %s/%d%s%s via %s "
"proxy %s/%d%s..."),
- irc_buffer_get_server_prefix (server, NULL),
IRC_PLUGIN_NAME,
server->addresses_array[server->index_current_address],
server->ports_array[server->index_current_address],
@@ -2353,8 +2186,7 @@ irc_server_connect (struct t_irc_server *server)
else
{
weechat_printf (server->buffer,
- _("%s%s: connecting to server %s/%d%s%s..."),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: connecting to server %s/%d%s%s..."),
IRC_PLUGIN_NAME,
server->addresses_array[server->index_current_address],
server->ports_array[server->index_current_address],
@@ -2393,8 +2225,7 @@ irc_server_connect (struct t_irc_server *server)
{
weechat_printf (server->buffer,
_("%s%s: cannot create socket"),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
return 0;
}
@@ -2406,8 +2237,7 @@ irc_server_connect (struct t_irc_server *server)
weechat_printf (server->buffer,
_("%s%s: cannot set socket option "
"\"SO_REUSEADDR\""),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
}
/* set SO_KEEPALIVE option for socket */
@@ -2418,8 +2248,7 @@ irc_server_connect (struct t_irc_server *server)
weechat_printf (server->buffer,
_("%s%s: cannot set socket option "
"\"SO_KEEPALIVE\""),
- irc_buffer_get_server_prefix (server, "error"),
- IRC_PLUGIN_NAME);
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
}
/* init SSL if asked */
@@ -2458,8 +2287,7 @@ void
irc_server_reconnect (struct t_irc_server *server)
{
weechat_printf (server->buffer,
- _("%s%s: reconnecting to server..."),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: reconnecting to server..."),
IRC_PLUGIN_NAME);
server->reconnect_start = 0;
server->index_current_address = 0;
@@ -2519,8 +2347,7 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect)
if (server->buffer)
{
weechat_printf (server->buffer,
- _("%s%s: disconnected from server"),
- irc_buffer_get_server_prefix (server, NULL),
+ _("%s: disconnected from server"),
IRC_PLUGIN_NAME);
}
@@ -3023,11 +2850,6 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
(server->buffer) ?
weechat_buffer_get_string (server->buffer, "short_name") : ""))
return 0;
- if (!weechat_infolist_new_var_integer (ptr_item, "selected",
- (weechat_config_boolean (irc_config_look_one_server_buffer)
- && (irc_current_server != server)) ?
- 0 : 1))
- return 0;
if (!weechat_infolist_new_var_string (ptr_item, "addresses",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_ADDRESSES)))
return 0;
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 49344adc0..23ec2f30c 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -153,7 +153,6 @@ struct t_irc_message
};
extern struct t_irc_server *irc_servers;
-extern struct t_irc_server *irc_current_server;
#ifdef HAVE_GNUTLS
extern const int gnutls_cert_type_prio[];
extern const int gnutls_prot_prio[];
@@ -168,11 +167,9 @@ extern char *irc_server_get_name_without_port (const char *name);
extern void irc_server_set_addresses (struct t_irc_server *server,
const char *addresses);
extern void irc_server_set_nicks (struct t_irc_server *server, const char *nicks);
-extern void irc_server_buffer_set_highlight_words (struct t_gui_buffer *buffer);
extern void irc_server_set_nick (struct t_irc_server *server, const char *nick);
extern struct t_irc_server *irc_server_alloc (const char *name);
extern int irc_server_alloc_with_url (const char *irc_url);
-extern void irc_server_switch_next ();
extern void irc_server_free_all ();
extern struct t_irc_server *irc_server_copy (struct t_irc_server *server,
const char *new_name);
@@ -184,9 +181,7 @@ extern void irc_server_sendf (struct t_irc_server *server, int queue_msg,
const char *format, ...);
extern struct t_irc_server *irc_server_search (const char *server_name);
extern void irc_server_set_buffer_title (struct t_irc_server *server);
-extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server,
- int all_servers);
-extern void irc_server_set_current_server (struct t_irc_server *server);
+extern struct t_gui_buffer *irc_server_create_buffer (struct t_irc_server *server);
extern int irc_server_connect (struct t_irc_server *server);
extern void irc_server_auto_connect ();
extern void irc_server_autojoin_channels ();
diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c
index 01bbad4a9..cacc9ed19 100644
--- a/src/plugins/irc/irc-upgrade.c
+++ b/src/plugins/irc/irc-upgrade.c
@@ -226,16 +226,7 @@ irc_upgrade_read_cb (void *data,
ptr_buffer = weechat_buffer_search (IRC_PLUGIN_NAME,
buffer_name);
if (ptr_buffer)
- {
irc_upgrade_current_server->buffer = ptr_buffer;
- if (weechat_config_boolean (irc_config_look_one_server_buffer)
- && !irc_buffer_servers)
- {
- irc_buffer_servers = ptr_buffer;
- }
- if (weechat_infolist_integer (infolist, "selected"))
- irc_current_server = irc_upgrade_current_server;
- }
}
irc_upgrade_current_server->index_current_address =
weechat_infolist_integer (infolist, "index_current_address");
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index f36956b3d..d349fe7b7 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -113,7 +113,7 @@ irc_signal_upgrade_cb (void *data, const char *signal, const char *type_data,
weechat_printf (ptr_server->buffer,
_("%s%s: disconnecting from server because upgrade "
"can't work for servers connected via SSL"),
- irc_buffer_get_server_prefix (ptr_server, "error"),
+ weechat_prefix ("error"),
IRC_PLUGIN_NAME);
irc_server_disconnect (ptr_server, 0);
/* schedule reconnection: WeeChat will reconnect to this server
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index c7c867b46..754f75ae2 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -47,6 +47,7 @@
#include "../gui/gui-filter.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-keyboard.h"
+#include "../gui/gui-line.h"
#include "../gui/gui-nicklist.h"
#include "../gui/gui-window.h"
#include "plugin.h"
@@ -531,11 +532,12 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
- for (ptr_line = ((struct t_gui_buffer *)pointer)->lines; ptr_line;
- ptr_line = ptr_line->next_line)
+ for (ptr_line = ((struct t_gui_buffer *)pointer)->own_lines->first_line;
+ ptr_line; ptr_line = ptr_line->next_line)
{
- if (!gui_buffer_line_add_to_infolist (ptr_infolist,
- pointer, ptr_line))
+ if (!gui_line_add_to_infolist (ptr_infolist,
+ ((struct t_gui_buffer *)pointer)->own_lines,
+ ptr_line))
{
infolist_free (ptr_infolist);
return NULL;
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 3f5f443e0..913ebcbf9 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -516,8 +516,11 @@ plugin_load (const char *filename)
new_plugin->buffer_new = &gui_buffer_new;
new_plugin->buffer_search = &gui_buffer_search_by_name;
+ new_plugin->buffer_search_main = &gui_buffer_search_main;
new_plugin->buffer_clear = &gui_buffer_clear;
new_plugin->buffer_close = &gui_buffer_close;
+ new_plugin->buffer_merge = &gui_buffer_merge;
+ new_plugin->buffer_unmerge = &gui_buffer_unmerge;
new_plugin->buffer_get_integer = &gui_buffer_get_integer;
new_plugin->buffer_get_string = &gui_buffer_get_string;
new_plugin->buffer_get_pointer = &gui_buffer_get_pointer;
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index 5f3852128..2143fbfdc 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -4646,6 +4646,29 @@ weechat_lua_api_buffer_search (lua_State *L)
}
/*
+ * weechat_lua_api_buffer_search_main: search main buffer (WeeChat core buffer)
+ */
+
+static int
+weechat_lua_api_buffer_search_main (lua_State *L)
+{
+ char *result;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_search_main");
+ LUA_RETURN_EMPTY;
+ }
+
+ result = script_ptr2str (weechat_buffer_search_main ());
+
+ LUA_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_lua_api_current_buffer: get current buffer
*/
@@ -4743,6 +4766,84 @@ weechat_lua_api_buffer_close (lua_State *L)
}
/*
+ * weechat_lua_api_buffer_merge: merge a buffer to another buffer
+ */
+
+static int
+weechat_lua_api_buffer_merge (lua_State *L)
+{
+ const char *buffer, *target_buffer;
+ int n;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_merge");
+ LUA_RETURN_ERROR;
+ }
+
+ buffer = NULL;
+ target_buffer = NULL;
+
+ n = lua_gettop (lua_current_interpreter);
+
+ if (n < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_merge");
+ LUA_RETURN_ERROR;
+ }
+
+ buffer = lua_tostring (lua_current_interpreter, -2);
+ target_buffer = lua_tostring (lua_current_interpreter, -1);
+
+ weechat_buffer_merge (script_str2ptr (buffer),
+ script_str2ptr (target_buffer));
+
+ LUA_RETURN_OK;
+}
+
+/*
+ * weechat_lua_api_buffer_unmerge: unmerge a buffer from a group of merged
+ * buffers
+ */
+
+static int
+weechat_lua_api_buffer_unmerge (lua_State *L)
+{
+ const char *buffer;
+ int n, number;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ LUA_RETURN_ERROR;
+ }
+
+ buffer = NULL;
+ number = 0;
+
+ n = lua_gettop (lua_current_interpreter);
+
+ if (n < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ LUA_RETURN_ERROR;
+ }
+
+ buffer = lua_tostring (lua_current_interpreter, -2);
+ number = lua_tonumber (lua_current_interpreter, -1);
+
+ weechat_buffer_unmerge (script_str2ptr (buffer), number);
+
+ LUA_RETURN_OK;
+}
+
+/*
* weechat_lua_api_buffer_get_integer: get a buffer property as integer
*/
@@ -7114,9 +7215,12 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "unhook_all", &weechat_lua_api_unhook_all },
{ "buffer_new", &weechat_lua_api_buffer_new },
{ "buffer_search", &weechat_lua_api_buffer_search },
+ { "buffer_search_main", &weechat_lua_api_buffer_search_main },
{ "current_buffer", &weechat_lua_api_current_buffer },
{ "buffer_clear", &weechat_lua_api_buffer_clear },
{ "buffer_close", &weechat_lua_api_buffer_close },
+ { "buffer_merge", &weechat_lua_api_buffer_merge },
+ { "buffer_unmerge", &weechat_lua_api_buffer_unmerge },
{ "buffer_get_integer", &weechat_lua_api_buffer_get_integer },
{ "buffer_get_string", &weechat_lua_api_buffer_get_string },
{ "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer },
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index f3fe2fe37..baf1c428e 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -3965,6 +3965,30 @@ static XS (XS_weechat_api_buffer_search)
}
/*
+ * weechat::buffer_search_main: search main buffer (WeeChat core buffer)
+ */
+
+static XS (XS_weechat_api_buffer_search_main)
+{
+ char *result;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) items;
+ (void) cv;
+
+ if (!perl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_search_main");
+ PERL_RETURN_EMPTY;
+ }
+
+ result = script_ptr2str (weechat_buffer_search_main ());
+
+ PERL_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat::current_buffer: get current buffer
*/
@@ -4047,6 +4071,64 @@ static XS (XS_weechat_api_buffer_close)
}
/*
+ * weechat::buffer_merge: merge a buffer to another buffer
+ */
+
+static XS (XS_weechat_api_buffer_merge)
+{
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_merge");
+ PERL_RETURN_ERROR;
+ }
+
+ if (items < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_merge");
+ PERL_RETURN_ERROR;
+ }
+
+ weechat_buffer_merge (script_str2ptr (SvPV (ST (0), PL_na)), /* buffer */
+ script_str2ptr (SvPV (ST (1), PL_na))); /* target_buffer */
+
+ PERL_RETURN_OK;
+}
+
+/*
+ * weechat::buffer_unmerge: unmerge a buffer from group of merged buffers
+ */
+
+static XS (XS_weechat_api_buffer_unmerge)
+{
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ PERL_RETURN_ERROR;
+ }
+
+ if (items < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ PERL_RETURN_ERROR;
+ }
+
+ weechat_buffer_unmerge (script_str2ptr (SvPV (ST (0), PL_na)), /* buffer */
+ SvIV (ST (1))); /* number */
+
+ PERL_RETURN_OK;
+}
+
+/*
* weechat::buffer_get_integer: get a buffer property as integer
*/
@@ -5709,9 +5791,12 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::unhook_all", XS_weechat_api_unhook_all, "weechat");
newXS ("weechat::buffer_new", XS_weechat_api_buffer_new, "weechat");
newXS ("weechat::buffer_search", XS_weechat_api_buffer_search, "weechat");
+ newXS ("weechat::buffer_search_main", XS_weechat_api_buffer_search_main, "weechat");
newXS ("weechat::current_buffer", XS_weechat_api_current_buffer, "weechat");
newXS ("weechat::buffer_clear", XS_weechat_api_buffer_clear, "weechat");
newXS ("weechat::buffer_close", XS_weechat_api_buffer_close, "weechat");
+ newXS ("weechat::buffer_merge", XS_weechat_api_buffer_merge, "weechat");
+ newXS ("weechat::buffer_unmerge", XS_weechat_api_buffer_unmerge, "weechat");
newXS ("weechat::buffer_get_integer", XS_weechat_api_buffer_get_integer, "weechat");
newXS ("weechat::buffer_get_string", XS_weechat_api_buffer_get_string, "weechat");
newXS ("weechat::buffer_get_pointer", XS_weechat_api_buffer_get_pointer, "weechat");
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index 0c58130b1..b5919c97f 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -4162,6 +4162,31 @@ weechat_python_api_buffer_search (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_buffer_search_main: search main buffer (WeeChat core buffer)
+ */
+
+static PyObject *
+weechat_python_api_buffer_search_main (PyObject *self, PyObject *args)
+{
+ char *result;
+ PyObject *object;
+
+ /* make C compiler happy */
+ (void) self;
+ (void) args;
+
+ if (!python_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_search_main");
+ PYTHON_RETURN_EMPTY;
+ }
+
+ result = script_ptr2str (weechat_buffer_search_main ());
+
+ PYTHON_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_python_api_current_buffer: get current buffer
*/
@@ -4251,6 +4276,73 @@ weechat_python_api_buffer_close (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_buffer_merge: merge a buffer to another buffer
+ */
+
+static PyObject *
+weechat_python_api_buffer_merge (PyObject *self, PyObject *args)
+{
+ char *buffer, *target_buffer;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_merge");
+ PYTHON_RETURN_ERROR;
+ }
+
+ buffer = NULL;
+ target_buffer = NULL;
+
+ if (!PyArg_ParseTuple (args, "ss", &buffer, &target_buffer))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_merge");
+ PYTHON_RETURN_ERROR;
+ }
+
+ weechat_buffer_merge (script_str2ptr (buffer),
+ script_str2ptr (target_buffer));
+
+ PYTHON_RETURN_OK;
+}
+
+/*
+ * weechat_python_api_buffer_unmerge: unmerge a buffer from group of merged
+ * buffers
+ */
+
+static PyObject *
+weechat_python_api_buffer_unmerge (PyObject *self, PyObject *args)
+{
+ char *buffer;
+ int number;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ PYTHON_RETURN_ERROR;
+ }
+
+ buffer = NULL;
+ number = 0;
+
+ if (!PyArg_ParseTuple (args, "si", &buffer, &number))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ PYTHON_RETURN_ERROR;
+ }
+
+ weechat_buffer_unmerge (script_str2ptr (buffer), number);
+
+ PYTHON_RETURN_OK;
+}
+
+/*
* weechat_python_api_buffer_get_integer get a buffer property as integer
*/
@@ -5987,9 +6079,12 @@ PyMethodDef weechat_python_funcs[] =
{ "unhook_all", &weechat_python_api_unhook_all, METH_VARARGS, "" },
{ "buffer_new", &weechat_python_api_buffer_new, METH_VARARGS, "" },
{ "buffer_search", &weechat_python_api_buffer_search, METH_VARARGS, "" },
+ { "buffer_search_main", &weechat_python_api_buffer_search_main, METH_VARARGS, "" },
{ "current_buffer", &weechat_python_api_current_buffer, METH_VARARGS, "" },
{ "buffer_clear", &weechat_python_api_buffer_clear, METH_VARARGS, "" },
{ "buffer_close", &weechat_python_api_buffer_close, METH_VARARGS, "" },
+ { "buffer_merge", &weechat_python_api_buffer_merge, METH_VARARGS, "" },
+ { "buffer_unmerge", &weechat_python_api_buffer_unmerge, METH_VARARGS, "" },
{ "buffer_get_integer", &weechat_python_api_buffer_get_integer, METH_VARARGS, "" },
{ "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" },
{ "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" },
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c
index 266f45497..e7f49d004 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -4800,6 +4800,30 @@ weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name)
}
/*
+ * weechat_ruby_api_buffer_search_main: search main buffer (WeeChat core buffer)
+ */
+
+static VALUE
+weechat_ruby_api_buffer_search_main (VALUE class)
+{
+ char *result;
+ VALUE return_value;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_search_main");
+ RUBY_RETURN_EMPTY;
+ }
+
+ result = script_ptr2str (weechat_buffer_search_main ());
+
+ RUBY_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_ruby_api_current_buffer: get current buffer
*/
@@ -4896,6 +4920,85 @@ weechat_ruby_api_buffer_close (VALUE class, VALUE buffer)
}
/*
+ * weechat_ruby_api_buffer_merge: merge a buffer to another buffer
+ */
+
+static VALUE
+weechat_ruby_api_buffer_merge (VALUE class, VALUE buffer, VALUE target_buffer)
+{
+ char *c_buffer, *c_target_buffer;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_merge");
+ RUBY_RETURN_ERROR;
+ }
+
+ c_buffer = NULL;
+ c_target_buffer = NULL;
+
+ if (NIL_P (buffer) || NIL_P (target_buffer))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_merge");
+ RUBY_RETURN_ERROR;
+ }
+
+ Check_Type (buffer, T_STRING);
+ Check_Type (target_buffer, T_STRING);
+
+ c_buffer = STR2CSTR (buffer);
+ c_target_buffer = STR2CSTR (target_buffer);
+
+ weechat_buffer_merge (script_str2ptr (c_buffer),
+ script_str2ptr (c_target_buffer));
+
+ RUBY_RETURN_OK;
+}
+
+/*
+ * weechat_ruby_api_buffer_unmerge: unmerge a buffer from a group of merged
+ * buffers
+ */
+
+static VALUE
+weechat_ruby_api_buffer_unmerge (VALUE class, VALUE buffer, VALUE number)
+{
+ char *c_buffer;
+ int c_number;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ RUBY_RETURN_ERROR;
+ }
+
+ c_buffer = NULL;
+ c_number = 0;
+
+ if (NIL_P (buffer) || NIL_P (number))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ RUBY_RETURN_ERROR;
+ }
+
+ Check_Type (buffer, T_STRING);
+ Check_Type (number, T_FIXNUM);
+
+ c_buffer = STR2CSTR (buffer);
+ c_number = FIX2INT (number);
+
+ weechat_buffer_unmerge (script_str2ptr (c_buffer), number);
+
+ RUBY_RETURN_OK;
+}
+
+/*
* weechat_ruby_api_buffer_get_integer: get a buffer property as integer
*/
@@ -6902,9 +7005,12 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "unhook_all", &weechat_ruby_api_unhook_all, 0);
rb_define_module_function (ruby_mWeechat, "buffer_new", &weechat_ruby_api_buffer_new, 5);
rb_define_module_function (ruby_mWeechat, "buffer_search", &weechat_ruby_api_buffer_search, 2);
+ rb_define_module_function (ruby_mWeechat, "buffer_search_main", &weechat_ruby_api_buffer_search_main, 0);
rb_define_module_function (ruby_mWeechat, "current_buffer", &weechat_ruby_api_current_buffer, 0);
rb_define_module_function (ruby_mWeechat, "buffer_clear", &weechat_ruby_api_buffer_clear, 1);
rb_define_module_function (ruby_mWeechat, "buffer_close", &weechat_ruby_api_buffer_close, 1);
+ rb_define_module_function (ruby_mWeechat, "buffer_merge", &weechat_ruby_api_buffer_merge, 2);
+ rb_define_module_function (ruby_mWeechat, "buffer_unmerge", &weechat_ruby_api_buffer_unmerge, 2);
rb_define_module_function (ruby_mWeechat, "buffer_get_integer", &weechat_ruby_api_buffer_get_integer, 2);
rb_define_module_function (ruby_mWeechat, "buffer_get_string", &weechat_ruby_api_buffer_get_string, 2);
rb_define_module_function (ruby_mWeechat, "buffer_get_pointer", &weechat_ruby_api_buffer_get_pointer, 2);
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index afc4a388d..202710276 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -4440,6 +4440,33 @@ weechat_tcl_api_buffer_search (ClientData clientData, Tcl_Interp *interp,
}
/*
+ * weechat_tcl_api_buffer_search_main: search main buffer (WeeChat core buffer)
+ */
+
+static int
+weechat_tcl_api_buffer_search_main (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ char *result;
+
+ /* make C compiler happy */
+ (void) clientData;
+ (void) objc;
+ (void) objv;
+
+ if (!tcl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_search_main");
+ TCL_RETURN_EMPTY;
+ }
+
+ result = script_ptr2str (weechat_buffer_search_main ());
+
+ TCL_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_tcl_api_current_buffer: get current buffer
*/
@@ -4531,6 +4558,77 @@ weechat_tcl_api_buffer_close (ClientData clientData, Tcl_Interp *interp,
}
/*
+ * weechat_tcl_api_buffer_merge: merge a buffer to another buffer
+ */
+
+static int
+weechat_tcl_api_buffer_merge (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ int i;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_merge");
+ TCL_RETURN_ERROR;
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_merge");
+ TCL_RETURN_ERROR;
+ }
+
+ weechat_buffer_merge (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)), /* buffer */
+ script_str2ptr (Tcl_GetStringFromObj (objv[2], &i))); /* target_buffer */
+
+ TCL_RETURN_OK;
+}
+
+/*
+ * weechat_tcl_api_buffer_unmerge: unmerge a buffer from a group of merged
+ * buffers
+ */
+
+static int
+weechat_tcl_api_buffer_unmerge (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ int i, number;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ TCL_RETURN_ERROR;
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ TCL_RETURN_ERROR;
+ }
+
+ if (Tcl_GetIntFromObj (interp, objv[2], &number) != TCL_OK)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge");
+ TCL_RETURN_ERROR;
+ }
+
+ weechat_buffer_unmerge (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)),
+ number);
+
+ TCL_RETURN_OK;
+}
+
+/*
* weechat_tcl_api_buffer_get_integer: get a buffer property as integer
*/
@@ -6528,12 +6626,18 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_buffer_new, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_search",
weechat_tcl_api_buffer_search, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::buffer_search_main",
+ weechat_tcl_api_buffer_search_main, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::current_buffer",
weechat_tcl_api_current_buffer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_clear",
weechat_tcl_api_buffer_clear, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_close",
weechat_tcl_api_buffer_close, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::buffer_merge",
+ weechat_tcl_api_buffer_merge, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::buffer_unmerge",
+ weechat_tcl_api_buffer_unmerge, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_get_integer",
weechat_tcl_api_buffer_get_integer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::buffer_get_string",
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 628de70b8..d8bd0d8f3 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -33,7 +33,7 @@ struct t_infolist;
struct t_weelist;
/* API version (used to check that plugin has same API and can be loaded) */
-#define WEECHAT_PLUGIN_API_VERSION "20090510-01"
+#define WEECHAT_PLUGIN_API_VERSION "20090608-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -486,8 +486,12 @@ struct t_weechat_plugin
struct t_gui_buffer *buffer),
void *close_callback_data);
struct t_gui_buffer *(*buffer_search) (const char *plugin, const char *name);
+ struct t_gui_buffer *(*buffer_search_main) ();
void (*buffer_clear) (struct t_gui_buffer *buffer);
void (*buffer_close) (struct t_gui_buffer *buffer);
+ void (*buffer_merge) (struct t_gui_buffer *buffer,
+ struct t_gui_buffer *target_buffer);
+ void (*buffer_unmerge) (struct t_gui_buffer *buffer, int number);
int (*buffer_get_integer) (struct t_gui_buffer *buffer,
const char *property);
const char *(*buffer_get_string) (struct t_gui_buffer *buffer,
@@ -1023,12 +1027,18 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__close_callback, __close_callback_data)
#define weechat_buffer_search(__plugin, __name) \
weechat_plugin->buffer_search(__plugin, __name)
+#define weechat_buffer_search_main() \
+ weechat_plugin->buffer_search_main()
#define weechat_current_buffer() \
weechat_plugin->buffer_search(NULL, NULL)
#define weechat_buffer_clear(__buffer) \
weechat_plugin->buffer_clear(__buffer)
#define weechat_buffer_close(__buffer) \
weechat_plugin->buffer_close(__buffer)
+#define weechat_buffer_merge(__buffer, __target_buffer) \
+ weechat_plugin->buffer_merge(__buffer, __target_buffer)
+#define weechat_buffer_unmerge(__buffer, __number) \
+ weechat_plugin->buffer_unmerge(__buffer, __number)
#define weechat_buffer_get_integer(__buffer, __property) \
weechat_plugin->buffer_get_integer(__buffer, __property)
#define weechat_buffer_get_string(__buffer, __property) \