summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-07-03 16:02:03 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-07-03 16:02:03 +0200
commitb97a979f611c0ece7fd26f9c303394d2ee9d0b0e (patch)
tree26474a3c486c3bd2a69a5bc3ea2b9aaf962bd3bf /src
parent31f9a82f1628212a3b43678c23e9828eede46911 (diff)
downloadweechat-b97a979f611c0ece7fd26f9c303394d2ee9d0b0e.zip
Add "buffer_nicklist" bar item and scroll feature in bars with /bar scroll
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c170
-rw-r--r--src/core/wee-config.c15
-rw-r--r--src/core/wee-config.h2
-rw-r--r--src/gui/curses/gui-curses-bar.c381
-rw-r--r--src/gui/curses/gui-curses-chat.c8
-rw-r--r--src/gui/curses/gui-curses-color.c1
-rw-r--r--src/gui/curses/gui-curses-keyboard.c8
-rw-r--r--src/gui/curses/gui-curses-main.c10
-rw-r--r--src/gui/curses/gui-curses-nicklist.c28
-rw-r--r--src/gui/curses/gui-curses.h1
-rw-r--r--src/gui/gtk/gui-gtk-bar.c93
-rw-r--r--src/gui/gtk/gui-gtk.h1
-rw-r--r--src/gui/gui-bar-item.c133
-rw-r--r--src/gui/gui-bar-item.h3
-rw-r--r--src/gui/gui-bar.c99
-rw-r--r--src/gui/gui-bar.h12
-rw-r--r--src/gui/gui-color.c5
-rw-r--r--src/gui/gui-color.h1
-rw-r--r--src/gui/gui-nicklist.c61
-rw-r--r--src/gui/gui-nicklist.h6
-rw-r--r--src/plugins/irc/irc-nick.c13
-rw-r--r--src/plugins/irc/irc-protocol.c16
-rw-r--r--src/plugins/plugin-api.c9
23 files changed, 898 insertions, 178 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index cb75947bb..d24094291 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -140,9 +140,11 @@ command_bar (void *data, struct t_gui_buffer *buffer,
{
int type, position;
long number;
- char *error, *str_type, *pos_condition;
+ char *error, *str_type, *pos_condition, *pos_point, *category;
+ char *ptr_buffer_name;
struct t_gui_bar *ptr_bar;
struct t_gui_bar_item *ptr_item;
+ struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) data;
@@ -296,18 +298,27 @@ command_bar (void *data, struct t_gui_buffer *buffer,
"bar");
return WEECHAT_RC_ERROR;
}
- ptr_bar = gui_bar_search (argv[2]);
- if (!ptr_bar)
+ if (string_strcasecmp (argv[2], "-all") == 0)
{
- gui_chat_printf (NULL,
- _("%sError: unknown bar \"%s\""),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- argv[2]);
- return WEECHAT_RC_ERROR;
+ gui_bar_free_all ();
+ gui_chat_printf (NULL, _("All bars deleted"));
+ //gui_bar_create_default ();
}
- gui_bar_free (ptr_bar);
- gui_chat_printf (NULL, _("Bar deleted"));
-
+ else
+ {
+ ptr_bar = gui_bar_search (argv[2]);
+ if (!ptr_bar)
+ {
+ gui_chat_printf (NULL,
+ _("%sError: unknown bar \"%s\""),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ argv[2]);
+ return WEECHAT_RC_ERROR;
+ }
+ gui_bar_free (ptr_bar);
+ gui_chat_printf (NULL, _("Bar deleted"));
+ }
+
return WEECHAT_RC_OK;
}
@@ -344,7 +355,7 @@ command_bar (void *data, struct t_gui_buffer *buffer,
return WEECHAT_RC_OK;
}
-
+
/* hide a bar */
if (string_strcasecmp (argv[1], "hide") == 0)
{
@@ -411,6 +422,66 @@ command_bar (void *data, struct t_gui_buffer *buffer,
return WEECHAT_RC_OK;
}
+ /* scroll in a bar */
+ if (string_strcasecmp (argv[1], "scroll") == 0)
+ {
+ if (argc < 5)
+ {
+ gui_chat_printf (NULL,
+ _("%sError: missing arguments for \"%s\" "
+ "command"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ "bar");
+ return WEECHAT_RC_ERROR;
+ }
+ ptr_bar = gui_bar_search (argv[2]);
+ if (!ptr_bar)
+ {
+ gui_chat_printf (NULL,
+ _("%sError: unknown bar \"%s\""),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ argv[2]);
+ return WEECHAT_RC_ERROR;
+ }
+ if (strcmp (argv[3], "*") == 0)
+ ptr_buffer = buffer;
+ else
+ {
+ pos_point = strchr (argv[3], '.');
+ if (pos_point)
+ {
+ category = string_strndup (argv[3], pos_point - argv[3]);
+ ptr_buffer_name = pos_point + 1;
+ }
+ else
+ {
+ category = NULL;
+ ptr_buffer_name = argv[3];
+ }
+ ptr_buffer = gui_buffer_search_by_category_name (category,
+ ptr_buffer_name);
+ if (category)
+ free (category);
+ }
+ if (!ptr_buffer)
+ {
+ gui_chat_printf (NULL,
+ _("%sError: buffer not found for \"%s\" command"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], "bar");
+ return WEECHAT_RC_ERROR;
+ }
+ if (!gui_bar_scroll (ptr_bar, ptr_buffer, argv_eol[4]))
+ {
+ gui_chat_printf (NULL,
+ _("%sError: unable to scroll bar \"%s\""),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ argv[2]);
+ return WEECHAT_RC_ERROR;
+ }
+
+ return WEECHAT_RC_OK;
+ }
+
gui_chat_printf (NULL,
_("%sError: unknown option for \"%s\" "
"command"),
@@ -2684,37 +2755,56 @@ command_init ()
N_("manage bars"),
N_("[add barname type[,cond1,cond2,...] position size "
"separator item1,item2,...] | [default] | "
- "[del barname] | [set barname name|priority|condition|"
- "position|filling|size|separator|items value] | "
- "[hide|show barname] | [list] | [listitems]"),
- N_(" add: add a new bar\n"
- " barname: name of bar (must be unique)\n"
- " type: root: outside windows),\n"
- " window: inside windows, with optional "
+ "[del barname|-all] | [set barname name|priority|"
+ "condition|position|filling|size|separator|"
+ "items value] | [hide|show barname] | [scroll barname "
+ "category.name value] | [list] | [listitems]"),
+ N_(" add: add a new bar\n"
+ " barname: name of bar (must be unique)\n"
+ " type: root: outside windows),\n"
+ " window: inside windows, with optional "
"conditions (see below)\n"
- "cond1,...: condition(s) for displaying bar (only for "
+ " cond1,...: condition(s) for displaying bar (only for "
"type \"window\"):\n"
- " active: on active window\n"
- " inactive: on inactive windows\n"
- " nicklist: on windows with nicklist\n"
- " without condition, bar is always displayed\n"
- " position: bottom, top, left or right\n"
- " filling: horizontal or vertical\n"
- " size: size of bar (in chars)\n"
- "separator: 1 for using separator (line), 0 or nothing "
+ " active: on active window\n"
+ " inactive: on inactive windows\n"
+ " nicklist: on windows with nicklist\n"
+ " without condition, bar is always displayed\n"
+ " position: bottom, top, left or right\n"
+ " filling: horizontal or vertical\n"
+ " size: size of bar (in chars)\n"
+ " separator: 1 for using separator (line), 0 or nothing "
"means no separator\n"
- "item1,...: items for this bar\n"
- " default: create default bars\n"
- " del: delete a bar\n"
- " set: set a value for a bar property\n"
- " hide: hide a bar\n"
- " show: show an hidden bar\n"
- " list: list all bars\n"
- " listfull: list all bars (verbose)\n"
- "listitems: list all bar items"),
- "add|default|del|set|hide|show|list|listfull|listitems %r "
- "name|priority|conditions|position|filling|size|separator|"
- "items",
+ " item1,...: items for this bar\n"
+ " default: create default bars\n"
+ " del: delete a bar (or all bars with -all)\n"
+ " set: set a value for a bar property\n"
+ " hide: hide a bar\n"
+ " show: show an hidden bar\n"
+ " scroll: scroll bar up/down\n"
+ "category.name: category and name of buffer to scroll ('*' "
+ "means current buffer, you should use '*' for root bars)\n"
+ " value: value for scroll: 'x' or 'y', followed by "
+ "'+', '-', 'b' (beginning) or 'e' (end), value (for +/-), "
+ "and optional %% (to scroll by %% of width/height, "
+ "otherwise value is number of chars)\n"
+ " list: list all bars\n"
+ " listfull: list all bars (verbose)\n"
+ " listitems: list all bar items\n\n"
+ "Examples:\n"
+ " create a bar with time and completion:\n"
+ " /bar add mybar root bottom 1 0 [time],completion\n"
+ " hide a bar:\n"
+ " /bar hide mybar\n"
+ " scroll nicklist 10 lines down on current buffer:\n"
+ " /bar scroll nicklist * y+10\n"
+ " scroll nicklist one page up on #weechat buffer:\n"
+ " /bar scroll nicklist #weechat y-100%\n"
+ " scroll to end of nicklist on current buffer:\n"
+ " /bar scroll nicklist * ye"),
+ "add|default|del|set|hide|show|scroll|list|listfull|"
+ "listitems %r name|priority|conditions|position|filling|"
+ "size|separator|items",
&command_bar, NULL);
hook_command (NULL, "buffer",
N_("manage buffers"),
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 2ef268827..bb516027e 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -100,9 +100,9 @@ struct t_config_option *config_look_set_title;
/* config, colors section */
struct t_config_option *config_color_separator;
+struct t_config_option *config_color_bar_more;
struct t_config_option *config_color_title;
struct t_config_option *config_color_title_bg;
-struct t_config_option *config_color_title_more;
struct t_config_option *config_color_chat;
struct t_config_option *config_color_chat_bg;
struct t_config_option *config_color_chat_time;
@@ -945,6 +945,13 @@ config_weechat_init ()
N_("background color for window separators (when splited)"),
NULL, GUI_COLOR_SEPARATOR, 0, "blue",
NULL, NULL, &config_change_color, NULL, NULL, NULL);
+ /* bar colors */
+ config_color_bar_more = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "bar_more", "color",
+ N_("text color for '+' when scrolling bars"),
+ NULL, -1, 0, "lightmagenta",
+ NULL, NULL, &config_change_color, NULL, NULL, NULL);
/* title window */
config_color_title = config_file_new_option (
weechat_config_file, ptr_section,
@@ -958,12 +965,6 @@ config_weechat_init ()
N_("background color for title bar"),
NULL, -1, 0, "blue",
NULL, NULL, &config_change_color, NULL, NULL, NULL);
- config_color_title_more = config_file_new_option (
- weechat_config_file, ptr_section,
- "title_more", "color",
- N_("text color for '+' when scrolling title"),
- NULL, GUI_COLOR_TITLE_MORE, 0, "lightmagenta",
- NULL, NULL, &config_change_color, NULL, NULL, NULL);
/* chat window */
config_color_chat = config_file_new_option (
weechat_config_file, ptr_section,
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index 008e557e0..2377ad81a 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -85,9 +85,9 @@ extern struct t_config_option *config_look_scroll_amount;
extern struct t_config_option *config_look_set_title;
extern struct t_config_option *config_color_separator;
+extern struct t_config_option *config_color_bar_more;
extern struct t_config_option *config_color_title;
extern struct t_config_option *config_color_title_bg;
-extern struct t_config_option *config_color_title_more;
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;
diff --git a/src/gui/curses/gui-curses-bar.c b/src/gui/curses/gui-curses-bar.c
index 22e681d3b..8aacb980c 100644
--- a/src/gui/curses/gui-curses-bar.c
+++ b/src/gui/curses/gui-curses-bar.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <limits.h>
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
@@ -146,6 +147,80 @@ gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window,
}
/*
+ * gui_bar_get_min_width: return minimum width of a bar window displayed for
+ * a bar
+ * for example, if a bar is displayed in 3 windows,
+ * this function return min width of these 3 bar windows
+ */
+
+int
+gui_bar_get_min_width (struct t_gui_bar *bar)
+{
+ struct t_gui_window *ptr_win;
+ struct t_gui_bar_window *ptr_bar_win;
+ int min_width;
+
+ if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ return bar->bar_window->width;
+
+ min_width = INT_MAX;
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ for (ptr_bar_win = GUI_CURSES(ptr_win)->bar_windows;
+ ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
+ {
+ if (ptr_bar_win->bar == bar)
+ {
+ if (ptr_bar_win->width < min_width)
+ min_width = ptr_bar_win->width;
+ }
+ }
+ }
+
+ if (min_width == INT_MAX)
+ return 0;
+
+ return min_width;
+}
+
+/*
+ * gui_bar_get_min_height: return minimum height of a bar window displayed for
+ * a bar
+ * for example, if a bar is displayed in 3 windows,
+ * this function return min width of these 3 bar windows
+ */
+
+int
+gui_bar_get_min_height (struct t_gui_bar *bar)
+{
+ struct t_gui_window *ptr_win;
+ struct t_gui_bar_window *ptr_bar_win;
+ int min_height;
+
+ if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ return bar->bar_window->height;
+
+ min_height = INT_MAX;
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ for (ptr_bar_win = GUI_CURSES(ptr_win)->bar_windows;
+ ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
+ {
+ if (ptr_bar_win->bar == bar)
+ {
+ if (ptr_bar_win->height < min_height)
+ min_height = ptr_bar_win->height;
+ }
+ }
+ }
+
+ if (min_height == INT_MAX)
+ return 0;
+
+ return min_height;
+}
+
+/*
* gui_bar_check_size_add: check if "add_size" is ok for bar
* return 1 if new size is ok
* 0 if new size is too big
@@ -401,6 +476,8 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
new_bar_window->y = 0;
new_bar_window->width = 1;
new_bar_window->height = 1;
+ new_bar_window->scroll_x = 0;
+ new_bar_window->scroll_y = 0;
new_bar_window->cursor_x = -1;
new_bar_window->cursor_y = -1;
new_bar_window->current_size = (CONFIG_INTEGER(bar->size) == 0) ?
@@ -579,9 +656,12 @@ gui_bar_window_add_missing_bars (struct t_gui_window *window)
/*
* gui_bar_window_print_string: print a string text on a bar window
+ * return 1 if all was printed, 0 if some text
+ * was not displayed (wrapped due to bar window
+ * width)
*/
-void
+int
gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
int *x, int *y,
const char *string)
@@ -590,7 +670,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
char str_fg[3], str_bg[3], utf_char[16], *next_char, *output;
if (!string || !string[0])
- return;
+ return 1;
wmove (bar_window->win_bar, *y, *x);
@@ -710,9 +790,9 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
if (*x + size_on_screen > bar_window->width)
{
if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_VERTICAL)
- return;
+ return 0;
if (*y >= bar_window->height - 1)
- return;
+ return 0;
*x = 0;
(*y)++;
wmove (bar_window->win_bar, *y, *x);
@@ -728,6 +808,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
string = next_char;
}
}
+ return 1;
}
/*
@@ -743,6 +824,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
char space_with_reinit_color[32];
int length_reinit_color, content_length, length, length_on_screen;
int max_length, optimal_number_of_lines, chars_available;
+ int some_data_not_displayed;
if (!gui_init_ok)
return;
@@ -877,18 +959,60 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
CONFIG_COLOR(bar_window->bar->color_bg));
x = 0;
y = 0;
+ some_data_not_displayed = 0;
+ if ((bar_window->scroll_y > 0)
+ && (bar_window->scroll_y >= items_count))
+ {
+ bar_window->scroll_y = items_count - bar_window->height;
+ if (bar_window->scroll_y < 0)
+ bar_window->scroll_y = 0;
+ }
for (line = 0;
(line < items_count) && (y < bar_window->height);
line++)
{
- gui_bar_window_print_string (bar_window, &x, &y,
- items[line]);
- if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_VERTICAL)
+ if ((bar_window->scroll_y == 0)
+ || (line >= bar_window->scroll_y))
{
- x = 0;
- y++;
+ if (!gui_bar_window_print_string (bar_window, &x, &y,
+ items[line]))
+ {
+ some_data_not_displayed = 1;
+ }
+ if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_VERTICAL)
+ {
+ x = 0;
+ y++;
+ }
+ else
+ {
+ gui_bar_window_print_string (bar_window, &x, &y,
+ space_with_reinit_color);
+ }
}
}
+ if (bar_window->scroll_y > 0)
+ {
+ x = (bar_window->height > 1) ? bar_window->width - 2 : 0;
+ if (x < 0)
+ x = 0;
+ y = 0;
+ gui_window_set_custom_color_fg_bg (bar_window->win_bar,
+ CONFIG_COLOR(config_color_bar_more),
+ CONFIG_INTEGER(bar_window->bar->color_bg));
+ mvwprintw (bar_window->win_bar, y, x, "--");
+ }
+ if (some_data_not_displayed || (line < items_count))
+ {
+ x = bar_window->width - 2;
+ if (x < 0)
+ x = 0;
+ y = (bar_window->height > 1) ? bar_window->height - 1 : 0;
+ gui_window_set_custom_color_fg_bg (bar_window->win_bar,
+ CONFIG_COLOR(config_color_bar_more),
+ CONFIG_INTEGER(bar_window->bar->color_bg));
+ mvwprintw (bar_window->win_bar, y, x, "++");
+ }
}
if (items)
string_free_exploded (items);
@@ -936,23 +1060,60 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
item_value2 : item_value,
"\n", 0, 0,
&items_count);
+ some_data_not_displayed = 0;
+ if ((bar_window->scroll_y > 0)
+ && (bar_window->scroll_y >= items_count))
+ {
+ bar_window->scroll_y = items_count - bar_window->height;
+ if (bar_window->scroll_y < 0)
+ bar_window->scroll_y = 0;
+ }
for (line = 0;
(line < items_count) && (y < bar_window->height);
line++)
{
- gui_bar_window_print_string (bar_window, &x, &y,
- items[line]);
- if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_VERTICAL)
+ if ((bar_window->scroll_y == 0)
+ || (line >= bar_window->scroll_y))
{
- x = 0;
- y++;
- }
- else
- {
- gui_bar_window_print_string (bar_window, &x, &y,
- space_with_reinit_color);
+ if (!gui_bar_window_print_string (bar_window, &x, &y,
+ items[line]))
+ {
+ some_data_not_displayed = 1;
+ }
+ if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_VERTICAL)
+ {
+ x = 0;
+ y++;
+ }
+ else
+ {
+ gui_bar_window_print_string (bar_window, &x, &y,
+ space_with_reinit_color);
+ }
}
}
+ if (bar_window->scroll_y > 0)
+ {
+ x = (bar_window->height > 1) ? bar_window->width - 2 : 0;
+ if (x < 0)
+ x = 0;
+ y = 0;
+ gui_window_set_custom_color_fg_bg (bar_window->win_bar,
+ CONFIG_COLOR(config_color_bar_more),
+ CONFIG_INTEGER(bar_window->bar->color_bg));
+ mvwprintw (bar_window->win_bar, y, x, "--");
+ }
+ if (some_data_not_displayed || (line < items_count))
+ {
+ x = bar_window->width - 2;
+ if (x < 0)
+ x = 0;
+ y = (bar_window->height > 1) ? bar_window->height - 1 : 0;
+ gui_window_set_custom_color_fg_bg (bar_window->win_bar,
+ CONFIG_COLOR(config_color_bar_more),
+ CONFIG_INTEGER(bar_window->bar->color_bg));
+ mvwprintw (bar_window->win_bar, y, x, "++");
+ }
if (item_value2)
free (item_value2);
if (items)
@@ -1046,6 +1207,186 @@ gui_bar_draw (struct t_gui_bar *bar)
}
/*
+ * gui_bar_window_scroll: scroll a bar window with a value
+ * if add == 1, then value is added (otherwise subtracted)
+ * if add_x == 1, then value is added to scroll_x (otherwise scroll_y)
+ * if percent == 1, then value is a percentage (otherwise number of chars)
+ */
+
+void
+gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
+ struct t_gui_window *window,
+ int add_x, int scroll_beginning, int scroll_end,
+ int add, int percent, int value)
+{
+ int old_scroll_x, old_scroll_y;
+
+ old_scroll_x = bar_window->scroll_x;
+ old_scroll_y = bar_window->scroll_y;
+
+ if (scroll_beginning)
+ {
+ if (add_x)
+ bar_window->scroll_x = 0;
+ else
+ bar_window->scroll_y = 0;
+ }
+ else if (scroll_end)
+ {
+ if (add_x)
+ bar_window->scroll_x = INT_MAX;
+ else
+ bar_window->scroll_y = INT_MAX;
+ }
+ else
+ {
+ if (percent)
+ {
+ if (add_x)
+ value = (bar_window->width * value) / 100;
+ else
+ value = (bar_window->height * value) / 100;
+ if (value == 0)
+ value = 1;
+ }
+ if (add)
+ {
+ if (add_x)
+ bar_window->scroll_x += value;
+ else
+ bar_window->scroll_y += value;
+ }
+ else
+ {
+ if (add_x)
+ bar_window->scroll_x -= value;
+ else
+ bar_window->scroll_y -= value;
+ }
+ }
+
+ if (bar_window->scroll_x < 0)
+ bar_window->scroll_x = 0;
+
+ if (bar_window->scroll_y < 0)
+ bar_window->scroll_y = 0;
+
+ /* refresh only if scroll has changed (X and/or Y) */
+ if ((old_scroll_x != bar_window->scroll_x)
+ || (old_scroll_y != bar_window->scroll_y))
+ {
+ gui_bar_window_draw (bar_window, window);
+ }
+}
+
+/*
+ * gui_bar_scroll: scroll a bar for a buffer
+ * return 1 if scroll is ok, 0 if error
+ */
+
+int
+gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_buffer *buffer,
+ const char *scroll)
+{
+ struct t_gui_window *ptr_win;
+ struct t_gui_bar_window *ptr_bar_win;
+ long number;
+ char *str, *error;
+ int length, add_x, add, percent, scroll_beginning, scroll_end;
+
+ add_x = 0;
+ str = NULL;
+ number = 0;
+ add = 0;
+ percent = 0;
+ scroll_beginning = 0;
+ scroll_end = 0;
+
+ if ((scroll[0] == 'x') || (scroll[0] == 'X'))
+ {
+ add_x = 1;
+ scroll++;
+ }
+ else if ((scroll[0] == 'y') || (scroll[0] == 'Y'))
+ {
+ scroll++;
+ }
+ else
+ return 0;
+
+ if ((scroll[0] == 'b') || (scroll[0] == 'B'))
+ {
+ scroll_beginning = 1;
+ }
+ else if ((scroll[0] == 'e') || (scroll[0] == 'E'))
+ {
+ scroll_end = 1;
+ }
+ else
+ {
+ if (scroll[0] == '+')
+ {
+ add = 1;
+ scroll++;
+ }
+ else if (scroll[0] == '-')
+ {
+ scroll++;
+ }
+ else
+ return 0;
+
+ length = strlen (scroll);
+ if (length == 0)
+ return 0;
+
+ if (scroll[length - 1] == '%')
+ {
+ str = string_strndup (scroll, length - 1);
+ percent = 1;
+ }
+ else
+ str = strdup (scroll);
+ if (!str)
+ return 0;
+
+ error = NULL;
+ number = strtol (str, &error, 10);
+
+ if (!error || error[0] || (number <= 0))
+ {
+ free (str);
+ return 0;
+ }
+ }
+
+ if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ gui_bar_window_scroll (bar->bar_window, NULL,
+ add_x, scroll_beginning, scroll_end,
+ add, percent, number);
+ else
+ {
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ if (ptr_win->buffer == buffer)
+ {
+ for (ptr_bar_win = GUI_CURSES(ptr_win)->bar_windows;
+ ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
+ {
+ gui_bar_window_scroll (ptr_bar_win, ptr_win,
+ add_x, scroll_beginning, scroll_end,
+ add, percent, number);
+ }
+ }
+ }
+ }
+
+ free (str);
+
+ return 1;
+}
+
+/*
* gui_bar_window_print_log: print bar window infos in log (usually for crash dump)
*/
@@ -1059,6 +1400,8 @@ gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
log_printf (" y . . . . . . . . : %d", bar_window->y);
log_printf (" width . . . . . . : %d", bar_window->width);
log_printf (" height. . . . . . : %d", bar_window->height);
+ log_printf (" scroll_x. . . . . : %d", bar_window->scroll_x);
+ log_printf (" scroll_y. . . . . : %d", bar_window->scroll_y);
log_printf (" cursor_x. . . . . : %d", bar_window->cursor_x);
log_printf (" cursor_y. . . . . : %d", bar_window->cursor_y);
log_printf (" current_size. . . : %d", bar_window->current_size);
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index bd20dca1b..9f1a8e480 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -84,8 +84,8 @@ gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
if (ptr_win->win_title_start > 0)
{
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
- GUI_COLOR_TITLE_MORE);
+ //gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
+ // GUI_COLOR_TITLE_MORE);
wprintw (GUI_CURSES(ptr_win)->win_title, "%s", "++");
}
@@ -94,8 +94,8 @@ gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
GUI_COLOR_TITLE);
wprintw (GUI_CURSES(ptr_win)->win_title, "%s", ptr_title);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
- GUI_COLOR_TITLE_MORE);
+ //gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
+ // GUI_COLOR_TITLE_MORE);
mvwprintw (GUI_CURSES(ptr_win)->win_title, 0,
ptr_win->win_width - 2,
"%s", "++");
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c
index 818a0f4f3..42557dd99 100644
--- a/src/gui/curses/gui-curses-color.c
+++ b/src/gui/curses/gui-curses-color.c
@@ -357,7 +357,6 @@ gui_color_init_weechat ()
gui_color_build (GUI_COLOR_SEPARATOR, CONFIG_COLOR(config_color_separator), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_TITLE, CONFIG_COLOR(config_color_title), CONFIG_COLOR(config_color_title_bg));
- gui_color_build (GUI_COLOR_TITLE_MORE, CONFIG_COLOR(config_color_title_more), CONFIG_COLOR(config_color_title_bg));
gui_color_build (GUI_COLOR_CHAT, CONFIG_COLOR(config_color_chat), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_CHAT_TIME, CONFIG_COLOR(config_color_chat_time), CONFIG_COLOR(config_color_chat_bg));
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index 4eeaede59..02f9b6023 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -123,10 +123,10 @@ gui_keyboard_default_bindings ()
gui_keyboard_bind (NULL, /* m-p */ "meta-p", "/window scroll_previous_highlight");
gui_keyboard_bind (NULL, /* F9 */ "meta2-20~", "/window scroll_topic_left");
gui_keyboard_bind (NULL, /* F10 */ "meta2-21~", "/window scroll_topic_right");
- gui_keyboard_bind (NULL, /* F11 */ "meta2-23~", "/window nicklist_page_up");
- gui_keyboard_bind (NULL, /* F12 */ "meta2-24~", "/window nicklist_page_down");
- gui_keyboard_bind (NULL, /* m-F11 */ "meta-meta2-23~", "/window nicklist_beginning");
- gui_keyboard_bind (NULL, /* m-F12 */ "meta-meta2-24~", "/window nicklist_end");
+ gui_keyboard_bind (NULL, /* F11 */ "meta2-23~", "/bar scroll nicklist * y-100%");
+ gui_keyboard_bind (NULL, /* F12 */ "meta2-24~", "/bar scroll nicklist * y+100%");
+ gui_keyboard_bind (NULL, /* m-F11 */ "meta-meta2-23~", "/bar scroll nicklist * yb");
+ gui_keyboard_bind (NULL, /* m-F12 */ "meta-meta2-24~", "/bar scroll nicklist * ye");
gui_keyboard_bind (NULL, /* ^L */ "ctrl-L", "/window refresh");
gui_keyboard_bind (NULL, /* F7 */ "meta2-18~", "/window -1");
gui_keyboard_bind (NULL, /* F8 */ "meta2-19~", "/window +1");
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index 2fb742703..f76c7ae09 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -211,6 +211,7 @@ gui_main_loop ()
struct t_hook *hook_fd_keyboard;
struct t_gui_window *ptr_win;
struct t_gui_buffer *ptr_buffer;
+ struct t_gui_bar *ptr_bar;
struct timeval tv_timeout;
fd_set read_fds, write_fds, except_fds;
int max_fd;
@@ -250,6 +251,15 @@ gui_main_loop ()
if (gui_status_refresh_needed)
gui_status_draw (1);
+ for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
+ {
+ if (ptr_bar->bar_refresh_needed)
+ {
+ gui_bar_draw (ptr_bar);
+ ptr_bar->bar_refresh_needed = 0;
+ }
+ }
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->refresh_needed)
diff --git a/src/gui/curses/gui-curses-nicklist.c b/src/gui/curses/gui-curses-nicklist.c
index 1ac90ae6a..8b189099f 100644
--- a/src/gui/curses/gui-curses-nicklist.c
+++ b/src/gui/curses/gui-curses-nicklist.c
@@ -48,6 +48,7 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
struct t_gui_window *ptr_win;
struct t_gui_nick_group *ptr_group, *save_ptr_group;
struct t_gui_nick *ptr_nick, *save_ptr_nick;
+ struct t_config_option *ptr_option;
int i, j, k, x, y, x2, max_y, column, max_length, max_chars;
int nicks_displayed, num_to_display, chars_left;
char format_empty[32], *buf, *ptr_buf, *ptr_next, saved_char;
@@ -241,15 +242,30 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
}
chars_left -= ptr_nick->group->level;
}
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
- ptr_nick->prefix_color);
+
+ //gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ // ptr_nick->prefix_color);
+ config_file_search_with_string (ptr_nick->prefix_color,
+ NULL, NULL, &ptr_option,
+ NULL);
+ if (ptr_option)
+ gui_window_set_custom_color_fg (GUI_CURSES(ptr_win)->win_nick,
+ CONFIG_COLOR(ptr_option));
+
mvwprintw (GUI_CURSES(ptr_win)->win_nick,
y, x, "%c", ptr_nick->prefix);
x++;
chars_left--;
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
- ptr_nick->color);
+ //gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ // ptr_nick->color);
+ config_file_search_with_string (ptr_nick->color,
+ NULL, NULL, &ptr_option,
+ NULL);
+ if (ptr_option)
+ gui_window_set_custom_color_fg (GUI_CURSES(ptr_win)->win_nick,
+ CONFIG_COLOR(ptr_option));
+
ptr_buf = ptr_nick->name;
}
else
@@ -262,8 +278,8 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
x++;
}
chars_left -= ptr_group->level;
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
- ptr_group->color);
+ //gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ // ptr_group->color);
//wattron (GUI_CURSES(ptr_win)->win_nick, A_UNDERLINE);
ptr_buf = gui_nicklist_get_group_start (ptr_group->name);
}
diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h
index 92e815ea9..ac48ff02e 100644
--- a/src/gui/curses/gui-curses.h
+++ b/src/gui/curses/gui-curses.h
@@ -43,6 +43,7 @@ struct t_gui_bar_window
struct t_gui_bar *bar; /* pointer to bar */
int x, y; /* position of window */
int width, height; /* window size */
+ int scroll_x, scroll_y; /* X-Y scroll in bar */
int cursor_x, cursor_y; /* use to move cursor on screen (for */
/* input_text item) */
WINDOW *win_bar; /* bar Curses window */
diff --git a/src/gui/gtk/gui-gtk-bar.c b/src/gui/gtk/gui-gtk-bar.c
index 1c2e821c1..f07f2cceb 100644
--- a/src/gui/gtk/gui-gtk-bar.c
+++ b/src/gui/gtk/gui-gtk-bar.c
@@ -111,6 +111,80 @@ gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window,
}
/*
+ * gui_bar_get_min_width: return minimum width of a bar window displayed for
+ * a bar
+ * for example, if a bar is displayed in 3 windows,
+ * this function return min width of these 3 bar windows
+ */
+
+int
+gui_bar_get_min_width (struct t_gui_bar *bar)
+{
+ struct t_gui_window *ptr_win;
+ struct t_gui_bar_window *ptr_bar_win;
+ int min_width;
+
+ if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ return bar->bar_window->width;
+
+ min_width = INT_MAX;
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ for (ptr_bar_win = GUI_GTK(ptr_win)->bar_windows;
+ ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
+ {
+ if (ptr_bar_win->bar == bar)
+ {
+ if (ptr_bar_win->width < min_width)
+ min_width = ptr_bar_win->width;
+ }
+ }
+ }
+
+ if (min_width == INT_MAX)
+ return 0;
+
+ return min_width;
+}
+
+/*
+ * gui_bar_get_min_height: return minimum height of a bar window displayed for
+ * a bar
+ * for example, if a bar is displayed in 3 windows,
+ * this function return min width of these 3 bar windows
+ */
+
+int
+gui_bar_get_min_height (struct t_gui_bar *bar)
+{
+ struct t_gui_window *ptr_win;
+ struct t_gui_bar_window *ptr_bar_win;
+ int min_height;
+
+ if (CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT)
+ return bar->bar_window->height;
+
+ min_height = INT_MAX;
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ for (ptr_bar_win = GUI_GTK(ptr_win)->bar_windows;
+ ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window)
+ {
+ if (ptr_bar_win->bar == bar)
+ {
+ if (ptr_bar_win->height < min_height)
+ min_height = ptr_bar_win->height;
+ }
+ }
+ }
+
+ if (min_height == INT_MAX)
+ return 0;
+
+ return min_height;
+}
+
+/*
* gui_bar_check_size_add: check if "add_size" is ok for bar
* return 1 if new size is ok
* 0 if new size is too big
@@ -333,6 +407,23 @@ gui_bar_draw (struct t_gui_bar *bar)
}
/*
+ * gui_bar_scroll: scroll a bar for a buffer
+ * return 1 if scroll is ok, 0 if error
+ */
+
+int
+gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_buffer *buffer,
+ const char *scroll)
+{
+ (void) bar;
+ (void) buffer;
+ (void) scroll;
+
+ /* TODO: write this function for Gtk */
+ return 0;
+}
+
+/*
* gui_bar_window_print_log: print bar window infos in log (usually for crash dump)
*/
@@ -346,6 +437,8 @@ gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
log_printf (" y . . . . . . . . : %d", bar_window->y);
log_printf (" width . . . . . . : %d", bar_window->width);
log_printf (" height. . . . . . : %d", bar_window->height);
+ log_printf (" scroll_x. . . . . : %d", bar_window->scroll_x);
+ log_printf (" scroll_y. . . . . : %d", bar_window->scroll_y);
log_printf (" prev_bar_window . : 0x%x", bar_window->prev_bar_window);
log_printf (" next_bar_window . : 0x%x", bar_window->next_bar_window);
}
diff --git a/src/gui/gtk/gui-gtk.h b/src/gui/gtk/gui-gtk.h
index 6b5a339a0..53428daac 100644
--- a/src/gui/gtk/gui-gtk.h
+++ b/src/gui/gtk/gui-gtk.h
@@ -59,6 +59,7 @@ struct t_gui_bar_window
struct t_gui_bar *bar; /* pointer to bar */
int x, y; /* position of window */
int width, height; /* window size */
+ int scroll_x, scroll_y; /* X-Y scroll in bar */
int current_size; /* current size (width or height) */
struct t_gui_bar_window *prev_bar_window; /* link to previous bar win */
/* (only for non-root bars) */
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index 35498dce3..c91820afc 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -42,6 +42,7 @@
#include "gui-completion.h"
#include "gui-filter.h"
#include "gui-hotlist.h"
+#include "gui-nicklist.h"
#include "gui-window.h"
@@ -49,8 +50,8 @@ struct t_gui_bar_item *gui_bar_items = NULL; /* first bar item */
struct t_gui_bar_item *last_gui_bar_item = NULL; /* last bar item */
char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] =
{ "input_prompt", "input_text", "time", "buffer_count", "buffer_plugin",
- "buffer_name", "buffer_filter", "nicklist_count", "scroll", "hotlist",
- "completion", "buffer_title"
+ "buffer_name", "buffer_filter", "buffer_nicklist_count", "scroll", "hotlist",
+ "completion", "buffer_title", "buffer_nicklist"
};
struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL;
struct t_hook *gui_bar_item_timer = NULL;
@@ -268,7 +269,7 @@ gui_bar_item_input_text_update_for_display (const char *item_content,
if (buf)
{
length_screen_before_cursor = gui_chat_strlen_screen (buf);
- length_screen_after_cursor = gui_chat_strlen_screen (pos_cursor + strlen (str_cursor));
+ length_screen_after_cursor = gui_chat_strlen_screen (pos_cursor);
free (buf);
}
}
@@ -531,7 +532,7 @@ gui_bar_item_update (const char *item_name)
if (!CONFIG_BOOLEAN(ptr_bar->hidden)
&& gui_bar_contains_item (ptr_bar, item_name))
{
- gui_bar_draw (ptr_bar);
+ gui_bar_ask_refresh (ptr_bar);
}
}
}
@@ -797,14 +798,15 @@ gui_bar_item_default_buffer_filter (void *data, struct t_gui_bar_item *item,
}
/*
- * gui_bar_item_default_nicklist_count: default item for number of nicks in
- * buffer nicklist
+ * gui_bar_item_default_buffer_nicklist_count: default item for number of nicks
+ * in buffer nicklist
*/
char *
-gui_bar_item_default_nicklist_count (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window,
- int max_width, int max_height)
+gui_bar_item_default_buffer_nicklist_count (void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ int max_width, int max_height)
{
char buf[32];
@@ -1016,6 +1018,102 @@ gui_bar_item_default_buffer_title (void *data, struct t_gui_bar_item *item,
}
/*
+ * gui_bar_item_default_buffer_nicklist: default item for nicklist
+ */
+
+char *
+gui_bar_item_default_buffer_nicklist (void *data, struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ int max_width, int max_height)
+{
+ struct t_gui_nick_group *ptr_group;
+ struct t_gui_nick *ptr_nick;
+ struct t_config_option *ptr_option;
+ int i, length;
+ char *buf, str_prefix[2];
+
+ /* make C compiler happy */
+ (void) data;
+ (void) item;
+ (void) max_width;
+ (void) max_height;
+
+ if (!window)
+ window = gui_current_window;
+
+ length = 1;
+ ptr_group = NULL;
+ ptr_nick = NULL;
+ gui_nicklist_get_next_item (window->buffer, &ptr_group, &ptr_nick);
+ while (ptr_group || ptr_nick)
+ {
+ if ((ptr_nick && ptr_nick->visible)
+ || (ptr_group && window->buffer->nicklist_display_groups
+ && ptr_group->visible))
+ {
+ if (ptr_nick)
+ length += ptr_nick->group->level + 16 /* color */
+ + 1 /* prefix */ + 16 /* color */
+ + strlen (ptr_nick->name) + 1;
+ else
+ length += ptr_group->level - 1
+ + strlen (gui_nicklist_get_group_start (ptr_group->name))
+ + 1;
+ }
+ gui_nicklist_get_next_item (window->buffer, &ptr_group, &ptr_nick);
+ }
+
+ buf = malloc (length);
+ if (buf)
+ {
+ buf[0] = '\0';
+ ptr_group = NULL;
+ ptr_nick = NULL;
+ gui_nicklist_get_next_item (window->buffer, &ptr_group, &ptr_nick);
+ while (ptr_group || ptr_nick)
+ {
+ if ((ptr_nick && ptr_nick->visible)
+ || (ptr_group && window->buffer->nicklist_display_groups
+ && ptr_group->visible))
+ {
+ if (ptr_nick)
+ {
+ if (window->buffer->nicklist_display_groups)
+ {
+ for (i = 0; i < ptr_nick->group->level; i++)
+ {
+ strcat (buf, " ");
+ }
+ }
+ config_file_search_with_string (ptr_nick->prefix_color,
+ NULL, NULL, &ptr_option,
+ NULL);
+ if (ptr_option)
+ strcat (buf, gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(ptr_option))));
+ str_prefix[0] = ptr_nick->prefix;
+ str_prefix[1] = '\0';
+ strcat (buf, str_prefix);
+ strcat (buf, GUI_COLOR_CUSTOM_BAR_FG);
+ strcat (buf, ptr_nick->name);
+ }
+ else
+ {
+ for (i = 0; i < ptr_group->level - 1; i++)
+ {
+ strcat (buf, " ");
+ }
+ strcat (buf, gui_nicklist_get_group_start (ptr_group->name));
+ }
+ strcat (buf, "\n");
+ }
+ gui_nicklist_get_next_item (window->buffer, &ptr_group, &ptr_nick);
+ }
+ }
+
+ return buf;
+}
+
+/*
* gui_bar_item_timer_cb: timer callback
*/
@@ -1152,14 +1250,14 @@ gui_bar_item_init ()
gui_bar_item_hook ("filters_*",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER]);
- /* nicklist count */
+ /* buffer nicklist count */
gui_bar_item_new (NULL,
- gui_bar_item_names[GUI_BAR_ITEM_NICKLIST_COUNT],
- &gui_bar_item_default_nicklist_count, NULL);
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT],
+ &gui_bar_item_default_buffer_nicklist_count, NULL);
gui_bar_item_hook ("buffer_switch",
- gui_bar_item_names[GUI_BAR_ITEM_NICKLIST_COUNT]);
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT]);
gui_bar_item_hook ("nicklist_changed",
- gui_bar_item_names[GUI_BAR_ITEM_NICKLIST_COUNT]);
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT]);
/* scroll indicator */
gui_bar_item_new (NULL,
@@ -1188,6 +1286,13 @@ gui_bar_item_init ()
&gui_bar_item_default_buffer_title, NULL);
gui_bar_item_hook ("buffer_title_changed",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE]);
+
+ /* buffer nicklist */
+ gui_bar_item_new (NULL,
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST],
+ &gui_bar_item_default_buffer_nicklist, NULL);
+ gui_bar_item_hook ("nicklist_changed",
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST]);
}
/*
diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h
index 7d225c217..e522921c4 100644
--- a/src/gui/gui-bar-item.h
+++ b/src/gui/gui-bar-item.h
@@ -29,11 +29,12 @@ enum t_gui_bar_item_weechat
GUI_BAR_ITEM_BUFFER_PLUGIN,
GUI_BAR_ITEM_BUFFER_NAME,
GUI_BAR_ITEM_BUFFER_FILTER,
- GUI_BAR_ITEM_NICKLIST_COUNT,
+ GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT,
GUI_BAR_ITEM_SCROLL,
GUI_BAR_ITEM_HOTLIST,
GUI_BAR_ITEM_COMPLETION,
GUI_BAR_ITEM_BUFFER_TITLE,
+ GUI_BAR_ITEM_BUFFER_NICKLIST,
/* number of bar items */
GUI_BAR_NUM_ITEMS,
};
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index 09358c5d4..e513b6967 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -300,6 +300,16 @@ gui_bar_search_with_option_name (const char *option_name)
}
/*
+ * gui_bar_ask_refresh: ask refresh for bar
+ */
+
+void
+gui_bar_ask_refresh (struct t_gui_bar *bar)
+{
+ bar->bar_refresh_needed = 1;
+}
+
+/*
* gui_bar_refresh: ask for bar refresh on screen (for all windows where bar is)
*/
@@ -1173,6 +1183,7 @@ gui_bar_alloc (const char *name)
new_bar->items_count = 0;
new_bar->items_array = NULL;
new_bar->bar_window = NULL;
+ new_bar->bar_refresh_needed = 0;
new_bar->prev_bar = NULL;
new_bar->next_bar = NULL;
}
@@ -1244,6 +1255,7 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name,
new_bar->items_array = NULL;
}
new_bar->bar_window = NULL;
+ new_bar->bar_refresh_needed = 1;
/* add bar to bars list */
gui_bar_insert (new_bar);
@@ -1570,7 +1582,7 @@ gui_bar_create_default ()
/* search an input_text item */
if (!gui_bar_item_used_in_a_bar (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT], 1))
{
- ptr_bar = gui_bar_search ("input");
+ ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_INPUT);
if (ptr_bar)
{
/* add item "input_text" to input bar */
@@ -1587,6 +1599,8 @@ gui_bar_create_default ()
CONFIG_STRING(ptr_bar->items) : "",
gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]);
config_file_option_set (ptr_bar->items, buf, 1);
+ gui_chat_printf (NULL, _("Bar \"%s\" updated"),
+ GUI_BAR_DEFAULT_NAME_INPUT);
gui_bar_draw (ptr_bar);
free (buf);
}
@@ -1605,15 +1619,23 @@ gui_bar_create_default ()
snprintf (buf, length, "[%s],%s",
gui_bar_item_names[GUI_BAR_ITEM_INPUT_PROMPT],
gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT]);
- if (gui_bar_new (NULL, "input", "0", "999", "window", "",
- "bottom", "horizontal", "1", "0",
+ if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_INPUT,
+ "0", /* hidden */
+ "1000", /* priority */
+ "window", /* type */
+ "", /* conditions */
+ "bottom", /* position */
+ "horizontal", /* filling */
+ "1", /* size */
+ "0", /* size_max */
gui_color_get_name (CONFIG_COLOR(config_color_input)),
gui_color_get_name (CONFIG_COLOR(config_color_input_delimiters)),
gui_color_get_name (CONFIG_COLOR(config_color_input_bg)),
- "0", buf))
+ "0", /* separators */
+ buf)) /* items */
{
gui_chat_printf (NULL, _("Bar \"%s\" created"),
- "input");
+ GUI_BAR_DEFAULT_NAME_INPUT);
}
free (buf);
}
@@ -1621,7 +1643,7 @@ gui_bar_create_default ()
}
/* search status bar */
- ptr_bar = gui_bar_search ("status");
+ ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_STATUS);
if (!ptr_bar)
{
/* create status bar */
@@ -1633,7 +1655,7 @@ gui_bar_create_default ()
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER])
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_COMPLETION])
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_SCROLL])
- + strlen (gui_bar_item_names[GUI_BAR_ITEM_NICKLIST_COUNT])
+ + strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT])
+ (9 * 4) + 1;
buf = malloc (length);
if (buf)
@@ -1643,39 +1665,80 @@ gui_bar_create_default ()
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_COUNT],
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_PLUGIN],
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME],
- gui_bar_item_names[GUI_BAR_ITEM_NICKLIST_COUNT],
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT],
gui_bar_item_names[GUI_BAR_ITEM_HOTLIST],
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_FILTER],
gui_bar_item_names[GUI_BAR_ITEM_COMPLETION],
gui_bar_item_names[GUI_BAR_ITEM_SCROLL]);
- if (gui_bar_new (NULL, "status", "0", "0", "window", "",
- "bottom", "horizontal", "1", "0",
+ if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_STATUS,
+ "0", /* hidden */
+ "500", /* priority */
+ "window", /* type */
+ "", /* conditions */
+ "bottom", /* position */
+ "horizontal", /* filling */
+ "1", /* size */
+ "0", /* size_max */
gui_color_get_name (CONFIG_COLOR(config_color_status)),
gui_color_get_name (CONFIG_COLOR(config_color_status_delimiters)),
gui_color_get_name (CONFIG_COLOR(config_color_status_bg)),
- "0", buf))
+ "0", /* separators */
+ buf)) /* items */
{
gui_chat_printf (NULL, _("Bar \"%s\" created"),
- "status");
+ GUI_BAR_DEFAULT_NAME_STATUS);
}
free (buf);
}
}
/* search title bar */
- ptr_bar = gui_bar_search ("title");
+ ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_TITLE);
if (!ptr_bar)
{
/* create title bar */
- if (gui_bar_new (NULL, "title", "0", "0", "window", "",
- "top", "horizontal", "1", "0",
+ if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_TITLE,
+ "0", /* hidden */
+ "500", /* priority */
+ "window", /* type */
+ "", /* conditions */
+ "top", /* position */
+ "horizontal", /* filling */
+ "1", /* size */
+ "0", /* size_max */
gui_color_get_name (CONFIG_COLOR(config_color_title)),
gui_color_get_name (CONFIG_COLOR(config_color_title)),
gui_color_get_name (CONFIG_COLOR(config_color_title_bg)),
- "0", gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE]))
+ "0", /* separators */
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_TITLE])) /* items */
{
gui_chat_printf (NULL, _("Bar \"%s\" created"),
- "title");
+ GUI_BAR_DEFAULT_NAME_TITLE);
+ }
+ }
+
+ /* search nicklist bar */
+ ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_NICKLIST);
+ if (!ptr_bar)
+ {
+ /* create nicklist bar */
+ if (gui_bar_new (NULL, GUI_BAR_DEFAULT_NAME_NICKLIST,
+ "0", /* hidden */
+ "200", /* priority */
+ "window", /* type */
+ "nicklist", /* conditions */
+ "right", /* position */
+ "vertical", /* filling */
+ "0", /* size */
+ "0", /* size_max */
+ gui_color_get_name (CONFIG_COLOR(config_color_nicklist)),
+ gui_color_get_name (CONFIG_COLOR(config_color_nicklist)),
+ gui_color_get_name (CONFIG_COLOR(config_color_nicklist_bg)),
+ "1", /* separators */
+ gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST])) /* items */
+ {
+ gui_chat_printf (NULL, _("Bar \"%s\" created"),
+ GUI_BAR_DEFAULT_NAME_NICKLIST);
}
}
}
@@ -1692,7 +1755,7 @@ gui_bar_update (const char *name)
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
if (!CONFIG_BOOLEAN(ptr_bar->hidden) && (strcmp (ptr_bar->name, name) == 0))
- gui_bar_draw (ptr_bar);
+ gui_bar_ask_refresh (ptr_bar);
}
}
diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h
index 57579fc76..7b686bb05 100644
--- a/src/gui/gui-bar.h
+++ b/src/gui/gui-bar.h
@@ -22,6 +22,12 @@
struct t_weechat_plugin;
struct t_gui_window;
+struct t_gui_buffer;
+
+#define GUI_BAR_DEFAULT_NAME_INPUT "input"
+#define GUI_BAR_DEFAULT_NAME_STATUS "status"
+#define GUI_BAR_DEFAULT_NAME_TITLE "title"
+#define GUI_BAR_DEFAULT_NAME_NICKLIST "nicklist"
enum t_gui_bar_option
{
@@ -94,6 +100,7 @@ struct t_gui_bar
char **items_array; /* exploded bar items */
struct t_gui_bar_window *bar_window; /* pointer to bar window */
/* (for type root only) */
+ int bar_refresh_needed; /* refresh for bar is needed? */
struct t_gui_bar *prev_bar; /* link to previous bar */
struct t_gui_bar *next_bar; /* link to next bar */
};
@@ -118,6 +125,7 @@ extern int gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
extern int gui_bar_root_get_size (struct t_gui_bar *bar,
enum t_gui_bar_position position);
extern struct t_gui_bar *gui_bar_search (const char *name);
+extern void gui_bar_ask_refresh (struct t_gui_bar *bar);
extern int gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value);
extern void gui_bar_create_option_temp (struct t_gui_bar *temp_bar,
int index_option, const char *value);
@@ -151,6 +159,8 @@ extern void gui_bar_window_set_current_size (struct t_gui_bar *bar, int size);
extern int gui_bar_window_get_size (struct t_gui_bar *bar,
struct t_gui_window *window,
enum t_gui_bar_position position);
+extern int gui_bar_get_min_width (struct t_gui_bar *bar);
+extern int gui_bar_get_min_height (struct t_gui_bar *bar);
extern int gui_bar_check_size_add (struct t_gui_bar *bar, int add_size);
extern int gui_bar_window_new (struct t_gui_bar *bar,
struct t_gui_window *window);
@@ -158,6 +168,8 @@ extern void gui_bar_window_free (struct t_gui_bar_window *bar_window,
struct t_gui_window *window);
extern void gui_bar_free_bar_windows (struct t_gui_bar *bar);
extern void gui_bar_draw (struct t_gui_bar *bar);
+extern int gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_buffer *buffer,
+ const char *scroll);
extern void gui_bar_window_print_log (struct t_gui_bar_window *bar_window);
#endif /* gui-bar.h */
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index 920771bd7..6b5db98f2 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -114,7 +114,10 @@ gui_color_get_custom (const char *color_name)
/* attribute or other color name (GUI dependent) */
index_color = (index_color + 1) % 20;
color[index_color][0] = '\0';
-
+
+ if (!color_name || !color_name[0])
+ return color[index_color];
+
if (string_strcasecmp (color_name, "reset") == 0)
{
snprintf (color[index_color], sizeof (color[index_color]),
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 41937d083..bc7464f45 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -27,7 +27,6 @@ enum t_gui_color_enum
GUI_COLOR_SEPARATOR = 0,
GUI_COLOR_TITLE,
- GUI_COLOR_TITLE_MORE,
GUI_COLOR_CHAT,
GUI_COLOR_CHAT_TIME,
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c
index aacafd96a..179b906f1 100644
--- a/src/gui/gui-nicklist.c
+++ b/src/gui/gui-nicklist.c
@@ -164,7 +164,6 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer,
const char *color, int visible)
{
struct t_gui_nick_group *new_group;
- int num_color;
if (!name || gui_nicklist_search_group (buffer, parent_group, name))
return NULL;
@@ -172,18 +171,9 @@ gui_nicklist_add_group (struct t_gui_buffer *buffer,
new_group = malloc (sizeof (*new_group));
if (!new_group)
return NULL;
-
- if (color)
- {
- num_color = gui_color_search_config_int (color);
- if (num_color < 0)
- num_color = GUI_COLOR_NICKLIST;
- }
- else
- num_color = GUI_COLOR_NICKLIST;
new_group->name = strdup (name);
- new_group->color = num_color;
+ new_group->color = (color) ? strdup (color) : NULL;
new_group->visible = visible;
new_group->parent = (parent_group) ? parent_group : buffer->nicklist_root;
new_group->level = (new_group->parent) ? new_group->parent->level + 1 : 0;
@@ -313,7 +303,6 @@ gui_nicklist_add_nick (struct t_gui_buffer *buffer,
int visible)
{
struct t_gui_nick *new_nick;
- int num_color, num_color_prefix;
if (!name || gui_nicklist_search_nick (buffer, NULL, name))
return NULL;
@@ -321,30 +310,12 @@ gui_nicklist_add_nick (struct t_gui_buffer *buffer,
new_nick = malloc (sizeof (*new_nick));
if (!new_nick)
return NULL;
-
- if (color)
- {
- num_color = gui_color_search_config_int (color);
- if (num_color < 0)
- num_color = GUI_COLOR_NICKLIST;
- }
- else
- num_color = GUI_COLOR_NICKLIST;
-
- if (prefix_color)
- {
- num_color_prefix = gui_color_search_config_int (prefix_color);
- if (num_color_prefix < 0)
- num_color_prefix = GUI_COLOR_NICKLIST;
- }
- else
- num_color_prefix = GUI_COLOR_NICKLIST;
-
+
new_nick->group = (group) ? group : buffer->nicklist_root;
new_nick->name = strdup (name);
- new_nick->color = num_color;
+ new_nick->color = (color) ? strdup (color) : NULL;
new_nick->prefix = prefix;
- new_nick->prefix_color = num_color_prefix;
+ new_nick->prefix_color = (prefix_color) ? strdup (prefix_color) : NULL;
new_nick->visible = visible;
gui_nicklist_insert_nick_sorted (new_nick->group, new_nick);
@@ -385,6 +356,10 @@ gui_nicklist_remove_nick (struct t_gui_buffer *buffer,
/* free data */
if (nick->name)
free (nick->name);
+ if (nick->color)
+ free (nick->color);
+ if (nick->prefix_color)
+ free (nick->prefix_color);
if (nick->visible)
{
@@ -442,6 +417,8 @@ gui_nicklist_remove_group (struct t_gui_buffer *buffer,
/* free data */
if (group->name)
free (group->name);
+ if (group->color)
+ free (group->color);
if (group->visible)
{
@@ -652,7 +629,7 @@ gui_nicklist_print_log (struct t_gui_nick_group *group, int indent)
(indent * 2) + 6);
log_printf (format, " ", group->name);
snprintf (format, sizeof (format),
- "%%-%dscolor . . . : %%d",
+ "%%-%dscolor . . . : '%%s'",
(indent * 2) + 6);
log_printf (format, " ", group->color);
snprintf (format, sizeof (format),
@@ -707,35 +684,35 @@ gui_nicklist_print_log (struct t_gui_nick_group *group, int indent)
(indent * 2) + 4);
log_printf (format, " ", ptr_nick);
snprintf (format, sizeof (format),
- "%%-%dsgroup . . . : 0x%%X",
+ "%%-%dsgroup . . . . . : 0x%%X",
(indent * 2) + 6);
log_printf (format, " ", ptr_nick->group);
snprintf (format, sizeof (format),
- "%%-%dsname. . . . : '%%s'",
+ "%%-%dsname. . . . . . : '%%s'",
(indent * 2) + 6);
log_printf (format, " ", ptr_nick->name);
snprintf (format, sizeof (format),
- "%%-%dscolor . . . : %%d",
+ "%%-%dscolor . . . . . : '%%s'",
(indent * 2) + 6);
log_printf (format, " ", ptr_nick->color);
snprintf (format, sizeof (format),
- "%%-%dsprefix. . . : '%%c'",
+ "%%-%dsprefix. . . . . : '%%c'",
(indent * 2) + 6);
log_printf (format, " ", ptr_nick->prefix);
snprintf (format, sizeof (format),
- "%%-%dsprefix_color: %%d",
+ "%%-%dsprefix_color. . : '%%s'",
(indent * 2) + 6);
log_printf (format, " ", ptr_nick->prefix_color);
snprintf (format, sizeof (format),
- "%%-%dsvisible . . : %%d",
+ "%%-%dsvisible . . . . : %%d",
(indent * 2) + 6);
log_printf (format, " ", ptr_nick->visible);
snprintf (format, sizeof (format),
- "%%-%dsprev_nick . : 0x%%X",
+ "%%-%dsprev_nick . . . : 0x%%X",
(indent * 2) + 6);
log_printf (format, " ", ptr_nick->prev_nick);
snprintf (format, sizeof (format),
- "%%-%dsnext_nick . : 0x%%X",
+ "%%-%dsnext_nick . . . : 0x%%X",
(indent * 2) + 6);
log_printf (format, " ", ptr_nick->next_nick);
}
diff --git a/src/gui/gui-nicklist.h b/src/gui/gui-nicklist.h
index cf031675b..4ca8f7a70 100644
--- a/src/gui/gui-nicklist.h
+++ b/src/gui/gui-nicklist.h
@@ -25,7 +25,7 @@ struct t_gui_buffer;
struct t_gui_nick_group
{
char *name; /* group name */
- int color; /* color for group in nicklist */
+ char *color; /* color for group in nicklist */
int visible; /* 1 if group is displayed */
int level; /* group level (root is 0) */
struct t_gui_nick_group *parent; /* parent */
@@ -41,9 +41,9 @@ struct t_gui_nick
{
struct t_gui_nick_group *group; /* group which contains nick */
char *name; /* nick name */
- int color; /* color for nick in nicklist */
+ char *color; /* color for nick in nicklist */
char prefix; /* prefix for nick (for admins, ..) */
- int prefix_color; /* color for prefix */
+ char *prefix_color; /* color for prefix */
int visible; /* 1 if nick is displayed */
struct t_gui_nick *prev_nick; /* link to previous nick */
struct t_gui_nick *next_nick; /* link to next nick */
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index 67289a31d..704bb0147 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -189,10 +189,10 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
irc_nick_get_gui_infos (ptr_nick, &prefix,
&prefix_color, channel->buffer, &ptr_group);
snprintf (str_prefix_color, sizeof (str_prefix_color),
- "nicklist_prefix%d",
+ "weechat.color.nicklist_prefix%d",
prefix_color);
weechat_nicklist_add_nick (channel->buffer, ptr_group,
- ptr_nick->name, ptr_nick->color,
+ ptr_nick->name, "weechat.color.nicklist",
prefix, str_prefix_color, 1);
return ptr_nick;
@@ -235,10 +235,11 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
irc_nick_get_gui_infos (new_nick, &prefix, &prefix_color,
channel->buffer, &ptr_group);
snprintf (str_prefix_color, sizeof (str_prefix_color),
- "nicklist_prefix%d",
+ "weechat.color.nicklist_prefix%d",
prefix_color);
+
weechat_nicklist_add_nick (channel->buffer, ptr_group,
- new_nick->name, new_nick->color,
+ new_nick->name, "weechat.color.nicklist",
prefix, str_prefix_color, 1);
/* all is ok, return address of new nick */
@@ -290,7 +291,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
"nicklist_prefix%d",
prefix_color);
weechat_nicklist_add_nick (channel->buffer, ptr_group,
- nick->name, nick->color,
+ nick->name, "weechat.color.nicklist",
prefix, str_prefix_color, 1);
}
@@ -324,7 +325,7 @@ irc_nick_set (struct t_irc_channel *channel,
"nicklist_prefix%d",
prefix_color);
weechat_nicklist_add_nick (channel->buffer, ptr_group,
- nick->name, nick->color,
+ nick->name, "weechat.color.nicklist",
prefix, str_prefix_color, 1);
}
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index fc8c1c194..a1e3c99a9 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -3568,6 +3568,7 @@ irc_protocol_cmd_366 (struct t_irc_server *server, const char *command,
{
struct t_irc_channel *ptr_channel;
struct t_plugin_infolist *infolist;
+ struct t_config_option *ptr_option;
int num_nicks, num_op, num_halfop, num_voice, num_normal, length, i;
char *string, *prefix;
@@ -3590,8 +3591,12 @@ irc_protocol_cmd_366 (struct t_irc_server *server, const char *command,
if (strcmp (weechat_infolist_string (infolist, "type"),
"nick") == 0)
{
+ weechat_config_search_with_string (weechat_infolist_string (infolist,
+ "prefix_color"),
+ NULL, NULL, &ptr_option,
+ NULL);
length +=
- strlen (weechat_infolist_string (infolist, "prefix_color")) +
+ ((ptr_option) ? strlen (weechat_color (weechat_config_string (ptr_option))) : 0) +
strlen (weechat_infolist_string (infolist, "prefix")) +
strlen (IRC_COLOR_CHAT) +
strlen (weechat_infolist_string (infolist, "name")) + 1;
@@ -3612,9 +3617,12 @@ irc_protocol_cmd_366 (struct t_irc_server *server, const char *command,
prefix = weechat_infolist_string (infolist, "prefix");
if (prefix[0] && (prefix[0] != ' '))
{
- strcat (string,
- weechat_color (weechat_infolist_string (infolist,
- "prefix_color")));
+ weechat_config_search_with_string (weechat_infolist_string (infolist,
+ "prefix_color"),
+ NULL, NULL, &ptr_option,
+ NULL);
+ if (ptr_option)
+ strcat (string, weechat_color (weechat_config_string (ptr_option)));
strcat (string, prefix);
}
strcat (string, IRC_COLOR_CHAT);
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 91bf20e36..e979f7e3b 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -451,15 +451,13 @@ plugin_api_infolist_get_add_nicklist (struct t_plugin_infolist *infolist,
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "name", ptr_nick->name))
return 0;
- if (!plugin_infolist_new_var_string (ptr_item, "color",
- gui_color_search_config_str (ptr_nick->color)))
+ if (!plugin_infolist_new_var_string (ptr_item, "color", ptr_nick->color))
return 0;
prefix[0] = ptr_nick->prefix;
prefix[1] = '\0';
if (!plugin_infolist_new_var_string (ptr_item, "prefix", prefix))
return 0;
- if (!plugin_infolist_new_var_string (ptr_item, "prefix_color",
- gui_color_search_config_str (ptr_nick->prefix_color)))
+ if (!plugin_infolist_new_var_string (ptr_item, "prefix_color", ptr_nick->prefix_color))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "visible", ptr_nick->visible))
return 0;
@@ -470,8 +468,7 @@ plugin_api_infolist_get_add_nicklist (struct t_plugin_infolist *infolist,
return 0;
if (!plugin_infolist_new_var_string (ptr_item, "name", ptr_group->name))
return 0;
- if (!plugin_infolist_new_var_string (ptr_item, "color",
- gui_color_search_config_str (ptr_group->color)))
+ if (!plugin_infolist_new_var_string (ptr_item, "color", ptr_group->color))
return 0;
if (!plugin_infolist_new_var_integer (ptr_item, "visible", ptr_group->visible))
return 0;