summaryrefslogtreecommitdiff
path: root/src
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 /src
parent56055de12e90e6037565146700765afe871ac4c6 (diff)
downloadweechat-45638dca236a198a2a0c8561af5c1edd864a17b7.zip
core: allow value "0" in buffer property "unread" to remove read marker from buffer
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui-buffer.c30
-rw-r--r--src/gui/gui-buffer.h3
2 files changed, 24 insertions, 9 deletions
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,