buflist: add option buflist.look.auto_scroll (issue #332)

v2.8-utf8proc
Sébastien Helleu 2017-06-08 06:56:42 +02:00
parent e2589aaaca
commit f140a9198e
26 changed files with 370 additions and 15 deletions

View File

@ -22,6 +22,7 @@ New features::
* api: allow update of variables "scroll_x" and "scroll_y" in bar_window with function hdata_update
* api: add functions config_option_get_string() and hdata_compare()
* buflist: add option buflist.look.auto_scroll (issue #332)
* buflist: add keys kbd:[F1]/kbd:[F2], kbd:[Alt+F1]/kbd:[Alt+F2] to scroll the buflist bar
Improvements::

View File

@ -80,6 +80,12 @@
** Werte: beliebige Zeichenkette
** Standardwert: `+"${color:green}${number}${if:${number_displayed}?.: }"+`
* [[option_buflist.look.auto_scroll]] *buflist.look.auto_scroll*
** Beschreibung: pass:none[automatically scroll the buflist bar to always see the current buffer (this works only with a bar on the left/right position with a "vertical" filling); this value is the percent number of lines displayed before the current buffer when scrolling (-1 = disable scroll); for example 50 means that after a scroll, the current buffer is at the middle of bar, 0 means on top of bar, 100 means at bottom of bar]
** Typ: integer
** Werte: -1 .. 100
** Standardwert: `+50+`
* [[option_buflist.look.display_conditions]] *buflist.look.display_conditions*
** Beschreibung: pass:none[Bedingungen wann ein Buffer dargestellt werden soll (Hinweis: Inhalt ist evaluiert, siehe /help buflist); Beispielsweise werden Server-Buffer versteckt, sofern sie mit dem Core-Buffer zusammengefügt worden sind: "${buffer.hidden}==0 && ((${type}!=server && ${buffer.full_name}!=core.weechat) || ${buffer.active}==1)"]
** Typ: Zeichenkette

View File

@ -80,6 +80,12 @@
** values: any string
** default value: `+"${color:green}${number}${if:${number_displayed}?.: }"+`
* [[option_buflist.look.auto_scroll]] *buflist.look.auto_scroll*
** description: pass:none[automatically scroll the buflist bar to always see the current buffer (this works only with a bar on the left/right position with a "vertical" filling); this value is the percent number of lines displayed before the current buffer when scrolling (-1 = disable scroll); for example 50 means that after a scroll, the current buffer is at the middle of bar, 0 means on top of bar, 100 means at bottom of bar]
** type: integer
** values: -1 .. 100
** default value: `+50+`
* [[option_buflist.look.display_conditions]] *buflist.look.display_conditions*
** description: pass:none[conditions to display a buffer (note: content is evaluated, see /help buflist); for example to hide server buffers if they are merged with core buffer: "${buffer.hidden}==0 && ((${type}!=server && ${buffer.full_name}!=core.weechat) || ${buffer.active}==1)"]
** type: string

View File

@ -80,6 +80,12 @@
** valeurs: toute chaîne
** valeur par défaut: `+"${color:green}${number}${if:${number_displayed}?.: }"+`
* [[option_buflist.look.auto_scroll]] *buflist.look.auto_scroll*
** description: pass:none[faire défiler automatiquement la barre buflist pour toujours voir le tampon courant (cela fonctionne seulement avec une barre en position gauche/droite avec un remplissage "vertical") ; cette valeur est un pourcentage de lignes affichées avant le tampon courant lors du défilement (-1 = désactiver le défilement) ; par exemple 50 signifie qu'après un défilement, le tampon courant est au milieu de la barre, 0 signifie en haut de la barre et 100 signifie en bas de la barre]
** type: entier
** valeurs: -1 .. 100
** valeur par défaut: `+50+`
* [[option_buflist.look.display_conditions]] *buflist.look.display_conditions*
** description: pass:none[conditions pour afficher un tampon (note : le contenu est évalué, voir /help buflist) ; par exemple pour cacher les tampons de serveurs s'ils sont fusionnés avec le tampon "core" : "${buffer.hidden}==0 && ((${type}!=server && ${buffer.full_name}!=core.weechat) || ${buffer.active}==1)"]
** type: chaîne

View File

@ -80,6 +80,12 @@
** valori: qualsiasi stringa
** valore predefinito: `+"${color:green}${number}${if:${number_displayed}?.: }"+`
* [[option_buflist.look.auto_scroll]] *buflist.look.auto_scroll*
** descrizione: pass:none[automatically scroll the buflist bar to always see the current buffer (this works only with a bar on the left/right position with a "vertical" filling); this value is the percent number of lines displayed before the current buffer when scrolling (-1 = disable scroll); for example 50 means that after a scroll, the current buffer is at the middle of bar, 0 means on top of bar, 100 means at bottom of bar]
** tipo: intero
** valori: -1 .. 100
** valore predefinito: `+50+`
* [[option_buflist.look.display_conditions]] *buflist.look.display_conditions*
** descrizione: pass:none[conditions to display a buffer (note: content is evaluated, see /help buflist); for example to hide server buffers if they are merged with core buffer: "${buffer.hidden}==0 && ((${type}!=server && ${buffer.full_name}!=core.weechat) || ${buffer.active}==1)"]
** tipo: stringa

View File

@ -80,6 +80,12 @@
** 値: 未制約文字列
** デフォルト値: `+"${color:green}${number}${if:${number_displayed}?.: }"+`
* [[option_buflist.look.auto_scroll]] *buflist.look.auto_scroll*
** 説明: pass:none[automatically scroll the buflist bar to always see the current buffer (this works only with a bar on the left/right position with a "vertical" filling); this value is the percent number of lines displayed before the current buffer when scrolling (-1 = disable scroll); for example 50 means that after a scroll, the current buffer is at the middle of bar, 0 means on top of bar, 100 means at bottom of bar]
** タイプ: 整数
** 値: -1 .. 100
** デフォルト値: `+50+`
* [[option_buflist.look.display_conditions]] *buflist.look.display_conditions*
** 説明: pass:none[バッファの表示条件 (注意: 値は評価されます、/help eval を参照してください); サーババッファがコアバッファにマージされている場合にサーババッファを隠す例: "${buffer.hidden}==0 && ((${type}!=server && ${buffer.full_name}!=core.weechat) || ${buffer.active}==1)"]
** タイプ: 文字列

View File

@ -80,6 +80,12 @@
** wartości: dowolny ciąg
** domyślna wartość: `+"${color:green}${number}${if:${number_displayed}?.: }"+`
* [[option_buflist.look.auto_scroll]] *buflist.look.auto_scroll*
** opis: pass:none[automatically scroll the buflist bar to always see the current buffer (this works only with a bar on the left/right position with a "vertical" filling); this value is the percent number of lines displayed before the current buffer when scrolling (-1 = disable scroll); for example 50 means that after a scroll, the current buffer is at the middle of bar, 0 means on top of bar, 100 means at bottom of bar]
** typ: liczba
** wartości: -1 .. 100
** domyślna wartość: `+50+`
* [[option_buflist.look.display_conditions]] *buflist.look.display_conditions*
** opis: pass:none[warunki do wyświetlenia buforu (uwaga: zawartość jest przetwarzana, zobacz /help buflist); na przykład w celu ukrycia buforów serwerów, kiedy są połączone z głównym buforem: "${buffer.hidden}==0 && ((${type}!=server && ${buffer.full_name}!=core.weechat) || ${buffer.active}==1)"]
** typ: ciąg

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-05-13 22:06+0200\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -4977,6 +4977,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr " napojené signály:"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -19,7 +19,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-06-02 20:00+0200\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
@ -5925,6 +5925,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr "%s: %d Signale hooked"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-01-06 22:01+0100\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -5191,6 +5191,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr " señales enganchadas:"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"PO-Revision-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-06-08 06:45+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@ -5798,6 +5798,22 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr "%s: %d signaux accrochés"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
"faire défiler automatiquement la barre buflist pour toujours voir le tampon "
"courant (cela fonctionne seulement avec une barre en position gauche/droite "
"avec un remplissage \"vertical\") ; cette valeur est un pourcentage de "
"lignes affichées avant le tampon courant lors du défilement (-1 = désactiver "
"le défilement) ; par exemple 50 signifie qu'après un défilement, le tampon "
"courant est au milieu de la barre, 0 signifie en haut de la barre et 100 "
"signifie en bas de la barre"
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-01-06 22:03+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -4515,6 +4515,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr " üzenetkezelők:\n"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-01-06 22:04+0100\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -5329,6 +5329,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr " hook sui segnali:"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-06-03 09:00+0900\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
@ -5525,6 +5525,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr "%s: %d 個のシグナルがフックされました"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-04-08 14:49+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -5653,6 +5653,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr "%s: %d powiązanych sygnałów"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-04-08 14:50+0200\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <>\n"
@ -5585,6 +5585,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr " sinais ligados:"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2016-09-03 08:24+0200\n"
"Last-Translator: Eduardo Elias <camponez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -5131,6 +5131,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr " sinais relacionados:"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-01-06 22:06+0100\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -4553,6 +4553,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr " обработчики сообщений:\n"
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2017-01-06 22:07+0100\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -4118,6 +4118,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr ""
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2017-06-05 14:55+0200\n"
"POT-Creation-Date: 2017-06-08 06:42+0200\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -4103,6 +4103,15 @@ msgstr ""
msgid "%s: %d signals hooked"
msgstr ""
msgid ""
"automatically scroll the buflist bar to always see the current buffer (this "
"works only with a bar on the left/right position with a \"vertical\" "
"filling); this value is the percent number of lines displayed before the "
"current buffer when scrolling (-1 = disable scroll); for example 50 means "
"that after a scroll, the current buffer is at the middle of bar, 0 means on "
"top of bar, 100 means at bottom of bar"
msgstr ""
msgid ""
"conditions to display a buffer (note: content is evaluated, see /help "
"buflist); for example to hide server buffers if they are merged with core "

View File

@ -36,6 +36,8 @@ struct t_hashtable *buflist_hashtable_options = NULL;
struct t_hashtable *buflist_hashtable_options_conditions = NULL;
struct t_arraylist *buflist_list_buffers = NULL;
int old_line_number_current_buffer = -1;
/*
* Updates buflist bar item if buflist is enabled.
@ -48,6 +50,159 @@ buflist_bar_item_update ()
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
}
/*
* Checks if the bar can be scrolled, the bar must have:
* - a position "left" or "right"
* - a filling "vertical"
* - "buflist" as first item.
*
* Returns:
* 1: bar can be scrolled
* 0: bar must not be scrolled
*/
int
buflist_bar_item_bar_can_scroll (struct t_gui_bar *bar)
{
const char *ptr_bar_name, *ptr_bar_position, *ptr_bar_filling;
int items_count, *items_subcount;
char ***items_name, str_option[1024];
ptr_bar_name = weechat_hdata_string (buflist_hdata_bar, bar, "name");
if (!ptr_bar_name)
return 0;
/* check that bar option "position" is "left" or "right" */
snprintf (str_option, sizeof (str_option),
"weechat.bar.%s.position",
ptr_bar_name);
ptr_bar_position = weechat_config_string (weechat_config_get (str_option));
if (!ptr_bar_position
|| ((strcmp (ptr_bar_position, "left") != 0)
&& (strcmp (ptr_bar_position, "right") != 0)))
{
return 0;
}
/* check that bar option "filling_left_right" is "vertical" */
snprintf (str_option, sizeof (str_option),
"weechat.bar.%s.filling_left_right",
ptr_bar_name);
ptr_bar_filling = weechat_config_string (weechat_config_get (str_option));
if (!ptr_bar_filling || (strcmp (ptr_bar_filling, "vertical") != 0))
{
return 0;
}
/* check that "buflist" is the first item in bar */
items_count = weechat_hdata_integer (buflist_hdata_bar, bar,
"items_count");
if (items_count <= 0)
return 0;
items_subcount = weechat_hdata_pointer (buflist_hdata_bar, bar,
"items_subcount");
if (!items_subcount || (items_subcount[0] <= 0))
return 0;
items_name = weechat_hdata_pointer (buflist_hdata_bar, bar, "items_name");
if (!items_name || (strcmp (items_name[0][0], BUFLIST_BAR_ITEM_NAME) != 0))
return 0;
/* OK, bar can be scrolled! */
return 1;
}
/*
* Auto-scrolls a bar window displaying buflist item.
*/
void
buflist_bar_item_auto_scroll_bar_window (struct t_gui_bar_window *bar_window,
int line_number)
{
int height, scroll_y, new_scroll_y, auto_scroll;
char str_scroll[64];
struct t_hashtable *hashtable;
if (!bar_window || (line_number < 0))
return;
height = weechat_hdata_integer (buflist_hdata_bar_window, bar_window,
"height");
scroll_y = weechat_hdata_integer (buflist_hdata_bar_window, bar_window,
"scroll_y");
/* no scroll needed if the line_number is already displayed */
if ((line_number >= scroll_y) && (line_number < scroll_y + height))
return;
hashtable = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL, NULL);
if (hashtable)
{
auto_scroll = weechat_config_integer (buflist_config_look_auto_scroll);
new_scroll_y = line_number - (((height - 1) * auto_scroll) / 100);
if (new_scroll_y < 0)
new_scroll_y = 0;
snprintf (str_scroll, sizeof (str_scroll),
"%d", new_scroll_y);
weechat_hashtable_set (hashtable, "scroll_y", str_scroll);
weechat_hdata_update (buflist_hdata_bar_window, bar_window, hashtable);
weechat_hashtable_free (hashtable);
}
}
/*
* Auto-scrolls all bars with buflist item as first item.
*/
void
buflist_bar_item_auto_scroll (int line_number)
{
struct t_gui_bar *ptr_bar;
struct t_gui_bar_window *ptr_bar_window;
struct t_gui_window *ptr_window;
if (line_number < 0)
return;
/* auto-scroll in root bars */
ptr_bar = weechat_hdata_get_list (buflist_hdata_bar, "gui_bars");
while (ptr_bar)
{
ptr_bar_window = weechat_hdata_pointer (buflist_hdata_bar, ptr_bar,
"bar_window");
if (ptr_bar_window && buflist_bar_item_bar_can_scroll (ptr_bar))
{
buflist_bar_item_auto_scroll_bar_window (ptr_bar_window,
line_number);
}
ptr_bar = weechat_hdata_move (buflist_hdata_bar, ptr_bar, 1);
}
/* auto-scroll in window bars */
ptr_window = weechat_hdata_get_list (buflist_hdata_window, "gui_windows");
while (ptr_window)
{
ptr_bar_window = weechat_hdata_pointer (buflist_hdata_window,
ptr_window, "bar_windows");
while (ptr_bar_window)
{
ptr_bar = weechat_hdata_pointer (buflist_hdata_bar_window,
ptr_bar_window, "bar");
if (buflist_bar_item_bar_can_scroll (ptr_bar))
{
buflist_bar_item_auto_scroll_bar_window (ptr_bar_window,
line_number);
}
ptr_bar_window = weechat_hdata_move (buflist_hdata_bar_window,
ptr_bar_window, 1);
}
ptr_window = weechat_hdata_move (buflist_hdata_window, ptr_window, 1);
}
}
/*
* Returns content of bar item "buffer_plugin": bar item with buffer plugin.
*/
@ -79,7 +234,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
const char *ptr_lag;
int num_buffers, is_channel, is_private;
int i, j, length_max_number, current_buffer, number, prev_number, priority;
int rc, count;
int rc, count, line_number, line_number_current_buffer;
/* make C compiler happy */
(void) pointer;
@ -93,6 +248,8 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
return NULL;
prev_number = -1;
line_number = 0;
line_number_current_buffer = 0;
buflist = weechat_string_dyn_alloc (256);
@ -171,6 +328,8 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
weechat_hashtable_set (buflist_hashtable_extra_vars,
"current_buffer",
(current_buffer) ? "1" : "0");
if (current_buffer)
line_number_current_buffer = line_number;
/* buffer number */
number = weechat_hdata_integer (buflist_hdata_buffer,
@ -349,6 +508,8 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
free (line);
if (!rc)
goto error;
line_number++;
}
str_buflist = *buflist;
@ -362,6 +523,13 @@ end:
weechat_string_dyn_free (buflist, 0);
weechat_arraylist_free (buffers);
if ((line_number_current_buffer != old_line_number_current_buffer)
&& (weechat_config_integer (buflist_config_look_auto_scroll) >= 0))
{
buflist_bar_item_auto_scroll (line_number_current_buffer);
}
old_line_number_current_buffer = line_number_current_buffer;
return str_buflist;
}

View File

@ -32,6 +32,7 @@ struct t_config_file *buflist_config_file = NULL;
/* buflist config, look section */
struct t_config_option *buflist_config_look_auto_scroll;
struct t_config_option *buflist_config_look_display_conditions;
struct t_config_option *buflist_config_look_enabled;
struct t_config_option *buflist_config_look_mouse_jump_visited_buffer;
@ -336,6 +337,20 @@ buflist_config_init ()
return 0;
}
buflist_config_look_auto_scroll = weechat_config_new_option (
buflist_config_file, ptr_section,
"auto_scroll", "integer",
N_("automatically scroll the buflist bar to always see the current "
"buffer (this works only with a bar on the left/right position "
"with a \"vertical\" filling); this value is the percent number "
"of lines displayed before the current buffer when scrolling "
"(-1 = disable scroll); for example 50 means that after a scroll, "
"the current buffer is at the middle of bar, 0 means on top of "
"bar, 100 means at bottom of bar"),
NULL, -1, 100, "50", NULL, 0,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
buflist_config_look_display_conditions = weechat_config_new_option (
buflist_config_file, ptr_section,
"display_conditions", "string",

View File

@ -32,6 +32,7 @@
extern struct t_config_file *buflist_config_file;
extern struct t_config_option *buflist_config_look_auto_scroll;
extern struct t_config_option *buflist_config_look_display_conditions;
extern struct t_config_option *buflist_config_look_enabled;
extern struct t_config_option *buflist_config_look_mouse_jump_visited_buffer;

View File

@ -40,8 +40,11 @@ WEECHAT_PLUGIN_PRIORITY(8000);
struct t_weechat_plugin *weechat_buflist_plugin = NULL;
struct t_hdata *buflist_hdata_window = NULL;
struct t_hdata *buflist_hdata_buffer = NULL;
struct t_hdata *buflist_hdata_hotlist = NULL;
struct t_hdata *buflist_hdata_bar = NULL;
struct t_hdata *buflist_hdata_bar_window = NULL;
/*
@ -403,8 +406,11 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_plugin = plugin;
buflist_hdata_window = weechat_hdata_get ("window");
buflist_hdata_buffer = weechat_hdata_get ("buffer");
buflist_hdata_hotlist = weechat_hdata_get ("hotlist");
buflist_hdata_bar = weechat_hdata_get ("bar");
buflist_hdata_bar_window = weechat_hdata_get ("bar_window");
if (!buflist_config_init ())
return WEECHAT_RC_ERROR;

View File

@ -27,8 +27,11 @@
extern struct t_weechat_plugin *weechat_buflist_plugin;
extern struct t_hdata *buflist_hdata_window;
extern struct t_hdata *buflist_hdata_buffer;
extern struct t_hdata *buflist_hdata_hotlist;
extern struct t_hdata *buflist_hdata_bar;
extern struct t_hdata *buflist_hdata_bar_window;
extern void buflist_add_bar ();
extern void buflist_buffer_get_irc_pointers(struct t_gui_buffer *buffer,

View File

@ -42,6 +42,7 @@ struct t_gui_window;
struct t_gui_buffer;
struct t_gui_bar;
struct t_gui_bar_item;
struct t_gui_bar_window;
struct t_gui_completion;
struct t_gui_nick;
struct t_gui_nick_group;