mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
core: add option "scroll_beyond_end" for command /window (task #6745)
This commit is contained in:
@@ -784,7 +784,6 @@
|
||||
'scrolling' (integer) +
|
||||
'start_col' (integer) +
|
||||
'lines_after' (integer) +
|
||||
'reset_allowed' (integer) +
|
||||
'prev_scroll' (pointer, hdata: "window_scroll") +
|
||||
'next_scroll' (pointer, hdata: "window_scroll") |
|
||||
|
|
||||
|
||||
@@ -784,7 +784,6 @@
|
||||
'scrolling' (integer) +
|
||||
'start_col' (integer) +
|
||||
'lines_after' (integer) +
|
||||
'reset_allowed' (integer) +
|
||||
'prev_scroll' (pointer, hdata: "window_scroll") +
|
||||
'next_scroll' (pointer, hdata: "window_scroll") |
|
||||
|
|
||||
|
||||
@@ -784,7 +784,6 @@
|
||||
'scrolling' (integer) +
|
||||
'start_col' (integer) +
|
||||
'lines_after' (integer) +
|
||||
'reset_allowed' (integer) +
|
||||
'prev_scroll' (pointer, hdata: "window_scroll") +
|
||||
'next_scroll' (pointer, hdata: "window_scroll") |
|
||||
|
|
||||
|
||||
@@ -784,7 +784,6 @@
|
||||
'scrolling' (integer) +
|
||||
'start_col' (integer) +
|
||||
'lines_after' (integer) +
|
||||
'reset_allowed' (integer) +
|
||||
'prev_scroll' (pointer, hdata: "window_scroll") +
|
||||
'next_scroll' (pointer, hdata: "window_scroll") |
|
||||
|
|
||||
|
||||
@@ -784,7 +784,6 @@
|
||||
'scrolling' (integer) +
|
||||
'start_col' (integer) +
|
||||
'lines_after' (integer) +
|
||||
'reset_allowed' (integer) +
|
||||
'prev_scroll' (pointer, hdata: "window_scroll") +
|
||||
'next_scroll' (pointer, hdata: "window_scroll") |
|
||||
|
|
||||
|
||||
+10
-1
@@ -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)"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
@@ -1494,6 +1487,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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user