summaryrefslogtreecommitdiff
path: root/src/gui/gui-window.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-01-24 21:20:52 +0100
committerSebastien Helleu <flashcode@flashtux.org>2012-01-24 21:20:52 +0100
commitd242f30950d2f71d26ec35361ebdc638913a464b (patch)
tree1a65ad193701f9bc0f6d6053e43f0c950a83b692 /src/gui/gui-window.c
parent009925b9ac9fc280a1bb30d7aa64db6777d0ac43 (diff)
downloadweechat-d242f30950d2f71d26ec35361ebdc638913a464b.zip
core: move option "scroll_unread" from command /input to /window
Diffstat (limited to 'src/gui/gui-window.c')
-rw-r--r--src/gui/gui-window.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index 938a3eea8..d7bfdd0dc 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -1386,6 +1386,39 @@ gui_window_scroll_next_highlight (struct t_gui_window *window)
}
/*
+ * gui_window_scroll_unread: scroll to first unread line of buffer
+ */
+
+void
+gui_window_scroll_unread (struct t_gui_window *window)
+{
+ if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ {
+ if (CONFIG_STRING(config_look_read_marker) &&
+ CONFIG_STRING(config_look_read_marker)[0] &&
+ (window->buffer->type == GUI_BUFFER_TYPE_FORMATTED) &&
+ (window->buffer->lines->first_line_not_read ||
+ (window->buffer->lines->last_read_line &&
+ window->buffer->lines->last_read_line != window->buffer->lines->last_line)))
+ {
+ if (window->buffer->lines->first_line_not_read)
+ window->scroll->start_line = window->buffer->lines->first_line;
+ else
+ window->scroll->start_line = window->buffer->lines->last_read_line->next_line;
+ if (window->scroll->start_line)
+ {
+ if (!gui_line_is_displayed (window->scroll->start_line))
+ window->scroll->start_line = gui_line_get_next_displayed (window->scroll->start_line);
+ }
+ window->scroll->start_line_pos = 0;
+ window->scroll->first_line_displayed =
+ (window->scroll->start_line == gui_line_get_first_displayed (window->buffer));
+ gui_buffer_ask_chat_refresh (window->buffer, 2);
+ }
+ }
+}
+
+/*
* gui_window_search_text: search text in a buffer
* return 1 if line has been found with text, otherwise 0
*/