summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-12-26 01:27:45 +0100
committerSébastien Helleu <flashcode@flashtux.org>2022-12-26 01:27:45 +0100
commit45638dca236a198a2a0c8561af5c1edd864a17b7 (patch)
tree6390a13714897af670825d2fa73a7316ba4a7dcf
parent56055de12e90e6037565146700765afe871ac4c6 (diff)
downloadweechat-45638dca236a198a2a0c8561af5c1edd864a17b7.zip
core: allow value "0" in buffer property "unread" to remove read marker from buffer
-rw-r--r--ChangeLog.adoc1
-rw-r--r--doc/en/weechat_plugin_api.en.adoc5
-rw-r--r--doc/fr/weechat_plugin_api.fr.adoc6
-rw-r--r--doc/it/weechat_plugin_api.it.adoc6
-rw-r--r--doc/ja/weechat_plugin_api.ja.adoc6
-rw-r--r--doc/sr/weechat_plugin_api.sr.adoc6
-rw-r--r--src/gui/gui-buffer.c30
-rw-r--r--src/gui/gui-buffer.h3
8 files changed, 44 insertions, 19 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 3d6d4c91c..9f0bc1188 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
New features::
+ * core: allow value "0" in buffer property "unread" to remove read marker from buffer
* core: add command `/allbuf`
* core: add command `/hotlist`
* core: move some `/input` actions to commands `/allbuf`, `/buffer` and `/hotlist`
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index 991dea597..95d00a573 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -13785,8 +13785,9 @@ Properties:
"1": do not stop completion when command line is updated
(global setting, buffer pointer is not used).
-| unread | | -
-| Set unread marker after last line of buffer.
+| unread | | empty string or "0"
+| empty string: set unread marker after last line of buffer +
+ "0": remove unread marker from buffer.
| display | | "1" or "auto"
| "1": switch to this buffer in current window +
diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc
index 6c5a3bcc3..1950ce2c9 100644
--- a/doc/fr/weechat_plugin_api.fr.adoc
+++ b/doc/fr/weechat_plugin_api.fr.adoc
@@ -14084,8 +14084,10 @@ Propriétés :
"1" : ne pas arrêter la complétion lorsque la ligne de commande est mise à
jour (option globale, le pointeur vers le tampon n'est pas utilisé).
-| unread | | -
-| Définit le marqueur de données non lues après la dernière ligne du tampon.
+| unread | | chaîne vide ou "0"
+| chaîne vide : définit le marqueur de données non lues après la dernière ligne
+ du tampon +
+ "0" : supprime le marqueur de données non lues du tampon.
| display | | "1" ou "auto"
| "1" : basculer vers ce tampon dans la fenêtre active +
diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc
index a06a47c3f..1a85e1efc 100644
--- a/doc/it/weechat_plugin_api.it.adoc
+++ b/doc/it/weechat_plugin_api.it.adoc
@@ -14427,8 +14427,10 @@ Properties:
"1": do not stop completion when command line is updated
(impostazione globale, il puntatore al buffer non è utilizzato).
-| unread | | -
-| Imposta l'evidenziatore di lettura dopo l'ultima riga del buffer.
+// TRANSLATION MISSING
+| unread | | empty string or "0"
+| empty string: set unread marker after last line of buffer +
+ "0": remove unread marker from buffer.
| display | | "1" oppure "auto"
| "1": passa a questo buffer nella finestra corrente +
diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc
index 4300be134..393cad643 100644
--- a/doc/ja/weechat_plugin_api.ja.adoc
+++ b/doc/ja/weechat_plugin_api.ja.adoc
@@ -13936,8 +13936,10 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
"1": コマンドラインが更新された際に補完を継続する
(グローバル設定、バッファへのポインタは使われない)
-| unread | | -
-| バッファの最後の行の後に未読マーカーを設定
+// TRANSLATION MISSING
+| unread | | empty string or "0"
+| empty string: set unread marker after last line of buffer +
+ "0": remove unread marker from buffer.
| display | | "1" または "auto"
| "1": 指定したバッファを現在のウィンドウに表示 +
diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc
index eb75afef5..14fc72ab4 100644
--- a/doc/sr/weechat_plugin_api.sr.adoc
+++ b/doc/sr/weechat_plugin_api.sr.adoc
@@ -13356,8 +13356,10 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
"1": довршавање се не зауставља када се ажурира командна линија
(глобално подешавање, не користи се показивач на бафер).
-| unread | | -
-| Поставља маркер непрочитаних линија након последње линије бафера.
+// TRANSLATION MISSING
+| unread | | empty string or "0"
+| empty string: set unread marker after last line of buffer +
+ "0": remove unread marker from buffer.
| display | | "1" или "auto"
| "1": прелазак на овај бафер у текућем прозору +
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index cbf5c616b..f871e5593 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -2107,21 +2107,34 @@ gui_buffer_set_input_multiline (struct t_gui_buffer *buffer,
/*
* Sets unread marker for a buffer.
+ *
+ * If remove_marker == 1, then unread marker is removed, otherwise it's set
+ * after the last line.
*/
void
-gui_buffer_set_unread (struct t_gui_buffer *buffer)
+gui_buffer_set_unread (struct t_gui_buffer *buffer, int remove_marker)
{
int refresh;
if (!buffer || (buffer->type != GUI_BUFFER_TYPE_FORMATTED))
return;
- refresh = ((buffer->lines->last_read_line != NULL)
- && (buffer->lines->last_read_line != buffer->lines->last_line));
-
- buffer->lines->last_read_line = buffer->lines->last_line;
- buffer->lines->first_line_not_read = (buffer->lines->last_read_line) ? 0 : 1;
+ if (remove_marker)
+ {
+ /* remove unread marker */
+ refresh = (buffer->lines->last_read_line != NULL);
+ buffer->lines->last_read_line = NULL;
+ buffer->lines->first_line_not_read = 0;
+ }
+ else
+ {
+ /* set unread marker after last line */
+ refresh = ((buffer->lines->last_read_line != NULL)
+ && (buffer->lines->last_read_line != buffer->lines->last_line));
+ buffer->lines->last_read_line = buffer->lines->last_line;
+ buffer->lines->first_line_not_read = (buffer->lines->last_read_line) ? 0 : 1;
+ }
if (refresh)
gui_buffer_ask_chat_refresh (buffer, 2);
@@ -2135,7 +2148,7 @@ void
gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value)
{
- int gui_chat_mute_old;
+ int gui_chat_mute_old, remove_marker;
long number;
char *error;
const char *ptr_notify;
@@ -2182,7 +2195,8 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
/* properties that need a buffer */
if (string_strcasecmp (property, "unread") == 0)
{
- gui_buffer_set_unread (buffer);
+ remove_marker = (strcmp (value, "0") == 0);
+ gui_buffer_set_unread (buffer, remove_marker);
}
else if (string_strcasecmp (property, "display") == 0)
{
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index 5fc4da2ca..d7302566d 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -330,7 +330,8 @@ extern void gui_buffer_set_highlight_tags (struct t_gui_buffer *buffer,
const char *new_tags);
extern void gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
const char *new_hotlist_max_level_nicks);
-extern void gui_buffer_set_unread (struct t_gui_buffer *buffer);
+extern void gui_buffer_set_unread (struct t_gui_buffer *buffer,
+ int remove_marker);
extern void gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
const char *value);
extern void gui_buffer_set_pointer (struct t_gui_buffer *buffer,