summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/de/weechat_user.de.adoc32
-rw-r--r--doc/en/weechat_dev.en.adoc1
-rw-r--r--doc/en/weechat_user.en.adoc30
-rw-r--r--doc/fr/weechat_dev.fr.adoc3
-rw-r--r--doc/fr/weechat_user.fr.adoc32
-rw-r--r--doc/it/weechat_user.it.adoc32
-rw-r--r--doc/ja/weechat_dev.ja.adoc2
-rw-r--r--doc/ja/weechat_user.ja.adoc32
-rw-r--r--doc/pl/weechat_user.pl.adoc32
-rw-r--r--doc/sr/weechat_dev.sr.adoc2
-rw-r--r--doc/sr/weechat_user.sr.adoc32
-rw-r--r--src/gui/curses/gui-curses-bar-window.c165
-rw-r--r--src/gui/curses/gui-curses-chat.c1
-rw-r--r--src/gui/gui-bar-item.c37
-rw-r--r--src/gui/gui-bar-item.h1
-rw-r--r--src/gui/gui-bar-window.c111
-rw-r--r--src/gui/gui-bar-window.h7
-rw-r--r--src/gui/gui-color.c3
-rw-r--r--src/gui/gui-color.h1
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/tests.cpp1
-rw-r--r--tests/unit/gui/test-gui-bar-window.cpp456
23 files changed, 976 insertions, 39 deletions
diff --git a/doc/de/weechat_user.de.adoc b/doc/de/weechat_user.de.adoc
index b65666810..36eeaeab9 100644
--- a/doc/de/weechat_user.de.adoc
+++ b/doc/de/weechat_user.de.adoc
@@ -2764,14 +2764,42 @@ Vor oder nach dem Item können Zeichen eingefügt werden. Diese dürfen nicht al
`+-+` oder `+_+` sein. Die Zeichen werden mit der entsprechenden Farbe, für Trennzeichen,
dargestellt (Option _color_delim_).
-Beispiel einer Bar mit den Items, "[time],buffer_number+:+buffer_plugin+.+buffer_name":
+Beispiel einer Bar mit den Items,
+"[time],buffer_number+:+buffer_plugin+.+buffer_name,[buffer_last_number]":
....
┌───────────────────────────────────────────────────────────────────────────┐
-│[12:55] 3:irc/libera.#weechat │
+│[12:55] 3:irc/libera.#weechat [9] │
└───────────────────────────────────────────────────────────────────────────┘
....
+// TRANSLATION MISSING
+[[item_spacer]]
+===== Spacer item
+
+An item called `spacer` can be used to align items (left, center, right).
+
+When at least one `spacer` item is used in a bar, the whole bar width is used:
+the spacers auto expand with the same size (or almost). +
+When the bar is not large enough for all items, spacers are not displayed.
+
+[NOTE]
+The `spacer` bar item can be used only in bars with position `top` or `bottom`,
+filling `horizontal` and size `1`.
+
+Example of bar with items
+"[time],spacer,buffer_number+:+buffer_plugin+.+buffer_name,spacer,[buffer_last_number]":
+
+....
+┌───────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/libera.#weechat [9]│
+└───────────────────────────────────────────────────────────────────────────┘
+....
+
+// TRANSLATION MISSING
+[[item_force_buffer]]
+===== Force buffer
+
Eine Besonderheit stellt die Möglichkeit dar, ein Item eines bestimmten Buffers
anzuzeigen. Syntax: "@buffer:item" ("buffer" ist der vollständige Name des Buffers
und "item" der Name der Bar-Item)
diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc
index 56876064a..9123856b6 100644
--- a/doc/en/weechat_dev.en.adoc
+++ b/doc/en/weechat_dev.en.adoc
@@ -422,6 +422,7 @@ WeeChat "core" is located in following directories:
|          test-core-utf8.cpp | Tests: UTF-8.
|          test-core-util.cpp | Tests: utility functions.
|       gui/ | Root of unit tests for interfaces.
+|          test-gui-bar-window.cpp | Tests: bar window functions.
|          test-gui-buffer.cpp | Tests: buffer functions.
|          test-gui-chat.cpp | Tests: chat functions.
|          test-gui-color.cpp | Tests: colors.
diff --git a/doc/en/weechat_user.en.adoc b/doc/en/weechat_user.en.adoc
index 750195f36..fd7fe3eaf 100644
--- a/doc/en/weechat_user.en.adoc
+++ b/doc/en/weechat_user.en.adoc
@@ -2712,14 +2712,40 @@ Before or after item name, you can use chars (that are not alphanumeric, `+-+`
or `+_+`). They will be displayed before/after item with the delimiters color
defined in bar (option _color_delim_).
-Example of bar with items "[time],buffer_number+:+buffer_plugin+.+buffer_name":
+Example of bar with items
+"[time],buffer_number+:+buffer_plugin+.+buffer_name,[buffer_last_number]":
....
┌───────────────────────────────────────────────────────────────────────────┐
-│[12:55] 3:irc/libera.#weechat │
+│[12:55] 3:irc/libera.#weechat [9] │
└───────────────────────────────────────────────────────────────────────────┘
....
+[[item_spacer]]
+===== Spacer item
+
+An item called `spacer` can be used to align items (left, center, right).
+
+When at least one `spacer` item is used in a bar, the whole bar width is used:
+the spacers auto expand with the same size (or almost). +
+When the bar is not large enough for all items, spacers are not displayed.
+
+[NOTE]
+The `spacer` bar item can be used only in bars with position `top` or `bottom`,
+filling `horizontal` and size `1`.
+
+Example of bar with items
+"[time],spacer,buffer_number+:+buffer_plugin+.+buffer_name,spacer,[buffer_last_number]":
+
+....
+┌───────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/libera.#weechat [9]│
+└───────────────────────────────────────────────────────────────────────────┘
+....
+
+[[item_force_buffer]]
+===== Force buffer
+
A special syntax can be used to force the buffer used when displaying the bar
item: "@buffer:item" (where "buffer" is the full name of buffer and "item" is
the name of a bar item).
diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc
index 99b400fe6..48c8b39b7 100644
--- a/doc/fr/weechat_dev.fr.adoc
+++ b/doc/fr/weechat_dev.fr.adoc
@@ -424,7 +424,8 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|          test-core-utf8.cpp | Tests : UTF-8.
|          test-core-util.cpp | Tests : fonctions utiles.
|       gui/ | Racine des tests unitaires pour les interfaces.
-|          test-gui-buffer.cpp | Tests : tampons.
+|          test-gui-bar-window.cpp | Tests : fonctions de fenêtres de barre.
+|          test-gui-buffer.cpp | Tests : fonctions de tampons.
|          test-gui-chat.cpp | Tests : fonctions de discussion.
|          test-gui-color.cpp | Tests : couleurs.
|          test-gui-line.cpp | Tests : lignes.
diff --git a/doc/fr/weechat_user.fr.adoc b/doc/fr/weechat_user.fr.adoc
index 240114ecd..e1b95d104 100644
--- a/doc/fr/weechat_user.fr.adoc
+++ b/doc/fr/weechat_user.fr.adoc
@@ -2797,14 +2797,42 @@ l'objet de barre avec la couleur des délimiteurs définie dans la barre (option
_color_delim_).
Exemple de barre avec les objets
-"[time],buffer_number+:+buffer_plugin+.+buffer_name" :
+"[time],buffer_number+:+buffer_plugin+.+buffer_name,[buffer_last_number]" :
....
┌───────────────────────────────────────────────────────────────────────────┐
-│[12:55] 3:irc/libera.#weechat │
+│[12:55] 3:irc/libera.#weechat [9] │
└───────────────────────────────────────────────────────────────────────────┘
....
+[[item_spacer]]
+===== Objet d'espacement
+
+Un objet appelé `spacer` peut être utilisé pour aligner les objets
+(gauche, centre, droite).
+
+Lorsqu'au moins un objet `spacer` est utilisé dans une barre, la largeur totale
+de la barre est utilisée : les espacements sont automatiquement étendus avec la
+même taille (ou presque). +
+Lorsque la barre n'est pas assez large pour afficher tous les objets, les
+espacements ne sont pas affichés.
+
+[NOTE]
+L'objet de barre `spacer` ne peut être utilisé que dans les barres avec position
+`top` ou `bottom`, remplissage `horizontal` et taille `1`.
+
+Exemple de barre avec les objets
+"[time],spacer,buffer_number+:+buffer_plugin+.+buffer_name,spacer,[buffer_last_number]" :
+
+....
+┌───────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/libera.#weechat [9]│
+└───────────────────────────────────────────────────────────────────────────┘
+....
+
+[[item_force_buffer]]
+===== Tampon forcé
+
Une syntaxe spéciale peut être utilisée pour forcer le tampon utilisé lors de
l'affichage de l'objet de barre : "@tampon:objet" (où "tampon" est le nom
complet du tampon et "objet" est le nom d'un objet de barre).
diff --git a/doc/it/weechat_user.it.adoc b/doc/it/weechat_user.it.adoc
index 49c0eaeb9..7e8c2dc90 100644
--- a/doc/it/weechat_user.it.adoc
+++ b/doc/it/weechat_user.it.adoc
@@ -2947,15 +2947,43 @@ Before or after item name, you can use chars (that are not alphanumeric, `+-+`
or `+_+`). They will be displayed before/after item with the delimiters color
defined in bar (option _color_delim_).
-Example of bar with items "[time],buffer_number+:+buffer_plugin+.+buffer_name":
+Example of bar with items
+"[time],buffer_number+:+buffer_plugin+.+buffer_name,[buffer_last_number]":
....
┌───────────────────────────────────────────────────────────────────────────┐
-│[12:55] 3:irc/libera.#weechat │
+│[12:55] 3:irc/libera.#weechat [9] │
└───────────────────────────────────────────────────────────────────────────┘
....
// TRANSLATION MISSING
+[[item_spacer]]
+===== Spacer item
+
+An item called `spacer` can be used to align items (left, center, right).
+
+When at least one `spacer` item is used in a bar, the whole bar width is used:
+the spacers auto expand with the same size (or almost). +
+When the bar is not large enough for all items, spacers are not displayed.
+
+[NOTE]
+The `spacer` bar item can be used only in bars with position `top` or `bottom`,
+filling `horizontal` and size `1`.
+
+Example of bar with items
+"[time],spacer,buffer_number+:+buffer_plugin+.+buffer_name,spacer,[buffer_last_number]":
+
+....
+┌───────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/libera.#weechat [9]│
+└───────────────────────────────────────────────────────────────────────────┘
+....
+
+// TRANSLATION MISSING
+[[item_force_buffer]]
+===== Force buffer
+
+// TRANSLATION MISSING
A special syntax can be used to force the buffer used when displaying the bar
item: "@buffer:item" (where "buffer" is the full name of buffer and "item" is
the name of a bar item).
diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc
index 338628eb4..1d7ff50b5 100644
--- a/doc/ja/weechat_dev.ja.adoc
+++ b/doc/ja/weechat_dev.ja.adoc
@@ -450,6 +450,8 @@ WeeChat "core" は以下のディレクトリに配置されています:
|          test-core-util.cpp | テスト: ユーティリティ関数
|       gui/ | インターフェースの単体テストを収める最上位ディレクトリ
// TRANSLATION MISSING
+|          test-gui-bar-window.cpp | Tests: bar window functions.
+// TRANSLATION MISSING
|          test-gui-buffer.cpp | Tests: buffer functions.
// TRANSLATION MISSING
|          test-gui-chat.cpp | Tests: chat functions.
diff --git a/doc/ja/weechat_user.ja.adoc b/doc/ja/weechat_user.ja.adoc
index 68612b774..5524b4e0b 100644
--- a/doc/ja/weechat_user.ja.adoc
+++ b/doc/ja/weechat_user.ja.adoc
@@ -2825,14 +2825,42 @@ _items_ オプションはバー要素をコンマ (画面上の要素同士に
または `+_+`)。この文字はバー (_color_delim_ オプション)
で定義された区切り文字の色をつけて要素の前または後に表示されます。
-バー要素を含むバーの例 "[time],buffer_number+:+buffer_plugin+.+buffer_name":
+バー要素を含むバーの例
+"[time],buffer_number+:+buffer_plugin+.+buffer_name,[buffer_last_number]":
....
┌───────────────────────────────────────────────────────────────────────────┐
-│[12:55] 3:irc/libera.#weechat │
+│[12:55] 3:irc/libera.#weechat [9] │
└───────────────────────────────────────────────────────────────────────────┘
....
+// TRANSLATION MISSING
+[[item_spacer]]
+===== Spacer item
+
+An item called `spacer` can be used to align items (left, center, right).
+
+When at least one `spacer` item is used in a bar, the whole bar width is used:
+the spacers auto expand with the same size (or almost). +
+When the bar is not large enough for all items, spacers are not displayed.
+
+[NOTE]
+The `spacer` bar item can be used only in bars with position `top` or `bottom`,
+filling `horizontal` and size `1`.
+
+Example of bar with items
+"[time],spacer,buffer_number+:+buffer_plugin+.+buffer_name,spacer,[buffer_last_number]":
+
+....
+┌───────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/libera.#weechat [9]│
+└───────────────────────────────────────────────────────────────────────────┘
+....
+
+// TRANSLATION MISSING
+[[item_force_buffer]]
+===== Force buffer
+
特殊構文を使うことで、バー要素: "@buffer:item"
("buffer" はバッファの完全な名前、"item" はバー要素の名前)
を表示する際に強制的に指定されたバッファを利用することが可能です。
diff --git a/doc/pl/weechat_user.pl.adoc b/doc/pl/weechat_user.pl.adoc
index 0c02fee81..013912824 100644
--- a/doc/pl/weechat_user.pl.adoc
+++ b/doc/pl/weechat_user.pl.adoc
@@ -2740,14 +2740,42 @@ Przed i za nazwą elementu można używać znaków (nie będących alfanumeryczn
`+-+` lub `+_+`). Będą one wyświetlane przed/za elementem z kolorem separatorów
zdefiniowanych dla paska (opcja _color_delim_).
-Przykład paska z elementami "[time],buffer_number+:+buffer_plugin+.+buffer_name":
+Przykład paska z elementami
+"[time],buffer_number+:+buffer_plugin+.+buffer_name,[buffer_last_number]":
....
┌───────────────────────────────────────────────────────────────────────────┐
-│[12:55] 3:irc/libera.#weechat │
+│[12:55] 3:irc/libera.#weechat [9] │
└───────────────────────────────────────────────────────────────────────────┘
....
+// TRANSLATION MISSING
+[[item_spacer]]
+===== Spacer item
+
+An item called `spacer` can be used to align items (left, center, right).
+
+When at least one `spacer` item is used in a bar, the whole bar width is used:
+the spacers auto expand with the same size (or almost). +
+When the bar is not large enough for all items, spacers are not displayed.
+
+[NOTE]
+The `spacer` bar item can be used only in bars with position `top` or `bottom`,
+filling `horizontal` and size `1`.
+
+Example of bar with items
+"[time],spacer,buffer_number+:+buffer_plugin+.+buffer_name,spacer,[buffer_last_number]":
+
+....
+┌───────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/libera.#weechat [9]│
+└───────────────────────────────────────────────────────────────────────────┘
+....
+
+// TRANSLATION MISSING
+[[item_force_buffer]]
+===== Force buffer
+
Specjalna składnia może zostać użyta, żeby wymusić bufor używany do wyświetlenia
elementów paska: "@bufor:element" (gdzie "bufor" to pełna nazwa bufora i "element"
to nazwa elementu paska).
diff --git a/doc/sr/weechat_dev.sr.adoc b/doc/sr/weechat_dev.sr.adoc
index bdd43a161..da2bf4ca8 100644
--- a/doc/sr/weechat_dev.sr.adoc
+++ b/doc/sr/weechat_dev.sr.adoc
@@ -422,6 +422,8 @@ WeeChat „језгро” се налази у следећим директо
|          test-core-utf8.cpp | Тестови: UTF-8.
|          test-core-util.cpp | Тестови: помоћне функције.
|       gui/ | Корен unit тестова интерфејса.
+// TRANSLATION MISSING
+|          test-gui-bar-window.cpp | Tests: bar window functions.
|          test-gui-buffer.cpp | Тестови: бафер функције.
|          test-gui-chat.cpp | Тестови: чет функције.
|          test-gui-color.cpp | Тестови: боје.
diff --git a/doc/sr/weechat_user.sr.adoc b/doc/sr/weechat_user.sr.adoc
index fb5cc9a85..727af3f6c 100644
--- a/doc/sr/weechat_user.sr.adoc
+++ b/doc/sr/weechat_user.sr.adoc
@@ -2536,14 +2536,42 @@ _трака_ је површина уз разговор која може да
Испред или након имена ставке можете да употребите карактере (који нису слова или цифре, `+-+` или `+_+`). Они ће се приказивати испред/иза ставке у боји граничника која је дефинисана за траку (опција _color_delim_).
-Пример за траку са ставкама „[time],buffer_number+:+buffer_plugin+.+buffer_name”:
+Пример за траку са ставкама
+„[time],buffer_number+:+buffer_plugin+.+buffer_name,[buffer_last_number]”:
....
┌───────────────────────────────────────────────────────────────────────────┐
-│[12:55] 3:irc/libera.#weechat │
+│[12:55] 3:irc/libera.#weechat [9] │
└───────────────────────────────────────────────────────────────────────────┘
....
+// TRANSLATION MISSING
+[[item_spacer]]
+===== Spacer item
+
+An item called `spacer` can be used to align items (left, center, right).
+
+When at least one `spacer` item is used in a bar, the whole bar width is used:
+the spacers auto expand with the same size (or almost). +
+When the bar is not large enough for all items, spacers are not displayed.
+
+[NOTE]
+The `spacer` bar item can be used only in bars with position `top` or `bottom`,
+filling `horizontal` and size `1`.
+
+Example of bar with items
+"[time],spacer,buffer_number+:+buffer_plugin+.+buffer_name,spacer,[buffer_last_number]":
+
+....
+┌───────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/libera.#weechat [9]│
+└───────────────────────────────────────────────────────────────────────────┘
+....
+
+// TRANSLATION MISSING
+[[item_force_buffer]]
+===== Force buffer
+
Ако желите да форсирате бафер у којем ће се приказивати ставка траке, употребите посебну синтаксу: „@бафер:ставка” (где је „бафер” пуно име бафера, а „ставка” је име ставке траке).
Ово је корисно у кореним (root) тракама код приказа ставке за неки одређени бафер који се не приказује у текућем прозору (или се чак уопште не приказује).
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c
index e3bc5b55b..6b2ba74be 100644
--- a/src/gui/curses/gui-curses-bar-window.c
+++ b/src/gui/curses/gui-curses-bar-window.c
@@ -300,6 +300,9 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
*x + bar_window->x,
*y + bar_window->y);
break;
+ case GUI_COLOR_BAR_SPACER:
+ string += 2;
+ break;
default:
string++;
break;
@@ -407,6 +410,115 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
}
/*
+ * Expands spacers using the sizes computed, replacing them by 0 to N spaces.
+ *
+ * Note: result must be freed after use.
+ */
+
+char *
+gui_bar_window_expand_spacers (const char *string, int length_on_screen,
+ int bar_window_width, int num_spacers)
+{
+ int *spacers, index_spacer, i;
+ char **result, *result2, *next_char;
+
+ if (!string || !string[0])
+ return NULL;
+
+ spacers = gui_bar_window_compute_spacers_size (length_on_screen,
+ bar_window_width,
+ num_spacers);
+ if (!spacers)
+ return NULL;
+
+ result = string_dyn_alloc (256);
+ if (!result)
+ {
+ free (spacers);
+ return NULL;
+ }
+
+ index_spacer = 0;
+
+ while (string && string[0])
+ {
+ switch (string[0])
+ {
+ case GUI_COLOR_COLOR_CHAR:
+ switch (string[1])
+ {
+ case GUI_COLOR_FG_CHAR:
+ case GUI_COLOR_BG_CHAR:
+ case GUI_COLOR_FG_BG_CHAR:
+ case GUI_COLOR_EXTENDED_CHAR:
+ case GUI_COLOR_EMPHASIS_CHAR:
+ case GUI_COLOR_RESET_CHAR:
+ string_dyn_concat (result, string, 2);
+ string += 2;
+ break;
+ case GUI_COLOR_BAR_CHAR:
+ switch (string[2])
+ {
+ case GUI_COLOR_BAR_FG_CHAR:
+ case GUI_COLOR_BAR_DELIM_CHAR:
+ case GUI_COLOR_BAR_BG_CHAR:
+ case GUI_COLOR_BAR_START_INPUT_CHAR:
+ case GUI_COLOR_BAR_START_INPUT_HIDDEN_CHAR:
+ case GUI_COLOR_BAR_MOVE_CURSOR_CHAR:
+ case GUI_COLOR_BAR_START_ITEM:
+ case GUI_COLOR_BAR_START_LINE_ITEM:
+ string_dyn_concat (result, string, 3);
+ string += 3;
+ break;
+ case GUI_COLOR_BAR_SPACER:
+ if (index_spacer < num_spacers)
+ {
+ for (i = 0; i < spacers[index_spacer]; i++)
+ {
+ string_dyn_concat (result, " ", 1);
+ }
+ }
+ index_spacer++;
+ string += 3;
+ break;
+ default:
+ string_dyn_concat (result, string, 2);
+ string += 2;
+ break;
+ }
+ break;
+ default:
+ string_dyn_concat (result, string, 1);
+ string++;
+ break;
+ }
+ break;
+ case GUI_COLOR_SET_ATTR_CHAR:
+ case GUI_COLOR_REMOVE_ATTR_CHAR:
+ case GUI_COLOR_RESET_CHAR:
+ string_dyn_concat (result, string, 1);
+ string++;
+ break;
+ default:
+ next_char = (char *)utf8_next_char (string);
+ if (!next_char)
+ break;
+ string_dyn_concat (result, string, next_char - string);
+ string = next_char;
+ break;
+ }
+ }
+
+ free (spacers);
+
+ result2 = *result;
+
+ string_dyn_free (result, 0);
+
+ return result2;
+}
+
+/*
* Draws a bar for a window.
*/
@@ -414,16 +526,16 @@ void
gui_bar_window_draw (struct t_gui_bar_window *bar_window,
struct t_gui_window *window)
{
- int x, y, items_count, num_lines, line, color_bg;
- enum t_gui_bar_filling filling;
- char *content, **items;
+ int x, y, items_count, num_lines, line, color_bg, bar_position, bar_size;
+ enum t_gui_bar_filling bar_filling;
+ char *content, *content2, **items;
static char str_start_input[16] = { '\0' };
static char str_start_input_hidden[16] = { '\0' };
static char str_cursor[16] = { '\0' };
char *pos_start_input, *pos_after_start_input, *pos_cursor, *buf;
char *new_start_input, *ptr_string;
static int length_start_input, length_start_input_hidden;
- int length_on_screen;
+ int num_spacers, length_on_screen;
int chars_available, index, size;
int length_screen_before_cursor, length_screen_after_cursor;
int diff, max_length, optimal_number_of_lines;
@@ -478,16 +590,31 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
gui_window_current_emphasis = 0;
- filling = gui_bar_get_filling (bar_window->bar);
+ bar_position = CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]);
+ bar_filling = gui_bar_get_filling (bar_window->bar);
+ bar_size = CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]);
- content = gui_bar_window_content_get_with_filling (bar_window, window);
+ content = gui_bar_window_content_get_with_filling (bar_window, window,
+ &num_spacers);
if (content)
{
utf8_normalize (content, '?');
- if ((filling == GUI_BAR_FILLING_HORIZONTAL)
+ length_on_screen = gui_chat_strlen_screen (content);
+ if ((num_spacers > 0) && gui_bar_window_can_use_spacer (bar_window))
+ {
+ content2 = gui_bar_window_expand_spacers (content,
+ length_on_screen,
+ bar_window->width,
+ num_spacers);
+ if (content2)
+ {
+ free (content);
+ content = content2;
+ }
+ }
+ if ((bar_filling == GUI_BAR_FILLING_HORIZONTAL)
&& (bar_window->scroll_x > 0))
{
- length_on_screen = gui_chat_strlen_screen (content);
if (bar_window->scroll_x > length_on_screen - bar_window->width)
{
bar_window->scroll_x = length_on_screen - bar_window->width;
@@ -502,7 +629,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
0, &items_count);
if (items_count == 0)
{
- if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
+ if (bar_size == 0)
gui_bar_window_set_current_size (bar_window, window, 1);
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
@@ -511,7 +638,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
else
{
/* bar with auto size ? then compute new size, according to content */
- if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
+ if (bar_size == 0)
{
/* search longer line and optimal number of lines */
max_length = 0;
@@ -538,11 +665,11 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
if (max_length == 0)
max_length = 1;
- switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
+ switch (bar_position)
{
case GUI_BAR_POSITION_BOTTOM:
case GUI_BAR_POSITION_TOP:
- if (filling == GUI_BAR_FILLING_HORIZONTAL)
+ if (bar_filling == GUI_BAR_FILLING_HORIZONTAL)
num_lines = optimal_number_of_lines;
else
num_lines = items_count;
@@ -656,7 +783,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{
if (!gui_bar_window_print_string (bar_window,
window,
- filling,
+ bar_filling,
&x, &y,
items[line], 1, 1,
&index_item,
@@ -668,7 +795,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
if (x < bar_window->width)
{
- if (filling == GUI_BAR_FILLING_HORIZONTAL)
+ if (bar_filling == GUI_BAR_FILLING_HORIZONTAL)
{
gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
@@ -687,7 +814,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{
gui_bar_window_print_string (bar_window,
window,
- filling,
+ bar_filling,
&x, &y, " ", 0, 0,
&index_item,
&index_subitem,
@@ -702,7 +829,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
if ((bar_window->cursor_x < 0) && (bar_window->cursor_y < 0)
&& ((bar_window->scroll_x > 0) || (bar_window->scroll_y > 0)))
{
- if (filling == GUI_BAR_FILLING_HORIZONTAL)
+ if (bar_filling == GUI_BAR_FILLING_HORIZONTAL)
{
ptr_string = CONFIG_STRING(config_look_bar_more_left);
x = 0;
@@ -728,7 +855,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
if ((bar_window->cursor_x < 0) && (bar_window->cursor_y < 0)
&& (some_data_not_displayed || (line < items_count)))
{
- ptr_string = (filling == GUI_BAR_FILLING_HORIZONTAL) ?
+ ptr_string = (bar_filling == GUI_BAR_FILLING_HORIZONTAL) ?
CONFIG_STRING(config_look_bar_more_right) :
CONFIG_STRING(config_look_bar_more_down);
x = bar_window->width - utf8_strlen_screen (ptr_string);
@@ -752,7 +879,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
else
{
- if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]) == 0)
+ if (bar_size == 0)
gui_bar_window_set_current_size (bar_window, window, 1);
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
@@ -784,7 +911,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SEPARATOR]))
{
- switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
+ switch (bar_position)
{
case GUI_BAR_POSITION_BOTTOM:
gui_window_set_weechat_color (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator,
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index a7776e491..5ad362bbc 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -292,6 +292,7 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
case GUI_COLOR_BAR_MOVE_CURSOR_CHAR:
case GUI_COLOR_BAR_START_ITEM:
case GUI_COLOR_BAR_START_LINE_ITEM:
+ case GUI_COLOR_BAR_SPACER:
string++;
break;
}
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index 75d576c45..758d34702 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -63,7 +63,8 @@ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] =
"buffer_name", "buffer_short_name", "buffer_modes", "buffer_filter",
"buffer_zoom", "buffer_nicklist_count", "buffer_nicklist_count_groups",
"buffer_nicklist_count_all", "scroll", "hotlist", "completion",
- "buffer_title", "buffer_nicklist", "window_number", "mouse_status", "away"
+ "buffer_title", "buffer_nicklist", "window_number", "mouse_status", "away",
+ "spacer"
};
char *gui_bar_items_default_for_bars[][2] =
{ { GUI_BAR_DEFAULT_NAME_INPUT,
@@ -1989,6 +1990,35 @@ gui_bar_item_away_cb (const void *pointer, void *data,
}
/*
+ * Bar item with spacer.
+ */
+
+char *
+gui_bar_item_spacer_cb (const void *pointer, void *data,
+ struct t_gui_bar_item *item,
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
+{
+ char str_spacer[16];
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) item;
+ (void) window;
+ (void) buffer;
+ (void) extra_info;
+
+ snprintf (str_spacer, sizeof (str_spacer), "%c%c%c",
+ GUI_COLOR_COLOR_CHAR,
+ GUI_COLOR_BAR_CHAR,
+ GUI_COLOR_BAR_SPACER);
+
+ return strdup (str_spacer);
+}
+
+/*
* Focus on nicklist.
*/
@@ -2436,6 +2466,11 @@ gui_bar_item_init ()
&gui_bar_item_away_cb, NULL, NULL);
gui_bar_item_hook_signal ("buffer_localvar_*",
gui_bar_item_names[GUI_BAR_ITEM_AWAY]);
+
+ /* spacer */
+ gui_bar_item_new (NULL,
+ gui_bar_item_names[GUI_BAR_ITEM_SPACER],
+ &gui_bar_item_spacer_cb, NULL, NULL);
}
/*
diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h
index 822cfb1d0..fc8dda3bf 100644
--- a/src/gui/gui-bar-item.h
+++ b/src/gui/gui-bar-item.h
@@ -47,6 +47,7 @@ enum t_gui_bar_item_weechat
GUI_BAR_ITEM_WINDOW_NUMBER,
GUI_BAR_ITEM_MOUSE_STATUS,
GUI_BAR_ITEM_AWAY,
+ GUI_BAR_ITEM_SPACER,
/* number of bar items */
GUI_BAR_NUM_ITEMS,
};
diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c
index f87ee210b..a5a943c9d 100644
--- a/src/gui/gui-bar-window.c
+++ b/src/gui/gui-bar-window.c
@@ -668,15 +668,37 @@ gui_bar_window_content_get (struct t_gui_bar_window *bar_window,
}
/*
+ * Checks if the item content is a spacer (bar item "spacer").
+ *
+ * Returns:
+ * 1: item is a spacer
+ * 1: item is not a spacer
+ */
+
+int
+gui_bar_window_item_is_spacer (const char *item)
+{
+ return (item
+ && (item[0] == GUI_COLOR_COLOR_CHAR)
+ && (item[1] == GUI_COLOR_BAR_CHAR)
+ && (item[2] == GUI_COLOR_BAR_SPACER)
+ && !item[3]);
+}
+
+/*
* Gets content of a bar window, formatted for display, according to filling
* for bar position.
*
+ * The integer variable *num_spacers is set with the number of spacers found
+ * (bar item "spacer").
+ *
* Note: result must be freed after use.
*/
char *
gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
- struct t_gui_window *window)
+ struct t_gui_window *window,
+ int *num_spacers)
{
enum t_gui_bar_filling filling;
const char *ptr_content;
@@ -689,6 +711,9 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
int length_reinit_color, length_reinit_color_space, length_start_item;
int length, max_length, max_length_screen;
int total_items, columns, lines;
+ int item_is_spacer;
+
+ *num_spacers = 0;
if (!bar_window
|| !bar_window->items_subcount || !bar_window->items_content
@@ -757,7 +782,10 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
{
item_value = NULL;
}
- if (at_least_one_item && first_sub_item)
+ item_is_spacer = gui_bar_window_item_is_spacer (
+ (item_value) ? item_value : ptr_content);
+ if (at_least_one_item && first_sub_item
+ && !item_is_spacer)
{
/* first sub item: insert space after last item */
if (filling == GUI_BAR_FILLING_HORIZONTAL)
@@ -788,7 +816,10 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
first_sub_item = 0;
if (item_value)
free (item_value);
- at_least_one_item = 1;
+ if (item_is_spacer)
+ (*num_spacers)++;
+ else
+ at_least_one_item = 1;
}
else
{
@@ -963,6 +994,80 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
}
/*
+ * Checks if spacer can be used in the bar according to its position, filling
+ * and size.
+ *
+ * Returns:
+ * 1: spacers can be used
+ * 0: spacers can not be used
+ */
+
+int
+gui_bar_window_can_use_spacer (struct t_gui_bar_window *bar_window)
+{
+ int position, filling, bar_size;
+ int pos_ok, filling_ok, size_ok;
+
+ if (!bar_window)
+ return 0;
+
+ position = CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]);
+ filling = gui_bar_get_filling (bar_window->bar);
+ bar_size = CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SIZE]);
+
+ pos_ok = ((position == GUI_BAR_POSITION_TOP)
+ || (position == GUI_BAR_POSITION_BOTTOM));
+ filling_ok = (filling == GUI_BAR_FILLING_HORIZONTAL);
+ size_ok = (bar_size == 1);
+
+ return pos_ok && filling_ok && size_ok;
+}
+
+/*
+ * Computes size of each spacer in the bar.
+ *
+ * Note: result must be freed after use.
+ */
+
+int *
+gui_bar_window_compute_spacers_size (int length_on_screen,
+ int bar_window_width,
+ int num_spacers)
+{
+ int *spacers, spacer_size, i;
+
+ if ((length_on_screen < 0) || (bar_window_width < 1) || (num_spacers <= 0))
+ return NULL;
+
+ /* if not enough space for spacers, ignore them all */
+ if (length_on_screen >= bar_window_width)
+ return NULL;
+
+ spacers = malloc (num_spacers * sizeof (spacers[0]));
+ if (!spacers)
+ return NULL;
+
+ spacer_size = (bar_window_width - length_on_screen) / num_spacers;
+
+ for (i = 0; i < num_spacers; i++)
+ {
+ spacers[i] = spacer_size;
+ }
+
+ length_on_screen += num_spacers * spacer_size;
+
+ i = 0;
+ while ((length_on_screen < bar_window_width) && (i < num_spacers))
+ {
+ spacers[i]++;
+ i++;
+ length_on_screen++;
+ }
+
+ return spacers;
+}
+
+/*
* Adds coordinates (item index/subindex and x,y).
*/
diff --git a/src/gui/gui-bar-window.h b/src/gui/gui-bar-window.h
index 37b1fbc39..4813e63c1 100644
--- a/src/gui/gui-bar-window.h
+++ b/src/gui/gui-bar-window.h
@@ -77,7 +77,12 @@ extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_wind
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,
- struct t_gui_window *window);
+ struct t_gui_window *window,
+ int *num_spacers);
+extern int gui_bar_window_can_use_spacer (struct t_gui_bar_window *bar_window);
+extern int *gui_bar_window_compute_spacers_size (int length_on_screen,
+ int bar_window_width,
+ int num_spacers);
extern struct t_gui_bar_window *gui_bar_window_search_bar (struct t_gui_window *window,
struct t_gui_bar *bar);
extern int gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window);
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index a4557ac57..1bd0aca63 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -707,6 +707,7 @@ gui_color_code_size (const char *string)
case GUI_COLOR_BAR_MOVE_CURSOR_CHAR:
case GUI_COLOR_BAR_START_ITEM:
case GUI_COLOR_BAR_START_LINE_ITEM:
+ case GUI_COLOR_BAR_SPACER:
ptr_string++;
break;
}
@@ -892,6 +893,7 @@ gui_color_decode (const char *string, const char *replacement)
case GUI_COLOR_BAR_MOVE_CURSOR_CHAR:
case GUI_COLOR_BAR_START_ITEM:
case GUI_COLOR_BAR_START_LINE_ITEM:
+ case GUI_COLOR_BAR_SPACER:
ptr_string++;
break;
}
@@ -1518,6 +1520,7 @@ gui_color_encode_ansi (const char *string)
case GUI_COLOR_BAR_MOVE_CURSOR_CHAR:
case GUI_COLOR_BAR_START_ITEM:
case GUI_COLOR_BAR_START_LINE_ITEM:
+ case GUI_COLOR_BAR_SPACER:
ptr_string++;
break;
}
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 50e78d018..799fd76bd 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -134,6 +134,7 @@ enum t_gui_color_enum
#define GUI_COLOR_BAR_MOVE_CURSOR_CHAR '#'
#define GUI_COLOR_BAR_START_ITEM 'i'
#define GUI_COLOR_BAR_START_LINE_ITEM 'l'
+#define GUI_COLOR_BAR_SPACER 's'
#define GUI_COLOR_EXTENDED_FLAG 0x0100000
#define GUI_COLOR_EXTENDED_BOLD_FLAG 0x0200000
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b46c1184b..a0a0c862c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -42,6 +42,7 @@ set(LIB_WEECHAT_UNIT_TESTS_CORE_SRC
unit/core/test-core-url.cpp
unit/core/test-core-utf8.cpp
unit/core/test-core-util.cpp
+ unit/gui/test-gui-bar-window.cpp
unit/gui/test-gui-buffer.cpp
unit/gui/test-gui-chat.cpp
unit/gui/test-gui-color.cpp
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 01b6b2e06..d4c610f6a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -39,6 +39,7 @@ lib_weechat_unit_tests_core_a_SOURCES = unit/core/test-core-arraylist.cpp \
unit/core/test-core-url.cpp \
unit/core/test-core-utf8.cpp \
unit/core/test-core-util.cpp \
+ unit/gui/test-gui-bar-window.cpp \
unit/gui/test-gui-buffer.cpp \
unit/gui/test-gui-chat.cpp \
unit/gui/test-gui-color.cpp \
diff --git a/tests/tests.cpp b/tests/tests.cpp
index 923d5caca..08a8e3318 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -79,6 +79,7 @@ IMPORT_TEST_GROUP(CoreUrl);
IMPORT_TEST_GROUP(CoreUtf8);
IMPORT_TEST_GROUP(CoreUtil);
/* GUI */
+IMPORT_TEST_GROUP(GuiBarWindow);
IMPORT_TEST_GROUP(GuiBuffer);
IMPORT_TEST_GROUP(GuiChat);
IMPORT_TEST_GROUP(GuiColor);
diff --git a/tests/unit/gui/test-gui-bar-window.cpp b/tests/unit/gui/test-gui-bar-window.cpp
new file mode 100644
index 000000000..af489b10b
--- /dev/null
+++ b/tests/unit/gui/test-gui-bar-window.cpp
@@ -0,0 +1,456 @@
+/*
+ * test-gui-bar-window.cpp - test bar window functions
+ *
+ * Copyright (C) 2022 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WeeChat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "CppUTest/TestHarness.h"
+
+extern "C"
+{
+#include <string.h>
+#include "src/gui/gui-bar-window.h"
+#include "src/gui/gui-color.h"
+#include "src/gui/gui-window.h"
+
+extern int gui_bar_window_item_is_spacer (const char *item);
+}
+
+TEST_GROUP(GuiBarWindow)
+{
+};
+
+/*
+ * Tests functions:
+ * gui_bar_window_valid
+ */
+
+TEST(GuiBarWindow, Valid)
+{
+ LONGS_EQUAL(0, gui_bar_window_valid (NULL));
+ LONGS_EQUAL(0, gui_bar_window_valid ((struct t_gui_bar_window *)0x1));
+
+ LONGS_EQUAL(1, gui_bar_window_valid (gui_windows->bar_windows));
+
+ LONGS_EQUAL(0, gui_bar_window_valid (gui_windows->bar_windows + 1));
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_search_bar
+ */
+
+TEST(GuiBarWindow, SearchBar)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_search_by_xy
+ */
+
+TEST(GuiBarWindow, SearchByXy)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_get_size
+ */
+
+TEST(GuiBarWindow, GetSize)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_calculate_pos_size
+ */
+
+TEST(GuiBarWindow, CalculatePosSize)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_find_pos
+ */
+
+TEST(GuiBarWindow, FindPos)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_content_alloc
+ */
+
+TEST(GuiBarWindow, ContentAlloc)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_content_free
+ */
+
+TEST(GuiBarWindow, ContentFree)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_content_build_item
+ */
+
+TEST(GuiBarWindow, ContentBuildItem)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_content_build
+ */
+
+TEST(GuiBarWindow, ContentBuild)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_content_get
+ */
+
+TEST(GuiBarWindow, ContentGet)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_item_is_spacer
+ */
+
+TEST(GuiBarWindow, ItemIsSpacer)
+{
+ char str_spacer[16];
+
+ LONGS_EQUAL(0, gui_bar_window_item_is_spacer (NULL));
+ LONGS_EQUAL(0, gui_bar_window_item_is_spacer (""));
+
+ snprintf (str_spacer, sizeof (str_spacer),
+ "%c",
+ GUI_COLOR_COLOR_CHAR);
+ LONGS_EQUAL(0, gui_bar_window_item_is_spacer (str_spacer));
+
+ snprintf (str_spacer, sizeof (str_spacer),
+ "%c%c",
+ GUI_COLOR_COLOR_CHAR,
+ GUI_COLOR_BAR_CHAR);
+ LONGS_EQUAL(0, gui_bar_window_item_is_spacer (str_spacer));
+
+ snprintf (str_spacer, sizeof (str_spacer),
+ "%c%c%c",
+ GUI_COLOR_COLOR_CHAR,
+ GUI_COLOR_BAR_CHAR,
+ GUI_COLOR_BAR_SPACER);
+ LONGS_EQUAL(1, gui_bar_window_item_is_spacer (str_spacer));
+
+ snprintf (str_spacer, sizeof (str_spacer),
+ "%c%c%c ",
+ GUI_COLOR_COLOR_CHAR,
+ GUI_COLOR_BAR_CHAR,
+ GUI_COLOR_BAR_SPACER);
+ LONGS_EQUAL(0, gui_bar_window_item_is_spacer (str_spacer));
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_content_get_with_filling
+ */
+
+TEST(GuiBarWindow, ContentGetWithFilling)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_can_use_spacer
+ */
+
+TEST(GuiBarWindow, CanUseSpacer)
+{
+ struct t_gui_bar *bar;
+ struct t_gui_bar_window *bar_window;
+
+ bar = gui_bar_search ("title");
+ CHECK(bar);
+ bar_window = gui_bar_window_search_bar (gui_windows, bar);
+ CHECK(bar_window);
+ LONGS_EQUAL(1, gui_bar_window_can_use_spacer (bar_window));
+
+ bar = gui_bar_search ("status");
+ CHECK(bar);
+ bar_window = gui_bar_window_search_bar (gui_windows, bar);
+ CHECK(bar_window);
+ LONGS_EQUAL(1, gui_bar_window_can_use_spacer (bar_window));
+
+ bar = gui_bar_search ("input");
+ CHECK(bar);
+ bar_window = gui_bar_window_search_bar (gui_windows, bar);
+ CHECK(bar_window);
+ LONGS_EQUAL(0, gui_bar_window_can_use_spacer (bar_window));
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_compute_spacers_size
+ */
+
+TEST(GuiBarWindow, ComputeSpacersSize)
+{
+ int *spacers;
+
+ POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (-1, 0, 0));
+ POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (10, 0, 0));
+ POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (10, 20, 0));
+ POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (10, 20, 0));
+
+ /* length on screen == bar window width */
+ POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (20, 20, 3));
+
+ /* length on screen > bar window width */
+ POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (25, 20, 3));
+
+ /* single spacer */
+ spacers = gui_bar_window_compute_spacers_size (10, 20, 1);
+ CHECK(spacers);
+ LONGS_EQUAL(10, spacers[0]);
+ free (spacers);
+
+ /* 2 spacers */
+ spacers = gui_bar_window_compute_spacers_size (10, 20, 2);
+ CHECK(spacers);
+ LONGS_EQUAL(5, spacers[0]);
+ LONGS_EQUAL(5, spacers[1]);
+ free (spacers);
+
+ /* 3 spacers */
+ spacers = gui_bar_window_compute_spacers_size (10, 20, 3);
+ CHECK(spacers);
+ LONGS_EQUAL(4, spacers[0]);
+ LONGS_EQUAL(3, spacers[1]);
+ LONGS_EQUAL(3, spacers[2]);
+ free (spacers);
+
+ /* 4 spacers */
+ spacers = gui_bar_window_compute_spacers_size (10, 20, 4);
+ CHECK(spacers);
+ LONGS_EQUAL(3, spacers[0]);
+ LONGS_EQUAL(3, spacers[1]);
+ LONGS_EQUAL(2, spacers[2]);
+ LONGS_EQUAL(2, spacers[3]);
+ free (spacers);
+
+ /* 12 spacers */
+ spacers = gui_bar_window_compute_spacers_size (10, 20, 12);
+ CHECK(spacers);
+ LONGS_EQUAL(1, spacers[0]);
+ LONGS_EQUAL(1, spacers[1]);
+ LONGS_EQUAL(1, spacers[2]);
+ LONGS_EQUAL(1, spacers[3]);
+ LONGS_EQUAL(1, spacers[4]);
+ LONGS_EQUAL(1, spacers[5]);
+ LONGS_EQUAL(1, spacers[6]);
+ LONGS_EQUAL(1, spacers[7]);
+ LONGS_EQUAL(1, spacers[8]);
+ LONGS_EQUAL(1, spacers[9]);
+ LONGS_EQUAL(0, spacers[10]);
+ LONGS_EQUAL(0, spacers[11]);
+ free (spacers);
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_coords_add
+ */
+
+TEST(GuiBarWindow, CoordsAdd)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_coords_free
+ */
+
+TEST(GuiBarWindow, CoordsFree)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_insert
+ */
+
+TEST(GuiBarWindow, Insert)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_new
+ */
+
+TEST(GuiBarWindow, New)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_get_current_size
+ */
+
+TEST(GuiBarWindow, GetCurrentSize)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_get_max_size_in_window
+ */
+
+TEST(GuiBarWindow, GetMaxSizeInWindow)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_get_max_size
+ */
+
+TEST(GuiBarWindow, GetMaxSize)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_set_current_size
+ */
+
+TEST(GuiBarWindow, SetCurrentSize)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_free
+ */
+
+TEST(GuiBarWindow, Free)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_remove_unused_bars
+ */
+
+TEST(GuiBarWindow, RemoveUnusedBars)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_add_missing_bars
+ */
+
+TEST(GuiBarWindow, AddMissingBars)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_scroll
+ */
+
+TEST(GuiBarWindow, Scroll)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_update_cb
+ */
+
+TEST(GuiBarWindow, UpdateCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_hdata_bar_window_cb
+ */
+
+TEST(GuiBarWindow, HdataBarWindowCb)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_add_to_infolist
+ */
+
+TEST(GuiBarWindow, AddToInfolist)
+{
+ /* TODO: write tests */
+}
+
+/*
+ * Tests functions:
+ * gui_bar_window_print_log
+ */
+
+TEST(GuiBarWindow, PrintLog)
+{
+ /* TODO: write tests */
+}