1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 12:05:41 +02:00

core: add buffer property "modes"

This commit is contained in:
Sébastien Helleu
2024-05-12 09:26:10 +02:00
parent e57777acb1
commit e7b2d98b6e
11 changed files with 114 additions and 8 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ For a list of important changes that require manual actions, please look at rele
New features::
* core: add buffer property "input_prompt"
* core: add buffer properties "input_prompt" and "modes"
* core: send signal "buffer_line_added" on buffers with free content
* core: add support of XDG "state" directory (issue #2106, issue #1747)
* core: use nick offline color for nick in action message
+8
View File
@@ -12146,6 +12146,10 @@ List of signals sent by WeeChat and plugins:
| Pointer: buffer.
| Title of buffer changed.
| weechat | [[hook_signal_buffer_modes_changed]] buffer_modes_changed | 4.3.0
| Pointer: buffer.
| Modes of buffer changed.
| weechat | [[hook_signal_buffer_type_changed]] buffer_type_changed |
| Pointer: buffer.
| Type of buffer changed.
@@ -14707,6 +14711,7 @@ Arguments:
** _short_name_: short name of buffer (note: used for display only and can be changed by user, this must not be used to find name of buffer, use instead _name_, _full_name_ or local variable _channel_)
** _type_: type of buffer: "formatted" or "free" _(WeeChat ≥ 4.2.0)_
** _title_: title of buffer
** _modes_: modes _(WeeChat ≥ 4.3.0)_
** _nicklist_last_id_assigned_: last unique identifier used in this buffer for a group or nick _(WeeChat ≥ 4.3.0)_
** _input_prompt_: input prompt _(WeeChat ≥ 4.3.0)_
** _input_: input text
@@ -14883,6 +14888,9 @@ Properties:
| title | | any string
| Set new title for buffer.
| modes | 4.3.0 | any string
| Set new modes for buffer.
| time_for_each_line | | "0" or "1"
| "0" to hide time for all lines in buffer, "1" to see time for all lines
(default for a new buffer).
+8
View File
@@ -12397,6 +12397,10 @@ Liste des signaux envoyés par WeeChat et les extensions :
| Pointeur : tampon.
| Titre du tampon changé.
| weechat | [[hook_signal_buffer_modes_changed]] buffer_modes_changed | 4.3.0
| Pointeur : tampon.
| Modes du tampon changés.
| weechat | [[hook_signal_buffer_type_changed]] buffer_type_changed |
| Pointeur : tampon.
| Type de tampon changé.
@@ -15024,6 +15028,7 @@ Paramètres :
** _short_name_ : nom court du tampon (note : utilisé pour l'affichage seulement et peut être changé par l'utilisateur, il ne doit pas être utilisé pour trouver le nom du tampon, utilisez à la place _name_, _full_name_ ou bien la variable locale _channel_)
** _type_ : type de tampon : "formatted" (formaté) ou "free" (contenu libre) _(WeeChat ≥ 4.2.0)_
** _title_ : titre du tampon
** _modes_ : modes _(WeeChat ≥ 4.3.0)_
** _nicklist_last_id_assigned_ : dernier identifiant unique utilisé dans ce tampon pour un groupe ou un pseudo _(WeeChat ≥ 4.3.0)_
** _input_prompt_ : invite de la zone saisie _(WeeChat ≥ 4.3.0)_
** _input_ : texte saisi
@@ -15204,6 +15209,9 @@ Propriétés :
| title | | toute chaîne
| Change le titre du tampon.
| modes | 4.3.0 | toue chaîne
| Change les modes du tampon.
| time_for_each_line | | "0" ou "1"
| "0" pour cacher l'heure sur toutes les lignes du tampon, "1" pour afficher
l'heure sur toutes les lignes (par défaut pour un nouveau tampon).
+11
View File
@@ -12647,6 +12647,11 @@ List of signals sent by WeeChat and plugins:
| Puntatore: buffer.
| Titolo del buffer modificato.
// TRANSLATION MISSING
| weechat | [[hook_signal_buffer_modes_changed]] buffer_modes_changed | 4.3.0
| Pointer: buffer.
| Modes of buffer changed.
| weechat | [[hook_signal_buffer_type_changed]] buffer_type_changed |
| Puntatore: buffer.
| Tipo di buffer modificato.
@@ -15408,6 +15413,8 @@ Argomenti:
** _type_: type of buffer: "formatted" or "free" _(WeeChat ≥ 4.2.0)_
** _title_: titolo del buffer
// TRANSLATION MISSING
** _modes_: modes _(WeeChat ≥ 4.3.0)_
// TRANSLATION MISSING
** _nicklist_last_id_assigned_: last unique identifier used in this buffer for a group or nick _(WeeChat ≥ 4.3.0)_
// TRANSLATION MISSING
** _input_prompt_: input prompt _(WeeChat ≥ 4.3.0)_
@@ -15608,6 +15615,10 @@ Properties:
| title | | qualsiasi stringa
| Imposta nuovo titolo per il buffer.
// TRANSLATION MISSING
| modes | 4.3.0 | any string
| Set new modes for buffer.
| time_for_each_line | | "0" oppure "1"
| "0" per nascondere l'orario in tutte le righe del buffer, "1" per
visualizzarlo su tutte le righe (predefinito per un nuovo buffer).
+11
View File
@@ -12308,6 +12308,11 @@ WeeChat とプラグインが送信するシグナルのリスト:
| Pointer: バッファ
| バッファのタイトルを変更
// TRANSLATION MISSING
| weechat | [[hook_signal_buffer_modes_changed]] buffer_modes_changed | 4.3.0
| Pointer: buffer.
| Modes of buffer changed.
| weechat | [[hook_signal_buffer_type_changed]] buffer_type_changed |
| Pointer: バッファ
| バッファのタイプを変更
@@ -14943,6 +14948,8 @@ const char *weechat_buffer_get_string (struct t_gui_buffer *buffer,
** _type_: type of buffer: "formatted" or "free" _(WeeChat ≥ 4.2.0)_
** _title_: バッファのタイトル
// TRANSLATION MISSING
** _modes_: modes _(WeeChat ≥ 4.3.0)_
// TRANSLATION MISSING
** _nicklist_last_id_assigned_: last unique identifier used in this buffer for a group or nick _(WeeChat ≥ 4.3.0)_
// TRANSLATION MISSING
** _input_prompt_: input prompt _(WeeChat ≥ 4.3.0)_
@@ -15126,6 +15133,10 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
| title | | 任意の文字列
| 指定したバッファの新しいタイトルを設定
// TRANSLATION MISSING
| modes | 4.3.0 | any string
| Set new modes for buffer.
| time_for_each_line | | "0" または "1"
| バッファのすべての行に時間を表示しない場合は "0"、表示する場合は
"1" (新規バッファに対するデフォルト)
+11
View File
@@ -11821,6 +11821,11 @@ struct t_hook *weechat_hook_signal (const char *signal,
| Показивач: бафер.
| Промењен је наслов бафера.
// TRANSLATION MISSING
| weechat | [[hook_signal_buffer_modes_changed]] buffer_modes_changed | 4.3.0
| Pointer: buffer.
| Modes of buffer changed.
| weechat | [[hook_signal_buffer_type_changed]] buffer_type_changed |
| Показивач: бафер.
| Промењен је тип бафера.
@@ -14285,6 +14290,8 @@ const char *weechat_buffer_get_string (struct t_gui_buffer *buffer,
** _short_name_: кратко име бафера (напомена: користи се само за приказ и корисник може да га промени, ово не сме да се употребљава за проналажење имена бафера, уместо њега употребите _name_, _full_name_ или локалну променљиву _channel_)
** _type_: тип бафера: „formatted” или „free” _(WeeChat ≥ 4.2.0)_
** _title_: наслов бафера
// TRANSLATION MISSING
** _modes_: modes _(WeeChat ≥ 4.3.0)_
** _nicklist_last_id_assigned_: последњи јединствени идентификатор употребљен у овом баферу за групу или надимак _(WeeChat ≥ 4.3.0)_
// TRANSLATION MISSING
** _input_prompt_: input prompt _(WeeChat ≥ 4.3.0)_
@@ -14462,6 +14469,10 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
| title | | било који стринг
| Поставља нови наслов бафера.
// TRANSLATION MISSING
| modes | 4.3.0 | any string
| Set new modes for buffer.
| time_for_each_line | | "0" или "1"
| "0" да се скрива време у свим линијама бафера, "1" да се приказује у свим
линијама (подразумевано за нови бафер).
+3
View File
@@ -523,6 +523,9 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist)
ptr_buffer->title = (str) ? strdup (str) : NULL;
}
/* modes */
gui_buffer_set_modes (ptr_buffer, infolist_string (infolist, "modes"));
/* first line not read */
ptr_buffer->lines->first_line_not_read =
infolist_integer (infolist, "first_line_not_read");
+5 -3
View File
@@ -1301,10 +1301,12 @@ gui_bar_item_buffer_modes_cb (const void *pointer, void *data,
(void) data;
(void) item;
(void) window;
(void) buffer;
(void) extra_info;
return NULL;
if (!buffer)
return NULL;
return (buffer->modes) ? strdup (buffer->modes) : NULL;
}
/*
@@ -2387,7 +2389,7 @@ gui_bar_item_init ()
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_MODES],
&gui_bar_item_buffer_modes_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch;buffer_switch",
gui_bar_item_hook_signal ("window_switch;buffer_switch;buffer_modes_changed",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_MODES]);
/* buffer filter */
+37 -4
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -146,6 +146,9 @@ struct t_gui_buffer
/* buffer title */
char *title; /* buffer title */
/* buffer modes */
char *modes; /* buffer modes */
/* chat content */
struct t_gui_lines *own_lines; /* lines (for this buffer only) */
struct t_gui_lines *mixed_lines; /* mixed lines (if buffers merged) */
@@ -373,6 +376,8 @@ extern void gui_buffer_ask_chat_refresh (struct t_gui_buffer *buffer,
int refresh);
extern void gui_buffer_set_title (struct t_gui_buffer *buffer,
const char *new_title);
extern void gui_buffer_set_modes (struct t_gui_buffer *buffer,
const char *new_modes);
extern void gui_buffer_set_highlight_words (struct t_gui_buffer *buffer,
const char *new_highlight_words);
extern void gui_buffer_set_highlight_disable_regex (struct t_gui_buffer *buffer,
+14
View File
@@ -552,6 +552,7 @@ TEST(GuiBuffer, NewProps)
POINTERS_EQUAL(NULL, buffer->close_callback_data);
LONGS_EQUAL(0, buffer->closing);
POINTERS_EQUAL(NULL, buffer->title);
POINTERS_EQUAL(NULL, buffer->modes);
CHECK(buffer->own_lines);
POINTERS_EQUAL(NULL, buffer->own_lines->first_line);
POINTERS_EQUAL(NULL, buffer->own_lines->last_line);
@@ -639,6 +640,7 @@ TEST(GuiBuffer, NewProps)
gui_buffer_close (buffer);
hashtable_set (properties, "title", "the buffer title");
hashtable_set (properties, "modes", "+nt");
hashtable_set (properties, "short_name", "the_short_name");
hashtable_set (properties, "localvar_set_test", "value");
hashtable_set (properties, "key_bind_meta-y", "/test_y arg1 arg2");
@@ -647,6 +649,7 @@ TEST(GuiBuffer, NewProps)
&test_buffer_input_cb, NULL, NULL,
&test_buffer_close_cb, NULL, NULL);
STRCMP_EQUAL("the buffer title", buffer->title);
STRCMP_EQUAL("+nt", buffer->modes);
STRCMP_EQUAL("the_short_name", buffer->short_name);
LONGS_EQUAL(3, buffer->local_variables->items_count);
STRCMP_EQUAL("value",
@@ -934,6 +937,7 @@ TEST(GuiBuffer, GetString)
STRCMP_EQUAL("weechat", gui_buffer_get_string (gui_buffers, "short_name"));
STRCMP_EQUAL("formatted", gui_buffer_get_string (gui_buffers, "type"));
STRNCMP_EQUAL("WeeChat ", gui_buffer_get_string (gui_buffers, "title"), 8);
POINTERS_EQUAL(NULL, gui_buffer_get_string (gui_buffers, "modes"));
POINTERS_EQUAL(NULL, gui_buffer_get_string (gui_buffers, "input_prompt"));
STRCMP_EQUAL("", gui_buffer_get_string (gui_buffers, "input"));
POINTERS_EQUAL(NULL, gui_buffer_get_string (gui_buffers, "text_search_input"));
@@ -1033,6 +1037,16 @@ TEST(GuiBuffer, SetTitle)
/* TODO: write tests */
}
/*
* Tests functions:
* gui_buffer_set_modes
*/
TEST(GuiBuffer, SetModes)
{
/* TODO: write tests */
}
/*
* Tests functions:
* gui_buffer_set_time_for_each_line