diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-07-20 11:54:52 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-07-20 11:54:52 +0200 |
commit | 765297c038ec20668210eea69aa327e7aad60a34 (patch) | |
tree | 88af7e49adf45a9b864b0f598dc6df453be17081 | |
parent | 94b9104d14c1aee0e95ce1f9a69f7da01bf5e0d6 (diff) | |
parent | 27882ee74e7f77e143ae0df2656ae3b845aff5cd (diff) | |
download | weechat-765297c038ec20668210eea69aa327e7aad60a34.zip |
Merge branch 'scroll-beyond-end'
-rw-r--r-- | doc/de/autogen/plugin_api/hdata.txt | 1 | ||||
-rw-r--r-- | doc/en/autogen/plugin_api/hdata.txt | 1 | ||||
-rw-r--r-- | doc/fr/autogen/plugin_api/hdata.txt | 1 | ||||
-rw-r--r-- | doc/it/autogen/plugin_api/hdata.txt | 1 | ||||
-rw-r--r-- | doc/ja/autogen/plugin_api/hdata.txt | 1 | ||||
-rw-r--r-- | src/core/wee-command.c | 11 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 61 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 26 | ||||
-rw-r--r-- | src/gui/gui-input.c | 18 | ||||
-rw-r--r-- | src/gui/gui-window.c | 6 | ||||
-rw-r--r-- | src/gui/gui-window.h | 3 |
11 files changed, 92 insertions, 38 deletions
diff --git a/doc/de/autogen/plugin_api/hdata.txt b/doc/de/autogen/plugin_api/hdata.txt index 39c4a0648..b7f42f7d1 100644 --- a/doc/de/autogen/plugin_api/hdata.txt +++ b/doc/de/autogen/plugin_api/hdata.txt @@ -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") | | diff --git a/doc/en/autogen/plugin_api/hdata.txt b/doc/en/autogen/plugin_api/hdata.txt index 60fafc2cc..6ecf890b6 100644 --- a/doc/en/autogen/plugin_api/hdata.txt +++ b/doc/en/autogen/plugin_api/hdata.txt @@ -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") | | diff --git a/doc/fr/autogen/plugin_api/hdata.txt b/doc/fr/autogen/plugin_api/hdata.txt index d41ea5d63..2485567b3 100644 --- a/doc/fr/autogen/plugin_api/hdata.txt +++ b/doc/fr/autogen/plugin_api/hdata.txt @@ -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") | | diff --git a/doc/it/autogen/plugin_api/hdata.txt b/doc/it/autogen/plugin_api/hdata.txt index fb7da3bed..31bc627ea 100644 --- a/doc/it/autogen/plugin_api/hdata.txt +++ b/doc/it/autogen/plugin_api/hdata.txt @@ -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") | | diff --git a/doc/ja/autogen/plugin_api/hdata.txt b/doc/ja/autogen/plugin_api/hdata.txt index fc4c2bc84..3e984b9e1 100644 --- a/doc/ja/autogen/plugin_api/hdata.txt +++ b/doc/ja/autogen/plugin_api/hdata.txt @@ -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") | | 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..aa75ac4c1 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 = gui_line_get_next_displayed (ptr_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 = gui_line_get_next_displayed (ptr_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..920e18324 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,25 @@ 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; + + if (window->buffer->lines->last_line) + { + 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-input.c b/src/gui/gui-input.c index 73158b737..831482134 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -1261,7 +1261,9 @@ void gui_input_jump_smart (struct t_gui_buffer *buffer) { struct t_gui_window *window; + int scroll_to_bottom; + scroll_to_bottom = 0; window = gui_window_search_with_buffer (buffer); if (window && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) @@ -1272,7 +1274,7 @@ gui_input_jump_smart (struct t_gui_buffer *buffer) gui_hotlist_initial_buffer = window->buffer; gui_window_switch_to_buffer (window, gui_hotlist->buffer, 1); gui_hotlist_remove_buffer (window->buffer); - gui_window_scroll_bottom (window); + scroll_to_bottom = 1; } else { @@ -1282,7 +1284,7 @@ gui_input_jump_smart (struct t_gui_buffer *buffer) { gui_window_switch_to_buffer (window, gui_hotlist_initial_buffer, 1); - gui_window_scroll_bottom (window); + scroll_to_bottom = 1; } gui_hotlist_initial_buffer = NULL; } @@ -1291,6 +1293,18 @@ gui_input_jump_smart (struct t_gui_buffer *buffer) gui_hotlist_initial_buffer = NULL; } } + + /* + * scroll to bottom if window was scrolled (except if scrolled + * beyond the end) + */ + if (scroll_to_bottom + && window->scroll + && window->scroll->start_line + && (window->scroll->start_line_pos >= 0)) + { + gui_window_scroll_bottom (window); + } } } 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, |