Add sub-items in bars (items glued with "+" as separator instead of comma), add buffer_number default bar item

This commit is contained in:
Sebastien Helleu 2008-12-19 10:17:55 +01:00
parent cfc12b2b8c
commit d07a7cedc8
16 changed files with 402 additions and 218 deletions

View File

@ -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-12-17 18:53+0100\n"
"POT-Creation-Date: 2008-12-19 10:04+0100\n"
"PO-Revision-Date: 2008-09-17 16:19+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -708,7 +708,8 @@ msgid ""
" 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"
" item1,...: items for this bar (items can be separated by comma (space "
"between items) or \"+\" (glued items))\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"
@ -728,8 +729,9 @@ msgid ""
" 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"
" create a bar with time, buffer number + name, and completion:\n"
" /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,"
"completion\n"
" hide a bar:\n"
" /bar hide mybar\n"
" scroll nicklist 10 lines down on current buffer:\n"

View File

@ -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-12-17 18:53+0100\n"
"POT-Creation-Date: 2008-12-19 10:04+0100\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"
@ -769,7 +769,8 @@ msgid ""
" 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"
" item1,...: items for this bar (items can be separated by comma (space "
"between items) or \"+\" (glued items))\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"
@ -789,8 +790,9 @@ msgid ""
" 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"
" create a bar with time, buffer number + name, and completion:\n"
" /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,"
"completion\n"
" hide a bar:\n"
" /bar hide mybar\n"
" scroll nicklist 10 lines down on current buffer:\n"

View File

@ -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-12-17 18:53+0100\n"
"POT-Creation-Date: 2008-12-19 10:04+0100\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"
@ -765,7 +765,8 @@ msgid ""
" 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"
" item1,...: items for this bar (items can be separated by comma (space "
"between items) or \"+\" (glued items))\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"
@ -785,8 +786,9 @@ msgid ""
" 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"
" create a bar with time, buffer number + name, and completion:\n"
" /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,"
"completion\n"
" hide a bar:\n"
" /bar hide mybar\n"
" scroll nicklist 10 lines down on current buffer:\n"

View File

@ -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-12-17 18:53+0100\n"
"PO-Revision-Date: 2008-12-17 18:54+0100\n"
"POT-Creation-Date: 2008-12-19 10:04+0100\n"
"PO-Revision-Date: 2008-12-19 10:05+0100\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"MIME-Version: 1.0\n"
@ -715,7 +715,8 @@ msgid ""
" 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"
" item1,...: items for this bar (items can be separated by comma (space "
"between items) or \"+\" (glued items))\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"
@ -735,8 +736,9 @@ msgid ""
" 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"
" create a bar with time, buffer number + name, and completion:\n"
" /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,"
"completion\n"
" hide a bar:\n"
" /bar hide mybar\n"
" scroll nicklist 10 lines down on current buffer:\n"
@ -762,7 +764,8 @@ msgstr ""
" taille: taille de la barre (en caractères)\n"
" séparateur: 1 pour utiliser un séparateur (ligne), 0 ou rien signifie "
"sans séparateur\n"
" objet1,...: objets pour cette barre\n"
" objet1,...: objets pour cette barre (les objets peuvent être séparés par "
"une virgule (espace entre les objets) ou \"+\" (objets collés))\n"
" default: créer les barres par défaut\n"
" del: supprime une barre (ou toutes les barres avec -all)\n"
" set: change la valeur d'une propriété de la barre\n"
@ -783,8 +786,9 @@ msgstr ""
" listitems: liste tous les objets de barre\n"
"\n"
"Exemples :\n"
" créer une barre avec l'heure et la complétion :\n"
" /bar add mabarre root bottom 1 0 [time],completion\n"
" créer une barre avec l'heure, numéro + nom de tampon, et la complétion :\n"
" /bar add mabarre root bottom 1 0 [time],buffer_number+:+buffer_name,"
"completion\n"
" cacher une barre :\n"
" /bar hide mabarre\n"
" faire défiler la liste des pseudos de 10 lignes vers le bas sur le tampon "

View File

@ -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-12-17 18:53+0100\n"
"POT-Creation-Date: 2008-12-19 10:04+0100\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"
@ -769,7 +769,8 @@ msgid ""
" 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"
" item1,...: items for this bar (items can be separated by comma (space "
"between items) or \"+\" (glued items))\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"
@ -789,8 +790,9 @@ msgid ""
" 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"
" create a bar with time, buffer number + name, and completion:\n"
" /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,"
"completion\n"
" hide a bar:\n"
" /bar hide mybar\n"
" scroll nicklist 10 lines down on current buffer:\n"

View File

@ -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-12-17 18:53+0100\n"
"POT-Creation-Date: 2008-12-19 10:04+0100\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"
@ -763,7 +763,8 @@ msgid ""
" 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"
" item1,...: items for this bar (items can be separated by comma (space "
"between items) or \"+\" (glued items))\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"
@ -783,8 +784,9 @@ msgid ""
" 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"
" create a bar with time, buffer number + name, and completion:\n"
" /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,"
"completion\n"
" hide a bar:\n"
" /bar hide mybar\n"
" scroll nicklist 10 lines down on current buffer:\n"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-12-17 18:53+0100\n"
"POT-Creation-Date: 2008-12-19 10:04+0100\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"
@ -680,7 +680,8 @@ msgid ""
" 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"
" item1,...: items for this bar (items can be separated by comma (space "
"between items) or \"+\" (glued items))\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"
@ -700,8 +701,9 @@ msgid ""
" 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"
" create a bar with time, buffer number + name, and completion:\n"
" /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,"
"completion\n"
" hide a bar:\n"
" /bar hide mybar\n"
" scroll nicklist 10 lines down on current buffer:\n"

View File

@ -3374,7 +3374,8 @@ command_init ()
" 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"
" item1,...: items for this bar (items can be separated "
"by comma (space between items) or \"+\" (glued items))\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"
@ -3394,8 +3395,8 @@ command_init ()
" 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"
" create a bar with time, buffer number + name, and completion:\n"
" /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,completion\n"
" hide a bar:\n"
" /bar hide mybar\n"
" scroll nicklist 10 lines down on current buffer:\n"

View File

@ -618,6 +618,6 @@ void
gui_bar_window_objects_print_log (struct t_gui_bar_window *bar_window)
{
log_printf (" bar window specific objects for Curses:");
log_printf (" win_bar . . . . . . : 0x%lx", GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar);
log_printf (" win_separator . . . : 0x%lx", GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator);
log_printf (" win_bar. . . . . . . : 0x%lx", GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar);
log_printf (" win_separator. . . . : 0x%lx", GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator);
}

View File

@ -53,9 +53,9 @@ 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_paste", "input_prompt", "input_search", "input_text", "time",
"buffer_count", "buffer_plugin", "buffer_name", "buffer_filter",
"buffer_nicklist_count", "scroll", "hotlist", "completion", "buffer_title",
"buffer_nicklist"
"buffer_count", "buffer_plugin", "buffer_number", "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;
@ -226,7 +226,7 @@ int
gui_bar_item_used_in_a_bar (const char *item_name, int partial_name)
{
struct t_gui_bar *ptr_bar;
int i, length;
int i, j, length;
const char *ptr_start;
length = strlen (item_name);
@ -235,15 +235,18 @@ gui_bar_item_used_in_a_bar (const char *item_name, int partial_name)
{
for (i = 0; i < ptr_bar->items_count; i++)
{
ptr_start = gui_bar_item_string_get_item_start (ptr_bar->items_array[i]);
if (ptr_start)
for (j = 0; j < ptr_bar->items_subcount[i]; j++)
{
if ((partial_name
&& strncmp (ptr_start, item_name, length) == 0)
|| (!partial_name
&& strcmp (ptr_start, item_name) == 0))
ptr_start = gui_bar_item_string_get_item_start (ptr_bar->items_array[i][j]);
if (ptr_start)
{
return 1;
if ((partial_name
&& strncmp (ptr_start, item_name, length) == 0)
|| (!partial_name
&& strcmp (ptr_start, item_name) == 0))
{
return 1;
}
}
}
}
@ -439,20 +442,21 @@ gui_bar_item_update (const char *item_name)
struct t_gui_bar *ptr_bar;
struct t_gui_window *ptr_window;
struct t_gui_bar_window *ptr_bar_window;
int item_index;
int index_item, index_subitem;
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
if (!CONFIG_BOOLEAN(ptr_bar->hidden))
{
item_index = gui_bar_get_item_index (ptr_bar, item_name);
if (item_index >= 0)
gui_bar_get_item_index (ptr_bar, item_name, &index_item, &index_subitem);
if ((index_item >= 0) && (index_subitem >= 0))
{
if (ptr_bar->bar_window)
{
gui_bar_window_content_build_item (ptr_bar->bar_window,
NULL,
item_index);
index_item,
index_subitem);
}
else
{
@ -467,7 +471,8 @@ gui_bar_item_update (const char *item_name)
{
gui_bar_window_content_build_item (ptr_bar_window,
ptr_window,
item_index);
index_item,
index_subitem);
}
}
}
@ -775,6 +780,30 @@ gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
return (plugin_name) ? strdup (plugin_name) : strdup ("");
}
/*
* gui_bar_item_default_buffer_number: default item for number of buffer
*/
char *
gui_bar_item_default_buffer_number (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window)
{
char buf[64];
/* make C compiler happy */
(void) data;
(void) item;
if (!window)
window = gui_current_window;
snprintf (buf, sizeof (buf), "%s%d",
gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_number))),
window->buffer->number);
return strdup (buf);
}
/*
* gui_bar_item_default_buffer_name: default item for name of buffer
*/
@ -792,10 +821,7 @@ gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item,
if (!window)
window = gui_current_window;
snprintf (buf, sizeof (buf), "%s%d%s:%s%s",
gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_number))),
window->buffer->number,
GUI_COLOR_CUSTOM_BAR_DELIM,
snprintf (buf, sizeof (buf), "%s%s",
gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_name))),
window->buffer->name);
@ -1295,6 +1321,15 @@ gui_bar_item_init ()
gui_bar_item_hook_signal ("buffer_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_PLUGIN]);
/* buffer number */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER],
&gui_bar_item_default_buffer_number, NULL);
gui_bar_item_hook_signal ("buffer_switch",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER]);
gui_bar_item_hook_signal ("buffer_moved",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER]);
/* buffer name */
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME],

View File

@ -29,6 +29,7 @@ enum t_gui_bar_item_weechat
GUI_BAR_ITEM_TIME,
GUI_BAR_ITEM_BUFFER_COUNT,
GUI_BAR_ITEM_BUFFER_PLUGIN,
GUI_BAR_ITEM_BUFFER_NUMBER,
GUI_BAR_ITEM_BUFFER_NAME,
GUI_BAR_ITEM_BUFFER_FILTER,
GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT,

View File

@ -239,20 +239,29 @@ gui_bar_window_find_pos (struct t_gui_bar *bar, struct t_gui_window *window)
void
gui_bar_window_content_alloc (struct t_gui_bar_window *bar_window)
{
int i;
int i, j;
bar_window->items_count = bar_window->bar->items_count;
bar_window->items_content = malloc((bar_window->items_count) *
sizeof (bar_window->items_content[0]));
bar_window->items_subcount = malloc (bar_window->items_count *
sizeof (*bar_window->items_subcount));
bar_window->items_content = malloc ((bar_window->items_count) *
sizeof (*bar_window->items_content));
if (bar_window->items_content)
{
for (i = 0; i < bar_window->items_count; i++)
{
bar_window->items_content[i] = NULL;
bar_window->items_subcount[i] = bar_window->bar->items_subcount[i];
bar_window->items_content[i] = malloc (bar_window->items_subcount[i] *
sizeof (**bar_window->items_content));
if (bar_window->items_content[i])
{
for (j = 0; j < bar_window->items_subcount[i]; j++)
{
bar_window->items_content[i][j] = NULL;
}
}
}
}
else
bar_window->items_count = 0;
}
/*
@ -262,14 +271,21 @@ gui_bar_window_content_alloc (struct t_gui_bar_window *bar_window)
void
gui_bar_window_content_free (struct t_gui_bar_window *bar_window)
{
int i;
int i, j;
if (bar_window->items_content)
{
for (i = 0; i < bar_window->items_count; i++)
{
if (bar_window->items_content[i])
{
for (j = 0; j < bar_window->items_subcount[i]; j++)
{
if (bar_window->items_content[i][j])
free (bar_window->items_content[i][j]);
}
free (bar_window->items_content[i]);
}
}
free (bar_window->items_content);
bar_window->items_content = NULL;
@ -286,20 +302,20 @@ gui_bar_window_content_free (struct t_gui_bar_window *bar_window)
void
gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window,
struct t_gui_window *window,
int item_index)
int index_item, int index_subitem)
{
if (bar_window->items_content[item_index])
if (bar_window->items_content[index_item][index_subitem])
{
free (bar_window->items_content[item_index]);
bar_window->items_content[item_index] = NULL;
free (bar_window->items_content[index_item][index_subitem]);
bar_window->items_content[index_item][index_subitem] = NULL;
}
/* build item, but only if there's a buffer in window */
if ((window && window->buffer)
|| (gui_current_window && gui_current_window->buffer))
{
bar_window->items_content[item_index] =
gui_bar_item_get_value (bar_window->bar->items_array[item_index],
bar_window->items_content[index_item][index_subitem] =
gui_bar_item_get_value (bar_window->bar->items_array[index_item][index_subitem],
bar_window->bar, window);
}
}
@ -314,18 +330,17 @@ void
gui_bar_window_content_build (struct t_gui_bar_window *bar_window,
struct t_gui_window *window)
{
int i;
int i, j;
if (bar_window->items_count != bar_window->bar->items_count)
{
gui_bar_window_content_free (bar_window);
gui_bar_window_content_alloc (bar_window);
}
gui_bar_window_content_free (bar_window);
gui_bar_window_content_alloc (bar_window);
for (i = 0; i < bar_window->items_count; i++)
{
gui_bar_window_content_build_item (bar_window, window, i);
for (j = 0; j < bar_window->items_subcount[i]; j++)
{
gui_bar_window_content_build_item (bar_window, window, i, j);
}
}
}
@ -339,19 +354,27 @@ char *
gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window)
{
enum t_gui_bar_filling filling;
char *content, space_with_reinit_color[32], *item_value;
int index_content, content_length, length_reinit_color, i, j, k, index;
char *content, reinit_color[32], reinit_color_space[32], *item_value;
int index_content, content_length, i, sub, j, k, index;
int length_reinit_color, length_reinit_color_space;
int length, max_length, max_length_screen, total_items, columns, lines;
char ***splitted_items, **linear_items;
char ****splitted_items, **linear_items;
snprintf (space_with_reinit_color,
sizeof (space_with_reinit_color),
snprintf (reinit_color, sizeof (reinit_color),
"%c%c%02d,%02d",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_FG_BG_CHAR,
CONFIG_COLOR(bar_window->bar->color_fg),
CONFIG_COLOR(bar_window->bar->color_bg));
length_reinit_color = strlen (reinit_color);
snprintf (reinit_color_space, sizeof (reinit_color_space),
"%c%c%02d,%02d ",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_FG_BG_CHAR,
CONFIG_COLOR(bar_window->bar->color_fg),
CONFIG_COLOR(bar_window->bar->color_bg));
length_reinit_color = strlen (space_with_reinit_color);
length_reinit_color_space = strlen (reinit_color_space);
content = NULL;
content_length = 1;
@ -362,38 +385,49 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window)
case GUI_BAR_FILLING_VERTICAL: /* items separated by \n */
for (i = 0; i < bar_window->items_count; i++)
{
if (bar_window->items_content[i]
&& bar_window->items_content[i][0])
for (sub = 0; sub < bar_window->items_subcount[i]; sub++)
{
if (gui_bar_get_filling (bar_window->bar) == GUI_BAR_FILLING_HORIZONTAL)
if (bar_window->items_content[i][sub]
&& bar_window->items_content[i][sub][0])
{
item_value = string_replace (bar_window->items_content[i],
"\n",
space_with_reinit_color);
}
else
item_value = NULL;
if (!content)
{
content_length += strlen ((item_value) ?
item_value : bar_window->items_content[i]);
content = strdup ((item_value) ?
item_value : bar_window->items_content[i]);
}
else
{
content_length += length_reinit_color +
strlen ((item_value) ? item_value : bar_window->items_content[i]);
content = realloc (content, content_length);
if (gui_bar_get_filling (bar_window->bar) == GUI_BAR_FILLING_HORIZONTAL)
strcat (content, space_with_reinit_color);
{
item_value = string_replace (bar_window->items_content[i][sub],
"\n",
reinit_color_space);
}
else
strcat (content, "\n");
strcat (content,
(item_value) ? item_value : bar_window->items_content[i]);
item_value = NULL;
if (!content)
{
content_length += strlen ((item_value) ?
item_value : bar_window->items_content[i][sub]);
content = strdup ((item_value) ?
item_value : bar_window->items_content[i][sub]);
}
else
{
content_length += length_reinit_color_space +
strlen ((item_value) ? item_value : bar_window->items_content[i][sub]);
content = realloc (content, content_length);
if (sub == 0)
{
/* first sub item: insert space after last item */
if (gui_bar_get_filling (bar_window->bar) == GUI_BAR_FILLING_HORIZONTAL)
strcat (content, reinit_color_space);
else
strcat (content, "\n");
}
else
{
strcat (content, reinit_color);
}
strcat (content,
(item_value) ? item_value : bar_window->items_content[i][sub]);
}
if (item_value)
free (item_value);
}
if (item_value)
free (item_value);
}
}
break;
@ -405,22 +439,31 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window)
splitted_items = malloc(bar_window->items_count * sizeof(*splitted_items));
for (i = 0; i < bar_window->items_count; i++)
{
if (bar_window->items_content[i]
&& bar_window->items_content[i][0])
if (bar_window->items_subcount[i] > 0)
{
splitted_items[i] = string_explode (bar_window->items_content[i],
"\n", 0, 0, NULL);
for (j = 0; splitted_items[i][j]; j++)
splitted_items[i] = malloc (bar_window->items_subcount[i] * sizeof (**splitted_items));
for (sub = 0; sub < bar_window->items_subcount[i]; sub++)
{
total_items++;
length = strlen (splitted_items[i][j]);
if (length > max_length)
max_length = length;
length = gui_chat_strlen_screen (splitted_items[i][j]);
if (length > max_length_screen)
max_length_screen = length;
if (bar_window->items_content[i][sub]
&& bar_window->items_content[i][sub][0])
{
splitted_items[i][sub] = string_explode (bar_window->items_content[i][sub],
"\n", 0, 0, NULL);
for (j = 0; splitted_items[i][sub][j]; j++)
{
total_items++;
length = strlen (splitted_items[i][sub][j]);
if (length > max_length)
max_length = length;
length = gui_chat_strlen_screen (splitted_items[i][sub][j]);
if (length > max_length_screen)
max_length_screen = length;
}
}
else
splitted_items[i] = NULL;
}
}
else
@ -451,16 +494,22 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window)
{
if (splitted_items[i])
{
for (j = 0; splitted_items[i][j]; j++)
for (sub = 0; sub < bar_window->items_subcount[i]; sub++)
{
linear_items[index++] = splitted_items[i][j];
if (splitted_items[i][sub])
{
for (j = 0; splitted_items[i][sub][j]; j++)
{
linear_items[index++] = splitted_items[i][sub][j];
}
}
}
}
}
/* build content with lines and columns */
content = malloc (1 + (lines *
((columns * (max_length + length_reinit_color)) + 1)));
((columns * (max_length + length_reinit_color_space)) + 1)));
content[0] = '\0';
index_content = 0;
for (i = 0; i < lines; i++)
@ -492,8 +541,8 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window)
}
if (j < columns - 1)
{
strcpy (content + index_content, space_with_reinit_color);
index_content += length_reinit_color;
strcpy (content + index_content, reinit_color_space);
index_content += length_reinit_color_space;
}
}
content[index_content++] = '\n';
@ -504,7 +553,14 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window)
for (i = 0; i < bar_window->items_count; i++)
{
if (splitted_items[i])
string_free_exploded (splitted_items[i]);
{
for (sub = 0; sub < bar_window->items_subcount[i]; sub++)
{
if (splitted_items[i][sub])
string_free_exploded (splitted_items[i][sub]);
}
free (splitted_items[i]);
}
}
free (splitted_items);
break;
@ -588,8 +644,9 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
new_bar_window->cursor_y = -1;
new_bar_window->current_size = (CONFIG_INTEGER(bar->size) == 0) ?
1 : CONFIG_INTEGER(bar->size);
new_bar_window->items_content = NULL;
new_bar_window->items_count = 0;
new_bar_window->items_subcount = NULL;
new_bar_window->items_content = NULL;
gui_bar_window_objects_init (new_bar_window);
gui_bar_window_content_build (new_bar_window, window);
@ -959,7 +1016,7 @@ gui_bar_window_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar_window *bar_window)
{
struct t_infolist_item *ptr_item;
int i;
int i, j;
char option_name[64];
if (!infolist || !bar_window)
@ -993,10 +1050,14 @@ gui_bar_window_add_to_infolist (struct t_infolist *infolist,
return 0;
for (i = 0; i < bar_window->items_count; i++)
{
snprintf (option_name, sizeof (option_name), "items_content_%05d", i + 1);
if (!infolist_new_var_string (ptr_item, option_name,
bar_window->items_content[i]))
return 0;
for (j = 0; j < bar_window->items_subcount[i]; j++)
{
snprintf (option_name, sizeof (option_name),
"items_content_%05d_%05d", i + 1, j + 1);
if (!infolist_new_var_string (ptr_item, option_name,
bar_window->items_content[i][j]))
return 0;
}
}
if (!infolist_new_var_pointer (ptr_item, "gui_objects", bar_window->gui_objects))
return 0;
@ -1011,33 +1072,38 @@ gui_bar_window_add_to_infolist (struct t_infolist *infolist,
void
gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
{
int i;
int i, j;
log_printf ("");
log_printf (" [window bar (addr:0x%lx)]", bar_window);
log_printf (" bar . . . . . . . : 0x%lx ('%s')",
log_printf (" bar. . . . . . . . . : 0x%lx ('%s')",
bar_window->bar,
(bar_window->bar) ? bar_window->bar->name : "");
log_printf (" x . . . . . . . . . : %d", bar_window->x);
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);
log_printf (" items_count . . . . : %d", bar_window->items_count);
log_printf (" x. . . . . . . . . . . : %d", bar_window->x);
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);
log_printf (" items_count. . . . . . : %d", bar_window->items_count);
for (i = 0; i < bar_window->items_count; i++)
{
log_printf (" items_content[%03d]. : '%s' (item: '%s')",
i,
bar_window->items_content[i],
(bar_window->bar->items_count >= i + 1) ?
bar_window->bar->items_array[i] : "?");
log_printf (" items_subcount[%03d]. . : %d",
i, bar_window->items_subcount[i]);
for (j = 0; j < bar_window->items_subcount[i]; j++)
{
log_printf (" items_content[%03d][%03d]: '%s' (item: '%s')",
i, j,
bar_window->items_content[i][j],
(bar_window->items_count >= i + 1) ?
bar_window->bar->items_array[i][j] : "?");
}
}
log_printf (" gui_objects . . . . : 0x%lx", bar_window->gui_objects);
log_printf (" gui_objects. . . . . . : 0x%lx", bar_window->gui_objects);
gui_bar_window_objects_print_log (bar_window);
log_printf (" prev_bar_window . . : 0x%lx", bar_window->prev_bar_window);
log_printf (" next_bar_window . . : 0x%lx", bar_window->next_bar_window);
log_printf (" prev_bar_window. . . . : 0x%lx", bar_window->prev_bar_window);
log_printf (" next_bar_window. . . . : 0x%lx", bar_window->next_bar_window);
}

View File

@ -32,8 +32,9 @@ struct t_gui_bar_window
int cursor_x, cursor_y; /* use to move cursor on screen (for */
/* input_text item) */
int current_size; /* current size (width or height) */
int items_count; /* number of items */
char **items_content; /* content for each item of bar */
int items_count; /* number of bar items */
int *items_subcount; /* number of sub items */
char ***items_content; /* content for each item/sub item of bar*/
void *gui_objects; /* pointer to a GUI specific struct */
struct t_gui_bar_window *prev_bar_window; /* link to previous bar win */
/* (only for non-root bars) */
@ -48,7 +49,7 @@ extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_wind
struct t_gui_window *window);
extern void gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window,
struct t_gui_window *window,
int item_index);
int index_item, int index_subitem);
extern void gui_bar_window_content_build (struct t_gui_bar_window *bar_window,
struct t_gui_window *window);
extern char *gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window);

View File

@ -289,28 +289,42 @@ gui_bar_get_filling (struct t_gui_bar *bar)
}
/*
* gui_bar_get_item_index: return index of item in bar (position of item in
* items list)
* return -1 if item is not in bar
* gui_bar_get_item_index: return index of item and sub item in bar (position
* of item in items list)
* for example, if items are:
* item1,sub1+sub2+sub3,item3
* index of sub3 is 1, sub index is 2
* return -1 for index and sub index if item is not
* found in bar
*/
int
gui_bar_get_item_index (struct t_gui_bar *bar, const char *item_name)
void
gui_bar_get_item_index (struct t_gui_bar *bar, const char *item_name,
int *index_item, int *index_subitem)
{
int i;
int i, j;
*index_item = -1;
*index_subitem = -1;
if (!bar || !item_name || !item_name[0])
return -1;
return;
for (i = 0; i < bar->items_count; i++)
{
/* skip non letters chars at beginning (prefix) */
if (gui_bar_item_string_is_item (bar->items_array[i], item_name))
return i;
for (j = 0; j < bar->items_subcount[i]; j++)
{
/* skip non letters chars at beginning (prefix) */
if (gui_bar_item_string_is_item (bar->items_array[i][j], item_name))
{
*index_item = i;
*index_subitem = j;
return;
}
}
}
/* item is not in bar */
return -1;
}
/*
@ -592,6 +606,62 @@ gui_bar_draw (struct t_gui_bar *bar)
bar->bar_refresh_needed = 0;
}
/*
* gui_bar_free_items_array: free array with items for a bar
*/
void
gui_bar_free_items_array (struct t_gui_bar *bar)
{
int i;
for (i = 0; i < bar->items_count; i++)
{
if (bar->items_array[i])
string_free_exploded (bar->items_array[i]);
}
if (bar->items_array)
{
free (bar->items_array);
bar->items_array = NULL;
}
if (bar->items_subcount)
{
free (bar->items_subcount);
bar->items_subcount = NULL;
}
bar->items_count = 0;
}
/*
* gui_bar_set_items_array: build array with items for a bar
*/
void
gui_bar_set_items_array (struct t_gui_bar *bar, const char *items)
{
int i, count;
char **tmp_array;
gui_bar_free_items_array (bar);
if (items && items[0])
{
tmp_array = string_explode (items, ",", 0, 0, &count);
if (count > 0)
{
bar->items_count = count;
bar->items_subcount = malloc (count * sizeof (*bar->items_subcount));
bar->items_array = malloc (count * sizeof (*bar->items_array));
for (i = 0; i < count; i++)
{
bar->items_array[i] = string_explode (tmp_array[i], "+", 0, 0,
&(bar->items_subcount[i]));
}
}
}
}
/*
* gui_bar_config_check_type: callback for checking bar type before changing it
*/
@ -928,21 +998,8 @@ gui_bar_config_change_items (void *data, struct t_config_option *option)
ptr_bar = gui_bar_search_with_option_name (option->name);
if (ptr_bar)
{
if (ptr_bar->items_array)
string_free_exploded (ptr_bar->items_array);
gui_bar_set_items_array (ptr_bar, CONFIG_STRING(ptr_bar->items));
if (CONFIG_STRING(ptr_bar->items) && CONFIG_STRING(ptr_bar->items)[0])
{
ptr_bar->items_array = string_explode (CONFIG_STRING(ptr_bar->items),
",", 0, 0,
&ptr_bar->items_count);
}
else
{
ptr_bar->items_count = 0;
ptr_bar->items_array = NULL;
}
if (!CONFIG_BOOLEAN(ptr_bar->hidden))
{
gui_bar_content_build_bar_windows (ptr_bar);
@ -1533,17 +1590,10 @@ gui_bar_new_with_options (const char *name,
new_bar->color_bg = color_bg;
new_bar->separator = separator;
new_bar->items = items;
if (CONFIG_STRING(items) && CONFIG_STRING(items)[0])
{
new_bar->items_array = string_explode (CONFIG_STRING(items),
",", 0, 0,
&new_bar->items_count);
}
else
{
new_bar->items_count = 0;
new_bar->items_array = NULL;
}
new_bar->items_count = 0;
new_bar->items_subcount = NULL;
new_bar->items_array = NULL;
gui_bar_set_items_array (new_bar, CONFIG_STRING(items));
new_bar->bar_window = NULL;
new_bar->bar_refresh_needed = 1;
@ -2010,20 +2060,25 @@ gui_bar_create_default_status ()
length = strlen (gui_bar_item_names[GUI_BAR_ITEM_TIME])
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_COUNT])
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_PLUGIN])
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NUMBER])
+ 1 /* ":" */
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME])
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT])
+ 3 /* "lag" */
+ strlen (gui_bar_item_names[GUI_BAR_ITEM_HOTLIST])
+ 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_BUFFER_NICKLIST_COUNT])
+ (9 * 4) + 1;
+ (12 * 4) /* all items delimiters: ",:+[]()" */
+ 1;
buf = malloc (length);
if (buf)
{
snprintf (buf, length, "[%s],[%s],[%s],%s,(%s),[lag],[%s],[%s],%s,%s",
snprintf (buf, length, "[%s],[%s],[%s],%s+:+%s+(%s),[lag],[%s],[%s],%s,%s",
gui_bar_item_names[GUI_BAR_ITEM_TIME],
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_NUMBER],
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME],
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NICKLIST_COUNT],
gui_bar_item_names[GUI_BAR_ITEM_HOTLIST],
@ -2291,8 +2346,7 @@ gui_bar_free (struct t_gui_bar *bar)
config_file_option_free (bar->items);
if (bar->conditions_array)
string_free_exploded (bar->conditions_array);
if (bar->items_array)
string_free_exploded (bar->items_array);
gui_bar_free_items_array (bar);
free (bar);
}
@ -2345,7 +2399,7 @@ gui_bar_add_to_infolist (struct t_infolist *infolist,
struct t_gui_bar *bar)
{
struct t_infolist_item *ptr_item;
int i;
int i, j;
char option_name[64];
if (!infolist || !bar)
@ -2397,11 +2451,14 @@ gui_bar_add_to_infolist (struct t_infolist *infolist,
return 0;
for (i = 0; i < bar->items_count; i++)
{
snprintf (option_name, sizeof (option_name),
"items_array_%05d", i + 1);
if (!infolist_new_var_string (ptr_item, option_name,
bar->items_array[i]))
return 0;
for (j = 0; j < bar->items_subcount[i]; j++)
{
snprintf (option_name, sizeof (option_name),
"items_array_%05d_%05d", i + 1, j + 1);
if (!infolist_new_var_string (ptr_item, option_name,
bar->items_array[i][j]))
return 0;
}
}
if (!infolist_new_var_pointer (ptr_item, "bar_window", bar->bar_window))
return 0;
@ -2417,6 +2474,7 @@ void
gui_bar_print_log ()
{
struct t_gui_bar *ptr_bar;
int i, j;
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
@ -2454,7 +2512,16 @@ gui_bar_print_log ()
log_printf (" separator. . . . . . . : %d", CONFIG_INTEGER(ptr_bar->separator));
log_printf (" items. . . . . . . . . : '%s'", CONFIG_STRING(ptr_bar->items));
log_printf (" items_count. . . . . . : %d", ptr_bar->items_count);
log_printf (" items_array. . . . . . : 0x%lx", ptr_bar->items_array);
for (i = 0; i < ptr_bar->items_count; i++)
{
log_printf (" items_subcount[%03d]. : %d",
i, ptr_bar->items_subcount[i]);
for (j = 0; j < ptr_bar->items_subcount[i]; j++)
{
log_printf (" items_array[%03d][%03d]: '%s'",
i, j, ptr_bar->items_array[i][j]);
}
}
log_printf (" bar_window . . . . . . : 0x%lx", ptr_bar->bar_window);
log_printf (" prev_bar . . . . . . . : 0x%lx", ptr_bar->prev_bar);
log_printf (" next_bar . . . . . . . : 0x%lx", ptr_bar->next_bar);

View File

@ -102,7 +102,8 @@ struct t_gui_bar
int conditions_count; /* number of conditions */
char **conditions_array; /* exploded bar conditions */
int items_count; /* number of bar items */
char **items_array; /* exploded bar items */
int *items_subcount; /* number of sub items */
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? */
@ -127,8 +128,9 @@ extern int gui_bar_search_option (const char *option_name);
extern int gui_bar_search_type (const char *type);
extern int gui_bar_search_position (const char *position);
extern enum t_gui_bar_filling gui_bar_get_filling (struct t_gui_bar *bar);
extern int gui_bar_get_item_index (struct t_gui_bar *bar,
const char *item_name);
extern void gui_bar_get_item_index (struct t_gui_bar *bar,
const char *item_name,
int *index_item, int *index_subitem);
extern int gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
struct t_gui_window *window);
extern int gui_bar_root_get_size (struct t_gui_bar *bar,

View File

@ -77,7 +77,7 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
{
char buf[512], buf_name[256], modes[128], away[128];
const char *name;
int number, part_from_channel;
int part_from_channel;
struct t_gui_buffer *buffer;
struct t_irc_server *server;
struct t_irc_channel *channel;
@ -97,8 +97,6 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
if (buffer)
{
number = weechat_buffer_get_integer (buffer, "number");
irc_buffer_get_server_channel (buffer, &server, &channel);
if (server || channel)
{
@ -170,10 +168,7 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
snprintf (buf_name, sizeof (buf_name), "%s", name);
}
snprintf (buf, sizeof (buf), "%s%d%s:%s%s%s%s",
IRC_COLOR_STATUS_NUMBER,
number,
IRC_COLOR_BAR_DELIM,
snprintf (buf, sizeof (buf), "%s%s%s%s",
IRC_COLOR_STATUS_NAME,
buf_name,
modes,