diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-10-05 20:33:35 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-10-05 20:33:35 +0200 |
commit | 1fec7e8856e10f8f45a6de2f5eec0651b75429d6 (patch) | |
tree | 9e87b73f025d9d4693292a268a5786b9f8adcc2e /src/gui | |
parent | 236d22e364fe14c92b4407954332b3231b8a2b5f (diff) | |
download | weechat-1fec7e8856e10f8f45a6de2f5eec0651b75429d6.zip |
core: fix page scroll in bare display (closes #1830)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 7 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 50 |
2 files changed, 40 insertions, 17 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 5ad362bbc..e8e0a9105 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -1806,6 +1806,13 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, *line_pos = 0; } } + + /* special case for bare display */ + if (gui_window_bare_display && backward && (*line_pos > 0)) + { + *line = gui_line_get_next_displayed (*line); + *line_pos = 0; + } } /* diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 9bb2c63e5..6c27be299 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -1381,17 +1381,20 @@ void gui_window_page_up (struct t_gui_window *window) { char scroll[32]; - int num_lines; + int height, num_lines; if (!gui_init_ok) return; - num_lines = ((window->win_chat_height - 1) * + height = (gui_window_bare_display) ? + gui_term_lines : window->win_chat_height; + + num_lines = ((height - 1) * CONFIG_INTEGER(config_look_scroll_page_percent)) / 100; if (num_lines < 1) num_lines = 1; - else if (num_lines > window->win_chat_height - 1) - num_lines = window->win_chat_height - 1; + else if (num_lines > height - 1) + num_lines = height - 1; switch (window->buffer->type) { @@ -1402,7 +1405,7 @@ gui_window_page_up (struct t_gui_window *window) &window->scroll->start_line_pos, (window->scroll->start_line) ? (-1) * (num_lines) : - (-1) * (num_lines + window->win_chat_height - 1)); + (-1) * (num_lines + height - 1)); gui_buffer_ask_chat_refresh (window->buffer, 2); } break; @@ -1429,18 +1432,21 @@ void gui_window_page_down (struct t_gui_window *window) { struct t_gui_line *ptr_line; - int line_pos, num_lines; + int height, num_lines, line_pos; char scroll[32]; if (!gui_init_ok) return; - num_lines = ((window->win_chat_height - 1) * + height = (gui_window_bare_display) ? + gui_term_lines : window->win_chat_height; + + num_lines = ((height - 1) * CONFIG_INTEGER(config_look_scroll_page_percent)) / 100; if (num_lines < 1) num_lines = 1; - else if (num_lines > window->win_chat_height - 1) - num_lines = window->win_chat_height - 1; + else if (num_lines > height - 1) + num_lines = height - 1; switch (window->buffer->type) { @@ -1456,7 +1462,7 @@ gui_window_page_down (struct t_gui_window *window) ptr_line = window->scroll->start_line; line_pos = window->scroll->start_line_pos; gui_chat_calculate_line_diff (window, &ptr_line, &line_pos, - window->win_chat_height); + height); if (!ptr_line) { window->scroll->start_line = NULL; @@ -1484,11 +1490,15 @@ gui_window_page_down (struct t_gui_window *window) void gui_window_scroll_up (struct t_gui_window *window) { + int height; char scroll[32]; if (!gui_init_ok) return; + height = (gui_window_bare_display) ? + gui_term_lines : window->win_chat_height; + switch (window->buffer->type) { case GUI_BUFFER_TYPE_FORMATTED: @@ -1498,8 +1508,8 @@ gui_window_scroll_up (struct t_gui_window *window) &window->scroll->start_line_pos, (window->scroll->start_line) ? (-1) * CONFIG_INTEGER(config_look_scroll_amount) : - (-1) * ( (window->win_chat_height - 1) + - CONFIG_INTEGER(config_look_scroll_amount))); + (-1) * ((height - 1) + + CONFIG_INTEGER(config_look_scroll_amount))); gui_buffer_ask_chat_refresh (window->buffer, 2); } break; @@ -1526,12 +1536,15 @@ void gui_window_scroll_down (struct t_gui_window *window) { struct t_gui_line *ptr_line; - int line_pos; + int height, line_pos; char scroll[32]; if (!gui_init_ok) return; + height = (gui_window_bare_display) ? + gui_term_lines : window->win_chat_height; + switch (window->buffer->type) { case GUI_BUFFER_TYPE_FORMATTED: @@ -1546,7 +1559,7 @@ gui_window_scroll_down (struct t_gui_window *window) ptr_line = window->scroll->start_line; line_pos = window->scroll->start_line_pos; gui_chat_calculate_line_diff (window, &ptr_line, &line_pos, - window->win_chat_height); + height); if (!ptr_line) { @@ -1609,11 +1622,15 @@ gui_window_scroll_top (struct t_gui_window *window) void gui_window_scroll_bottom (struct t_gui_window *window) { + int height; char scroll[32]; if (!gui_init_ok) return; + height = (gui_window_bare_display) ? + gui_term_lines : window->win_chat_height; + switch (window->buffer->type) { case GUI_BUFFER_TYPE_FORMATTED: @@ -1623,10 +1640,9 @@ gui_window_scroll_bottom (struct t_gui_window *window) break; case GUI_BUFFER_TYPE_FREE: window->scroll->start_line = NULL; - if (window->buffer->lines->lines_count > window->win_chat_height) + if (window->buffer->lines->lines_count > height) { - snprintf (scroll, sizeof (scroll), "--%d", - window->win_chat_height - 1); + snprintf (scroll, sizeof (scroll), "--%d", height - 1); gui_window_scroll (window, scroll); } else |