summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c11
-rw-r--r--src/gui/curses/gui-curses-chat.c61
-rw-r--r--src/gui/curses/gui-curses-window.c23
-rw-r--r--src/gui/gui-window.c6
-rw-r--r--src/gui/gui-window.h3
5 files changed, 73 insertions, 31 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 3daf55edc..2bad83267 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -5611,6 +5611,13 @@ COMMAND_CALLBACK(window)
return WEECHAT_RC_OK;
}
+ /* scroll beyond the end of buffer */
+ if (string_strcasecmp (argv[1], "scroll_beyond_end") == 0)
+ {
+ gui_window_scroll_beyond_end (ptr_win);
+ return WEECHAT_RC_OK;
+ }
+
/* scroll to previous highlight */
if (string_strcasecmp (argv[1], "scroll_previous_highlight") == 0)
{
@@ -6744,7 +6751,7 @@ command_init ()
" || scroll [-window <number>] [+/-]<value>[s|m|h|d|M|y]"
" || scroll_horiz [-window <number>] [+/-]<value>[%]"
" || scroll_up|scroll_down|scroll_top|"
- "scroll_bottom|scroll_previous_highlight|"
+ "scroll_bottom|scroll_beyond_end|scroll_previous_highlight|"
"scroll_next_highlight|scroll_unread [-window <number>]"
" || swap [-window <number>] [up|down|left|right]"
" || zoom[-window <number>]"),
@@ -6777,6 +6784,7 @@ command_init ()
" scroll_down: scroll a few lines down\n"
" scroll_top: scroll to top of buffer\n"
"scroll_bottom: scroll to bottom of buffer\n"
+ "scroll_beyond_end: scroll beyond the end of buffer\n"
"scroll_previous_highlight: scroll to previous highlight\n"
"scroll_next_highlight: scroll to next highlight\n"
"scroll_unread: scroll to unread marker\n"
@@ -6818,6 +6826,7 @@ command_init ()
" || scroll_down -window %(windows_numbers)"
" || scroll_top -window %(windows_numbers)"
" || scroll_bottom -window %(windows_numbers)"
+ " || scroll_beyond_end -window %(windows_numbers)"
" || scroll_previous_highlight -window %(windows_numbers)"
" || scroll_next_highlight -window %(windows_numbers)"
" || scroll_unread -window %(windows_numbers)"
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index 85b4901cf..d4b01ee74 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -1390,6 +1390,12 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
backward = (difference < 0);
+ if (*line && (*line_pos < 0))
+ {
+ *line = (*line)->next_line;
+ *line_pos = 0;
+ }
+
if (!(*line))
{
/* if looking backward, start at last line of buffer */
@@ -1480,20 +1486,44 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
void
gui_chat_draw_formatted_buffer (struct t_gui_window *window)
{
- struct t_gui_line *ptr_line;
- int line_pos, count, old_scrolling, old_lines_after;
+ struct t_gui_line *ptr_line, *ptr_line2;
+ int auto_search_first_line, line_pos, line_pos2, count;
+ int old_scrolling, old_lines_after;
/* display at position of scrolling */
+ auto_search_first_line = 1;
+ ptr_line = NULL;
+ line_pos = 0;
if (window->scroll->start_line)
{
+ auto_search_first_line = 0;
ptr_line = window->scroll->start_line;
line_pos = window->scroll->start_line_pos;
+ if (line_pos < 0)
+ {
+ ptr_line = ptr_line->next_line;
+ line_pos = 0;
+ if (ptr_line)
+ {
+ ptr_line2 = ptr_line;
+ line_pos2 = 0;
+ gui_chat_calculate_line_diff (window, &ptr_line2, &line_pos2,
+ window->win_chat_height);
+ if (ptr_line2)
+ {
+ auto_search_first_line = 1;
+ window->scroll->start_line = NULL;
+ window->scroll->start_line_pos = 0;
+ ptr_line = NULL;
+ line_pos = 0;
+ }
+ }
+ }
}
- else
+
+ if (auto_search_first_line)
{
/* look for first line to display, starting from last line */
- ptr_line = NULL;
- line_pos = 0;
gui_chat_calculate_line_diff (window, &ptr_line, &line_pos,
(-1) * (window->win_chat_height - 1));
}
@@ -1563,21 +1593,12 @@ gui_chat_draw_formatted_buffer (struct t_gui_window *window)
WEECHAT_HOOK_SIGNAL_POINTER, window);
}
- if (!window->scroll->scrolling
- && window->scroll->reset_allowed)
- {
- window->scroll->start_line = NULL;
- window->scroll->start_line_pos = 0;
- }
-
/* cursor is below end line of chat window? */
if (window->win_chat_cursor_y > window->win_chat_height - 1)
{
window->win_chat_cursor_x = 0;
window->win_chat_cursor_y = window->win_chat_height - 1;
}
-
- window->scroll->reset_allowed = 0;
}
/*
@@ -1590,8 +1611,16 @@ gui_chat_draw_free_buffer (struct t_gui_window *window, int clear_chat)
struct t_gui_line *ptr_line;
int y_start, y_end, y;
- ptr_line = (window->scroll->start_line) ?
- window->scroll->start_line : window->buffer->lines->first_line;
+ ptr_line = NULL;
+ if (window->scroll->start_line)
+ {
+ ptr_line = window->scroll->start_line;
+ if (window->scroll->start_line_pos < 0)
+ ptr_line = ptr_line->next_line;
+ }
+ else
+ ptr_line = window->buffer->lines->first_line;
+
if (ptr_line)
{
if (!ptr_line->data->displayed)
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index d205d8232..fc5b8e9b3 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -1095,7 +1095,6 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
window->scroll->start_line = NULL;
window->scroll->start_line_pos = 0;
window->scroll->scrolling = 0;
- window->scroll->reset_allowed = 1;
}
if (!gui_buffers_visited_frozen)
{
@@ -1252,7 +1251,6 @@ gui_window_page_up (struct t_gui_window *window)
(window->scroll->start_line) ?
(-1) * (num_lines) :
(-1) * (num_lines + window->win_chat_height - 1));
- window->scroll->reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
}
break;
@@ -1311,7 +1309,6 @@ gui_window_page_down (struct t_gui_window *window)
window->scroll->start_line = NULL;
window->scroll->start_line_pos = 0;
}
- window->scroll->reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
}
break;
@@ -1350,7 +1347,6 @@ gui_window_scroll_up (struct t_gui_window *window)
(-1) * CONFIG_INTEGER(config_look_scroll_amount) :
(-1) * ( (window->win_chat_height - 1) +
CONFIG_INTEGER(config_look_scroll_amount)));
- window->scroll->reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
}
break;
@@ -1403,7 +1399,6 @@ gui_window_scroll_down (struct t_gui_window *window)
window->scroll->start_line = NULL;
window->scroll->start_line_pos = 0;
}
- window->scroll->reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
}
break;
@@ -1436,7 +1431,6 @@ gui_window_scroll_top (struct t_gui_window *window)
{
window->scroll->start_line = gui_line_get_first_displayed (window->buffer);
window->scroll->start_line_pos = 0;
- window->scroll->reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
}
break;
@@ -1471,7 +1465,6 @@ gui_window_scroll_bottom (struct t_gui_window *window)
case GUI_BUFFER_TYPE_FORMATTED:
window->scroll->start_line = NULL;
window->scroll->start_line_pos = 0;
- window->scroll->reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
break;
case GUI_BUFFER_TYPE_FREE:
@@ -1495,6 +1488,22 @@ gui_window_scroll_bottom (struct t_gui_window *window)
}
/*
+ * Scrolls beyond the end of buffer (so that all lines become "hidden" above the
+ * top of window).
+ */
+
+void
+gui_window_scroll_beyond_end (struct t_gui_window *window)
+{
+ if (!gui_init_ok)
+ return;
+
+ window->scroll->start_line = window->buffer->lines->last_line;
+ window->scroll->start_line_pos = -1;
+ gui_buffer_ask_chat_refresh (window->buffer, 2);
+}
+
+/*
* Auto-resizes all windows, according to % of global size.
*
* This function is called after a terminal resize.
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index f4045796c..1b4caf8cf 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -380,7 +380,6 @@ gui_window_scroll_init (struct t_gui_window_scroll *window_scroll,
window_scroll->scrolling = 0;
window_scroll->start_col = 0;
window_scroll->lines_after = 0;
- window_scroll->reset_allowed = 0;
window_scroll->prev_scroll = NULL;
window_scroll->next_scroll = NULL;
}
@@ -440,8 +439,7 @@ gui_window_scroll_remove_not_scrolled (struct t_gui_window *window)
&& (ptr_scroll->start_line_pos == 0)
&& (ptr_scroll->scrolling == 0)
&& (ptr_scroll->start_col == 0)
- && (ptr_scroll->lines_after == 0)
- && (ptr_scroll->reset_allowed == 0))
+ && (ptr_scroll->lines_after == 0))
{
gui_window_scroll_free (window, ptr_scroll);
}
@@ -1729,7 +1727,6 @@ gui_window_hdata_window_scroll_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_gui_window_scroll, scrolling, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_window_scroll, start_col, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_window_scroll, lines_after, INTEGER, 0, NULL, NULL);
- HDATA_VAR(struct t_gui_window_scroll, reset_allowed, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_window_scroll, prev_scroll, POINTER, 0, NULL, hdata_name);
HDATA_VAR(struct t_gui_window_scroll, next_scroll, POINTER, 0, NULL, hdata_name);
}
@@ -1881,7 +1878,6 @@ gui_window_print_log ()
log_printf (" scrolling . . . . . : %d", ptr_scroll->scrolling);
log_printf (" start_col . . . . . : %d", ptr_scroll->start_col);
log_printf (" lines_after . . . . : %d", ptr_scroll->lines_after);
- log_printf (" reset_allowed . . . : %d", ptr_scroll->reset_allowed);
log_printf (" prev_scroll . . . . : 0x%lx", ptr_scroll->prev_scroll);
log_printf (" next_scroll . . . . : 0x%lx", ptr_scroll->next_scroll);
}
diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h
index 1dacf722c..4296b7b6d 100644
--- a/src/gui/gui-window.h
+++ b/src/gui/gui-window.h
@@ -96,8 +96,6 @@ struct t_gui_window_scroll
/* (for horizontal scrolling) */
int lines_after; /* number of lines after last line */
/* displayed (with scrolling) */
- int reset_allowed; /* reset scroll allowed (when using */
- /* keys like page_up/down, end, ..) */
struct t_gui_window_scroll *prev_scroll; /* link to prev. buf. scrolled */
struct t_gui_window_scroll *next_scroll; /* link to next buf. scrolled */
};
@@ -216,6 +214,7 @@ extern void gui_window_scroll_up (struct t_gui_window *window);
extern void gui_window_scroll_down (struct t_gui_window *window);
extern void gui_window_scroll_top (struct t_gui_window *window);
extern void gui_window_scroll_bottom (struct t_gui_window *window);
+extern void gui_window_scroll_beyond_end (struct t_gui_window *window);
extern struct t_gui_window *gui_window_split_horizontal (struct t_gui_window *window,
int percentage);
extern struct t_gui_window *gui_window_split_vertical (struct t_gui_window *window,