summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--po/cs.po14
-rw-r--r--po/de.po14
-rw-r--r--po/es.po14
-rw-r--r--po/fr.po10
-rw-r--r--po/hu.po14
-rw-r--r--po/ru.po14
-rw-r--r--po/weechat.pot8
-rw-r--r--src/core/wee-command.c4
-rw-r--r--src/gui/curses/gui-curses-bar.c183
-rw-r--r--src/gui/gui-bar-item.c259
-rw-r--r--src/gui/gui-bar-item.h4
-rw-r--r--src/gui/gui-bar.c61
-rw-r--r--src/gui/gui-bar.h3
-rw-r--r--src/gui/gui-color.c116
-rw-r--r--src/gui/gui-color.h5
-rw-r--r--src/plugins/plugin-api.c90
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c26
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c13
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c12
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c17
-rw-r--r--src/plugins/weechat-plugin.h20
21 files changed, 594 insertions, 307 deletions
diff --git a/po/cs.po b/po/cs.po
index 58ce6a0a6..eb5cbb227 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2008-06-21 11:30+0200\n"
+"POT-Creation-Date: 2008-06-22 10:47+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1683,6 +1683,10 @@ msgid "default text color for bar"
msgstr "barva textu v info baru"
#, fuzzy
+msgid "default delimiter color for bar"
+msgstr "barva textu v info baru"
+
+#, fuzzy
msgid "default background color for bar"
msgstr "barva textu v info baru"
@@ -1698,10 +1702,6 @@ msgstr "Seznam pro aliasy:\n"
msgid "filtered"
msgstr "uživatel byl zablokován"
-#, fuzzy
-msgid "(MORE)"
-msgstr "-VÍCE-"
-
#, fuzzy, c-format
msgid "%sError: a buffer with same name already exists (%s / %s)"
msgstr ""
@@ -4555,6 +4555,10 @@ msgstr "%s DCC: nemohu nastavit 'neblokovaci' volbu na soket\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s chybí argument pro volbu \"%s\"\n"
+#, fuzzy
+#~ msgid "(MORE)"
+#~ msgstr "-VÍCE-"
+
#~ msgid "enable info bar"
#~ msgstr "povolit info bar"
diff --git a/po/de.po b/po/de.po
index 5b51d044a..12e727022 100644
--- a/po/de.po
+++ b/po/de.po
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2008-06-21 11:30+0200\n"
+"POT-Creation-Date: 2008-06-22 10:47+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1684,6 +1684,10 @@ msgid "default text color for bar"
msgstr "Farbe des Infobar-Textes"
#, fuzzy
+msgid "default delimiter color for bar"
+msgstr "Farbe des Infobar-Textes"
+
+#, fuzzy
msgid "default background color for bar"
msgstr "Farbe des Infobar-Textes"
@@ -1699,10 +1703,6 @@ msgstr "Liste der Aliases:\n"
msgid "filtered"
msgstr "/users wurde deaktiviert"
-#, fuzzy
-msgid "(MORE)"
-msgstr "-MEHR-"
-
#, fuzzy, c-format
msgid "%sError: a buffer with same name already exists (%s / %s)"
msgstr ""
@@ -4545,6 +4545,10 @@ msgstr "%s DCC: kann die 'nonblock'-Option für den Socket nicht festlegen\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s fehlende Argumente für die \"--dir\"-Option\n"
+#, fuzzy
+#~ msgid "(MORE)"
+#~ msgstr "-MEHR-"
+
#~ msgid "enable info bar"
#~ msgstr "Infoleiste aktivieren"
diff --git a/po/es.po b/po/es.po
index fd41fff6d..2b04747ad 100644
--- a/po/es.po
+++ b/po/es.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2008-06-21 11:30+0200\n"
+"POT-Creation-Date: 2008-06-22 10:47+0200\n"
"PO-Revision-Date: 2007-09-19 12:09+0200\n"
"Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1668,6 +1668,10 @@ msgid "default text color for bar"
msgstr "color para el texto de la barra de información"
#, fuzzy
+msgid "default delimiter color for bar"
+msgstr "color para el texto de la barra de información"
+
+#, fuzzy
msgid "default background color for bar"
msgstr "color para el texto de la barra de información"
@@ -1682,10 +1686,6 @@ msgstr "Lista de alias:\n"
msgid "filtered"
msgstr "los usuarios han sido desactivados"
-#, fuzzy
-msgid "(MORE)"
-msgstr "-MÁS-"
-
#, fuzzy, c-format
msgid "%sError: a buffer with same name already exists (%s / %s)"
msgstr ""
@@ -4553,6 +4553,10 @@ msgstr "%s no es posible crear el servidor\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s falta un argumento para la opción --dir\n"
+#, fuzzy
+#~ msgid "(MORE)"
+#~ msgstr "-MÁS-"
+
#~ msgid "enable info bar"
#~ msgstr "activa la barra de información"
diff --git a/po/fr.po b/po/fr.po
index 1a1d560b6..10d9fae27 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2008-06-21 11:30+0200\n"
-"PO-Revision-Date: 2008-06-21 11:30+0200\n"
+"POT-Creation-Date: 2008-06-22 10:47+0200\n"
+"PO-Revision-Date: 2008-06-22 10:48+0200\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"MIME-Version: 1.0\n"
@@ -1647,6 +1647,9 @@ msgstr "taille max de la barre en caractères (0 = pas de limite)"
msgid "default text color for bar"
msgstr "couleur du texte par défaut pour la barre"
+msgid "default delimiter color for bar"
+msgstr "couleur du délimiteur par défaut pour la barre"
+
msgid "default background color for bar"
msgstr "couleur du fond par défaut pour la barre"
@@ -1659,9 +1662,6 @@ msgstr "objets de la barre"
msgid "filtered"
msgstr "filtré"
-msgid "(MORE)"
-msgstr "(PLUS)"
-
#, c-format
msgid "%sError: a buffer with same name already exists (%s / %s)"
msgstr "%sErreur: un tampon avec le même nom existe déjà (%s / %s)"
diff --git a/po/hu.po b/po/hu.po
index 8684bb2c9..9f1317a5c 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -12,7 +12,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2008-06-21 11:30+0200\n"
+"POT-Creation-Date: 2008-06-22 10:47+0200\n"
"PO-Revision-Date: 2007-10-10 18:07+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1688,6 +1688,10 @@ msgid "default text color for bar"
msgstr "információs pult szövegének színe"
#, fuzzy
+msgid "default delimiter color for bar"
+msgstr "információs pult szövegének színe"
+
+#, fuzzy
msgid "default background color for bar"
msgstr "információs pult szövegének színe"
@@ -1703,10 +1707,6 @@ msgstr "Aliaszok listája:\n"
msgid "filtered"
msgstr "a felhasználók le lettek tiltva"
-#, fuzzy
-msgid "(MORE)"
-msgstr "-TOVÁBB-"
-
#, fuzzy, c-format
msgid "%sError: a buffer with same name already exists (%s / %s)"
msgstr "%s nem sikerült a \"%s\" modult betölteni: már van ilyen nevű modul\n"
@@ -4561,6 +4561,10 @@ msgstr "%s DCC: nem sikerült 'nonblock' opciót beállítani a csatornán\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n"
+#, fuzzy
+#~ msgid "(MORE)"
+#~ msgstr "-TOVÁBB-"
+
#~ msgid "enable info bar"
#~ msgstr "információs pult engedélyezése"
diff --git a/po/ru.po b/po/ru.po
index 4f7c63c5c..8ab8270d7 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2008-06-21 11:30+0200\n"
+"POT-Creation-Date: 2008-06-22 10:47+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1692,6 +1692,10 @@ msgid "default text color for bar"
msgstr "цвет текста информационной панели"
#, fuzzy
+msgid "default delimiter color for bar"
+msgstr "цвет текста информационной панели"
+
+#, fuzzy
msgid "default background color for bar"
msgstr "цвет текста информационной панели"
@@ -1707,10 +1711,6 @@ msgstr "Список сокращений:\n"
msgid "filtered"
msgstr "команда users отключена"
-#, fuzzy
-msgid "(MORE)"
-msgstr "-ДАЛЬШЕ-"
-
#, fuzzy, c-format
msgid "%sError: a buffer with same name already exists (%s / %s)"
msgstr ""
@@ -4544,6 +4544,10 @@ msgstr "%s DCC: не могу установить неблокирующий р
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s нет аргумента для параметра \"%s\"\n"
+#, fuzzy
+#~ msgid "(MORE)"
+#~ msgstr "-ДАЛЬШЕ-"
+
#~ msgid "enable info bar"
#~ msgstr "включить информационную панель"
diff --git a/po/weechat.pot b/po/weechat.pot
index 943676e88..23fd0dfb6 100644
--- a/po/weechat.pot
+++ b/po/weechat.pot
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2008-06-21 11:30+0200\n"
+"POT-Creation-Date: 2008-06-22 10:47+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1399,6 +1399,9 @@ msgstr ""
msgid "default text color for bar"
msgstr ""
+msgid "default delimiter color for bar"
+msgstr ""
+
msgid "default background color for bar"
msgstr ""
@@ -1411,9 +1414,6 @@ msgstr ""
msgid "filtered"
msgstr ""
-msgid "(MORE)"
-msgstr ""
-
#, c-format
msgid "%sError: a buffer with same name already exists (%s / %s)"
msgstr ""
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 43383043f..253aea0f5 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -208,8 +208,8 @@ command_bar (void *data, struct t_gui_buffer *buffer,
((position == GUI_BAR_POSITION_LEFT)
|| (position == GUI_BAR_POSITION_RIGHT)) ?
"vertical" : "horizontal",
- argv[5], "0", "default", "default", argv[6],
- argv_eol[7]))
+ argv[5], "0", "default", "default", "default",
+ argv[6], argv_eol[7]))
{
gui_chat_printf (NULL, _("Bar \"%s\" created"),
argv[2]);
diff --git a/src/gui/curses/gui-curses-bar.c b/src/gui/curses/gui-curses-bar.c
index fac44ef65..aa40a821b 100644
--- a/src/gui/curses/gui-curses-bar.c
+++ b/src/gui/curses/gui-curses-bar.c
@@ -595,7 +595,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
string++;
switch (string[0])
{
- case 'F':
+ case 'F': /* fg color */
if (string[1] && string[2])
{
str_fg[0] = string[1];
@@ -607,7 +607,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
string += 3;
}
break;
- case 'B':
+ case 'B': /* bg color */
if (string[1] && string[2])
{
str_bg[0] = string[1];
@@ -619,7 +619,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
string += 3;
}
break;
- case '*':
+ case '*': /* fg + bg color */
if (string[1] && string[2] && (string[3] == ',')
&& string[4] && string[5])
{
@@ -636,6 +636,29 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
string += 6;
}
break;
+ case 'b': /* bar color */
+ switch (string[1])
+ {
+ case 'f': /* bar foreground */
+ gui_window_set_custom_color_fg (bar_window->win_bar,
+ CONFIG_INTEGER(bar_window->bar->color_fg));
+ string += 2;
+ break;
+ case 'd': /* bar delimiter */
+ gui_window_set_custom_color_fg (bar_window->win_bar,
+ CONFIG_INTEGER(bar_window->bar->color_delim));
+ string += 2;
+ break;
+ case 'b': /* bar background */
+ gui_window_set_custom_color_bg (bar_window->win_bar,
+ CONFIG_INTEGER(bar_window->bar->color_bg));
+ string += 2;
+ break;
+ default:
+ string++;
+ break;
+ }
+ break;
default:
if (isdigit (string[0]) && isdigit (string[1]))
{
@@ -698,7 +721,6 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
char *content, *item_value, *item_value2, **items;
char space_with_reinit_color[32];
int content_length, length, max_length, optimal_number_of_lines;
- struct t_gui_bar_item *ptr_item;
if (!gui_init_ok)
return;
@@ -709,53 +731,49 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
content_length = 1;
for (i = 0; i < bar_window->bar->items_count; i++)
{
- ptr_item = gui_bar_item_search (bar_window->bar->items_array[i]);
- if (ptr_item && ptr_item->build_callback)
+ item_value = gui_bar_item_get_value (bar_window->bar->items_array[i],
+ bar_window->bar, window,
+ 0, 0);
+ if (item_value)
{
- item_value = (ptr_item->build_callback) (ptr_item->build_callback_data,
- ptr_item, window,
- 0, 0);
- if (item_value)
+ if (item_value[0])
{
- if (item_value[0])
+ if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_HORIZONTAL)
+ {
+ snprintf (space_with_reinit_color,
+ sizeof (space_with_reinit_color),
+ "%c*%02d,%02d ",
+ GUI_COLOR_COLOR_CHAR,
+ CONFIG_COLOR(bar_window->bar->color_fg),
+ CONFIG_COLOR(bar_window->bar->color_bg));
+ item_value2 = string_replace (item_value, "\n",
+ space_with_reinit_color);
+ }
+ else
+ item_value2 = NULL;
+ if (!content)
{
+ content_length += strlen ((item_value2) ?
+ item_value2 : item_value);
+ content = strdup ((item_value2) ?
+ item_value2 : item_value);
+ }
+ else
+ {
+ content_length += 1 +
+ strlen ((item_value2) ? item_value2 : item_value);
+ content = realloc (content, content_length);
if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_HORIZONTAL)
- {
- snprintf (space_with_reinit_color,
- sizeof (space_with_reinit_color),
- "%c*%02d,%02d ",
- GUI_COLOR_COLOR_CHAR,
- CONFIG_COLOR(bar_window->bar->color_fg),
- CONFIG_COLOR(bar_window->bar->color_bg));
- item_value2 = string_replace (item_value, "\n",
- space_with_reinit_color);
- }
- else
- item_value2 = NULL;
- if (!content)
- {
- content_length += strlen ((item_value2) ?
- item_value2 : item_value);
- content = strdup ((item_value2) ?
- item_value2 : item_value);
- }
+ strcat (content, " ");
else
- {
- content_length += 1 +
- strlen ((item_value2) ? item_value2 : item_value);
- content = realloc (content, content_length);
- if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_HORIZONTAL)
- strcat (content, " ");
- else
- strcat (content, "\n");
- strcat (content,
- (item_value2) ? item_value2 : item_value);
- }
- if (item_value2)
- free (item_value2);
+ strcat (content, "\n");
+ strcat (content,
+ (item_value2) ? item_value2 : item_value);
}
- free (item_value);
+ if (item_value2)
+ free (item_value2);
}
+ free (item_value);
}
}
if (content)
@@ -856,57 +874,56 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
for (i = 0; i < bar_window->bar->items_count; i++)
{
- ptr_item = gui_bar_item_search (bar_window->bar->items_array[i]);
- if (ptr_item && ptr_item->build_callback)
+ item_value = gui_bar_item_get_value (bar_window->bar->items_array[i],
+ bar_window->bar, window,
+ bar_window->width,
+ bar_window->height);
+ if (item_value)
{
- item_value = (ptr_item->build_callback) (ptr_item->build_callback_data,
- ptr_item, window,
- bar_window->width,
- bar_window->height);
- if (item_value)
+ if (item_value[0])
{
- if (item_value[0])
+ if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_HORIZONTAL)
{
- if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_HORIZONTAL)
+ snprintf (space_with_reinit_color,
+ sizeof (space_with_reinit_color),
+ "%c*%02d,%02d ",
+ GUI_COLOR_COLOR_CHAR,
+ CONFIG_COLOR(bar_window->bar->color_fg),
+ CONFIG_COLOR(bar_window->bar->color_bg));
+ item_value2 = string_replace (item_value, "\n",
+ space_with_reinit_color);
+ }
+ else
+ item_value2 = NULL;
+ items = string_explode ((item_value2) ?
+ item_value2 : item_value,
+ "\n", 0, 0,
+ &items_count);
+ 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)
{
- snprintf (space_with_reinit_color,
- sizeof (space_with_reinit_color),
- "%c*%02d,%02d ",
- GUI_COLOR_COLOR_CHAR,
- CONFIG_COLOR(bar_window->bar->color_fg),
- CONFIG_COLOR(bar_window->bar->color_bg));
- item_value2 = string_replace (item_value, "\n",
- space_with_reinit_color);
+ x = 0;
+ y++;
}
else
- item_value2 = NULL;
- items = string_explode ((item_value2) ?
- item_value2 : item_value,
- "\n", 0, 0,
- &items_count);
- 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)
- {
- x = 0;
- y++;
- }
- }
- if (item_value2)
- free (item_value2);
- if (items)
- string_free_exploded (items);
+ " ");
}
- free (item_value);
+ if (item_value2)
+ free (item_value2);
+ if (items)
+ string_free_exploded (items);
}
+ free (item_value);
}
}
}
-
+
wnoutrefresh (bar_window->win_bar);
if (CONFIG_INTEGER(bar_window->bar->separator))
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index 6ee48ee1e..413dfaf9a 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -99,6 +99,157 @@ gui_bar_item_search_with_plugin (struct t_weechat_plugin *plugin, const char *na
}
/*
+ * gui_bar_item_valid_char_name: return 1 if char is valid for item name
+ * (any letter, digit, "-" or "_")
+ * return 0 otherwise
+ */
+
+int
+gui_bar_item_valid_char_name (char c)
+{
+ return (((c >= 'a') && (c <= 'z'))
+ || ((c >= 'A') && (c <= 'Z'))
+ || ((c >= '0') && (c <= '9'))
+ || (c == '-')
+ || (c == '_')) ?
+ 1 : 0;
+}
+
+/*
+ * gui_bar_item_get_value: return value of a bar item
+ * first look for prefix/suffix in name, then run item
+ * callback (if found) and concatene strings
+ * for example: if name == "[time]"
+ * return: color(delimiter) + "[" +
+ * (value of item "time") + color(delimiter) +
+ * "]"
+ */
+
+char *
+gui_bar_item_get_value (const char *name, struct t_gui_bar *bar,
+ struct t_gui_window *window,
+ int width, int height)
+{
+ const char *ptr, *start, *end;
+ char *prefix, *item_name, *suffix;
+ char *item_value, delimiter_color[32], bar_color[32];
+ char *result;
+ int valid_char, length;
+ struct t_gui_bar_item *ptr_item;
+
+ start = NULL;
+ end = NULL;
+ prefix = NULL;
+ item_name = NULL;
+ suffix = NULL;
+
+ ptr = name;
+ while (ptr && ptr[0])
+ {
+ valid_char = gui_bar_item_valid_char_name (ptr[0]);
+ if (!start && valid_char)
+ start = ptr;
+ else if (start && !end && !valid_char)
+ end = ptr - 1;
+ ptr++;
+ }
+ if (start)
+ {
+ if (start > name)
+ prefix = string_strndup (name, start - name);
+ }
+ else
+ prefix = strdup (name);
+ if (start)
+ {
+ item_name = (end) ?
+ string_strndup (start, end - start + 1) : strdup (start);
+ }
+ if (end && end[0] && end[1])
+ suffix = strdup (end + 1);
+
+ item_value = NULL;
+ if (item_name)
+ {
+ ptr_item = gui_bar_item_search (item_name);
+ if (ptr_item)
+ {
+ if (ptr_item->build_callback)
+ {
+ item_value = (ptr_item->build_callback) (ptr_item->build_callback_data,
+ ptr_item, window,
+ width,
+ height);
+ if (!item_value || !item_value[0])
+ {
+ if (prefix)
+ {
+ free (prefix);
+ prefix = NULL;
+ }
+ if (suffix)
+ {
+ free (suffix);
+ suffix = NULL;
+ }
+ }
+ }
+ }
+ else
+ item_value = strdup (item_name);
+ }
+
+ length = 0;
+ if (prefix)
+ length += 64 + strlen (prefix) + 1; /* color + prefix + color */
+ if (item_value && item_value[0])
+ length += strlen (item_value) + 1;
+ if (suffix)
+ length += 32 + strlen (suffix) + 1; /* color + suffix */
+
+ result = NULL;
+ if (length > 0)
+ {
+ result = malloc (length);
+ if (result)
+ {
+ delimiter_color[0] = '\0';
+ bar_color[0] = '\0';
+ if (prefix || suffix)
+ {
+ snprintf (delimiter_color, sizeof (delimiter_color),
+ "%cF%02d",
+ GUI_COLOR_COLOR_CHAR,
+ CONFIG_COLOR(bar->color_delim));
+ snprintf (bar_color, sizeof (bar_color),
+ "%cF%02d",
+ GUI_COLOR_COLOR_CHAR,
+ CONFIG_COLOR(bar->color_fg));
+ }
+ snprintf (result, length,
+ "%s%s%s%s%s%s",
+ (prefix) ? delimiter_color : "",
+ (prefix) ? prefix : "",
+ (prefix) ? bar_color : "",
+ (item_value) ? item_value : "",
+ (suffix) ? delimiter_color : "",
+ (suffix) ? suffix : "");
+ }
+ }
+
+ if (prefix)
+ free (prefix);
+ if (item_name)
+ free (item_name);
+ if (suffix)
+ free (suffix);
+ if (item_value)
+ free (item_value);
+
+ return result;
+}
+
+/*
* gui_bar_item_new: create a new bar item
*/
@@ -115,7 +266,7 @@ gui_bar_item_new (struct t_weechat_plugin *plugin, const char *name,
if (!name || !name[0])
return NULL;
- /* it's not possible to create 2 bar items with same name for same plugin*/
+ /* it's not possible to create 2 bar items with same name for same plugin */
if (gui_bar_item_search_with_plugin (plugin, name))
return NULL;
@@ -151,14 +302,25 @@ gui_bar_item_new (struct t_weechat_plugin *plugin, const char *name,
int
gui_bar_contains_item (struct t_gui_bar *bar, const char *name)
{
- int i;
+ int i, length;
+ char *ptr;
if (!bar || !name || !name[0])
return 0;
+ length = strlen (name);
+
for (i = 0; i < bar->items_count; i++)
{
- if (strcmp (bar->items_array[i], name) == 0)
+ /* skip non letters chars at beginning (prefix) */
+ ptr = bar->items_array[i];
+ while (ptr && ptr[0])
+ {
+ if (gui_bar_item_valid_char_name (ptr[0]))
+ break;
+ ptr++;
+ }
+ if (ptr && ptr[0] && (strncmp (ptr, name, length) == 0))
return 1;
}
@@ -251,7 +413,7 @@ gui_bar_item_default_time (void *data, struct t_gui_bar_item *item,
{
time_t date;
struct tm *local_time;
- char text_time[128], buf[512];
+ char text_time[128];
/* make C compiler happy */
(void) data;
@@ -267,13 +429,7 @@ gui_bar_item_default_time (void *data, struct t_gui_bar_item *item,
local_time) == 0)
return NULL;
- snprintf (buf, sizeof (buf), "%s[%s%s%s]",
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
- GUI_COLOR(GUI_COLOR_STATUS),
- text_time,
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
-
- return strdup (buf);
+ return strdup (text_time);
}
/*
@@ -285,7 +441,7 @@ gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window,
int max_width, int max_height)
{
- char buf[64];
+ char buf[32];
/* make C compiler happy */
(void) data;
@@ -294,11 +450,8 @@ gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item,
(void) max_width;
(void) max_height;
- snprintf (buf, sizeof (buf), "%s[%s%d%s]",
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
- GUI_COLOR(GUI_COLOR_STATUS),
- (last_gui_buffer) ? last_gui_buffer->number : 0,
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
+ snprintf (buf, sizeof (buf), "%d",
+ (last_gui_buffer) ? last_gui_buffer->number : 0);
return strdup (buf);
}
@@ -312,8 +465,6 @@ gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window,
int max_width, int max_height)
{
- char buf[64];
-
/* make C compiler happy */
(void) data;
(void) item;
@@ -323,13 +474,8 @@ gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
if (!window)
window = gui_current_window;
- snprintf (buf, sizeof (buf), "%s[%s%s%s]",
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
- GUI_COLOR(GUI_COLOR_STATUS),
- (window->buffer->plugin) ? window->buffer->plugin->name : "core",
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
-
- return strdup (buf);
+ return (window->buffer->plugin) ?
+ strdup (window->buffer->plugin->name) : strdup ("core");
}
/*
@@ -353,13 +499,13 @@ gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item,
window = gui_current_window;
snprintf (buf, sizeof (buf), "%s%d%s:%s%s%s/%s%s",
- GUI_COLOR(GUI_COLOR_STATUS_NUMBER),
+ gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_number))),
window->buffer->number,
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
- GUI_COLOR(GUI_COLOR_STATUS_CATEGORY),
+ GUI_COLOR_BAR_DELIM,
+ gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_category))),
window->buffer->category,
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
- GUI_COLOR(GUI_COLOR_STATUS_NAME),
+ GUI_COLOR_BAR_DELIM,
+ gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_name))),
window->buffer->name);
return strdup (buf);
@@ -389,12 +535,9 @@ gui_bar_item_default_buffer_filter (void *data, struct t_gui_bar_item *item,
return NULL;
snprintf (buf, sizeof (buf),
- "%s[%sF%s%s%s] ",
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
- GUI_COLOR(GUI_COLOR_STATUS),
+ "F%s%s",
(window->buffer->lines_hidden) ? "," : "",
- (window->buffer->lines_hidden) ? _("filtered") : "",
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
+ (window->buffer->lines_hidden) ? _("filtered") : "");
return strdup (buf);
}
@@ -409,7 +552,7 @@ 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)
{
- char buf[64];
+ char buf[32];
/* make C compiler happy */
(void) data;
@@ -423,11 +566,8 @@ gui_bar_item_default_nicklist_count (void *data, struct t_gui_bar_item *item,
if (!window->buffer->nicklist)
return NULL;
- snprintf (buf, sizeof (buf), "%s[%s%d%s]",
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
- GUI_COLOR(GUI_COLOR_STATUS),
- window->buffer->nicklist_visible_count,
- GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
+ snprintf (buf, sizeof (buf), "%d",
+ window->buffer->nicklist_visible_count);
return strdup (buf);
}
@@ -456,8 +596,8 @@ gui_bar_item_default_scroll (void *data, struct t_gui_bar_item *item,
return NULL;
snprintf (buf, sizeof (buf), "%s%s",
- GUI_COLOR(GUI_COLOR_STATUS_MORE),
- _("(MORE)"));
+ gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_more))),
+ _("-MORE-"));
return strdup (buf);
}
@@ -487,9 +627,6 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
buf[0] = '\0';
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
- strcat (buf, "[");
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS));
strcat (buf, _("Act: "));
names_count = 0;
@@ -499,19 +636,19 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
switch (ptr_hotlist->priority)
{
case GUI_HOTLIST_LOW:
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DATA_OTHER));
+ strcat (buf, gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_data_other))));
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 1) != 0);
break;
case GUI_HOTLIST_MESSAGE:
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DATA_MSG));
+ strcat (buf, gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_data_msg))));
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 2) != 0);
break;
case GUI_HOTLIST_PRIVATE:
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DATA_PRIVATE));
+ strcat (buf, gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_data_private))));
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 4) != 0);
break;
case GUI_HOTLIST_HIGHLIGHT:
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DATA_HIGHLIGHT));
+ strcat (buf, gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_data_highlight))));
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 8) != 0);
break;
default:
@@ -527,9 +664,9 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
{
names_count++;
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
+ strcat (buf, GUI_COLOR_BAR_DELIM);
strcat (buf, ":");
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS));
+ strcat (buf, GUI_COLOR_BAR_FG);
if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0)
snprintf (format, sizeof (format) - 1, "%%s");
else
@@ -545,8 +682,6 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
if (strlen (buf) > sizeof (buf) - 32)
break;
}
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
- strcat (buf, "]");
return strdup (buf);
}
@@ -570,13 +705,14 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item,
(void) window;
(void) max_width;
(void) max_height;
-
+
length = 1;
for (ptr_item = gui_completion_partial_list; ptr_item;
ptr_item = ptr_item->next_item)
{
length += strlen (ptr_item->word) + 32;
}
+
buf = malloc (length);
if (buf)
{
@@ -584,11 +720,11 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item,
for (ptr_item = gui_completion_partial_list; ptr_item;
ptr_item = ptr_item->next_item)
{
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS));
+ strcat (buf, GUI_COLOR_BAR_FG);
strcat (buf, ptr_item->word);
if (ptr_item->count > 0)
{
- strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
+ strcat (buf, GUI_COLOR_BAR_DELIM);
strcat (buf, "(");
snprintf (number_str, sizeof (number_str),
"%d", ptr_item->count);
@@ -598,9 +734,9 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item,
if (ptr_item->next_item)
strcat (buf, " ");
}
- return buf;
}
- return NULL;
+
+ return buf;
}
/*
@@ -622,6 +758,9 @@ gui_bar_item_timer_cb (void *data)
local_time) == 0)
return WEECHAT_RC_OK;
+ /* we update item only if it changed since last time
+ for example if time is only hours:minutes, we'll update
+ only when minute changed */
if (strcmp (new_item_time_text, item_time_text) != 0)
{
snprintf (item_time_text, sizeof (item_time_text),
diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h
index 05686e7ea..364127e22 100644
--- a/src/gui/gui-bar-item.h
+++ b/src/gui/gui-bar-item.h
@@ -65,6 +65,10 @@ extern struct t_gui_bar_item *last_gui_bar_item;
/* functions */
extern struct t_gui_bar_item *gui_bar_item_search (const char *name);
+extern char *gui_bar_item_get_value (const char *name,
+ struct t_gui_bar *bar,
+ struct t_gui_window *window,
+ int width, int height);
extern struct t_gui_bar_item *gui_bar_item_new (struct t_weechat_plugin *plugin,
const char *name,
char *(*build_callback)(void *data,
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index f5413fc8a..9b4470674 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -40,7 +40,7 @@
char *gui_bar_option_string[GUI_BAR_NUM_OPTIONS] =
{ "priority", "type", "conditions", "position", "filling", "size", "size_max",
- "color_fg", "color_bg", "separator", "items" };
+ "color_fg", "color_delim", "color_bg", "separator", "items" };
char *gui_bar_type_string[GUI_BAR_NUM_TYPES] =
{ "root", "window" };
char *gui_bar_position_string[GUI_BAR_NUM_POSITIONS] =
@@ -609,6 +609,8 @@ gui_bar_set_name (struct t_gui_bar *bar, const char *name)
config_file_option_rename (bar->size_max, option_name);
snprintf (option_name, length, "%s.color_fg", name);
config_file_option_rename (bar->color_fg, option_name);
+ snprintf (option_name, length, "%s.color_delim", name);
+ config_file_option_rename (bar->color_delim, option_name);
snprintf (option_name, length, "%s.color_bg", name);
config_file_option_rename (bar->color_bg, option_name);
snprintf (option_name, length, "%s.separator", name);
@@ -831,6 +833,12 @@ gui_bar_set (struct t_gui_bar *bar, const char *property, const char *value)
gui_bar_refresh (bar);
return 1;
}
+ else if (string_strcasecmp (property, "color_delim") == 0)
+ {
+ config_file_option_set (bar->color_delim, value, 1);
+ gui_bar_refresh (bar);
+ return 1;
+ }
else if (string_strcasecmp (property, "color_bg") == 0)
{
config_file_option_set (bar->color_bg, value, 1);
@@ -950,6 +958,16 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
&gui_bar_config_change_color, NULL,
NULL, NULL);
break;
+ case GUI_BAR_OPTION_COLOR_DELIM:
+ ptr_option = config_file_new_option (
+ weechat_config_file, weechat_config_section_bar,
+ option_name, "color",
+ N_("default delimiter color for bar"),
+ NULL, 0, 0, value,
+ NULL, NULL,
+ &gui_bar_config_change_color, NULL,
+ NULL, NULL);
+ break;
case GUI_BAR_OPTION_COLOR_BG:
ptr_option = config_file_new_option (
weechat_config_file, weechat_config_section_bar,
@@ -1026,6 +1044,9 @@ gui_bar_create_option_temp (struct t_gui_bar *temp_bar, int index_option,
case GUI_BAR_OPTION_COLOR_FG:
temp_bar->color_fg = new_option;
break;
+ case GUI_BAR_OPTION_COLOR_DELIM:
+ temp_bar->color_delim = new_option;
+ break;
case GUI_BAR_OPTION_COLOR_BG:
temp_bar->color_bg = new_option;
break;
@@ -1061,6 +1082,7 @@ gui_bar_alloc (const char *name)
new_bar->size = NULL;
new_bar->size_max = NULL;
new_bar->color_fg = NULL;
+ new_bar->color_delim = NULL;
new_bar->color_bg = NULL;
new_bar->separator = NULL;
new_bar->items = NULL;
@@ -1090,6 +1112,7 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name,
struct t_config_option *size,
struct t_config_option *size_max,
struct t_config_option *color_fg,
+ struct t_config_option *color_delim,
struct t_config_option *color_bg,
struct t_config_option *separator,
struct t_config_option *items)
@@ -1121,6 +1144,7 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, const char *name,
new_bar->size = size;
new_bar->size_max = size_max;
new_bar->color_fg = color_fg;
+ new_bar->color_delim = color_delim;
new_bar->color_bg = color_bg;
new_bar->separator = separator;
new_bar->items = items;
@@ -1169,12 +1193,14 @@ struct t_gui_bar *
gui_bar_new (struct t_weechat_plugin *plugin, const char *name,
const char *priority, const char *type, const char *conditions,
const char *position, const char *filling, const char *size,
- const char *size_max, const char *color_fg, const char *color_bg,
+ const char *size_max, const char *color_fg,
+ const char *color_delim, const char *color_bg,
const char *separators, const char *items)
{
struct t_config_option *option_priority, *option_type, *option_conditions;
struct t_config_option *option_position, *option_filling, *option_size;
- struct t_config_option *option_size_max, *option_color_fg, *option_color_bg;
+ struct t_config_option *option_size_max, *option_color_fg;
+ struct t_config_option *option_color_delim, *option_color_bg;
struct t_config_option *option_separator, *option_items;
struct t_gui_bar *new_bar;
@@ -1209,6 +1235,8 @@ gui_bar_new (struct t_weechat_plugin *plugin, const char *name,
size_max);
option_color_fg = gui_bar_create_option (name, GUI_BAR_OPTION_COLOR_FG,
color_fg);
+ option_color_delim = gui_bar_create_option (name, GUI_BAR_OPTION_COLOR_DELIM,
+ color_delim);
option_color_bg = gui_bar_create_option (name, GUI_BAR_OPTION_COLOR_BG,
color_bg);
option_separator = gui_bar_create_option (name, GUI_BAR_OPTION_SEPARATOR,
@@ -1220,8 +1248,9 @@ gui_bar_new (struct t_weechat_plugin *plugin, const char *name,
option_type,option_conditions,
option_position, option_filling,
option_size, option_size_max,
- option_color_fg, option_color_bg,
- option_separator, option_items);
+ option_color_fg, option_color_delim,
+ option_color_bg, option_separator,
+ option_items);
if (!new_bar)
{
if (option_priority)
@@ -1240,6 +1269,8 @@ gui_bar_new (struct t_weechat_plugin *plugin, const char *name,
config_file_option_free (option_size_max);
if (option_color_fg)
config_file_option_free (option_color_fg);
+ if (option_color_delim)
+ config_file_option_free (option_color_delim);
if (option_color_bg)
config_file_option_free (option_color_bg);
if (option_separator)
@@ -1304,6 +1335,11 @@ gui_bar_use_temp_bars ()
GUI_BAR_OPTION_COLOR_FG,
"default");
+ if (!ptr_temp_bar->color_delim)
+ ptr_temp_bar->color_delim = gui_bar_create_option (ptr_temp_bar->name,
+ GUI_BAR_OPTION_COLOR_DELIM,
+ "default");
+
if (!ptr_temp_bar->color_bg)
ptr_temp_bar->color_bg = gui_bar_create_option (ptr_temp_bar->name,
GUI_BAR_OPTION_COLOR_BG,
@@ -1323,8 +1359,8 @@ gui_bar_use_temp_bars ()
&& ptr_temp_bar->conditions && ptr_temp_bar->position
&& ptr_temp_bar->filling && ptr_temp_bar->size
&& ptr_temp_bar->size_max && ptr_temp_bar->color_fg
- && ptr_temp_bar->color_bg && ptr_temp_bar->separator
- && ptr_temp_bar->items)
+ && ptr_temp_bar->color_delim && ptr_temp_bar->color_bg
+ && ptr_temp_bar->separator && ptr_temp_bar->items)
{
gui_bar_new_with_options (NULL, ptr_temp_bar->name,
ptr_temp_bar->priority,
@@ -1335,6 +1371,7 @@ gui_bar_use_temp_bars ()
ptr_temp_bar->size,
ptr_temp_bar->size_max,
ptr_temp_bar->color_fg,
+ ptr_temp_bar->color_delim,
ptr_temp_bar->color_bg,
ptr_temp_bar->separator,
ptr_temp_bar->items);
@@ -1381,6 +1418,11 @@ gui_bar_use_temp_bars ()
config_file_option_free (ptr_temp_bar->color_fg);
ptr_temp_bar->color_fg = NULL;
}
+ if (ptr_temp_bar->color_delim)
+ {
+ config_file_option_free (ptr_temp_bar->color_delim);
+ ptr_temp_bar->color_delim = NULL;
+ }
if (ptr_temp_bar->color_bg)
{
config_file_option_free (ptr_temp_bar->color_bg);
@@ -1474,6 +1516,8 @@ gui_bar_free (struct t_gui_bar *bar)
config_file_option_free (bar->size_max);
if (bar->color_fg)
config_file_option_free (bar->color_fg);
+ if (bar->color_delim)
+ config_file_option_free (bar->color_delim);
if (bar->color_bg)
config_file_option_free (bar->color_bg);
if (bar->separator)
@@ -1555,6 +1599,9 @@ gui_bar_print_log ()
log_printf (" color_fg . . . . . . . : %d",
CONFIG_COLOR(ptr_bar->color_fg),
gui_color_get_name (CONFIG_COLOR(ptr_bar->color_fg)));
+ log_printf (" color_delim. . . . . . : %d",
+ CONFIG_COLOR(ptr_bar->color_delim),
+ gui_color_get_name (CONFIG_COLOR(ptr_bar->color_delim)));
log_printf (" color_bg . . . . . . . : %d",
CONFIG_COLOR(ptr_bar->color_bg),
gui_color_get_name (CONFIG_COLOR(ptr_bar->color_bg)));
diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h
index 78b9d055a..4e59d70c8 100644
--- a/src/gui/gui-bar.h
+++ b/src/gui/gui-bar.h
@@ -33,6 +33,7 @@ enum t_gui_bar_option
GUI_BAR_OPTION_SIZE,
GUI_BAR_OPTION_SIZE_MAX,
GUI_BAR_OPTION_COLOR_FG,
+ GUI_BAR_OPTION_COLOR_DELIM,
GUI_BAR_OPTION_COLOR_BG,
GUI_BAR_OPTION_SEPARATOR,
GUI_BAR_OPTION_ITEMS,
@@ -79,6 +80,7 @@ struct t_gui_bar
struct t_config_option *size; /* size of bar (in chars, 0 = auto) */
struct t_config_option *size_max; /* max size of bar (0 = no limit) */
struct t_config_option *color_fg; /* default text color for bar */
+ struct t_config_option *color_delim;/* default delimiter color for bar */
struct t_config_option *color_bg; /* default background color for bar */
struct t_config_option *separator; /* true if separator line displayed */
struct t_config_option *items; /* bar items */
@@ -126,6 +128,7 @@ extern struct t_gui_bar *gui_bar_new (struct t_weechat_plugin *plugin,
const char *filling, const char *size,
const char *size_max,
const char *color_fg,
+ const char *color_delim,
const char *color_bg,
const char *separator,
const char *items);
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index e7bc2c2c2..48f849ae4 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -100,6 +100,122 @@ gui_color_search_config_str (int color_number)
}
/*
+ * gui_color_get_custom: get a custom color with a name (GUI dependent)
+ */
+
+char *
+gui_color_get_custom (const char *color_name)
+{
+ int fg, bg;
+ static char color[20][16];
+ static int index_color = 0;
+ char *pos_comma, *str_fg, *pos_bg;
+
+ /* attribute or other color name (GUI dependent) */
+ index_color = (index_color + 1) % 20;
+ color[index_color][0] = '\0';
+
+ if (string_strcasecmp (color_name, "reset") == 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s",
+ GUI_COLOR_RESET_STR);
+ }
+ else if (string_strcasecmp (color_name, "bold") == 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s",
+ GUI_COLOR_SET_STR,
+ GUI_COLOR_ATTR_BOLD_STR);
+ }
+ else if (string_strcasecmp (color_name, "reverse") == 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s",
+ GUI_COLOR_SET_STR,
+ GUI_COLOR_ATTR_REVERSE_STR);
+ }
+ else if (string_strcasecmp (color_name, "italic") == 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s",
+ GUI_COLOR_SET_STR,
+ GUI_COLOR_ATTR_ITALIC_STR);
+ }
+ else if (string_strcasecmp (color_name, "underline") == 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s%s",
+ GUI_COLOR_SET_STR,
+ GUI_COLOR_ATTR_UNDERLINE_STR);
+ }
+ else if (string_strcasecmp (color_name, "bar_fg") == 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%cbf",
+ GUI_COLOR_COLOR_CHAR);
+ }
+ else if (string_strcasecmp (color_name, "bar_delim") == 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%cbd",
+ GUI_COLOR_COLOR_CHAR);
+ }
+ else if (string_strcasecmp (color_name, "bar_bg") == 0)
+ {
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%cbb",
+ GUI_COLOR_COLOR_CHAR);
+ }
+ else
+ {
+ /* custom color name (GUI dependent) */
+ pos_comma = strchr (color_name, ',');
+ if (pos_comma)
+ {
+ if (pos_comma == color_name)
+ str_fg = NULL;
+ else
+ str_fg = string_strndup (color_name, pos_comma - color_name);
+ pos_bg = pos_comma + 1;
+ }
+ else
+ {
+ str_fg = strdup (color_name);
+ pos_bg = NULL;
+ }
+
+ if (str_fg && pos_bg)
+ {
+ fg = gui_color_search (str_fg);
+ bg = gui_color_search (pos_bg);
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%s*%02d,%02d",
+ GUI_COLOR_COLOR_STR, fg, bg);
+ }
+ else if (str_fg && !pos_bg)
+ {
+ fg = gui_color_search (str_fg);
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%sF%02d",
+ GUI_COLOR_COLOR_STR, fg);
+ }
+ else if (!str_fg && pos_bg)
+ {
+ bg = gui_color_search (pos_bg);
+ snprintf (color[index_color], sizeof (color[index_color]),
+ "%sB%02d",
+ GUI_COLOR_COLOR_STR, bg);
+ }
+
+ if (str_fg)
+ free (str_fg);
+ }
+
+ return color[index_color];
+}
+
+/*
* gui_color_decode: parses a message and remove WeeChat color codes
* After use, string returned has to be free()
*/
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 647519218..f943dd7a5 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -117,6 +117,10 @@ enum t_gui_color_enum
#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "")
#define GUI_NO_COLOR GUI_COLOR_RESET_STR
+#define GUI_COLOR_BAR_FG (gui_color_get_custom ("bar_fg"))
+#define GUI_COLOR_BAR_DELIM (gui_color_get_custom ("bar_delim"))
+#define GUI_COLOR_BAR_BG (gui_color_get_custom ("bar_bg"))
+
/* color structure */
struct t_gui_color
@@ -135,6 +139,7 @@ extern struct t_gui_color *gui_color[];
extern int gui_color_search_config_int (const char *color_name);
extern char *gui_color_search_config_str (int color_number);
+extern char *gui_color_get_custom (const char *color_name);
extern unsigned char *gui_color_decode (const unsigned char *string);
extern void gui_color_free (struct t_gui_color *color);
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 33ca576b2..91bf20e36 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -222,10 +222,7 @@ plugin_api_prefix (const char *prefix)
char *
plugin_api_color (const char *color_name)
{
- int num_color, fg, bg;
- static char color[20][16];
- static int index_color = 0;
- char *pos_comma, *str_fg, *pos_bg;
+ int num_color;
if (!color_name)
return GUI_NO_COLOR;
@@ -234,91 +231,8 @@ plugin_api_color (const char *color_name)
num_color = gui_color_search_config_int (color_name);
if (num_color >= 0)
return GUI_COLOR(num_color);
-
- /* attribute or other color name (GUI dependent) */
- index_color = (index_color + 1) % 20;
- color[index_color][0] = '\0';
- if (string_strcasecmp (color_name, "reset") == 0)
- {
- snprintf (color[index_color], sizeof (color[index_color]),
- "%s",
- GUI_COLOR_RESET_STR);
- }
- else if (string_strcasecmp (color_name, "bold") == 0)
- {
- snprintf (color[index_color], sizeof (color[index_color]),
- "%s%s",
- GUI_COLOR_SET_STR,
- GUI_COLOR_ATTR_BOLD_STR);
- }
- else if (string_strcasecmp (color_name, "reverse") == 0)
- {
- snprintf (color[index_color], sizeof (color[index_color]),
- "%s%s",
- GUI_COLOR_SET_STR,
- GUI_COLOR_ATTR_REVERSE_STR);
- }
- else if (string_strcasecmp (color_name, "italic") == 0)
- {
- snprintf (color[index_color], sizeof (color[index_color]),
- "%s%s",
- GUI_COLOR_SET_STR,
- GUI_COLOR_ATTR_ITALIC_STR);
- }
- else if (string_strcasecmp (color_name, "underline") == 0)
- {
- snprintf (color[index_color], sizeof (color[index_color]),
- "%s%s",
- GUI_COLOR_SET_STR,
- GUI_COLOR_ATTR_UNDERLINE_STR);
- }
- else
- {
- /* custom color name (GUI dependent) */
- pos_comma = strchr (color_name, ',');
- if (pos_comma)
- {
- if (pos_comma == color_name)
- str_fg = NULL;
- else
- str_fg = string_strndup (color_name, pos_comma - color_name);
- pos_bg = pos_comma + 1;
- }
- else
- {
- str_fg = strdup (color_name);
- pos_bg = NULL;
- }
-
- if (str_fg && pos_bg)
- {
- fg = gui_color_search (str_fg);
- bg = gui_color_search (pos_bg);
- snprintf (color[index_color], sizeof (color[index_color]),
- "%s*%02d,%02d",
- GUI_COLOR_COLOR_STR, fg, bg);
- }
- else if (str_fg && !pos_bg)
- {
- fg = gui_color_search (str_fg);
- snprintf (color[index_color], sizeof (color[index_color]),
- "%sF%02d",
- GUI_COLOR_COLOR_STR, fg);
- }
- else if (!str_fg && pos_bg)
- {
- bg = gui_color_search (pos_bg);
- snprintf (color[index_color], sizeof (color[index_color]),
- "%sB%02d",
- GUI_COLOR_COLOR_STR, bg);
- }
-
- if (str_fg)
- free (str_fg);
- }
-
- return color[index_color];
+ return gui_color_get_custom (color_name);
}
/*
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index 0b0db0ff3..57be59a0b 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -4038,7 +4038,8 @@ static int
weechat_lua_api_bar_new (lua_State *L)
{
const char *name, *priority, *type, *conditions, *position, *filling;
- const char *size, *size_max, *color_fg, *color_bg, *separator, *items;
+ const char *size, *size_max, *color_fg, *color_delim, *color_bg;
+ const char *separator, *items;
char *result;
int n;
@@ -4060,27 +4061,29 @@ weechat_lua_api_bar_new (lua_State *L)
size = NULL;
size_max = NULL;
color_fg = NULL;
+ color_delim = NULL;
color_bg = NULL;
separator = NULL;
items = NULL;
n = lua_gettop (lua_current_interpreter);
- if (n < 12)
+ if (n < 13)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
LUA_RETURN_EMPTY;
}
- name = lua_tostring (lua_current_interpreter, -12);
- priority = lua_tostring (lua_current_interpreter, -11);
- type = lua_tostring (lua_current_interpreter, -10);
- conditions = lua_tostring (lua_current_interpreter, -9);
- position = lua_tostring (lua_current_interpreter, -8);
- filling = lua_tostring (lua_current_interpreter, -7);
- size = lua_tostring (lua_current_interpreter, -6);
- size_max = lua_tostring (lua_current_interpreter, -5);
- color_fg = lua_tostring (lua_current_interpreter, -4);
+ name = lua_tostring (lua_current_interpreter, -13);
+ priority = lua_tostring (lua_current_interpreter, -12);
+ type = lua_tostring (lua_current_interpreter, -11);
+ conditions = lua_tostring (lua_current_interpreter, -10);
+ position = lua_tostring (lua_current_interpreter, -9);
+ filling = lua_tostring (lua_current_interpreter, -8);
+ size = lua_tostring (lua_current_interpreter, -7);
+ size_max = lua_tostring (lua_current_interpreter, -6);
+ color_fg = lua_tostring (lua_current_interpreter, -5);
+ color_delim = lua_tostring (lua_current_interpreter, -4);
color_bg = lua_tostring (lua_current_interpreter, -3);
separator = lua_tostring (lua_current_interpreter, -2);
items = lua_tostring (lua_current_interpreter, -1);
@@ -4094,6 +4097,7 @@ weechat_lua_api_bar_new (lua_State *L)
size,
size_max,
color_fg,
+ color_delim,
color_bg,
separator,
items));
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index a77fbe329..47a9c6a9a 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -3354,7 +3354,8 @@ static XS (XS_weechat_bar_search)
static XS (XS_weechat_bar_new)
{
char *result, *name, *priority, *type, *conditions, *position, *filling;
- char *size, *size_max, *color_fg, *color_bg, *separator, *bar_items;
+ char *size, *size_max, *color_fg, *color_delim, *color_bg, *separator;
+ char *bar_items;
dXSARGS;
/* make C compiler happy */
@@ -3366,7 +3367,7 @@ static XS (XS_weechat_bar_new)
PERL_RETURN_EMPTY;
}
- if (items < 12)
+ if (items < 13)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
PERL_RETURN_EMPTY;
@@ -3381,9 +3382,10 @@ static XS (XS_weechat_bar_new)
size = SvPV (ST (6), PL_na);
size_max = SvPV (ST (7), PL_na);
color_fg = SvPV (ST (8), PL_na);
- color_bg = SvPV (ST (9), PL_na);
- separator = SvPV (ST (10), PL_na);
- bar_items = SvPV (ST (11), PL_na);
+ color_delim = SvPV (ST (9), PL_na);
+ color_bg = SvPV (ST (10), PL_na);
+ separator = SvPV (ST (11), PL_na);
+ bar_items = SvPV (ST (12), PL_na);
result = script_ptr2str (weechat_bar_new (name,
priority,
type,
@@ -3393,6 +3395,7 @@ static XS (XS_weechat_bar_new)
size,
size_max,
color_fg,
+ color_delim,
color_bg,
separator,
bar_items));
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index 8d7c4f990..484e3b850 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -3566,7 +3566,8 @@ static PyObject *
weechat_python_api_bar_new (PyObject *self, PyObject *args)
{
char *name, *priority, *type, *conditions, *position, *filling, *size;
- char *size_max, *color_fg, *color_bg, *separator, *items, *result;
+ char *size_max, *color_fg, *color_delim, *color_bg, *separator, *items;
+ char *result;
PyObject *object;
/* make C compiler happy */
@@ -3587,13 +3588,15 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args)
size = NULL;
size_max = NULL;
color_fg = NULL;
+ color_delim = NULL;
color_bg = NULL;
separator = NULL;
items = NULL;
- if (!PyArg_ParseTuple (args, "ssssssssssss", &name, &priority, &conditions,
- &type, &position, &filling, &size, &size_max,
- &color_fg, &color_bg, &separator, &items))
+ if (!PyArg_ParseTuple (args, "sssssssssssss", &name, &priority,
+ &conditions, &type, &position, &filling, &size,
+ &size_max, &color_fg, &color_delim, &color_bg,
+ &separator, &items))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
PYTHON_RETURN_EMPTY;
@@ -3608,6 +3611,7 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args)
size,
size_max,
color_fg,
+ color_delim,
color_bg,
separator,
items));
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c
index 92e07af80..0b68e7038 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -4096,11 +4096,12 @@ static VALUE
weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE priority, VALUE type,
VALUE conditions, VALUE position, VALUE filling,
VALUE size, VALUE size_max, VALUE color_fg,
- VALUE color_bg, VALUE separator, VALUE items)
+ VALUE color_delim, VALUE color_bg, VALUE separator,
+ VALUE items)
{
char *c_name, *c_priority, *c_type, *c_conditions, *c_position, *c_filling;
- char *c_size, *c_size_max, *c_color_fg, *c_color_bg, *c_separator;
- char *c_items;
+ char *c_size, *c_size_max, *c_color_fg, *c_color_delim, *c_color_bg;
+ char *c_separator, *c_items;
char *result;
VALUE return_value;
@@ -4122,14 +4123,15 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE priority, VALUE type,
c_size = NULL;
c_size_max = NULL;
c_color_fg = NULL;
+ c_color_delim = NULL;
c_color_bg = NULL;
c_separator = NULL;
c_items = NULL;
if (NIL_P (name) || NIL_P (priority) || NIL_P (type) || NIL_P (conditions)
|| NIL_P (position) || NIL_P (filling) || NIL_P (size)
- || NIL_P (size_max) || NIL_P (color_fg) || NIL_P (color_bg)
- || NIL_P (separator) || NIL_P (items))
+ || NIL_P (size_max) || NIL_P (color_fg) || NIL_P (color_delim)
+ || NIL_P (color_bg) || NIL_P (separator) || NIL_P (items))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
RUBY_RETURN_EMPTY;
@@ -4144,6 +4146,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE priority, VALUE type,
Check_Type (size, T_STRING);
Check_Type (size_max, T_STRING);
Check_Type (color_fg, T_STRING);
+ Check_Type (color_delim, T_STRING);
Check_Type (color_bg, T_STRING);
Check_Type (separator, T_STRING);
Check_Type (items, T_STRING);
@@ -4157,6 +4160,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE priority, VALUE type,
c_size = STR2CSTR (size);
c_size_max = STR2CSTR (size_max);
c_color_fg = STR2CSTR (color_fg);
+ c_color_delim = STR2CSTR (color_delim);
c_color_bg = STR2CSTR (color_bg);
c_separator = STR2CSTR (separator);
c_items = STR2CSTR (items);
@@ -4170,6 +4174,7 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE priority, VALUE type,
c_size,
c_size_max,
c_color_fg,
+ c_color_delim,
c_color_bg,
c_separator,
c_items));
@@ -4793,7 +4798,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "bar_item_update", &weechat_ruby_api_bar_item_update, 1);
rb_define_module_function (ruby_mWeechat, "bar_item_remove", &weechat_ruby_api_bar_item_remove, 1);
rb_define_module_function (ruby_mWeechat, "bar_search", &weechat_ruby_api_bar_search, 1);
- rb_define_module_function (ruby_mWeechat, "bar_new", &weechat_ruby_api_bar_new, 12);
+ rb_define_module_function (ruby_mWeechat, "bar_new", &weechat_ruby_api_bar_new, 13);
rb_define_module_function (ruby_mWeechat, "bar_set", &weechat_ruby_api_bar_set, 3);
rb_define_module_function (ruby_mWeechat, "bar_update", &weechat_ruby_api_bar_update, 1);
rb_define_module_function (ruby_mWeechat, "bar_remove", &weechat_ruby_api_bar_remove, 1);
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 3af989b0b..904773b8b 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -422,13 +422,18 @@ struct t_weechat_plugin
void (*bar_item_update) (const char *name);
void (*bar_item_remove) (struct t_gui_bar_item *item);
struct t_gui_bar *(*bar_search) (const char *name);
- struct t_gui_bar *(*bar_new) (struct t_weechat_plugin *plugin, const char *name,
- const char *priority, const char *type, const char *condition,
- const char *position, const char *filling, const char *size,
+ struct t_gui_bar *(*bar_new) (struct t_weechat_plugin *plugin,
+ const char *name,
+ const char *priority, const char *type,
+ const char *condition,
+ const char *position, const char *filling,
+ const char *size,
const char *size_max, const char *color_fg,
+ const char *color_delim,
const char *color_bg, const char *separator,
const char *items);
- int (*bar_set) (struct t_gui_bar *bar, const char *property, const char *value);
+ int (*bar_set) (struct t_gui_bar *bar, const char *property,
+ const char *value);
void (*bar_update) (const char *name);
void (*bar_remove) (struct t_gui_bar *bar);
@@ -853,11 +858,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->bar_search(__name)
#define weechat_bar_new(__name, __priority, __type, __condition, \
__position, __filling, __size, __size_max, \
- __color_fg, __color_bg, __separator, __items) \
+ __color_fg, __color_delim, __color_bg, \
+ __separator, __items) \
weechat_plugin->bar_new(weechat_plugin, __name, __priority, __type, \
__condition, __position, __filling, __size, \
- __size_max, __color_fg, __color_bg, \
- __separator, __items)
+ __size_max, __color_fg, __color_delim, \
+ __color_bg, __separator, __items)
#define weechat_bar_set(__bar, __property, __value) \
weechat_plugin->bar_set(__bar, __property, __value)
#define weechat_bar_update(__name) \