Added filling/color_fg/color_bg options for bars, added config_get/config_get_plugin/config_set_plugin in script API

This commit is contained in:
Sebastien Helleu 2008-04-24 12:18:26 +02:00
parent a5e5ab6e48
commit ab6684c60a
27 changed files with 1297 additions and 423 deletions

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n" "Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-22 18:08+0200\n" "POT-Creation-Date: 2008-04-23 18:30+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -114,7 +114,7 @@ msgid "List of bars:"
msgstr "Seznam pro aliasy:\n" msgstr "Seznam pro aliasy:\n"
#, fuzzy, c-format #, fuzzy, c-format
msgid " %d. %s: %s (cond: %s), %s, %s: %s%s%d%s, items: %s%s (plugin: %s)" msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgstr "%sna %s%s%s/%s%s%s:%s ignoruji %s%s%s od %s%s\n" msgstr "%sna %s%s%s/%s%s%s:%s ignoruji %s%s%s od %s%s\n"
#, fuzzy #, fuzzy
@ -127,6 +127,10 @@ msgstr ""
msgid "auto" msgid "auto"
msgstr "" msgstr ""
#, fuzzy, c-format
msgid " fg: %s, bg: %s, items: %s%s (plugin: %s)"
msgstr "%sna %s%s%s/%s%s%s:%s ignoruji %s%s%s od %s%s\n"
#, fuzzy #, fuzzy
msgid ", with separator" msgid ", with separator"
msgstr "barva pro dělič času" msgstr "barva pro dělič času"
@ -1706,6 +1710,11 @@ msgstr ""
msgid "bar position (bottom, top, left, right)" msgid "bar position (bottom, top, left, right)"
msgstr "pozice seznamu přezdívek (top, left, right (výchozí), bottom)" msgstr "pozice seznamu přezdívek (top, left, right (výchozí), bottom)"
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom))"
msgstr ""
msgid "bar size in chars (0 = auto size)" msgid "bar size in chars (0 = auto size)"
msgstr "" msgstr ""
@ -1713,6 +1722,14 @@ msgstr ""
msgid "max bar size in chars (0 = no limit)" msgid "max bar size in chars (0 = no limit)"
msgstr "maximální délka jmen v hotlistu (0 = bez limitu)" msgstr "maximální délka jmen v hotlistu (0 = bez limitu)"
#, fuzzy
msgid "default text color for bar"
msgstr "barva textu v info baru"
#, fuzzy
msgid "default background color for bar"
msgstr "barva textu v info baru"
#, fuzzy #, fuzzy
msgid "separator line between bar and other bars/windows" msgid "separator line between bar and other bars/windows"
msgstr "oddělovač mezi rozhovorem a seznamem přezdívek" msgstr "oddělovač mezi rozhovorem a seznamem přezdívek"

View File

@ -9,7 +9,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n" "Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-22 18:08+0200\n" "POT-Creation-Date: 2008-04-23 18:30+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n" "Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -119,7 +119,7 @@ msgid "List of bars:"
msgstr "Liste der Aliases:\n" msgstr "Liste der Aliases:\n"
#, fuzzy, c-format #, fuzzy, c-format
msgid " %d. %s: %s (cond: %s), %s, %s: %s%s%d%s, items: %s%s (plugin: %s)" msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgstr "%sin %s%s%s/%s%s%s:%s ignoriere %s%s%s von %s%s\n" msgstr "%sin %s%s%s/%s%s%s:%s ignoriere %s%s%s von %s%s\n"
#, fuzzy #, fuzzy
@ -132,6 +132,10 @@ msgstr ""
msgid "auto" msgid "auto"
msgstr "" msgstr ""
#, fuzzy, c-format
msgid " fg: %s, bg: %s, items: %s%s (plugin: %s)"
msgstr "%sin %s%s%s/%s%s%s:%s ignoriere %s%s%s von %s%s\n"
#, fuzzy #, fuzzy
msgid ", with separator" msgid ", with separator"
msgstr "Farbe für den Zeit-Separator" msgstr "Farbe für den Zeit-Separator"
@ -1706,6 +1710,11 @@ msgstr ""
msgid "bar position (bottom, top, left, right)" msgid "bar position (bottom, top, left, right)"
msgstr "Nicklisten-Position (top, left, right (Standard), bottom)" msgstr "Nicklisten-Position (top, left, right (Standard), bottom)"
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom))"
msgstr ""
msgid "bar size in chars (0 = auto size)" msgid "bar size in chars (0 = auto size)"
msgstr "" msgstr ""
@ -1713,6 +1722,14 @@ msgstr ""
msgid "max bar size in chars (0 = no limit)" msgid "max bar size in chars (0 = no limit)"
msgstr "maximale Länge der Namen in der Hotlist (0: kein Limit)" msgstr "maximale Länge der Namen in der Hotlist (0: kein Limit)"
#, fuzzy
msgid "default text color for bar"
msgstr "Farbe des Infobar-Textes"
#, fuzzy
msgid "default background color for bar"
msgstr "Farbe des Infobar-Textes"
#, fuzzy #, fuzzy
msgid "separator line between bar and other bars/windows" msgid "separator line between bar and other bars/windows"
msgstr "Trennzeichen zwischen Chatfenster und Nickliste" msgstr "Trennzeichen zwischen Chatfenster und Nickliste"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n" "Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-22 18:08+0200\n" "POT-Creation-Date: 2008-04-23 18:30+0200\n"
"PO-Revision-Date: 2007-09-19 12:09+0200\n" "PO-Revision-Date: 2007-09-19 12:09+0200\n"
"Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n" "Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -116,7 +116,7 @@ msgid "List of bars:"
msgstr "Lista de alias:\n" msgstr "Lista de alias:\n"
#, fuzzy, c-format #, fuzzy, c-format
msgid " %d. %s: %s (cond: %s), %s, %s: %s%s%d%s, items: %s%s (plugin: %s)" msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgstr "%sen %s%s%s/%s%s%s:%s ignorando %s%s%s de %s%s\n" msgstr "%sen %s%s%s/%s%s%s:%s ignorando %s%s%s de %s%s\n"
msgid "height" msgid "height"
@ -128,6 +128,10 @@ msgstr ""
msgid "auto" msgid "auto"
msgstr "" msgstr ""
#, fuzzy, c-format
msgid " fg: %s, bg: %s, items: %s%s (plugin: %s)"
msgstr "%sen %s%s%s/%s%s%s:%s ignorando %s%s%s de %s%s\n"
#, fuzzy #, fuzzy
msgid ", with separator" msgid ", with separator"
msgstr "color para el separador de la hora" msgstr "color para el separador de la hora"
@ -1692,6 +1696,11 @@ msgstr ""
"posición de la ventana de usuarios (arriba (top), izquierda (left), derecha " "posición de la ventana de usuarios (arriba (top), izquierda (left), derecha "
"(right, por defecto), abajo (bottom))" "(right, por defecto), abajo (bottom))"
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom))"
msgstr ""
msgid "bar size in chars (0 = auto size)" msgid "bar size in chars (0 = auto size)"
msgstr "" msgstr ""
@ -1699,6 +1708,14 @@ msgstr ""
msgid "max bar size in chars (0 = no limit)" msgid "max bar size in chars (0 = no limit)"
msgstr "longitud máxima de nombres en la hotlist (0 = sin límite)" msgstr "longitud máxima de nombres en la hotlist (0 = sin límite)"
#, fuzzy
msgid "default text 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"
msgid "separator line between bar and other bars/windows" msgid "separator line between bar and other bars/windows"
msgstr "" msgstr ""

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n" "Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-22 18:08+0200\n" "POT-Creation-Date: 2008-04-23 18:30+0200\n"
"PO-Revision-Date: 2008-04-22 18:09+0200\n" "PO-Revision-Date: 2008-04-23 18:32+0200\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n" "Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -111,9 +111,8 @@ msgid "List of bars:"
msgstr "Liste des barres:" msgstr "Liste des barres:"
#, c-format #, c-format
msgid " %d. %s: %s (cond: %s), %s, %s: %s%s%d%s, items: %s%s (plugin: %s)" msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgstr "" msgstr " %3d. %s%s%s: %s (cond: %s), %s, remplissage: %s, %s: %s%s%d%s"
" %d. %s: %s (cond: %s), %s, %s: %s%s%d%s, objets: %s%s (extension: %s)"
msgid "height" msgid "height"
msgstr "hauteur" msgstr "hauteur"
@ -124,6 +123,10 @@ msgstr "largeur"
msgid "auto" msgid "auto"
msgstr "auto" msgstr "auto"
#, c-format
msgid " fg: %s, bg: %s, items: %s%s (plugin: %s)"
msgstr " fg: %s, bg: %s, objets: %s%s (extension: %s)"
msgid ", with separator" msgid ", with separator"
msgstr ", avec séparateur" msgstr ", avec séparateur"
@ -1648,12 +1651,25 @@ msgstr ""
"position de la barre (bottom (bas), top (haut), left (gauche), right " "position de la barre (bottom (bas), top (haut), left (gauche), right "
"(droite))" "(droite))"
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom))"
msgstr ""
"direction de remplissage de la barre (\"horizontal\" (de gauche à droite) ou "
"\"vertical\" (de haut en bas))"
msgid "bar size in chars (0 = auto size)" msgid "bar size in chars (0 = auto size)"
msgstr "taille de la barre en caractères (0 = taille automatique)" msgstr "taille de la barre en caractères (0 = taille automatique)"
msgid "max bar size in chars (0 = no limit)" msgid "max bar size in chars (0 = no limit)"
msgstr "taille max de la barre en caractères (0 = pas de limite)" 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 background color for bar"
msgstr "couleur du fond par défaut pour la barre"
msgid "separator line between bar and other bars/windows" msgid "separator line between bar and other bars/windows"
msgstr "ligne de séparation entre la barre et les autres barres/fenêtres" msgstr "ligne de séparation entre la barre et les autres barres/fenêtres"

View File

@ -12,7 +12,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n" "Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-22 18:08+0200\n" "POT-Creation-Date: 2008-04-23 18:30+0200\n"
"PO-Revision-Date: 2007-10-10 18:07+0200\n" "PO-Revision-Date: 2007-10-10 18:07+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -120,7 +120,7 @@ msgid "List of bars:"
msgstr "Aliaszok listája:\n" msgstr "Aliaszok listája:\n"
#, fuzzy, c-format #, fuzzy, c-format
msgid " %d. %s: %s (cond: %s), %s, %s: %s%s%d%s, items: %s%s (plugin: %s)" msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgstr "%s %s%s%s/%s%s%s:%s %s%s%s mellőzése a következő(k)től: %s%s\n" msgstr "%s %s%s%s/%s%s%s:%s %s%s%s mellőzése a következő(k)től: %s%s\n"
#, fuzzy #, fuzzy
@ -133,6 +133,10 @@ msgstr ""
msgid "auto" msgid "auto"
msgstr "" msgstr ""
#, fuzzy, c-format
msgid " fg: %s, bg: %s, items: %s%s (plugin: %s)"
msgstr "%s %s%s%s/%s%s%s:%s %s%s%s mellőzése a következő(k)től: %s%s\n"
#, fuzzy #, fuzzy
msgid ", with separator" msgid ", with separator"
msgstr "időelválasztó színe" msgstr "időelválasztó színe"
@ -1710,12 +1714,25 @@ msgstr ""
msgid "bar position (bottom, top, left, right)" msgid "bar position (bottom, top, left, right)"
msgstr "névlista helye (top, left, right (alapértelmezett), bottom)" msgstr "névlista helye (top, left, right (alapértelmezett), bottom)"
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom))"
msgstr ""
msgid "bar size in chars (0 = auto size)" msgid "bar size in chars (0 = auto size)"
msgstr "" msgstr ""
msgid "max bar size in chars (0 = no limit)" msgid "max bar size in chars (0 = no limit)"
msgstr "" msgstr ""
#, fuzzy
msgid "default text 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"
#, fuzzy #, fuzzy
msgid "separator line between bar and other bars/windows" msgid "separator line between bar and other bars/windows"
msgstr "a névlista és a beszélgetőablak közti elválasztó" msgstr "a névlista és a beszélgetőablak közti elválasztó"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n" "Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-22 18:08+0200\n" "POT-Creation-Date: 2008-04-23 18:30+0200\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n" "Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -116,7 +116,7 @@ msgid "List of bars:"
msgstr "Список сокращений:\n" msgstr "Список сокращений:\n"
#, fuzzy, c-format #, fuzzy, c-format
msgid " %d. %s: %s (cond: %s), %s, %s: %s%s%d%s, items: %s%s (plugin: %s)" msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgstr "%sна %s%s%s/%s%s%s:%s игнорирует %s%s%s с %s%s\n" msgstr "%sна %s%s%s/%s%s%s:%s игнорирует %s%s%s с %s%s\n"
#, fuzzy #, fuzzy
@ -129,6 +129,10 @@ msgstr ""
msgid "auto" msgid "auto"
msgstr "" msgstr ""
#, fuzzy, c-format
msgid " fg: %s, bg: %s, items: %s%s (plugin: %s)"
msgstr "%sна %s%s%s/%s%s%s:%s игнорирует %s%s%s с %s%s\n"
#, fuzzy #, fuzzy
msgid ", with separator" msgid ", with separator"
msgstr "цвет разделителя времени" msgstr "цвет разделителя времени"
@ -1715,6 +1719,11 @@ msgid "bar position (bottom, top, left, right)"
msgstr "" msgstr ""
"расположение списка пользователей (top, left, right(по умолчанию), bottom)" "расположение списка пользователей (top, left, right(по умолчанию), bottom)"
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom))"
msgstr ""
msgid "bar size in chars (0 = auto size)" msgid "bar size in chars (0 = auto size)"
msgstr "" msgstr ""
@ -1722,6 +1731,14 @@ msgstr ""
msgid "max bar size in chars (0 = no limit)" msgid "max bar size in chars (0 = no limit)"
msgstr "максимальная длина имён в хотлисте (0=не ограничено)" msgstr "максимальная длина имён в хотлисте (0=не ограничено)"
#, fuzzy
msgid "default text color for bar"
msgstr "цвет текста информационной панели"
#, fuzzy
msgid "default background color for bar"
msgstr "цвет текста информационной панели"
#, fuzzy #, fuzzy
msgid "separator line between bar and other bars/windows" msgid "separator line between bar and other bars/windows"
msgstr "разделитель чата и никлиста" msgstr "разделитель чата и никлиста"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-04-22 18:08+0200\n" "POT-Creation-Date: 2008-04-23 18:30+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -94,7 +94,7 @@ msgid "List of bars:"
msgstr "" msgstr ""
#, c-format #, c-format
msgid " %d. %s: %s (cond: %s), %s, %s: %s%s%d%s, items: %s%s (plugin: %s)" msgid " %3d. %s%s%s: %s (cond: %s), %s, filling: %s, %s: %s%s%d%s"
msgstr "" msgstr ""
msgid "height" msgid "height"
@ -106,6 +106,10 @@ msgstr ""
msgid "auto" msgid "auto"
msgstr "" msgstr ""
#, c-format
msgid " fg: %s, bg: %s, items: %s%s (plugin: %s)"
msgstr ""
msgid ", with separator" msgid ", with separator"
msgstr "" msgstr ""
@ -1410,12 +1414,23 @@ msgstr ""
msgid "bar position (bottom, top, left, right)" msgid "bar position (bottom, top, left, right)"
msgstr "" msgstr ""
msgid ""
"bar filling direction (\"horizontal\" (from left to right) or \"vertical"
"\" (from top to bottom))"
msgstr ""
msgid "bar size in chars (0 = auto size)" msgid "bar size in chars (0 = auto size)"
msgstr "" msgstr ""
msgid "max bar size in chars (0 = no limit)" msgid "max bar size in chars (0 = no limit)"
msgstr "" msgstr ""
msgid "default text color for bar"
msgstr ""
msgid "default background color for bar"
msgstr ""
msgid "separator line between bar and other bars/windows" msgid "separator line between bar and other bars/windows"
msgstr "" msgstr ""

View File

@ -86,26 +86,36 @@ command_bar (void *data, struct t_gui_buffer *buffer,
ptr_bar = ptr_bar->next_bar) ptr_bar = ptr_bar->next_bar)
{ {
gui_chat_printf (NULL, gui_chat_printf (NULL,
_(" %d. %s: %s (cond: %s), %s, %s: " _(" %3d. %s%s%s: %s (cond: %s), %s, filling: %s, "
"%s%s%d%s, items: %s%s (plugin: %s)"), "%s: %s%s%d%s"),
ptr_bar->number, ptr_bar->number,
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
ptr_bar->name, ptr_bar->name,
GUI_COLOR(GUI_COLOR_CHAT),
gui_bar_type_str[CONFIG_INTEGER(ptr_bar->type)], gui_bar_type_str[CONFIG_INTEGER(ptr_bar->type)],
(CONFIG_STRING(ptr_bar->conditions) (CONFIG_STRING(ptr_bar->conditions)
&& CONFIG_STRING(ptr_bar->conditions)[0]) ? && CONFIG_STRING(ptr_bar->conditions)[0]) ?
CONFIG_STRING(ptr_bar->conditions) : "-", CONFIG_STRING(ptr_bar->conditions) : "-",
gui_bar_position_str[CONFIG_INTEGER(ptr_bar->position)], gui_bar_position_str[CONFIG_INTEGER(ptr_bar->position)],
gui_bar_filling_str[CONFIG_INTEGER(ptr_bar->filling)],
((CONFIG_INTEGER(ptr_bar->position) == GUI_BAR_POSITION_BOTTOM) ((CONFIG_INTEGER(ptr_bar->position) == GUI_BAR_POSITION_BOTTOM)
|| (CONFIG_INTEGER(ptr_bar->position) == GUI_BAR_POSITION_TOP)) ? || (CONFIG_INTEGER(ptr_bar->position) == GUI_BAR_POSITION_TOP)) ?
_("height") : _("width"), _("height") : _("width"),
(CONFIG_INTEGER(ptr_bar->size) == 0) ? _("auto") : "", (CONFIG_INTEGER(ptr_bar->size) == 0) ? _("auto") : "",
(CONFIG_INTEGER(ptr_bar->size) == 0) ? " (" : "", (CONFIG_INTEGER(ptr_bar->size) == 0) ? " (" : "",
ptr_bar->current_size, ptr_bar->current_size,
(CONFIG_INTEGER(ptr_bar->size) == 0) ? ")" : "", (CONFIG_INTEGER(ptr_bar->size) == 0) ? ")" : "");
(CONFIG_STRING(ptr_bar->items)) ? CONFIG_STRING(ptr_bar->items) : "-", gui_chat_printf (NULL,
_(" fg: %s, bg: %s, items: %s%s (plugin: "
"%s)"),
gui_color_get_name (CONFIG_COLOR(ptr_bar->color_fg)),
gui_color_get_name (CONFIG_COLOR(ptr_bar->color_bg)),
(CONFIG_STRING(ptr_bar->items) && CONFIG_STRING(ptr_bar->items)[0]) ?
CONFIG_STRING(ptr_bar->items) : "-",
(CONFIG_INTEGER(ptr_bar->separator)) ? (CONFIG_INTEGER(ptr_bar->separator)) ?
_(", with separator") : "", _(", with separator") : "",
(ptr_bar->plugin) ? ptr_bar->plugin->name : "-"); (ptr_bar->plugin) ? ptr_bar->plugin->name : "-");
} }
} }
else else
@ -194,7 +204,11 @@ command_bar (void *data, struct t_gui_buffer *buffer,
{ {
/* create bar */ /* create bar */
if (gui_bar_new (NULL, argv[2], str_type, pos_condition, argv[4], if (gui_bar_new (NULL, argv[2], str_type, pos_condition, argv[4],
argv[5], "0", argv[6], argv_eol[7])) ((position == GUI_BAR_POSITION_LEFT)
|| (position == GUI_BAR_POSITION_RIGHT)) ?
"vertical" : "horizontal",
argv[5], "0", "default", "default", argv[6],
argv_eol[7]))
{ {
gui_chat_printf (NULL, _("Bar \"%s\" created"), gui_chat_printf (NULL, _("Bar \"%s\" created"),
argv[2]); argv[2]);

View File

@ -454,7 +454,7 @@ config_file_new_option (struct t_config_file *config_file,
new_option->max = min; new_option->max = min;
new_option->default_value = malloc (sizeof (int)); new_option->default_value = malloc (sizeof (int));
if (!gui_color_assign (new_option->default_value, default_value)) if (!gui_color_assign (new_option->default_value, default_value))
new_option->default_value = 0; *((int *)new_option->default_value) = 0;
new_option->value = malloc (sizeof (int)); new_option->value = malloc (sizeof (int));
*((int *)new_option->value) = *((int *)new_option->default_value); *((int *)new_option->value) = *((int *)new_option->default_value);
break; break;
@ -1187,7 +1187,10 @@ config_file_option_string (struct t_config_option *option)
switch (option->type) switch (option->type)
{ {
case CONFIG_OPTION_TYPE_BOOLEAN: case CONFIG_OPTION_TYPE_BOOLEAN:
return NULL; if (CONFIG_BOOLEAN(option))
return config_boolean_true[0];
else
return config_boolean_false[0];
case CONFIG_OPTION_TYPE_INTEGER: case CONFIG_OPTION_TYPE_INTEGER:
if (option->string_values) if (option->string_values)
return option->string_values[CONFIG_INTEGER(option)]; return option->string_values[CONFIG_INTEGER(option)];
@ -1195,7 +1198,7 @@ config_file_option_string (struct t_config_option *option)
case CONFIG_OPTION_TYPE_STRING: case CONFIG_OPTION_TYPE_STRING:
return CONFIG_STRING(option); return CONFIG_STRING(option);
case CONFIG_OPTION_TYPE_COLOR: case CONFIG_OPTION_TYPE_COLOR:
return NULL; return gui_color_get_name (CONFIG_COLOR(option));
case CONFIG_NUM_OPTION_TYPES: case CONFIG_NUM_OPTION_TYPES:
return NULL; return NULL;
} }

View File

@ -600,12 +600,21 @@ config_weechat_bar_read (void *data, struct t_config_file *config_file,
case GUI_BAR_OPTION_POSITION: case GUI_BAR_OPTION_POSITION:
ptr_temp_bar->position = ptr_option; ptr_temp_bar->position = ptr_option;
break; break;
case GUI_BAR_OPTION_FILLING:
ptr_temp_bar->filling = ptr_option;
break;
case GUI_BAR_OPTION_SIZE: case GUI_BAR_OPTION_SIZE:
ptr_temp_bar->size = ptr_option; ptr_temp_bar->size = ptr_option;
break; break;
case GUI_BAR_OPTION_SIZE_MAX: case GUI_BAR_OPTION_SIZE_MAX:
ptr_temp_bar->size_max = ptr_option; ptr_temp_bar->size_max = ptr_option;
break; break;
case GUI_BAR_OPTION_COLOR_FG:
ptr_temp_bar->color_fg = ptr_option;
break;
case GUI_BAR_OPTION_COLOR_BG:
ptr_temp_bar->color_bg = ptr_option;
break;
case GUI_BAR_OPTION_SEPARATOR: case GUI_BAR_OPTION_SEPARATOR:
ptr_temp_bar->separator = ptr_option; ptr_temp_bar->separator = ptr_option;
break; break;

View File

@ -363,6 +363,13 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
if (window) if (window)
window->refresh_needed = 1; window->refresh_needed = 1;
} }
else
{
new_bar_window->x = 0;
new_bar_window->y = 0;
new_bar_window->width = 1;
new_bar_window->height = 1;
}
return 1; return 1;
} }
@ -526,40 +533,84 @@ gui_bar_window_add_missing_bars (struct t_gui_window *window)
/* /*
* gui_bar_window_print_string: print a string text on a bar window * gui_bar_window_print_string: print a string text on a bar window
* return number of chars displayed on screen
*/ */
int void
gui_bar_window_print_string (struct t_gui_bar_window *bar_window, gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
char *string, int max_chars_on_screen) int *x, int *y, char *string)
{ {
int weechat_color, chars_displayed, size_on_screen; int weechat_color, size_on_screen, fg, bg;
char str_color[3], utf_char[16], *next_char, *output; char str_fg[3], str_bg[3], utf_char[16], *next_char, *output;
if (!string || !string[0]) if (!string || !string[0])
return 0; return;
if ((CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_LEFT) wmove (bar_window->win_bar, *y, *x);
|| (CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_RIGHT))
gui_window_set_weechat_color (bar_window->win_bar, GUI_COLOR_CHAT); gui_window_set_custom_color_fg_bg (bar_window->win_bar,
else CONFIG_COLOR(bar_window->bar->color_fg),
gui_window_set_weechat_color (bar_window->win_bar, GUI_COLOR_STATUS); CONFIG_COLOR(bar_window->bar->color_bg));
chars_displayed = 0;
while (string && string[0]) while (string && string[0])
{ {
if (string[0] == GUI_COLOR_COLOR_CHAR) if (string[0] == GUI_COLOR_COLOR_CHAR)
{ {
string++; string++;
if (isdigit (string[0]) && isdigit (string[1])) switch (string[0])
{ {
str_color[0] = string[0]; case 'F':
str_color[1] = string[1]; if (string[1] && string[2])
str_color[2] = '\0'; {
string += 2; str_fg[0] = string[1];
sscanf (str_color, "%d", &weechat_color); str_fg[1] = string[2];
gui_window_set_weechat_color (bar_window->win_bar, weechat_color); str_fg[2] = '\0';
sscanf (str_fg, "%d", &fg);
gui_window_set_custom_color_fg (bar_window->win_bar,
fg);
string += 3;
}
break;
case 'B':
if (string[1] && string[2])
{
str_bg[0] = string[1];
str_bg[1] = string[2];
str_bg[2] = '\0';
sscanf (str_bg, "%d", &bg);
gui_window_set_custom_color_bg (bar_window->win_bar,
bg);
string += 3;
}
break;
case '*':
if (string[1] && string[2] && (string[3] == ',')
&& string[4] && string[5])
{
str_fg[0] = string[1];
str_fg[1] = string[2];
str_fg[2] = '\0';
str_bg[0] = string[4];
str_bg[1] = string[5];
str_bg[2] = '\0';
sscanf (str_fg, "%d", &fg);
sscanf (str_bg, "%d", &bg);
gui_window_set_custom_color_fg_bg (bar_window->win_bar,
fg, bg);
string += 6;
}
break;
default:
if (isdigit (string[0]) && isdigit (string[1]))
{
str_fg[0] = string[0];
str_fg[1] = string[1];
str_fg[2] = '\0';
sscanf (str_fg, "%d", &weechat_color);
gui_window_set_weechat_color (bar_window->win_bar,
weechat_color);
string += 2;
}
break;
} }
} }
else else
@ -571,45 +622,31 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
memcpy (utf_char, string, next_char - string); memcpy (utf_char, string, next_char - string);
utf_char[next_char - string] = '\0'; utf_char[next_char - string] = '\0';
if (gui_window_utf_char_valid (utf_char)) if (!gui_window_utf_char_valid (utf_char))
snprintf (utf_char, sizeof (utf_char), ".");
size_on_screen = utf8_char_size_screen (utf_char);
if (*x + size_on_screen > bar_window->width)
{ {
size_on_screen = utf8_char_size_screen (utf_char); if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_VERTICAL)
if (chars_displayed + size_on_screen > max_chars_on_screen) return;
return chars_displayed; if (*y >= bar_window->height - 1)
chars_displayed += size_on_screen; return;
output = string_iconv_from_internal (NULL, utf_char); *x = 0;
wprintw (bar_window->win_bar, "%s", (*y)++;
(output) ? output : utf_char); wmove (bar_window->win_bar, *y, *x);
if (output)
free (output);
}
else
{
if (chars_displayed + 1 > max_chars_on_screen)
return chars_displayed;
chars_displayed++;
wprintw (bar_window->win_bar, ".");
} }
output = string_iconv_from_internal (NULL, utf_char);
wprintw (bar_window->win_bar, "%s",
(output) ? output : utf_char);
if (output)
free (output);
*x += size_on_screen;
string = next_char; string = next_char;
} }
} }
return chars_displayed;
}
/*
* gui_bar_window_clear_bg: clear background for a bar window
*/
void
gui_bar_window_clear_bg (struct t_gui_bar_window *bar_window)
{
if ((CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_LEFT)
|| (CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_RIGHT))
gui_window_curses_clear (bar_window->win_bar, GUI_COLOR_CHAT);
else
gui_window_curses_clear (bar_window->win_bar, GUI_COLOR_STATUS);
} }
/* /*
@ -622,9 +659,13 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{ {
int x, y, i, items_count, num_lines, line; int x, y, i, items_count, num_lines, line;
char *content, *item_value, *item_value2, **items; char *content, *item_value, *item_value2, **items;
int content_length, length, max_length; char space_with_reinit_color[32];
int content_length, length, max_length, optimal_number_of_lines;
struct t_gui_bar_item *ptr_item; struct t_gui_bar_item *ptr_item;
if (!gui_init_ok)
return;
if (CONFIG_INTEGER(bar_window->bar->size) == 0) if (CONFIG_INTEGER(bar_window->bar->size) == 0)
{ {
content = NULL; content = NULL;
@ -641,22 +682,40 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{ {
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) if (!content)
{ {
content_length += strlen (item_value); content_length += strlen ((item_value2) ?
content = strdup (item_value); item_value2 : item_value);
content = strdup ((item_value2) ?
item_value2 : item_value);
} }
else else
{ {
content_length += 1 + strlen (item_value); content_length += 1 +
strlen ((item_value2) ? item_value2 : item_value);
content = realloc (content, content_length); content = realloc (content, content_length);
if ((CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_LEFT) if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_HORIZONTAL)
|| (CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_RIGHT)) strcat (content, " ");
{ else
strcat (content, "\n"); strcat (content, "\n");
} strcat (content,
strcat (content, item_value); (item_value2) ? item_value2 : item_value);
} }
if (item_value2)
free (item_value2);
} }
free (item_value); free (item_value);
} }
@ -669,32 +728,47 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{ {
gui_bar_set_current_size (bar_window->bar, 1); gui_bar_set_current_size (bar_window->bar, 1);
gui_bar_window_recreate_bar_windows (bar_window->bar); gui_bar_window_recreate_bar_windows (bar_window->bar);
gui_bar_window_clear_bg (bar_window); gui_window_clear (bar_window->win_bar,
CONFIG_COLOR(bar_window->bar->color_bg));
} }
else else
{ {
/* search longer line and optimal number of lines */
max_length = 0;
optimal_number_of_lines = 0;
for (line = 0; line < items_count; line++)
{
length = gui_chat_strlen_screen (items[line]);
if (length > max_length)
max_length = length;
if (length % bar_window->width == 0)
num_lines = length / bar_window->width;
else
num_lines = (length / bar_window->width) + 1;
if (num_lines == 0)
num_lines = 1;
optimal_number_of_lines += num_lines;
}
if (max_length == 0)
max_length = 1;
switch (CONFIG_INTEGER(bar_window->bar->position)) switch (CONFIG_INTEGER(bar_window->bar->position))
{ {
case GUI_BAR_POSITION_BOTTOM: case GUI_BAR_POSITION_BOTTOM:
case GUI_BAR_POSITION_TOP: case GUI_BAR_POSITION_TOP:
if (bar_window->bar->current_size != items_count) if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_HORIZONTAL)
num_lines = optimal_number_of_lines;
else
num_lines = items_count;
if (bar_window->bar->current_size != num_lines)
{ {
gui_bar_set_current_size (bar_window->bar, items_count); gui_bar_set_current_size (bar_window->bar, num_lines);
gui_bar_window_recreate_bar_windows (bar_window->bar); gui_bar_window_recreate_bar_windows (bar_window->bar);
} }
break; break;
case GUI_BAR_POSITION_LEFT: case GUI_BAR_POSITION_LEFT:
case GUI_BAR_POSITION_RIGHT: case GUI_BAR_POSITION_RIGHT:
/* search longer line */
max_length = 0;
for (line = 0; line < items_count; line++)
{
length = gui_chat_strlen_screen (items[line]);
if (length > max_length)
max_length = length;
}
if (max_length == 0)
max_length = 1;
if (bar_window->bar->current_size != max_length) if (bar_window->bar->current_size != max_length)
{ {
gui_bar_set_current_size (bar_window->bar, gui_bar_set_current_size (bar_window->bar,
@ -705,17 +779,21 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
case GUI_BAR_NUM_POSITIONS: case GUI_BAR_NUM_POSITIONS:
break; break;
} }
gui_bar_window_clear_bg (bar_window); gui_window_clear (bar_window->win_bar,
CONFIG_COLOR(bar_window->bar->color_bg));
x = 0; x = 0;
y = 0; y = 0;
for (line = 0; line < items_count; line++) for (line = 0;
(line < items_count) && (y < bar_window->height);
line++)
{ {
wmove (bar_window->win_bar, y, x); gui_bar_window_print_string (bar_window, &x, &y,
x += gui_bar_window_print_string (bar_window, items[line]);
items[line], if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_VERTICAL)
bar_window->width); {
x = 0; x = 0;
y++; y++;
}
} }
} }
if (items) if (items)
@ -726,12 +804,14 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{ {
gui_bar_set_current_size (bar_window->bar, 1); gui_bar_set_current_size (bar_window->bar, 1);
gui_bar_window_recreate_bar_windows (bar_window->bar); gui_bar_window_recreate_bar_windows (bar_window->bar);
gui_bar_window_clear_bg (bar_window); gui_window_clear (bar_window->win_bar,
CONFIG_COLOR(bar_window->bar->color_bg));
} }
} }
else else
{ {
gui_bar_window_clear_bg (bar_window); gui_window_clear (bar_window->win_bar,
CONFIG_COLOR(bar_window->bar->color_bg));
x = 0; x = 0;
y = 0; y = 0;
@ -749,21 +829,30 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{ {
if (item_value[0]) if (item_value[0])
{ {
/* replace \n by spaces when height is 1 */ if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_HORIZONTAL)
item_value2 = (bar_window->height == 1) ? {
string_replace (item_value, "\n", " ") : NULL; snprintf (space_with_reinit_color,
items = string_explode ((item_value2) ? item_value2 : item_value, 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, "\n", 0, 0,
&items_count); &items_count);
num_lines = (items_count <= bar_window->height) ? for (line = 0;
items_count : bar_window->height; (line < items_count) && (y < bar_window->height);
for (line = 0; line < num_lines; line++) line++)
{ {
wmove (bar_window->win_bar, y, x); gui_bar_window_print_string (bar_window, &x, &y,
x += gui_bar_window_print_string (bar_window, items[line]);
items[line], if (CONFIG_INTEGER(bar_window->bar->filling) == GUI_BAR_FILLING_VERTICAL)
bar_window->width);
if (num_lines > 1)
{ {
x = 0; x = 0;
y++; y++;

View File

@ -41,202 +41,6 @@
#include "gui-curses.h" #include "gui-curses.h"
/*
* gui_chat_set_style: set style (bold, underline, ..)
* for a chat window
*/
void
gui_chat_set_style (struct t_gui_window *window, int style)
{
wattron (GUI_CURSES(window)->win_chat, style);
}
/*
* gui_chat_remove_style: remove style (bold, underline, ..)
* for a chat window
*/
void
gui_chat_remove_style (struct t_gui_window *window, int style)
{
wattroff (GUI_CURSES(window)->win_chat, style);
}
/*
* gui_chat_toggle_style: toggle a style (bold, underline, ..)
* for a chat window
*/
void
gui_chat_toggle_style (struct t_gui_window *window, int style)
{
GUI_CURSES(window)->current_style_attr ^= style;
if (GUI_CURSES(window)->current_style_attr & style)
gui_chat_set_style (window, style);
else
gui_chat_remove_style (window, style);
}
/*
* gui_chat_reset_style: reset style (color and attr)
* for a chat window
*/
void
gui_chat_reset_style (struct t_gui_window *window)
{
GUI_CURSES(window)->current_style_fg = -1;
GUI_CURSES(window)->current_style_bg = -1;
GUI_CURSES(window)->current_style_attr = 0;
GUI_CURSES(window)->current_color_attr = 0;
gui_window_set_weechat_color (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
gui_chat_remove_style (window,
A_BOLD | A_UNDERLINE | A_REVERSE);
}
/*
* gui_chat_set_color_style: set style for color
*/
void
gui_chat_set_color_style (struct t_gui_window *window, int style)
{
GUI_CURSES(window)->current_color_attr |= style;
wattron (GUI_CURSES(window)->win_chat, style);
}
/*
* gui_chat_remove_color_style: remove style for color
*/
void
gui_chat_remove_color_style (struct t_gui_window *window, int style)
{
GUI_CURSES(window)->current_color_attr &= !style;
wattroff (GUI_CURSES(window)->win_chat, style);
}
/*
* gui_chat_reset_color_style: reset style for color
*/
void
gui_chat_reset_color_style (struct t_gui_window *window)
{
wattroff (GUI_CURSES(window)->win_chat,
GUI_CURSES(window)->current_color_attr);
GUI_CURSES(window)->current_color_attr = 0;
}
/*
* gui_chat_set_color: set color for a chat window
*/
void
gui_chat_set_color (struct t_gui_window *window, int fg, int bg)
{
GUI_CURSES(window)->current_style_fg = fg;
GUI_CURSES(window)->current_style_bg = bg;
if (((fg == -1) || (fg == 99))
&& ((bg == -1) || (bg == 99)))
wattron (GUI_CURSES(window)->win_chat, COLOR_PAIR(63));
else
{
if ((fg == -1) || (fg == 99))
fg = COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
wattron (GUI_CURSES(window)->win_chat, COLOR_PAIR((bg * 8) + fg));
}
}
/*
* gui_chat_set_weechat_color: set a WeeChat color for a chat window
*/
void
gui_chat_set_weechat_color (struct t_gui_window *window, int weechat_color)
{
if ((weechat_color >= 0) && (weechat_color < GUI_COLOR_NUM_COLORS))
{
gui_chat_reset_style (window);
gui_chat_set_style (window,
gui_color[weechat_color]->attributes);
gui_chat_set_color (window,
gui_color[weechat_color]->foreground,
gui_color[weechat_color]->background);
}
}
/*
* gui_chat_set_custom_color_fg_bg: set a custom color for a chat window
* (foreground and background)
*/
void
gui_chat_set_custom_color_fg_bg (struct t_gui_window *window, int fg, int bg)
{
if ((fg >= 0) && (fg < GUI_CURSES_NUM_WEECHAT_COLORS)
&& (bg >= 0) && (bg < GUI_CURSES_NUM_WEECHAT_COLORS))
{
gui_chat_reset_style (window);
gui_chat_set_style (window,
gui_weechat_colors[fg].attributes);
gui_chat_set_color (window,
gui_weechat_colors[fg].foreground,
gui_weechat_colors[bg].foreground);
}
}
/*
* gui_chat_set_custom_color_fg: set a custom color for a chat window
* (foreground only)
*/
void
gui_chat_set_custom_color_fg (struct t_gui_window *window, int fg)
{
int current_attr, current_bg;
if ((fg >= 0) && (fg < GUI_CURSES_NUM_WEECHAT_COLORS))
{
current_attr = GUI_CURSES(window)->current_style_attr;
current_bg = GUI_CURSES(window)->current_style_bg;
gui_chat_reset_style (window);
gui_chat_set_color_style (window, current_attr);
gui_chat_remove_color_style (window, A_BOLD);
gui_chat_set_color_style (window, gui_weechat_colors[fg].attributes);
gui_chat_set_color (window,
gui_weechat_colors[fg].foreground,
current_bg);
}
}
/*
* gui_chat_set_custom_color_bg: set a custom color for a chat window
* (background only)
*/
void
gui_chat_set_custom_color_bg (struct t_gui_window *window, int bg)
{
int current_attr, current_fg;
if ((bg >= 0) && (bg < GUI_CURSES_NUM_WEECHAT_COLORS))
{
current_attr = GUI_CURSES(window)->current_style_attr;
current_fg = GUI_CURSES(window)->current_style_fg;
gui_chat_reset_style (window);
gui_chat_set_color_style (window, current_attr);
gui_chat_set_color (window,
current_fg,
gui_weechat_colors[bg].foreground);
}
}
/* /*
* gui_chat_draw_title: draw title window for a buffer * gui_chat_draw_title: draw title window for a buffer
*/ */
@ -258,7 +62,8 @@ gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
if (ptr_win->buffer == buffer) if (ptr_win->buffer == buffer)
{ {
if (erase) if (erase)
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_title, GUI_COLOR_TITLE); gui_window_clear_weechat (GUI_CURSES(ptr_win)->win_title,
GUI_COLOR_TITLE);
snprintf (format, sizeof (format), "%%-%ds", ptr_win->win_title_width); snprintf (format, sizeof (format), "%%-%ds", ptr_win->win_title_width);
wmove (GUI_CURSES(ptr_win)->win_title, 0, 0); wmove (GUI_CURSES(ptr_win)->win_title, 0, 0);
@ -380,7 +185,7 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
case GUI_COLOR_RESET_CHAR: case GUI_COLOR_RESET_CHAR:
string++; string++;
if (apply_style) if (apply_style)
gui_chat_reset_style (window); gui_window_reset_style (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
break; break;
case GUI_COLOR_COLOR_CHAR: case GUI_COLOR_COLOR_CHAR:
string++; string++;
@ -395,7 +200,8 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
str_fg[1] = string[2]; str_fg[1] = string[2];
str_fg[2] = '\0'; str_fg[2] = '\0';
sscanf (str_fg, "%d", &fg); sscanf (str_fg, "%d", &fg);
gui_chat_set_custom_color_fg (window, fg); gui_window_set_custom_color_fg (GUI_CURSES(window)->win_chat,
fg);
} }
string += 3; string += 3;
} }
@ -409,7 +215,8 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
str_bg[1] = string[2]; str_bg[1] = string[2];
str_bg[2] = '\0'; str_bg[2] = '\0';
sscanf (str_bg, "%d", &bg); sscanf (str_bg, "%d", &bg);
gui_chat_set_custom_color_bg (window, bg); gui_window_set_custom_color_bg (GUI_CURSES(window)->win_chat,
bg);
} }
string += 3; string += 3;
} }
@ -428,7 +235,8 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
str_bg[2] = '\0'; str_bg[2] = '\0';
sscanf (str_fg, "%d", &fg); sscanf (str_fg, "%d", &fg);
sscanf (str_bg, "%d", &bg); sscanf (str_bg, "%d", &bg);
gui_chat_set_custom_color_fg_bg (window, fg, bg); gui_window_set_custom_color_fg_bg (GUI_CURSES(window)->win_chat,
fg, bg);
} }
string += 6; string += 6;
} }
@ -442,7 +250,8 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
str_fg[1] = string[1]; str_fg[1] = string[1];
str_fg[2] = '\0'; str_fg[2] = '\0';
sscanf (str_fg, "%d", &weechat_color); sscanf (str_fg, "%d", &weechat_color);
gui_chat_set_weechat_color (window, weechat_color); gui_window_set_weechat_color (GUI_CURSES(window)->win_chat,
weechat_color);
} }
string += 2; string += 2;
} }
@ -456,12 +265,14 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
case GUI_COLOR_ATTR_BOLD_CHAR: case GUI_COLOR_ATTR_BOLD_CHAR:
string++; string++;
if (apply_style) if (apply_style)
gui_chat_set_color_style (window, A_BOLD); gui_window_set_color_style (GUI_CURSES(window)->win_chat,
A_BOLD);
break; break;
case GUI_COLOR_ATTR_REVERSE_CHAR: case GUI_COLOR_ATTR_REVERSE_CHAR:
string++; string++;
if (apply_style) if (apply_style)
gui_chat_set_color_style (window, A_REVERSE); gui_window_set_color_style (GUI_CURSES(window)->win_chat,
A_REVERSE);
break; break;
case GUI_COLOR_ATTR_ITALIC_CHAR: case GUI_COLOR_ATTR_ITALIC_CHAR:
/* not available in Curses GUI */ /* not available in Curses GUI */
@ -470,7 +281,8 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
case GUI_COLOR_ATTR_UNDERLINE_CHAR: case GUI_COLOR_ATTR_UNDERLINE_CHAR:
string++; string++;
if (apply_style) if (apply_style)
gui_chat_set_color_style (window, A_UNDERLINE); gui_window_set_color_style (GUI_CURSES(window)->win_chat,
A_UNDERLINE);
break; break;
} }
break; break;
@ -481,12 +293,14 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
case GUI_COLOR_ATTR_BOLD_CHAR: case GUI_COLOR_ATTR_BOLD_CHAR:
string++; string++;
if (apply_style) if (apply_style)
gui_chat_remove_color_style (window, A_BOLD); gui_window_remove_color_style (GUI_CURSES(window)->win_chat,
A_BOLD);
break; break;
case GUI_COLOR_ATTR_REVERSE_CHAR: case GUI_COLOR_ATTR_REVERSE_CHAR:
string++; string++;
if (apply_style) if (apply_style)
gui_chat_remove_color_style (window, A_REVERSE); gui_window_remove_color_style (GUI_CURSES(window)->win_chat,
A_REVERSE);
break; break;
case GUI_COLOR_ATTR_ITALIC_CHAR: case GUI_COLOR_ATTR_ITALIC_CHAR:
/* not available in Curses GUI */ /* not available in Curses GUI */
@ -495,7 +309,8 @@ gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
case GUI_COLOR_ATTR_UNDERLINE_CHAR: case GUI_COLOR_ATTR_UNDERLINE_CHAR:
string++; string++;
if (apply_style) if (apply_style)
gui_chat_remove_color_style (window, A_UNDERLINE); gui_window_remove_color_style (GUI_CURSES(window)->win_chat,
A_UNDERLINE);
break; break;
} }
break; break;
@ -630,7 +445,8 @@ gui_chat_display_word (struct t_gui_window *window,
{ {
if (!simulate) if (!simulate)
{ {
gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_SUFFIX); gui_window_set_weechat_color (GUI_CURSES(window)->win_chat,
GUI_COLOR_CHAT_PREFIX_SUFFIX);
gui_chat_display_word_raw (window, gui_chat_display_word_raw (window,
CONFIG_STRING(config_look_prefix_suffix), CONFIG_STRING(config_look_prefix_suffix),
0, 1); 0, 1);
@ -640,7 +456,8 @@ gui_chat_display_word (struct t_gui_window *window,
gui_chat_display_word_raw (window, str_space, 0, 1); gui_chat_display_word_raw (window, str_space, 0, 1);
window->win_chat_cursor_x += gui_chat_strlen_screen (str_space); window->win_chat_cursor_x += gui_chat_strlen_screen (str_space);
if (!simulate) if (!simulate)
gui_chat_set_weechat_color (window, GUI_COLOR_CHAT); gui_window_set_weechat_color (GUI_CURSES(window)->win_chat,
GUI_COLOR_CHAT);
} }
} }
@ -713,7 +530,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
if (line->str_time && line->str_time[0]) if (line->str_time && line->str_time[0])
{ {
if (!simulate) if (!simulate)
gui_chat_reset_style (window); gui_window_reset_style (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
gui_chat_display_word (window, line, line->str_time, gui_chat_display_word (window, line, line->str_time,
NULL, 1, num_lines, count, lines_displayed, NULL, 1, num_lines, count, lines_displayed,
@ -729,7 +546,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
|| (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE))) || (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)))
{ {
if (!simulate) if (!simulate)
gui_chat_reset_style (window); gui_window_reset_style (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
if (CONFIG_INTEGER(config_look_prefix_align_max) > 0) if (CONFIG_INTEGER(config_look_prefix_align_max) > 0)
{ {
@ -770,7 +587,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
} }
if (!simulate) if (!simulate)
gui_chat_reset_style (window); gui_window_reset_style (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_LEFT) if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_LEFT)
{ {
@ -785,7 +602,8 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
&& (num_spaces < 0)) && (num_spaces < 0))
{ {
if (!simulate) if (!simulate)
gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_MORE); gui_window_set_weechat_color (GUI_CURSES(window)->win_chat,
GUI_COLOR_CHAT_PREFIX_MORE);
gui_chat_display_word (window, line, str_plus, gui_chat_display_word (window, line, str_plus,
NULL, 1, num_lines, count, lines_displayed, NULL, 1, num_lines, count, lines_displayed,
simulate); simulate);
@ -801,7 +619,8 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
&& CONFIG_STRING(config_look_prefix_suffix)[0])) && CONFIG_STRING(config_look_prefix_suffix)[0]))
{ {
if (!simulate) if (!simulate)
gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_SUFFIX); gui_window_set_weechat_color (GUI_CURSES(window)->win_chat,
GUI_COLOR_CHAT_PREFIX_SUFFIX);
gui_chat_display_word (window, line, gui_chat_display_word (window, line,
CONFIG_STRING(config_look_prefix_suffix), CONFIG_STRING(config_look_prefix_suffix),
NULL, 1, num_lines, count, NULL, 1, num_lines, count,
@ -869,7 +688,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
/* reset color & style for a new line */ /* reset color & style for a new line */
if (!simulate) if (!simulate)
gui_chat_reset_style (window); gui_window_reset_style (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
if (!line->message || !line->message[0]) if (!line->message || !line->message[0])
gui_chat_display_new_line (window, num_lines, count, gui_chat_display_new_line (window, num_lines, count,
@ -969,8 +788,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
if (gui_chat_line_search (line, window->buffer->input_buffer, if (gui_chat_line_search (line, window->buffer->input_buffer,
window->buffer->text_search_exact)) window->buffer->text_search_exact))
{ {
gui_chat_set_weechat_color (window, gui_window_set_weechat_color (GUI_CURSES(window)->win_chat,
GUI_COLOR_CHAT_READ_MARKER); GUI_COLOR_CHAT_READ_MARKER);
mvwprintw (GUI_CURSES(window)->win_chat, mvwprintw (GUI_CURSES(window)->win_chat,
read_marker_y, read_marker_x, read_marker_y, read_marker_x,
"%c", CONFIG_STRING(config_look_read_marker)[0]); "%c", CONFIG_STRING(config_look_read_marker)[0]);
@ -982,8 +801,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
if (window->buffer->last_read_line && if (window->buffer->last_read_line &&
(window->buffer->last_read_line == gui_chat_get_prev_line_displayed (line))) (window->buffer->last_read_line == gui_chat_get_prev_line_displayed (line)))
{ {
gui_chat_set_weechat_color (window, gui_window_set_weechat_color (GUI_CURSES(window)->win_chat,
GUI_COLOR_CHAT_READ_MARKER); GUI_COLOR_CHAT_READ_MARKER);
mvwprintw (GUI_CURSES(window)->win_chat, mvwprintw (GUI_CURSES(window)->win_chat,
read_marker_y, read_marker_x, read_marker_y, read_marker_x,
"%c", CONFIG_STRING(config_look_read_marker)[0]); "%c", CONFIG_STRING(config_look_read_marker)[0]);
@ -1004,10 +823,8 @@ void
gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line, gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
int y) int y)
{ {
int pair;
/* reset color & style for a new line */ /* reset color & style for a new line */
gui_chat_reset_style (window); gui_window_reset_style (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
window->win_chat_cursor_x = 0; window->win_chat_cursor_x = 0;
window->win_chat_cursor_y = y; window->win_chat_cursor_y = y;
@ -1020,10 +837,7 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
gui_chat_display_word_raw (window, line->message, gui_chat_display_word_raw (window, line->message,
window->win_chat_width, 1); window->win_chat_width, 1);
pair = (GUI_CURSES(window)->current_style_bg < 0) ? gui_window_clrtoeol_with_current_bg (GUI_CURSES(window)->win_chat);
63 : GUI_CURSES(window)->current_style_bg * 8;
wbkgdset (GUI_CURSES(window)->win_chat, ' ' | COLOR_PAIR (pair));
wclrtoeol (GUI_CURSES(window)->win_chat);
} }
/* /*

View File

@ -98,8 +98,8 @@ gui_infobar_draw (struct t_gui_buffer *buffer, int erase)
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{ {
if (erase) if (erase)
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_infobar, gui_window_clear_weechat (GUI_CURSES(ptr_win)->win_infobar,
GUI_COLOR_INFOBAR); GUI_COLOR_INFOBAR);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
GUI_COLOR_INFOBAR); GUI_COLOR_INFOBAR);

View File

@ -289,8 +289,8 @@ gui_input_draw (struct t_gui_buffer *buffer, int erase)
if (ptr_win->buffer == buffer) if (ptr_win->buffer == buffer)
{ {
if (erase) if (erase)
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_input, gui_window_clear_weechat (GUI_CURSES(ptr_win)->win_input,
GUI_COLOR_INPUT); GUI_COLOR_INPUT);
if (gui_keyboard_paste_pending) if (gui_keyboard_paste_pending)
{ {

View File

@ -58,8 +58,8 @@ gui_status_draw (int erase)
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{ {
if (erase) if (erase)
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_status, gui_window_clear_weechat (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS); GUI_COLOR_STATUS);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS); GUI_COLOR_STATUS);

View File

@ -46,6 +46,12 @@
#include "gui-curses.h" #include "gui-curses.h"
int current_style_fg; /* current foreground color */
int current_style_bg; /* current background color */
int current_style_attr; /* current attributes (bold, ..) */
int current_color_attr; /* attr sum of last color(s) used */
/* /*
* gui_window_get_width: get screen width (terminal width in chars for Curses) * gui_window_get_width: get screen width (terminal width in chars for Curses)
*/ */
@ -185,11 +191,11 @@ gui_window_wprintw (WINDOW *window, char *data, ...)
} }
/* /*
* gui_window_curses_clear: clear a Curses window * gui_window_curses_clear_weechat: clear a Curses window with a weechat color
*/ */
void void
gui_window_curses_clear (WINDOW *window, int num_color) gui_window_clear_weechat (WINDOW *window, int num_color)
{ {
if (!gui_ok) if (!gui_ok)
return; return;
@ -199,6 +205,91 @@ gui_window_curses_clear (WINDOW *window, int num_color)
wmove (window, 0, 0); wmove (window, 0, 0);
} }
/*
* gui_window_clear: clear a Curses window
*/
void
gui_window_clear (WINDOW *window, int bg)
{
int color;
if (!gui_ok)
return;
if ((bg >= 0) && (bg < GUI_CURSES_NUM_WEECHAT_COLORS))
{
color = gui_weechat_colors[bg].foreground;
wbkgdset (window,
' ' | COLOR_PAIR (((color == -1) || (color == 99)) ?
63 : color * 8));
werase (window);
wmove (window, 0, 0);
}
}
/*
* gui_window_reset_style: reset style (color and attr) for a window
*/
void
gui_window_reset_style (WINDOW *window, int num_color)
{
current_style_fg = -1;
current_style_bg = -1;
current_style_attr = 0;
current_color_attr = 0;
wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) |
gui_color[num_color]->attributes);
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
}
/*
* gui_window_set_color_style: set style for color
*/
void
gui_window_set_color_style (WINDOW *window, int style)
{
current_color_attr |= style;
wattron (window, style);
}
/*
* gui_window_remove_color_style: remove style for color
*/
void
gui_window_remove_color_style (WINDOW *window, int style)
{
current_color_attr &= !style;
wattroff (window, style);
}
/*
* gui_window_set_color: set color for a window
*/
void
gui_window_set_color (WINDOW *window, int fg, int bg)
{
current_style_fg = fg;
current_style_bg = bg;
if (((fg == -1) || (fg == 99))
&& ((bg == -1) || (bg == 99)))
wattron (window, COLOR_PAIR(63));
else
{
if ((fg == -1) || (fg == 99))
fg = COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
wattron (window, COLOR_PAIR((bg * 8) + fg));
}
}
/* /*
* gui_window_set_weechat_color: set WeeChat color for window * gui_window_set_weechat_color: set WeeChat color for window
*/ */
@ -208,12 +299,91 @@ gui_window_set_weechat_color (WINDOW *window, int num_color)
{ {
if ((num_color >= 0) && (num_color < GUI_COLOR_NUM_COLORS)) if ((num_color >= 0) && (num_color < GUI_COLOR_NUM_COLORS))
{ {
/*
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE); wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) | wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) |
gui_color[num_color]->attributes); gui_color[num_color]->attributes);
*/
gui_window_reset_style (window, num_color);
wattron (window, gui_color[num_color]->attributes);
gui_window_set_color (window,
gui_color[num_color]->foreground,
gui_color[num_color]->background);
} }
} }
/*
* gui_window_set_custom_color_fg_bg: set a custom color for a window
* (foreground and background)
*/
void
gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
{
if ((fg >= 0) && (fg < GUI_CURSES_NUM_WEECHAT_COLORS)
&& (bg >= 0) && (bg < GUI_CURSES_NUM_WEECHAT_COLORS))
{
wattron (window, gui_weechat_colors[fg].attributes);
gui_window_set_color (window,
gui_weechat_colors[fg].foreground,
gui_weechat_colors[bg].foreground);
}
}
/*
* gui_window_set_custom_color_fg: set a custom color for a window
* (foreground only)
*/
void
gui_window_set_custom_color_fg (WINDOW *window, int fg)
{
int current_attr, current_bg;
if ((fg >= 0) && (fg < GUI_CURSES_NUM_WEECHAT_COLORS))
{
current_attr = current_style_attr;
current_bg = current_style_bg;
gui_window_remove_color_style (window, A_BOLD);
gui_window_set_color_style (window, gui_weechat_colors[fg].attributes);
gui_window_set_color (window,
gui_weechat_colors[fg].foreground,
current_bg);
}
}
/*
* gui_window_set_custom_color_bg: set a custom color for a window
* (background only)
*/
void
gui_window_set_custom_color_bg (WINDOW *window, int bg)
{
int current_attr, current_fg;
if ((bg >= 0) && (bg < GUI_CURSES_NUM_WEECHAT_COLORS))
{
current_attr = current_style_attr;
current_fg = current_style_fg;
gui_window_set_color_style (window, current_attr);
gui_window_set_color (window, current_fg,
gui_weechat_colors[bg].foreground);
}
}
/*
* gui_window_clrtoeol_with_current_bg: clear until end of line with current bg
*/
void
gui_window_clrtoeol_with_current_bg (WINDOW *window)
{
wbkgdset (window,
' ' | COLOR_PAIR ((current_style_bg < 0) ? 63 : current_style_bg * 8));
wclrtoeol (window);
}
/* /*
* gui_window_calculate_pos_size: calculate position and size for a buffer & subwindows * gui_window_calculate_pos_size: calculate position and size for a buffer & subwindows
* return 1 if pos/size changed, 0 if no change * return 1 if pos/size changed, 0 if no change
@ -1694,10 +1864,6 @@ gui_window_objects_print_log (struct t_gui_window *window)
log_printf (" win_separator . . . : 0x%x", GUI_CURSES(window)->win_separator); log_printf (" win_separator . . . : 0x%x", GUI_CURSES(window)->win_separator);
log_printf (" bar_windows . . . . : 0x%x", GUI_CURSES(window)->bar_windows); log_printf (" bar_windows . . . . : 0x%x", GUI_CURSES(window)->bar_windows);
log_printf (" last_bar_windows. . : 0x%x", GUI_CURSES(window)->last_bar_window); log_printf (" last_bar_windows. . : 0x%x", GUI_CURSES(window)->last_bar_window);
log_printf (" current_style_fg. . : %d", GUI_CURSES(window)->current_style_fg);
log_printf (" current_style_bg. . : %d", GUI_CURSES(window)->current_style_bg);
log_printf (" current_style_attr. : %d", GUI_CURSES(window)->current_style_attr);
log_printf (" current_color_attr. : %d", GUI_CURSES(window)->current_color_attr);
for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win; for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win;
ptr_bar_win = ptr_bar_win->next_bar_window) ptr_bar_win = ptr_bar_win->next_bar_window)

View File

@ -62,10 +62,6 @@ struct t_gui_curses_objects
WINDOW *win_separator; /* separation between 2 splited (V) win */ WINDOW *win_separator; /* separation between 2 splited (V) win */
struct t_gui_bar_window *bar_windows; /* bar windows */ struct t_gui_bar_window *bar_windows; /* bar windows */
struct t_gui_bar_window *last_bar_window; /* last bar window */ struct t_gui_bar_window *last_bar_window; /* last bar window */
int current_style_fg; /* current foreground color */
int current_style_bg; /* current background color */
int current_style_attr; /* current attributes (bold, ..) */
int current_color_attr; /* attr sum of last color(s) used */
}; };
extern struct t_gui_color gui_weechat_colors[]; extern struct t_gui_color gui_weechat_colors[];
@ -95,8 +91,17 @@ extern int gui_keyboard_read_cb (void *data);
/* window functions */ /* window functions */
extern int gui_window_utf_char_valid (char *utf_char); extern int gui_window_utf_char_valid (char *utf_char);
extern void gui_window_wprintw (WINDOW *window, char *data, ...); extern void gui_window_wprintw (WINDOW *window, char *data, ...);
extern void gui_window_curses_clear (WINDOW *window, int num_color); extern void gui_window_clear_weechat (WINDOW *window, int num_color);
extern void gui_window_clear (WINDOW *window, int bg);
extern void gui_window_reset_style (WINDOW *window, int num_color);
extern void gui_window_set_color_style (WINDOW *window, int style);
extern void gui_window_remove_color_style (WINDOW *window, int style);
extern void gui_window_set_color (WINDOW *window, int fg, int bg);
extern void gui_window_set_weechat_color (WINDOW *window, int num_color); extern void gui_window_set_weechat_color (WINDOW *window, int num_color);
extern void gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg);
extern void gui_window_set_custom_color_fg (WINDOW *window, int fg);
extern void gui_window_set_custom_color_bg (WINDOW *window, int bg);
extern void gui_window_clrtoeol_with_current_bg (WINDOW *window);
extern void gui_window_refresh_screen_sigwinch (); extern void gui_window_refresh_screen_sigwinch ();
extern void gui_window_title_set (); extern void gui_window_title_set ();
extern void gui_window_title_reset (); extern void gui_window_title_reset ();

View File

@ -266,7 +266,7 @@ gui_bar_item_default_time (void *data, struct t_gui_bar_item *item,
local_time) == 0) local_time) == 0)
return NULL; return NULL;
snprintf (buf, sizeof (buf), "%s[%s%s%s] ", snprintf (buf, sizeof (buf), "%s[%s%s%s]",
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS), GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
GUI_COLOR(GUI_COLOR_STATUS), GUI_COLOR(GUI_COLOR_STATUS),
text_time, text_time,
@ -293,7 +293,7 @@ gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item,
(void) max_width; (void) max_width;
(void) max_height; (void) max_height;
snprintf (buf, sizeof (buf), "%s[%s%d%s] ", snprintf (buf, sizeof (buf), "%s[%s%d%s]",
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS), GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
GUI_COLOR(GUI_COLOR_STATUS), GUI_COLOR(GUI_COLOR_STATUS),
(last_gui_buffer) ? last_gui_buffer->number : 0, (last_gui_buffer) ? last_gui_buffer->number : 0,
@ -322,7 +322,7 @@ gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
if (!window) if (!window)
window = gui_current_window; window = gui_current_window;
snprintf (buf, sizeof (buf), "%s[%s%s%s] ", snprintf (buf, sizeof (buf), "%s[%s%s%s]",
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS), GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
GUI_COLOR(GUI_COLOR_STATUS), GUI_COLOR(GUI_COLOR_STATUS),
(window->buffer->plugin) ? window->buffer->plugin->name : "core", (window->buffer->plugin) ? window->buffer->plugin->name : "core",
@ -351,7 +351,7 @@ gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item,
if (!window) if (!window)
window = gui_current_window; window = gui_current_window;
snprintf (buf, sizeof (buf), "%s%d%s:%s%s%s/%s%s ", snprintf (buf, sizeof (buf), "%s%d%s:%s%s%s/%s%s",
GUI_COLOR(GUI_COLOR_STATUS_NUMBER), GUI_COLOR(GUI_COLOR_STATUS_NUMBER),
window->buffer->number, window->buffer->number,
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS), GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
@ -422,7 +422,7 @@ gui_bar_item_default_nicklist_count (void *data, struct t_gui_bar_item *item,
if (!window->buffer->nicklist) if (!window->buffer->nicklist)
return NULL; return NULL;
snprintf (buf, sizeof (buf), "%s[%s%d%s] ", snprintf (buf, sizeof (buf), "%s[%s%d%s]",
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS), GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
GUI_COLOR(GUI_COLOR_STATUS), GUI_COLOR(GUI_COLOR_STATUS),
window->buffer->nicklist_visible_count, window->buffer->nicklist_visible_count,
@ -454,7 +454,7 @@ gui_bar_item_default_scroll (void *data, struct t_gui_bar_item *item,
if (!window->scroll) if (!window->scroll)
return NULL; return NULL;
snprintf (buf, sizeof (buf), "%s%s ", snprintf (buf, sizeof (buf), "%s%s",
GUI_COLOR(GUI_COLOR_STATUS_MORE), GUI_COLOR(GUI_COLOR_STATUS_MORE),
_("(MORE)")); _("(MORE)"));
@ -545,7 +545,7 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
break; break;
} }
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS)); strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
strcat (buf, "] "); strcat (buf, "]");
return strdup (buf); return strdup (buf);
} }

View File

@ -34,15 +34,19 @@
#include "gui-bar.h" #include "gui-bar.h"
#include "gui-buffer.h" #include "gui-buffer.h"
#include "gui-chat.h" #include "gui-chat.h"
#include "gui-color.h"
#include "gui-window.h" #include "gui-window.h"
char *gui_bar_option_str[GUI_BAR_NUM_OPTIONS] = char *gui_bar_option_str[GUI_BAR_NUM_OPTIONS] =
{ "type", "conditions", "position", "size", "size_max", "separator", "items" }; { "type", "conditions", "position", "filling", "size", "size_max",
"color_fg", "color_bg", "separator", "items" };
char *gui_bar_type_str[GUI_BAR_NUM_TYPES] = char *gui_bar_type_str[GUI_BAR_NUM_TYPES] =
{ "root", "window" }; { "root", "window" };
char *gui_bar_position_str[GUI_BAR_NUM_POSITIONS] = char *gui_bar_position_str[GUI_BAR_NUM_POSITIONS] =
{ "bottom", "top", "left", "right" }; { "bottom", "top", "left", "right" };
char *gui_bar_filling_str[GUI_BAR_NUM_FILLING] =
{ "horizontal", "vertical" };
struct t_gui_bar *gui_bars = NULL; /* first bar */ struct t_gui_bar *gui_bars = NULL; /* first bar */
struct t_gui_bar *last_gui_bar = NULL; /* last bar */ struct t_gui_bar *last_gui_bar = NULL; /* last bar */
@ -340,6 +344,23 @@ gui_bar_config_change_position (void *data, struct t_config_option *option)
gui_bar_refresh (ptr_bar); gui_bar_refresh (ptr_bar);
} }
/*
* gui_bar_config_change_filling: callback when filling is changed
*/
void
gui_bar_config_change_filling (void *data, struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
if (ptr_bar)
gui_bar_refresh (ptr_bar);
}
/* /*
* gui_bar_config_check_size: callback for checking bar size before changing it * gui_bar_config_check_size: callback for checking bar size before changing it
*/ */
@ -421,6 +442,23 @@ gui_bar_config_change_size_max (void *data, struct t_config_option *option)
} }
} }
/*
* gui_bar_config_change_color: callback when color (fg or bg) is changed
*/
void
gui_bar_config_change_color (void *data, struct t_config_option *option)
{
struct t_gui_bar *ptr_bar;
/* make C compiler happy */
(void) data;
ptr_bar = gui_bar_search_with_option_name (option->name);
if (ptr_bar)
gui_bar_refresh (ptr_bar);
}
/* /*
* gui_bar_config_change_separator: callback when separator is changed * gui_bar_config_change_separator: callback when separator is changed
*/ */
@ -495,10 +533,16 @@ gui_bar_set_name (struct t_gui_bar *bar, char *name)
config_file_option_rename (bar->conditions, option_name); config_file_option_rename (bar->conditions, option_name);
snprintf (option_name, length, "%s.position", name); snprintf (option_name, length, "%s.position", name);
config_file_option_rename (bar->position, option_name); config_file_option_rename (bar->position, option_name);
snprintf (option_name, length, "%s.filling", name);
config_file_option_rename (bar->filling, option_name);
snprintf (option_name, length, "%s.size", name); snprintf (option_name, length, "%s.size", name);
config_file_option_rename (bar->size, option_name); config_file_option_rename (bar->size, option_name);
snprintf (option_name, length, "%s.size_max", name); snprintf (option_name, length, "%s.size_max", name);
config_file_option_rename (bar->size_max, option_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_bg", name);
config_file_option_rename (bar->color_bg, option_name);
snprintf (option_name, length, "%s.separator", name); snprintf (option_name, length, "%s.separator", name);
config_file_option_rename (bar->separator, option_name); config_file_option_rename (bar->separator, option_name);
snprintf (option_name, length, "%s.items", name); snprintf (option_name, length, "%s.items", name);
@ -751,6 +795,12 @@ gui_bar_set (struct t_gui_bar *bar, char *property, char *value)
gui_bar_refresh (bar); gui_bar_refresh (bar);
return 1; return 1;
} }
else if (string_strcasecmp (property, "filling") == 0)
{
config_file_option_set (bar->filling, value, 1);
gui_bar_refresh (bar);
return 1;
}
else if (string_strcasecmp (property, "size") == 0) else if (string_strcasecmp (property, "size") == 0)
{ {
gui_bar_set_size (bar, value); gui_bar_set_size (bar, value);
@ -763,6 +813,18 @@ gui_bar_set (struct t_gui_bar *bar, char *property, char *value)
gui_bar_refresh (bar); gui_bar_refresh (bar);
return 1; return 1;
} }
else if (string_strcasecmp (property, "color_fg") == 0)
{
config_file_option_set (bar->color_fg, 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);
gui_bar_refresh (bar);
return 1;
}
else if (string_strcasecmp (property, "separator") == 0) else if (string_strcasecmp (property, "separator") == 0)
{ {
config_file_option_set (bar->separator, config_file_option_set (bar->separator,
@ -799,8 +861,11 @@ gui_bar_alloc (char *name)
new_bar->type = NULL; new_bar->type = NULL;
new_bar->conditions = NULL; new_bar->conditions = NULL;
new_bar->position = NULL; new_bar->position = NULL;
new_bar->filling = NULL;
new_bar->size = NULL; new_bar->size = NULL;
new_bar->size_max = NULL; new_bar->size_max = NULL;
new_bar->color_fg = NULL;
new_bar->color_bg = NULL;
new_bar->separator = NULL; new_bar->separator = NULL;
new_bar->items = NULL; new_bar->items = NULL;
new_bar->current_size = 1; new_bar->current_size = 1;
@ -863,6 +928,15 @@ gui_bar_create_option (char *bar_name, int index_option, char *value)
"bottom|top|left|right", 0, 0, value, "bottom|top|left|right", 0, 0, value,
NULL, NULL, &gui_bar_config_change_position, NULL, NULL, NULL); NULL, NULL, &gui_bar_config_change_position, NULL, NULL, NULL);
break; break;
case GUI_BAR_OPTION_FILLING:
ptr_option = config_file_new_option (
weechat_config_file, weechat_config_section_bar,
option_name, "integer",
N_("bar filling direction (\"horizontal\" (from left to "
"right) or \"vertical\" (from top to bottom))"),
"horizontal|vertical", 0, 0, value,
NULL, NULL, &gui_bar_config_change_filling, NULL, NULL, NULL);
break;
case GUI_BAR_OPTION_SIZE: case GUI_BAR_OPTION_SIZE:
ptr_option = config_file_new_option ( ptr_option = config_file_new_option (
weechat_config_file, weechat_config_section_bar, weechat_config_file, weechat_config_section_bar,
@ -883,6 +957,26 @@ gui_bar_create_option (char *bar_name, int index_option, char *value)
&gui_bar_config_change_size_max, NULL, &gui_bar_config_change_size_max, NULL,
NULL, NULL); NULL, NULL);
break; break;
case GUI_BAR_OPTION_COLOR_FG:
ptr_option = config_file_new_option (
weechat_config_file, weechat_config_section_bar,
option_name, "color",
N_("default text 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,
option_name, "color",
N_("default background color for bar"),
NULL, 0, 0, value,
NULL, NULL,
&gui_bar_config_change_color, NULL,
NULL, NULL);
break;
case GUI_BAR_OPTION_SEPARATOR: case GUI_BAR_OPTION_SEPARATOR:
ptr_option = config_file_new_option ( ptr_option = config_file_new_option (
weechat_config_file, weechat_config_section_bar, weechat_config_file, weechat_config_section_bar,
@ -916,8 +1010,11 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, char *name,
struct t_config_option *type, struct t_config_option *type,
struct t_config_option *conditions, struct t_config_option *conditions,
struct t_config_option *position, struct t_config_option *position,
struct t_config_option *filling,
struct t_config_option *size, struct t_config_option *size,
struct t_config_option *size_max, struct t_config_option *size_max,
struct t_config_option *color_fg,
struct t_config_option *color_bg,
struct t_config_option *separator, struct t_config_option *separator,
struct t_config_option *items) struct t_config_option *items)
{ {
@ -944,10 +1041,13 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, char *name,
new_bar->conditions_array = NULL; new_bar->conditions_array = NULL;
} }
new_bar->position = position; new_bar->position = position;
new_bar->filling = filling;
new_bar->size = size; new_bar->size = size;
new_bar->current_size = (CONFIG_INTEGER(size) == 0) ? new_bar->current_size = (CONFIG_INTEGER(size) == 0) ?
1 : CONFIG_INTEGER(size); 1 : CONFIG_INTEGER(size);
new_bar->size_max = size_max; new_bar->size_max = size_max;
new_bar->color_fg = color_fg;
new_bar->color_bg = color_bg;
new_bar->separator = separator; new_bar->separator = separator;
new_bar->items = items; new_bar->items = items;
if (CONFIG_STRING(items) && CONFIG_STRING(items)[0]) if (CONFIG_STRING(items) && CONFIG_STRING(items)[0])
@ -999,12 +1099,14 @@ gui_bar_new_with_options (struct t_weechat_plugin *plugin, char *name,
struct t_gui_bar * struct t_gui_bar *
gui_bar_new (struct t_weechat_plugin *plugin, char *name, gui_bar_new (struct t_weechat_plugin *plugin, char *name,
char *type, char *conditions, char *position, char *size, char *type, char *conditions, char *position, char *filling,
char *size_max, char *separators, char *items) char *size, char *size_max, char *color_fg, char *color_bg,
char *separators, char *items)
{ {
struct t_config_option *option_type, *option_conditions, *option_position; struct t_config_option *option_type, *option_conditions, *option_position;
struct t_config_option *option_size, *option_size_max, *option_separator; struct t_config_option *option_filling, *option_size, *option_size_max;
struct t_config_option *option_items; struct t_config_option *option_color_fg, *option_color_bg;
struct t_config_option *option_separator, *option_items;
struct t_gui_bar *new_bar; struct t_gui_bar *new_bar;
if (!name || !name[0]) if (!name || !name[0])
@ -1028,10 +1130,16 @@ gui_bar_new (struct t_weechat_plugin *plugin, char *name,
conditions); conditions);
option_position = gui_bar_create_option (name, GUI_BAR_OPTION_POSITION, option_position = gui_bar_create_option (name, GUI_BAR_OPTION_POSITION,
position); position);
option_filling = gui_bar_create_option (name, GUI_BAR_OPTION_FILLING,
filling);
option_size = gui_bar_create_option (name, GUI_BAR_OPTION_SIZE, option_size = gui_bar_create_option (name, GUI_BAR_OPTION_SIZE,
size); size);
option_size_max = gui_bar_create_option (name, GUI_BAR_OPTION_SIZE_MAX, option_size_max = gui_bar_create_option (name, GUI_BAR_OPTION_SIZE_MAX,
size_max); size_max);
option_color_fg = gui_bar_create_option (name, GUI_BAR_OPTION_COLOR_FG,
color_fg);
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, option_separator = gui_bar_create_option (name, GUI_BAR_OPTION_SEPARATOR,
(config_file_string_to_boolean (separators)) ? (config_file_string_to_boolean (separators)) ?
"on" : "off"); "on" : "off");
@ -1039,8 +1147,10 @@ gui_bar_new (struct t_weechat_plugin *plugin, char *name,
items); items);
new_bar = gui_bar_new_with_options (plugin, name, option_type, new_bar = gui_bar_new_with_options (plugin, name, option_type,
option_conditions, option_position, option_conditions, option_position,
option_size, option_size_max, option_filling, option_size,
option_separator, option_items); option_size_max, option_color_fg,
option_color_bg, option_separator,
option_items);
if (!new_bar) if (!new_bar)
{ {
if (option_type) if (option_type)
@ -1049,10 +1159,16 @@ gui_bar_new (struct t_weechat_plugin *plugin, char *name,
config_file_option_free (option_conditions); config_file_option_free (option_conditions);
if (option_position) if (option_position)
config_file_option_free (option_position); config_file_option_free (option_position);
if (option_filling)
config_file_option_free (option_filling);
if (option_size) if (option_size)
config_file_option_free (option_size); config_file_option_free (option_size);
if (option_size_max) if (option_size_max)
config_file_option_free (option_size_max); config_file_option_free (option_size_max);
if (option_color_fg)
config_file_option_free (option_color_fg);
if (option_color_bg)
config_file_option_free (option_color_bg);
if (option_separator) if (option_separator)
config_file_option_free (option_separator); config_file_option_free (option_separator);
if (option_items) if (option_items)
@ -1087,7 +1203,15 @@ gui_bar_use_temp_bars ()
ptr_temp_bar->position = gui_bar_create_option (ptr_temp_bar->name, ptr_temp_bar->position = gui_bar_create_option (ptr_temp_bar->name,
GUI_BAR_OPTION_POSITION, GUI_BAR_OPTION_POSITION,
"top"); "top");
if (!ptr_temp_bar->filling)
ptr_temp_bar->filling = gui_bar_create_option (ptr_temp_bar->name,
GUI_BAR_OPTION_FILLING,
(ptr_temp_bar->position
&& ((CONFIG_INTEGER(ptr_temp_bar->position) == GUI_BAR_POSITION_LEFT)
|| (CONFIG_INTEGER(ptr_temp_bar->position) == GUI_BAR_POSITION_RIGHT))) ?
"vertical" : "horizontal");
if (!ptr_temp_bar->size) if (!ptr_temp_bar->size)
ptr_temp_bar->size = gui_bar_create_option (ptr_temp_bar->name, ptr_temp_bar->size = gui_bar_create_option (ptr_temp_bar->name,
GUI_BAR_OPTION_SIZE, GUI_BAR_OPTION_SIZE,
@ -1098,6 +1222,16 @@ gui_bar_use_temp_bars ()
GUI_BAR_OPTION_SIZE_MAX, GUI_BAR_OPTION_SIZE_MAX,
"0"); "0");
if (!ptr_temp_bar->color_fg)
ptr_temp_bar->color_fg = gui_bar_create_option (ptr_temp_bar->name,
GUI_BAR_OPTION_COLOR_FG,
"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,
"default");
if (!ptr_temp_bar->separator) if (!ptr_temp_bar->separator)
ptr_temp_bar->separator = gui_bar_create_option (ptr_temp_bar->name, ptr_temp_bar->separator = gui_bar_create_option (ptr_temp_bar->name,
GUI_BAR_OPTION_SEPARATOR, GUI_BAR_OPTION_SEPARATOR,
@ -1109,16 +1243,20 @@ gui_bar_use_temp_bars ()
""); "");
if (ptr_temp_bar->type && ptr_temp_bar->conditions if (ptr_temp_bar->type && ptr_temp_bar->conditions
&& ptr_temp_bar->position && ptr_temp_bar->size && ptr_temp_bar->position && ptr_temp_bar->filling
&& ptr_temp_bar->size_max && ptr_temp_bar->separator && ptr_temp_bar->size && ptr_temp_bar->size_max
&& ptr_temp_bar->items) && ptr_temp_bar->color_fg && ptr_temp_bar->color_bg
&& ptr_temp_bar->separator && ptr_temp_bar->items)
{ {
gui_bar_new_with_options (NULL, ptr_temp_bar->name, gui_bar_new_with_options (NULL, ptr_temp_bar->name,
ptr_temp_bar->type, ptr_temp_bar->type,
ptr_temp_bar->conditions, ptr_temp_bar->conditions,
ptr_temp_bar->position, ptr_temp_bar->position,
ptr_temp_bar->filling,
ptr_temp_bar->size, ptr_temp_bar->size,
ptr_temp_bar->size_max, ptr_temp_bar->size_max,
ptr_temp_bar->color_fg,
ptr_temp_bar->color_bg,
ptr_temp_bar->separator, ptr_temp_bar->separator,
ptr_temp_bar->items); ptr_temp_bar->items);
} }
@ -1139,6 +1277,11 @@ gui_bar_use_temp_bars ()
config_file_option_free (ptr_temp_bar->position); config_file_option_free (ptr_temp_bar->position);
ptr_temp_bar->position = NULL; ptr_temp_bar->position = NULL;
} }
if (ptr_temp_bar->filling)
{
config_file_option_free (ptr_temp_bar->filling);
ptr_temp_bar->filling = NULL;
}
if (ptr_temp_bar->size) if (ptr_temp_bar->size)
{ {
config_file_option_free (ptr_temp_bar->size); config_file_option_free (ptr_temp_bar->size);
@ -1149,6 +1292,16 @@ gui_bar_use_temp_bars ()
config_file_option_free (ptr_temp_bar->size_max); config_file_option_free (ptr_temp_bar->size_max);
ptr_temp_bar->size_max = NULL; ptr_temp_bar->size_max = NULL;
} }
if (ptr_temp_bar->color_fg)
{
config_file_option_free (ptr_temp_bar->color_fg);
ptr_temp_bar->color_fg = NULL;
}
if (ptr_temp_bar->color_bg)
{
config_file_option_free (ptr_temp_bar->color_bg);
ptr_temp_bar->color_bg = NULL;
}
if (ptr_temp_bar->separator) if (ptr_temp_bar->separator)
{ {
config_file_option_free (ptr_temp_bar->separator); config_file_option_free (ptr_temp_bar->separator);
@ -1227,10 +1380,16 @@ gui_bar_free (struct t_gui_bar *bar)
config_file_option_free (bar->conditions); config_file_option_free (bar->conditions);
if (bar->position) if (bar->position)
config_file_option_free (bar->position); config_file_option_free (bar->position);
if (bar->filling)
config_file_option_free (bar->filling);
if (bar->size) if (bar->size)
config_file_option_free (bar->size); config_file_option_free (bar->size);
if (bar->size_max) if (bar->size_max)
config_file_option_free (bar->size_max); config_file_option_free (bar->size_max);
if (bar->color_fg)
config_file_option_free (bar->color_fg);
if (bar->color_bg)
config_file_option_free (bar->color_bg);
if (bar->separator) if (bar->separator)
config_file_option_free (bar->separator); config_file_option_free (bar->separator);
if (bar->items) if (bar->items)
@ -1302,8 +1461,17 @@ gui_bar_print_log ()
log_printf (" position . . . . . . . : %d (%s)", log_printf (" position . . . . . . . : %d (%s)",
CONFIG_INTEGER(ptr_bar->position), CONFIG_INTEGER(ptr_bar->position),
gui_bar_position_str[CONFIG_INTEGER(ptr_bar->position)]); gui_bar_position_str[CONFIG_INTEGER(ptr_bar->position)]);
log_printf (" filling. . . . . . . . : %d (%s)",
CONFIG_INTEGER(ptr_bar->filling),
gui_bar_filling_str[CONFIG_INTEGER(ptr_bar->filling)]);
log_printf (" size . . . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->size)); log_printf (" size . . . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->size));
log_printf (" size_max . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->size_max)); log_printf (" size_max . . . . . . . : %d", CONFIG_INTEGER(ptr_bar->size_max));
log_printf (" color_fg . . . . . . . : %d",
CONFIG_COLOR(ptr_bar->color_fg),
gui_color_get_name (CONFIG_COLOR(ptr_bar->color_fg)));
log_printf (" color_bg . . . . . . . : %d",
CONFIG_COLOR(ptr_bar->color_bg),
gui_color_get_name (CONFIG_COLOR(ptr_bar->color_bg)));
log_printf (" current_size . . . . . : %d", ptr_bar->current_size); log_printf (" current_size . . . . . : %d", ptr_bar->current_size);
log_printf (" separator. . . . . . . : %d", CONFIG_INTEGER(ptr_bar->separator)); log_printf (" separator. . . . . . . : %d", CONFIG_INTEGER(ptr_bar->separator));
log_printf (" items. . . . . . . . . : '%s'", CONFIG_STRING(ptr_bar->items)); log_printf (" items. . . . . . . . . : '%s'", CONFIG_STRING(ptr_bar->items));

View File

@ -28,8 +28,11 @@ enum t_gui_bar_option
GUI_BAR_OPTION_TYPE = 0, GUI_BAR_OPTION_TYPE = 0,
GUI_BAR_OPTION_CONDITIONS, GUI_BAR_OPTION_CONDITIONS,
GUI_BAR_OPTION_POSITION, GUI_BAR_OPTION_POSITION,
GUI_BAR_OPTION_FILLING,
GUI_BAR_OPTION_SIZE, GUI_BAR_OPTION_SIZE,
GUI_BAR_OPTION_SIZE_MAX, GUI_BAR_OPTION_SIZE_MAX,
GUI_BAR_OPTION_COLOR_FG,
GUI_BAR_OPTION_COLOR_BG,
GUI_BAR_OPTION_SEPARATOR, GUI_BAR_OPTION_SEPARATOR,
GUI_BAR_OPTION_ITEMS, GUI_BAR_OPTION_ITEMS,
/* number of bar types */ /* number of bar types */
@ -54,6 +57,14 @@ enum t_gui_bar_position
GUI_BAR_NUM_POSITIONS, GUI_BAR_NUM_POSITIONS,
}; };
enum t_gui_bar_filling
{
GUI_BAR_FILLING_HORIZONTAL = 0,
GUI_BAR_FILLING_VERTICAL,
/* number of bar positions */
GUI_BAR_NUM_FILLING,
};
struct t_gui_bar struct t_gui_bar
{ {
/* user choices */ /* user choices */
@ -63,8 +74,11 @@ struct t_gui_bar
struct t_config_option *type; /* type (root or window) */ struct t_config_option *type; /* type (root or window) */
struct t_config_option *conditions; /* conditions for display */ struct t_config_option *conditions; /* conditions for display */
struct t_config_option *position; /* bottom, top, left, right */ struct t_config_option *position; /* bottom, top, left, right */
struct t_config_option *filling; /* filling (H=horizontal,V=vertical)*/
struct t_config_option *size; /* size of bar (in chars, 0 = auto) */ 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 *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_bg; /* default background color for bar */
struct t_config_option *separator; /* true if separator line displayed */ struct t_config_option *separator; /* true if separator line displayed */
struct t_config_option *items; /* bar items */ struct t_config_option *items; /* bar items */
@ -84,6 +98,7 @@ struct t_gui_bar
extern char *gui_bar_type_str[]; extern char *gui_bar_type_str[];
extern char *gui_bar_position_str[]; extern char *gui_bar_position_str[];
extern char *gui_bar_filling_str[];
extern struct t_gui_bar *gui_bars; extern struct t_gui_bar *gui_bars;
extern struct t_gui_bar *last_gui_bar; extern struct t_gui_bar *last_gui_bar;
extern struct t_gui_bar *gui_temp_bars; extern struct t_gui_bar *gui_temp_bars;
@ -107,9 +122,10 @@ extern struct t_config_option *gui_bar_create_option (char *bar_name,
char *value); char *value);
extern struct t_gui_bar *gui_bar_new (struct t_weechat_plugin *plugin, extern struct t_gui_bar *gui_bar_new (struct t_weechat_plugin *plugin,
char *name, char *type, char *conditions, char *name, char *type, char *conditions,
char *position, char *size, char *position, char *filling,
char *size_max, char *separator, char *size, char *size_max,
char *items); char *color_fg, char *color_bg,
char *separator, char *items);
extern void gui_bar_use_temp_bars (); extern void gui_bar_use_temp_bars ();
extern void gui_bar_update (char *name); extern void gui_bar_update (char *name);
extern void gui_bar_free (struct t_gui_bar *bar); extern void gui_bar_free (struct t_gui_bar *bar);

View File

@ -185,7 +185,7 @@ plugin_config_init ()
if (plugin_config_file) if (plugin_config_file)
{ {
plugin_config_section_var = config_file_new_section ( plugin_config_section_var = config_file_new_section (
plugin_config_file, "var", 0, 0, plugin_config_file, "var", 1, 1,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,

View File

@ -1851,6 +1851,124 @@ weechat_lua_api_config_free (lua_State *L)
LUA_RETURN_OK; LUA_RETURN_OK;
} }
/*
* weechat_lua_api_config_get: get config option
*/
static int
weechat_lua_api_config_get (lua_State *L)
{
const char *option;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get");
LUA_RETURN_EMPTY;
}
option = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get");
LUA_RETURN_EMPTY;
}
option = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (weechat_config_get ((char *)option));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_config_get_plugin: get value of a plugin option
*/
static int
weechat_lua_api_config_get_plugin (lua_State *L)
{
const char *option;
char *value;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin");
LUA_RETURN_EMPTY;
}
option = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin");
LUA_RETURN_EMPTY;
}
option = lua_tostring (lua_current_interpreter, -1);
value = script_api_config_get_plugin (weechat_lua_plugin,
lua_current_script,
(char *)option);
LUA_RETURN_STRING(value);
}
/*
* weechat_lua_api_config_set_plugin: set value of a plugin option
*/
static int
weechat_lua_api_config_set_plugin (lua_State *L)
{
const char *option, *value;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin");
LUA_RETURN_ERROR;
}
option = NULL;
value = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin");
LUA_RETURN_ERROR;
}
option = lua_tostring (lua_current_interpreter, -2);
value = lua_tostring (lua_current_interpreter, -1);
if (script_api_config_set_plugin (weechat_lua_plugin,
lua_current_script,
(char *)option,
(char *)value))
LUA_RETURN_OK;
LUA_RETURN_ERROR;
}
/* /*
* weechat_lua_api_prefix: get a prefix, used for display * weechat_lua_api_prefix: get a prefix, used for display
*/ */
@ -3878,8 +3996,8 @@ weechat_lua_api_bar_search (lua_State *L)
static int static int
weechat_lua_api_bar_new (lua_State *L) weechat_lua_api_bar_new (lua_State *L)
{ {
const char *name, *type, *conditions, *position, *size, *size_max; const char *name, *type, *conditions, *position, *filling, *size;
const char *separator, *items; const char *size_max, *color_fg, *color_bg, *separator, *items;
char *result; char *result;
int n; int n;
@ -3896,25 +4014,31 @@ weechat_lua_api_bar_new (lua_State *L)
type = NULL; type = NULL;
conditions = NULL; conditions = NULL;
position = NULL; position = NULL;
filling = NULL;
size = NULL; size = NULL;
size_max = NULL; size_max = NULL;
color_fg = NULL;
color_bg = NULL;
separator = NULL; separator = NULL;
items = NULL; items = NULL;
n = lua_gettop (lua_current_interpreter); n = lua_gettop (lua_current_interpreter);
if (n < 8) if (n < 11)
{ {
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
LUA_RETURN_EMPTY; LUA_RETURN_EMPTY;
} }
name = lua_tostring (lua_current_interpreter, -8); name = lua_tostring (lua_current_interpreter, -11);
type = lua_tostring (lua_current_interpreter, -7); type = lua_tostring (lua_current_interpreter, -10);
conditions = lua_tostring (lua_current_interpreter, -6); conditions = lua_tostring (lua_current_interpreter, -9);
position = lua_tostring (lua_current_interpreter, -5); position = lua_tostring (lua_current_interpreter, -8);
size = lua_tostring (lua_current_interpreter, -4); filling = lua_tostring (lua_current_interpreter, -7);
size_max = lua_tostring (lua_current_interpreter, -3); size = lua_tostring (lua_current_interpreter, -6);
size_max = lua_tostring (lua_current_interpreter, -5);
color_fg = lua_tostring (lua_current_interpreter, -4);
color_bg = lua_tostring (lua_current_interpreter, -3);
separator = lua_tostring (lua_current_interpreter, -2); separator = lua_tostring (lua_current_interpreter, -2);
items = lua_tostring (lua_current_interpreter, -1); items = lua_tostring (lua_current_interpreter, -1);
@ -3922,8 +4046,11 @@ weechat_lua_api_bar_new (lua_State *L)
(char *)type, (char *)type,
(char *)conditions, (char *)conditions,
(char *)position, (char *)position,
(char *)filling,
(char *)size, (char *)size,
(char *)size_max, (char *)size_max,
(char *)color_fg,
(char *)color_bg,
(char *)separator, (char *)separator,
(char *)items)); (char *)items));
@ -4639,6 +4766,9 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "config_read", &weechat_lua_api_config_read }, { "config_read", &weechat_lua_api_config_read },
{ "config_reload", &weechat_lua_api_config_reload }, { "config_reload", &weechat_lua_api_config_reload },
{ "config_free", &weechat_lua_api_config_free }, { "config_free", &weechat_lua_api_config_free },
{ "config_get", &weechat_lua_api_config_get },
{ "config_get_plugin", &weechat_lua_api_config_get_plugin },
{ "config_set_plugin", &weechat_lua_api_config_set_plugin },
{ "prefix", &weechat_lua_api_prefix }, { "prefix", &weechat_lua_api_prefix },
{ "color", &weechat_lua_api_color }, { "color", &weechat_lua_api_color },
{ "print", &weechat_lua_api_print }, { "print", &weechat_lua_api_print },

View File

@ -1530,6 +1530,101 @@ static XS (XS_weechat_config_free)
PERL_RETURN_OK; PERL_RETURN_OK;
} }
/*
* weechat::config_get: get config option
*/
static XS (XS_weechat_config_get)
{
char *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get");
PERL_RETURN_EMPTY;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get");
PERL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_config_get (SvPV (ST (0), PL_na)));
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::config_get_plugin: get value of a plugin option
*/
static XS (XS_weechat_config_get_plugin)
{
char *value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin");
PERL_RETURN_EMPTY;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin");
PERL_RETURN_EMPTY;
}
value = script_api_config_get_plugin (weechat_perl_plugin,
perl_current_script,
SvPV (ST (0), PL_na));
PERL_RETURN_STRING(value);
}
/*
* weechat::config_set_plugin: set value of a plugin option
*/
static XS (XS_weechat_config_set_plugin)
{
char *option, *value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin");
PERL_RETURN_ERROR;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin");
PERL_RETURN_ERROR;
}
option = SvPV (ST (0), PL_na);
value = SvPV (ST (1), PL_na);
if (script_api_config_set_plugin (weechat_perl_plugin,
perl_current_script,
option,
value))
PERL_RETURN_OK;
PERL_RETURN_ERROR;
}
/* /*
* weechat::prefix: get a prefix, used for display * weechat::prefix: get a prefix, used for display
*/ */
@ -2764,7 +2859,7 @@ static XS (XS_weechat_buffer_set)
if (!perl_current_script) if (!perl_current_script)
{ {
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_set"); WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_set");
PERL_RETURN_ERROR; PERL_RETURN_ERROR;
} }
if (items < 3) if (items < 3)
@ -3219,8 +3314,8 @@ static XS (XS_weechat_bar_search)
static XS (XS_weechat_bar_new) static XS (XS_weechat_bar_new)
{ {
char *result, *name, *type, *conditions, *position, *size, *size_max; char *result, *name, *type, *conditions, *position, *filling, *size;
char *separator, *bar_items; char *size_max, *color_fg, *color_bg, *separator, *bar_items;
dXSARGS; dXSARGS;
/* make C compiler happy */ /* make C compiler happy */
@ -3232,7 +3327,7 @@ static XS (XS_weechat_bar_new)
PERL_RETURN_EMPTY; PERL_RETURN_EMPTY;
} }
if (items < 8) if (items < 11)
{ {
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
PERL_RETURN_EMPTY; PERL_RETURN_EMPTY;
@ -3242,16 +3337,22 @@ static XS (XS_weechat_bar_new)
type = SvPV (ST (1), PL_na); type = SvPV (ST (1), PL_na);
conditions = SvPV (ST (2), PL_na); conditions = SvPV (ST (2), PL_na);
position = SvPV (ST (3), PL_na); position = SvPV (ST (3), PL_na);
size = SvPV (ST (4), PL_na); filling = SvPV (ST (4), PL_na);
size_max = SvPV (ST (5), PL_na); size = SvPV (ST (5), PL_na);
separator = SvPV (ST (6), PL_na); size_max = SvPV (ST (6), PL_na);
bar_items = SvPV (ST (7), PL_na); color_fg = SvPV (ST (7), PL_na);
color_bg = SvPV (ST (8), PL_na);
separator = SvPV (ST (9), PL_na);
bar_items = SvPV (ST (10), PL_na);
result = script_ptr2str (weechat_bar_new (name, result = script_ptr2str (weechat_bar_new (name,
type, type,
conditions, conditions,
position, position,
filling,
size, size,
size_max, size_max,
color_fg,
color_bg,
separator, separator,
bar_items)); bar_items));
@ -3739,6 +3840,9 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::config_read", XS_weechat_config_read, "weechat"); newXS ("weechat::config_read", XS_weechat_config_read, "weechat");
newXS ("weechat::config_reload", XS_weechat_config_reload, "weechat"); newXS ("weechat::config_reload", XS_weechat_config_reload, "weechat");
newXS ("weechat::config_free", XS_weechat_config_free, "weechat"); newXS ("weechat::config_free", XS_weechat_config_free, "weechat");
newXS ("weechat::config_get", XS_weechat_config_get, "weechat");
newXS ("weechat::config_get_plugin", XS_weechat_config_get_plugin, "weechat");
newXS ("weechat::config_set_plugin", XS_weechat_config_set_plugin, "weechat");
newXS ("weechat::prefix", XS_weechat_prefix, "weechat"); newXS ("weechat::prefix", XS_weechat_prefix, "weechat");
newXS ("weechat::color", XS_weechat_color, "weechat"); newXS ("weechat::color", XS_weechat_color, "weechat");
newXS ("weechat::print", XS_weechat_print, "weechat"); newXS ("weechat::print", XS_weechat_print, "weechat");

View File

@ -1626,6 +1626,107 @@ weechat_python_api_config_free (PyObject *self, PyObject *args)
PYTHON_RETURN_OK; PYTHON_RETURN_OK;
} }
/*
* weechat_python_api_config_get: get config option
*/
static PyObject *
weechat_python_api_config_get (PyObject *self, PyObject *args)
{
char *option, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get");
PYTHON_RETURN_EMPTY;
}
option = NULL;
if (!PyArg_ParseTuple (args, "s", &option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_config_get (option));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_config_get_plugin: get value of a plugin option
*/
static PyObject *
weechat_python_api_config_get_plugin (PyObject *self, PyObject *args)
{
char *option, *value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin");
PYTHON_RETURN_EMPTY;
}
option = NULL;
if (!PyArg_ParseTuple (args, "s", &option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin");
PYTHON_RETURN_EMPTY;
}
value = script_api_config_get_plugin (weechat_python_plugin,
python_current_script,
option);
PYTHON_RETURN_STRING(value);
}
/*
* weechat_python_api_config_set_plugin: set value of a plugin option
*/
static PyObject *
weechat_python_api_config_set_plugin (PyObject *self, PyObject *args)
{
char *option, *value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin");
PYTHON_RETURN_ERROR;
}
option = NULL;
value = NULL;
if (!PyArg_ParseTuple (args, "ss", &option, &value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin");
PYTHON_RETURN_ERROR;
}
if (script_api_config_set_plugin (weechat_python_plugin,
python_current_script,
option,
value))
PYTHON_RETURN_OK;
PYTHON_RETURN_ERROR;
}
/* /*
* weechat_python_api_prefix: get a prefix, used for display * weechat_python_api_prefix: get a prefix, used for display
*/ */
@ -3426,8 +3527,8 @@ weechat_python_api_bar_search (PyObject *self, PyObject *args)
static PyObject * static PyObject *
weechat_python_api_bar_new (PyObject *self, PyObject *args) weechat_python_api_bar_new (PyObject *self, PyObject *args)
{ {
char *name, *type, *conditions, *position, *size, *size_max, *separator; char *name, *type, *conditions, *position, *filling, *size, *size_max;
char *items, *result; char *color_fg, *color_bg, *separator, *items, *result;
PyObject *object; PyObject *object;
/* make C compiler happy */ /* make C compiler happy */
@ -3443,13 +3544,17 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args)
type = NULL; type = NULL;
conditions = NULL; conditions = NULL;
position = NULL; position = NULL;
filling = NULL;
size = NULL; size = NULL;
size_max = NULL; size_max = NULL;
color_fg = NULL;
color_bg = NULL;
separator = NULL; separator = NULL;
items = NULL; items = NULL;
if (!PyArg_ParseTuple (args, "ssssssss", &name, &conditions, &type, if (!PyArg_ParseTuple (args, "sssssssssss", &name, &conditions, &type,
&position, &size, &size_max, &separator, &items)) &position, &filling, &size, &size_max, &color_fg,
&color_bg, &separator, &items))
{ {
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
PYTHON_RETURN_EMPTY; PYTHON_RETURN_EMPTY;
@ -3459,8 +3564,11 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args)
type, type,
conditions, conditions,
position, position,
filling,
size, size,
size_max, size_max,
color_fg,
color_bg,
separator, separator,
items)); items));
@ -3975,6 +4083,9 @@ PyMethodDef weechat_python_funcs[] =
{ "config_read", &weechat_python_api_config_read, METH_VARARGS, "" }, { "config_read", &weechat_python_api_config_read, METH_VARARGS, "" },
{ "config_reload", &weechat_python_api_config_reload, METH_VARARGS, "" }, { "config_reload", &weechat_python_api_config_reload, METH_VARARGS, "" },
{ "config_free", &weechat_python_api_config_free, METH_VARARGS, "" }, { "config_free", &weechat_python_api_config_free, METH_VARARGS, "" },
{ "config_get", &weechat_python_api_config_get, METH_VARARGS, "" },
{ "config_get_plugin", &weechat_python_api_config_get_plugin, METH_VARARGS, "" },
{ "config_set_plugin", &weechat_python_api_config_set_plugin, METH_VARARGS, "" },
{ "prefix", &weechat_python_api_prefix, METH_VARARGS, "" }, { "prefix", &weechat_python_api_prefix, METH_VARARGS, "" },
{ "color", &weechat_python_api_color, METH_VARARGS, "" }, { "color", &weechat_python_api_color, METH_VARARGS, "" },
{ "prnt", &weechat_python_api_prnt, METH_VARARGS, "" }, { "prnt", &weechat_python_api_prnt, METH_VARARGS, "" },

View File

@ -1881,6 +1881,114 @@ weechat_ruby_api_config_free (VALUE class, VALUE config_file)
RUBY_RETURN_OK; RUBY_RETURN_OK;
} }
/*
* weechat_ruby_api_config_get: get config option
*/
static VALUE
weechat_ruby_api_config_get (VALUE class, VALUE option)
{
char *c_option, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get");
RUBY_RETURN_EMPTY;
}
if (NIL_P (option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get");
RUBY_RETURN_EMPTY;
}
Check_Type (option, T_STRING);
c_option = STR2CSTR (option);
result = script_ptr2str (weechat_config_get (c_option));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_config_get_plugin: get value of a plugin option
*/
static VALUE
weechat_ruby_api_config_get_plugin (VALUE class, VALUE option)
{
char *c_option, *value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_get_plugin");
RUBY_RETURN_EMPTY;
}
if (NIL_P (option))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_get_plugin");
RUBY_RETURN_EMPTY;
}
Check_Type (option, T_STRING);
c_option = STR2CSTR (option);
value = script_api_config_get_plugin (weechat_ruby_plugin,
ruby_current_script,
c_option);
RUBY_RETURN_STRING(value);
}
/*
* weechat_ruby_api_config_set_plugin: set value of a plugin option
*/
static VALUE
weechat_ruby_api_config_set_plugin (VALUE class, VALUE option, VALUE value)
{
char *c_option, *c_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin");
RUBY_RETURN_ERROR;
}
if (NIL_P (option) || NIL_P (value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin");
RUBY_RETURN_ERROR;
}
Check_Type (option, T_STRING);
Check_Type (value, T_STRING);
c_option = STR2CSTR (option);
c_value = STR2CSTR (value);
if (script_api_config_set_plugin (weechat_ruby_plugin,
ruby_current_script,
c_option,
c_value))
RUBY_RETURN_OK;
RUBY_RETURN_ERROR;
}
/* /*
* weechat_ruby_api_prefix: get a prefix, used for display * weechat_ruby_api_prefix: get a prefix, used for display
*/ */
@ -3942,12 +4050,14 @@ weechat_ruby_api_bar_search (VALUE class, VALUE name)
*/ */
static VALUE static VALUE
weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, VALUE conditions, weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type,
VALUE position, VALUE size, VALUE size_max, VALUE conditions, VALUE position, VALUE filling,
VALUE separator, VALUE items) VALUE size, VALUE size_max, VALUE color_fg,
VALUE color_bg, VALUE separator, VALUE items)
{ {
char *c_name, *c_type, *c_conditions, *c_position, *c_size, *c_size_max; char *c_name, *c_type, *c_conditions, *c_position, *c_filling, *c_size;
char *c_separator, *c_items, *result; char *c_size_max, *c_color_fg, *c_color_bg, *c_separator, *c_items;
char *result;
VALUE return_value; VALUE return_value;
/* make C compiler happy */ /* make C compiler happy */
@ -3963,13 +4073,17 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, VALUE conditions,
c_type = NULL; c_type = NULL;
c_conditions = NULL; c_conditions = NULL;
c_position = NULL; c_position = NULL;
c_filling = NULL;
c_size = NULL; c_size = NULL;
c_size_max = NULL; c_size_max = NULL;
c_color_fg = NULL;
c_color_bg = NULL;
c_separator = NULL; c_separator = NULL;
c_items = NULL; c_items = NULL;
if (NIL_P (name) || NIL_P (type) || NIL_P (conditions) || NIL_P (position) if (NIL_P (name) || NIL_P (type) || NIL_P (conditions) || NIL_P (position)
|| NIL_P (size) || NIL_P (size_max) || NIL_P (separator) || 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 (items))
{ {
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new"); WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
@ -3980,8 +4094,11 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, VALUE conditions,
Check_Type (type, T_STRING); Check_Type (type, T_STRING);
Check_Type (conditions, T_STRING); Check_Type (conditions, T_STRING);
Check_Type (position, T_STRING); Check_Type (position, T_STRING);
Check_Type (filling, T_STRING);
Check_Type (size, T_STRING); Check_Type (size, T_STRING);
Check_Type (size_max, T_STRING); Check_Type (size_max, T_STRING);
Check_Type (color_fg, T_STRING);
Check_Type (color_bg, T_STRING);
Check_Type (separator, T_STRING); Check_Type (separator, T_STRING);
Check_Type (items, T_STRING); Check_Type (items, T_STRING);
@ -3989,8 +4106,11 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, VALUE conditions,
c_type = STR2CSTR (type); c_type = STR2CSTR (type);
c_conditions = STR2CSTR (conditions); c_conditions = STR2CSTR (conditions);
c_position = STR2CSTR (position); c_position = STR2CSTR (position);
c_filling = STR2CSTR (filling);
c_size = STR2CSTR (size); c_size = STR2CSTR (size);
c_size_max = STR2CSTR (size_max); c_size_max = STR2CSTR (size_max);
c_color_fg = STR2CSTR (color_fg);
c_color_bg = STR2CSTR (color_bg);
c_separator = STR2CSTR (separator); c_separator = STR2CSTR (separator);
c_items = STR2CSTR (items); c_items = STR2CSTR (items);
@ -3998,8 +4118,11 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, VALUE conditions,
c_type, c_type,
c_conditions, c_conditions,
c_position, c_position,
c_filling,
c_size, c_size,
c_size_max, c_size_max,
c_color_fg,
c_color_bg,
c_separator, c_separator,
c_items)); c_items));
@ -4561,6 +4684,9 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "config_read", &weechat_ruby_api_config_read, 1); rb_define_module_function (ruby_mWeechat, "config_read", &weechat_ruby_api_config_read, 1);
rb_define_module_function (ruby_mWeechat, "config_reload", &weechat_ruby_api_config_reload, 1); rb_define_module_function (ruby_mWeechat, "config_reload", &weechat_ruby_api_config_reload, 1);
rb_define_module_function (ruby_mWeechat, "config_free", &weechat_ruby_api_config_free, 1); rb_define_module_function (ruby_mWeechat, "config_free", &weechat_ruby_api_config_free, 1);
rb_define_module_function (ruby_mWeechat, "config_get", &weechat_ruby_api_config_get, 1);
rb_define_module_function (ruby_mWeechat, "config_get_plugin", &weechat_ruby_api_config_get_plugin, 1);
rb_define_module_function (ruby_mWeechat, "config_set_plugin", &weechat_ruby_api_config_set_plugin, 2);
rb_define_module_function (ruby_mWeechat, "prefix", &weechat_ruby_api_prefix, 1); rb_define_module_function (ruby_mWeechat, "prefix", &weechat_ruby_api_prefix, 1);
rb_define_module_function (ruby_mWeechat, "color", &weechat_ruby_api_color, 1); rb_define_module_function (ruby_mWeechat, "color", &weechat_ruby_api_color, 1);
rb_define_module_function (ruby_mWeechat, "print", &weechat_ruby_api_print, 2); rb_define_module_function (ruby_mWeechat, "print", &weechat_ruby_api_print, 2);
@ -4599,7 +4725,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_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_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_search", &weechat_ruby_api_bar_search, 1);
rb_define_module_function (ruby_mWeechat, "bar_new", &weechat_ruby_api_bar_new, 8); rb_define_module_function (ruby_mWeechat, "bar_new", &weechat_ruby_api_bar_new, 11);
rb_define_module_function (ruby_mWeechat, "bar_set", &weechat_ruby_api_bar_set, 3); 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_update", &weechat_ruby_api_bar_update, 1);
rb_define_module_function (ruby_mWeechat, "bar_remove", &weechat_ruby_api_bar_remove, 1); rb_define_module_function (ruby_mWeechat, "bar_remove", &weechat_ruby_api_bar_remove, 1);

View File

@ -1158,7 +1158,7 @@ script_api_command (struct t_weechat_plugin *weechat_plugin,
/* /*
* script_api_config_get_plugin: get a value of a script option * script_api_config_get_plugin: get a value of a script option
* format in file is: plugin.script.option=value * format in file is: plugin.script.option = value
*/ */
char * char *
@ -1185,7 +1185,7 @@ script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
/* /*
* script_api_config_set_plugin: set value of a script config option * script_api_config_set_plugin: set value of a script config option
* format in file is: plugin.script.option=value * format in file is: plugin.script.option = value
*/ */
int int

View File

@ -377,8 +377,9 @@ struct t_weechat_plugin
struct t_gui_bar *(*bar_search) (char *name); struct t_gui_bar *(*bar_search) (char *name);
struct t_gui_bar *(*bar_new) (struct t_weechat_plugin *plugin, char *name, struct t_gui_bar *(*bar_new) (struct t_weechat_plugin *plugin, char *name,
char *type, char *condition, char *position, char *type, char *condition, char *position,
char *size, char *size_max, char *separator, char *filling, char *size, char *size_max,
char *items); char *color_fg, char *color_bg,
char *separator, char *items);
int (*bar_set) (struct t_gui_bar *bar, char *property, char *value); int (*bar_set) (struct t_gui_bar *bar, char *property, char *value);
void (*bar_update) (char *name); void (*bar_update) (char *name);
void (*bar_remove) (struct t_gui_bar *bar); void (*bar_remove) (struct t_gui_bar *bar);
@ -773,10 +774,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
#define weechat_bar_search(__name) \ #define weechat_bar_search(__name) \
weechat_plugin->bar_search(__name) weechat_plugin->bar_search(__name)
#define weechat_bar_new(__name, __type, __condition, __position, \ #define weechat_bar_new(__name, __type, __condition, __position, \
__size, __size_max, __separator, __items) \ __filling, __size, __size_max, __color_fg, \
__color_bg, __separator, __items) \
weechat_plugin->bar_new(weechat_plugin, __name, __type, \ weechat_plugin->bar_new(weechat_plugin, __name, __type, \
__condition, __position, __size, \ __condition, __position, __filling, __size, \
__size_max, __separator, __items) __size_max, __color_fg, __color_bg, \
__separator, __items)
#define weechat_bar_set(__bar, __property, __value) \ #define weechat_bar_set(__bar, __property, __value) \
weechat_plugin->bar_set(__bar, __property, __value) weechat_plugin->bar_set(__bar, __property, __value)
#define weechat_bar_update(__name) \ #define weechat_bar_update(__name) \