diff options
-rw-r--r-- | BUGS | 3 | ||||
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/gui/curses/gui-display.c | 277 | ||||
-rw-r--r-- | src/gui/gui-common.c | 12 | ||||
-rw-r--r-- | src/gui/gui.h | 17 | ||||
-rw-r--r-- | src/irc/irc-dcc.c | 4 | ||||
-rw-r--r-- | weechat/BUGS | 3 | ||||
-rw-r--r-- | weechat/ChangeLog | 4 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-display.c | 277 | ||||
-rw-r--r-- | weechat/src/gui/gui-common.c | 12 | ||||
-rw-r--r-- | weechat/src/gui/gui.h | 17 | ||||
-rw-r--r-- | weechat/src/irc/irc-dcc.c | 4 |
12 files changed, 442 insertions, 192 deletions
@@ -1,9 +1,8 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -WeeChat known bugs, 2005-09-14 +WeeChat known bugs, 2005-09-15 -- when scrolling back in history, if a new message is displayed, screen moves - color display problems when term has white background - ./configure does not check that Ruby libraries are installed - ./configure does not check that Gtk 2.0 libraries are installed @@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2005-09-14 +ChangeLog - 2005-09-15 Version 0.1.5 (under dev!): + * fixed scroll problem (screen moving when scrolling and new line + displayed) * fixed infinite loop when scrolling back and displaying long lines * fixed crash when closing a buffer used by more than one window * added some missing IRC commands diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index 5d75485c7..ef6a9d07e 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -594,9 +594,6 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat int word_length_with_spaces, word_length; int skip_spaces; - if (window->win_chat_cursor_y > window->win_chat_height - 1) - return 0; - if (simulate) { x = window->win_chat_cursor_x; @@ -607,6 +604,8 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat } else { + if (window->win_chat_cursor_y > window->win_chat_height - 1) + return 0; x = window->win_chat_cursor_x; y = window->win_chat_cursor_y; num_lines = gui_display_line (window, line, 0, 1); @@ -682,6 +681,105 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat } /* + * gui_calculate_line_diff: returns pointer to line & offset for a difference + * with given line + */ + +void +gui_calculate_line_diff (t_gui_window *window, t_gui_line **line, int *line_pos, + int difference) +{ + int backward, current_size; + + if (!line || !line_pos) + return; + + backward = (difference < 0); + + if (!(*line)) + { + /* if looking backward, start at last line of buffer */ + if (backward) + { + *line = window->buffer->last_line; + if (!(*line)) + return; + current_size = gui_display_line (window, *line, 0, 1); + if (current_size == 0) + current_size = 1; + *line_pos = current_size - 1; + } + /* if looking forward, start at first line of buffer */ + else + { + *line = window->buffer->lines; + if (!(*line)) + return; + *line_pos = 0; + current_size = gui_display_line (window, *line, 0, 1); + } + } + else + current_size = gui_display_line (window, *line, 0, 1); + + while ((*line) && (difference != 0)) + { + /* looking backward */ + if (backward) + { + if (*line_pos > 0) + (*line_pos)--; + else + { + *line = (*line)->prev_line; + if (*line) + { + current_size = gui_display_line (window, *line, 0, 1); + if (current_size == 0) + current_size = 1; + *line_pos = current_size - 1; + } + } + difference++; + } + /* looking forward */ + else + { + if (*line_pos < current_size - 1) + (*line_pos)++; + else + { + *line = (*line)->next_line; + if (*line) + { + current_size = gui_display_line (window, *line, 0, 1); + if (current_size == 0) + current_size = 1; + *line_pos = 0; + } + } + difference--; + } + } + + /* first or last line reached */ + if (!(*line)) + { + if (backward) + { + /* first line reached */ + *line = window->buffer->lines; + *line_pos = 0; + } + else + { + /* last line reached => consider we'll display all until the end */ + *line_pos = 0; + } + } +} + +/* * gui_draw_buffer_chat: draw chat window for a buffer */ @@ -692,7 +790,7 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) t_gui_line *ptr_line; t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc; char format_empty[32]; - int i, j, lines_used, num_bars; + int i, j, line_pos, count, num_bars; char *unit_name[] = { N_("bytes"), N_("Kb"), N_("Mb"), N_("Gb") }; char *unit_format[] = { "%.0Lf", "%.1Lf", "%.02Lf", "%.02Lf" }; long unit_divide[] = { 1, 1024, 1024*1024, 1024*1024,1024 }; @@ -835,48 +933,56 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) } else { - ptr_line = buffer->last_line; - lines_used = 0; ptr_win->win_chat_cursor_x = 0; ptr_win->win_chat_cursor_y = 0; - while (ptr_line - && (lines_used < (ptr_win->win_chat_height + ptr_win->sub_lines))) + + /* display at position of scrolling */ + if (ptr_win->start_line) + { + ptr_line = ptr_win->start_line; + line_pos = ptr_win->start_line_pos; + } + else { - lines_used += gui_display_line (ptr_win, ptr_line, 0, 1); - ptr_line = ptr_line->prev_line; + /* look for first line to display, sarting from last line */ + ptr_line = NULL; + line_pos = 0; + gui_calculate_line_diff (ptr_win, &ptr_line, &line_pos, + (-1) * (ptr_win->win_chat_height - 1)); } - if (lines_used > (ptr_win->win_chat_height + ptr_win->sub_lines)) + + if (line_pos > 0) { - /* screen will be full (we'll display only end of 1st line) */ - ptr_line = (ptr_line) ? ptr_line->next_line : buffer->lines; + /* display end of first line at top of screen */ gui_display_line (ptr_win, ptr_line, gui_display_line (ptr_win, ptr_line, 0, 1) - - (lines_used - (ptr_win->win_chat_height + ptr_win->sub_lines)), 0);; + line_pos, 0); ptr_line = ptr_line->next_line; ptr_win->first_line_displayed = 0; } else - { - /* all lines are displayed */ - if (!ptr_line) - { - ptr_win->first_line_displayed = 1; - ptr_line = buffer->lines; - } - else - { - ptr_win->first_line_displayed = 0; - ptr_line = ptr_line->next_line; - } - } + ptr_win->first_line_displayed = + (ptr_line == ptr_win->buffer->lines); /* display lines */ + count = 0; while (ptr_line && (ptr_win->win_chat_cursor_y <= ptr_win->win_chat_height - 1)) { - gui_display_line (ptr_win, ptr_line, 0, 0); + count = gui_display_line (ptr_win, ptr_line, 0, 0); ptr_line = ptr_line->next_line; } + /* check if last line of buffer is entirely displayed and scrolling */ + /* if so, disable scroll (to remove status bar indicator) */ + if (!ptr_line && ptr_win->start_line) + { + if (count == gui_display_line (ptr_win, ptr_win->buffer->last_line, 0, 1)) + { + ptr_win->start_line = NULL; + ptr_win->start_line_pos = 0; + } + } + /* cursor is below end line of chat window? */ if (ptr_win->win_chat_cursor_y > ptr_win->win_chat_height - 1) { @@ -1360,7 +1466,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) if (x < 0) x = 0; gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); - if (ptr_win->sub_lines > 0) + if (ptr_win->start_line) mvwprintw (ptr_win->win_status, 0, x, "%s", string); else { @@ -1762,7 +1868,8 @@ gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer) else window->win_status = newwin (1, window->win_width, window->win_y + window->win_height - 2, window->win_x); - window->sub_lines = 0; + window->start_line = NULL; + window->start_line_pos = 0; buffer->num_displayed++; @@ -1774,7 +1881,7 @@ gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer) */ t_gui_buffer * -gui_get_dcc_buffer () +gui_get_dcc_buffer (t_gui_window *window) { t_gui_buffer *ptr_buffer; @@ -1787,7 +1894,7 @@ gui_get_dcc_buffer () if (ptr_buffer) return ptr_buffer; else - return gui_buffer_new (gui_current_window, NULL, NULL, 1, 0); + return gui_buffer_new (window, NULL, NULL, 1, 0); } /* @@ -1795,17 +1902,20 @@ gui_get_dcc_buffer () */ void -gui_input_page_up () +gui_input_page_up (t_gui_window *window) { if (!gui_ok) return; - if (!gui_current_window->first_line_displayed) + if (!window->first_line_displayed) { - gui_current_window->sub_lines += - gui_current_window->win_chat_height - 1; - gui_draw_buffer_chat (gui_current_window->buffer, 0); - gui_draw_buffer_status (gui_current_window->buffer, 0); + gui_calculate_line_diff (window, &window->start_line, + &window->start_line_pos, + (window->start_line) ? + (-1) * (window->win_chat_height - 1) : + (-1) * ((window->win_chat_height - 1) * 2)); + gui_draw_buffer_chat (window->buffer, 0); + gui_draw_buffer_status (window->buffer, 0); } } @@ -1814,19 +1924,34 @@ gui_input_page_up () */ void -gui_input_page_down () +gui_input_page_down (t_gui_window *window) { + t_gui_line *ptr_line; + int line_pos; + if (!gui_ok) return; - if (gui_current_window->sub_lines > 0) + if (window->start_line) { - gui_current_window->sub_lines -= - gui_current_window->win_chat_height - 1; - if (gui_current_window->sub_lines < 0) - gui_current_window->sub_lines = 0; - gui_draw_buffer_chat (gui_current_window->buffer, 0); - gui_draw_buffer_status (gui_current_window->buffer, 0); + gui_calculate_line_diff (window, &window->start_line, + &window->start_line_pos, + window->win_chat_height - 1); + + /* check if we can display all */ + ptr_line = window->start_line; + line_pos = window->start_line_pos; + gui_calculate_line_diff (window, &ptr_line, + &line_pos, + window->win_chat_height - 1); + if (!ptr_line) + { + window->start_line = NULL; + window->start_line_pos = 0; + } + + gui_draw_buffer_chat (window->buffer, 0); + gui_draw_buffer_status (window->buffer, 0); } } @@ -1835,17 +1960,17 @@ gui_input_page_down () */ void -gui_input_nick_beginning () +gui_input_nick_beginning (t_gui_window *window) { if (!gui_ok) return; - if (gui_buffer_has_nicklist (gui_current_window->buffer)) + if (gui_buffer_has_nicklist (window->buffer)) { - if (gui_current_window->win_nick_start > 0) + if (window->win_nick_start > 0) { - gui_current_window->win_nick_start = 0; - gui_draw_buffer_nick (gui_current_window->buffer, 1); + window->win_nick_start = 0; + gui_draw_buffer_nick (window->buffer, 1); } } } @@ -1855,27 +1980,26 @@ gui_input_nick_beginning () */ void -gui_input_nick_end () +gui_input_nick_end (t_gui_window *window) { int new_start; if (!gui_ok) return; - if (gui_buffer_has_nicklist (gui_current_window->buffer)) + if (gui_buffer_has_nicklist (window->buffer)) { new_start = - CHANNEL(gui_current_window->buffer)->nicks_count - - gui_current_window->win_nick_height; + CHANNEL(window->buffer)->nicks_count - window->win_nick_height; if (new_start < 0) new_start = 0; else if (new_start >= 1) new_start++; - if (new_start != gui_current_window->win_nick_start) + if (new_start != window->win_nick_start) { - gui_current_window->win_nick_start = new_start; - gui_draw_buffer_nick (gui_current_window->buffer, 1); + window->win_nick_start = new_start; + gui_draw_buffer_nick (window->buffer, 1); } } } @@ -1885,20 +2009,19 @@ gui_input_nick_end () */ void -gui_input_nick_page_up () +gui_input_nick_page_up (t_gui_window *window) { if (!gui_ok) return; - if (gui_buffer_has_nicklist (gui_current_window->buffer)) + if (gui_buffer_has_nicklist (window->buffer)) { - if (gui_current_window->win_nick_start > 0) + if (window->win_nick_start > 0) { - gui_current_window->win_nick_start -= - (gui_current_window->win_nick_height - 1); - if (gui_current_window->win_nick_start <= 1) - gui_current_window->win_nick_start = 0; - gui_draw_buffer_nick (gui_current_window->buffer, 1); + window->win_nick_start -= (window->win_nick_height - 1); + if (window->win_nick_start <= 1) + window->win_nick_start = 0; + gui_draw_buffer_nick (window->buffer, 1); } } } @@ -1908,26 +2031,22 @@ gui_input_nick_page_up () */ void -gui_input_nick_page_down () +gui_input_nick_page_down (t_gui_window *window) { if (!gui_ok) return; - if (gui_buffer_has_nicklist (gui_current_window->buffer)) + if (gui_buffer_has_nicklist (window->buffer)) { - if ((CHANNEL(gui_current_window->buffer)->nicks_count > - gui_current_window->win_nick_height) - && (gui_current_window->win_nick_start + - gui_current_window->win_nick_height - 1 - < CHANNEL(gui_current_window->buffer)->nicks_count)) + if ((CHANNEL(window->buffer)->nicks_count > window->win_nick_height) + && (window->win_nick_start + window->win_nick_height - 1 + < CHANNEL(window->buffer)->nicks_count)) { - if (gui_current_window->win_nick_start == 0) - gui_current_window->win_nick_start += - (gui_current_window->win_nick_height - 1); + if (window->win_nick_start == 0) + window->win_nick_start += (window->win_nick_height - 1); else - gui_current_window->win_nick_start += - (gui_current_window->win_nick_height - 2); - gui_draw_buffer_nick (gui_current_window->buffer, 1); + window->win_nick_start += (window->win_nick_height - 2); + gui_draw_buffer_nick (window->buffer, 1); } } } diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index 814b6e0f1..b406053c8 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -115,7 +115,8 @@ gui_window_new (int x, int y, int width, int height) new_window->buffer = NULL; new_window->first_line_displayed = 0; - new_window->sub_lines = 0; + new_window->start_line = NULL; + new_window->start_line_pos = 0; /* add window to windows queue */ new_window->prev_window = last_gui_window; @@ -179,7 +180,8 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc, { window->buffer = new_buffer; window->first_line_displayed = 1; - window->sub_lines = 0; + window->start_line = NULL; + window->start_line_pos = 0; gui_calculate_pos_size (window); gui_window_init_subwindows (window); } @@ -284,7 +286,8 @@ gui_buffer_clear (t_gui_buffer *buffer) if (ptr_win->buffer == buffer) { ptr_win->first_line_displayed = 1; - ptr_win->sub_lines = 0; + ptr_win->start_line = NULL; + ptr_win->start_line_pos = 0; } } @@ -1867,7 +1870,8 @@ gui_window_print_log (t_gui_window *window) wee_log_printf (" dcc_last_displayed. : 0x%X\n", window->dcc_last_displayed); wee_log_printf (" buffer. . . . . . . : 0x%X\n", window->buffer); wee_log_printf (" first_line_displayed: %d\n", window->first_line_displayed); - wee_log_printf (" sub_lines . . . . . : %d\n", window->sub_lines); + wee_log_printf (" start_line. . . . . : 0x%X\n", window->start_line); + wee_log_printf (" start_line_pos. . . : %d\n", window->start_line_pos); wee_log_printf (" prev_window . . . . : 0x%X\n", window->prev_window); wee_log_printf (" next_window . . . . : 0x%X\n", window->next_window); diff --git a/src/gui/gui.h b/src/gui/gui.h index 5f1f2b6c8..43bbee0ab 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -260,7 +260,8 @@ struct t_gui_window t_gui_buffer *buffer; /* buffer currently displayed in window */ int first_line_displayed; /* = 1 if first line is displayed */ - int sub_lines; /* if > 0 then do not display until end */ + t_gui_line *start_line; /* pointer to line if scrolling */ + int start_line_pos; /* position in first line displayed */ t_gui_window *prev_window; /* link to previous window */ t_gui_window *next_window; /* link to next window */ @@ -391,13 +392,13 @@ extern void gui_draw_buffer_infobar (t_gui_buffer *, int); extern void gui_draw_buffer_input (t_gui_buffer *, int); extern void gui_redraw_buffer (t_gui_buffer *); extern void gui_switch_to_buffer (t_gui_window *, t_gui_buffer *); -extern t_gui_buffer *gui_get_dcc_buffer (); -extern void gui_input_page_up (); -extern void gui_input_page_down (); -extern void gui_input_nick_beginning (); -extern void gui_input_nick_end (); -extern void gui_input_nick_page_up (); -extern void gui_input_nick_page_down (); +extern t_gui_buffer *gui_get_dcc_buffer (t_gui_window *); +extern void gui_input_page_up (t_gui_window *); +extern void gui_input_page_down (t_gui_window *); +extern void gui_input_nick_beginning (t_gui_window *); +extern void gui_input_nick_end (t_gui_window *); +extern void gui_input_nick_page_up (t_gui_window *); +extern void gui_input_nick_page_down (t_gui_window *); extern void gui_curses_resize_handler (); extern void gui_window_init_subwindows (t_gui_window *); extern void gui_window_split_horiz (t_gui_window *); diff --git a/src/irc/irc-dcc.c b/src/irc/irc-dcc.c index 98252c4d6..443b97c22 100644 --- a/src/irc/irc-dcc.c +++ b/src/irc/irc-dcc.c @@ -57,10 +57,10 @@ char *dcc_status_string[] = /* strings for DCC status */ void dcc_redraw (int highlight) { - gui_redraw_buffer (gui_get_dcc_buffer ()); + gui_redraw_buffer (gui_get_dcc_buffer (gui_current_window)); if (highlight) { - hotlist_add (highlight, gui_get_dcc_buffer ()); + hotlist_add (highlight, gui_get_dcc_buffer (gui_current_window)); gui_draw_buffer_status (gui_current_window->buffer, 0); } } diff --git a/weechat/BUGS b/weechat/BUGS index b633ee8f3..98cb6d307 100644 --- a/weechat/BUGS +++ b/weechat/BUGS @@ -1,9 +1,8 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -WeeChat known bugs, 2005-09-14 +WeeChat known bugs, 2005-09-15 -- when scrolling back in history, if a new message is displayed, screen moves - color display problems when term has white background - ./configure does not check that Ruby libraries are installed - ./configure does not check that Gtk 2.0 libraries are installed diff --git a/weechat/ChangeLog b/weechat/ChangeLog index 1b75f5023..7cd643bc0 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2005-09-14 +ChangeLog - 2005-09-15 Version 0.1.5 (under dev!): + * fixed scroll problem (screen moving when scrolling and new line + displayed) * fixed infinite loop when scrolling back and displaying long lines * fixed crash when closing a buffer used by more than one window * added some missing IRC commands diff --git a/weechat/src/gui/curses/gui-display.c b/weechat/src/gui/curses/gui-display.c index 5d75485c7..ef6a9d07e 100644 --- a/weechat/src/gui/curses/gui-display.c +++ b/weechat/src/gui/curses/gui-display.c @@ -594,9 +594,6 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat int word_length_with_spaces, word_length; int skip_spaces; - if (window->win_chat_cursor_y > window->win_chat_height - 1) - return 0; - if (simulate) { x = window->win_chat_cursor_x; @@ -607,6 +604,8 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat } else { + if (window->win_chat_cursor_y > window->win_chat_height - 1) + return 0; x = window->win_chat_cursor_x; y = window->win_chat_cursor_y; num_lines = gui_display_line (window, line, 0, 1); @@ -682,6 +681,105 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat } /* + * gui_calculate_line_diff: returns pointer to line & offset for a difference + * with given line + */ + +void +gui_calculate_line_diff (t_gui_window *window, t_gui_line **line, int *line_pos, + int difference) +{ + int backward, current_size; + + if (!line || !line_pos) + return; + + backward = (difference < 0); + + if (!(*line)) + { + /* if looking backward, start at last line of buffer */ + if (backward) + { + *line = window->buffer->last_line; + if (!(*line)) + return; + current_size = gui_display_line (window, *line, 0, 1); + if (current_size == 0) + current_size = 1; + *line_pos = current_size - 1; + } + /* if looking forward, start at first line of buffer */ + else + { + *line = window->buffer->lines; + if (!(*line)) + return; + *line_pos = 0; + current_size = gui_display_line (window, *line, 0, 1); + } + } + else + current_size = gui_display_line (window, *line, 0, 1); + + while ((*line) && (difference != 0)) + { + /* looking backward */ + if (backward) + { + if (*line_pos > 0) + (*line_pos)--; + else + { + *line = (*line)->prev_line; + if (*line) + { + current_size = gui_display_line (window, *line, 0, 1); + if (current_size == 0) + current_size = 1; + *line_pos = current_size - 1; + } + } + difference++; + } + /* looking forward */ + else + { + if (*line_pos < current_size - 1) + (*line_pos)++; + else + { + *line = (*line)->next_line; + if (*line) + { + current_size = gui_display_line (window, *line, 0, 1); + if (current_size == 0) + current_size = 1; + *line_pos = 0; + } + } + difference--; + } + } + + /* first or last line reached */ + if (!(*line)) + { + if (backward) + { + /* first line reached */ + *line = window->buffer->lines; + *line_pos = 0; + } + else + { + /* last line reached => consider we'll display all until the end */ + *line_pos = 0; + } + } +} + +/* * gui_draw_buffer_chat: draw chat window for a buffer */ @@ -692,7 +790,7 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) t_gui_line *ptr_line; t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc; char format_empty[32]; - int i, j, lines_used, num_bars; + int i, j, line_pos, count, num_bars; char *unit_name[] = { N_("bytes"), N_("Kb"), N_("Mb"), N_("Gb") }; char *unit_format[] = { "%.0Lf", "%.1Lf", "%.02Lf", "%.02Lf" }; long unit_divide[] = { 1, 1024, 1024*1024, 1024*1024,1024 }; @@ -835,48 +933,56 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) } else { - ptr_line = buffer->last_line; - lines_used = 0; ptr_win->win_chat_cursor_x = 0; ptr_win->win_chat_cursor_y = 0; - while (ptr_line - && (lines_used < (ptr_win->win_chat_height + ptr_win->sub_lines))) + + /* display at position of scrolling */ + if (ptr_win->start_line) + { + ptr_line = ptr_win->start_line; + line_pos = ptr_win->start_line_pos; + } + else { - lines_used += gui_display_line (ptr_win, ptr_line, 0, 1); - ptr_line = ptr_line->prev_line; + /* look for first line to display, sarting from last line */ + ptr_line = NULL; + line_pos = 0; + gui_calculate_line_diff (ptr_win, &ptr_line, &line_pos, + (-1) * (ptr_win->win_chat_height - 1)); } - if (lines_used > (ptr_win->win_chat_height + ptr_win->sub_lines)) + + if (line_pos > 0) { - /* screen will be full (we'll display only end of 1st line) */ - ptr_line = (ptr_line) ? ptr_line->next_line : buffer->lines; + /* display end of first line at top of screen */ gui_display_line (ptr_win, ptr_line, gui_display_line (ptr_win, ptr_line, 0, 1) - - (lines_used - (ptr_win->win_chat_height + ptr_win->sub_lines)), 0);; + line_pos, 0); ptr_line = ptr_line->next_line; ptr_win->first_line_displayed = 0; } else - { - /* all lines are displayed */ - if (!ptr_line) - { - ptr_win->first_line_displayed = 1; - ptr_line = buffer->lines; - } - else - { - ptr_win->first_line_displayed = 0; - ptr_line = ptr_line->next_line; - } - } + ptr_win->first_line_displayed = + (ptr_line == ptr_win->buffer->lines); /* display lines */ + count = 0; while (ptr_line && (ptr_win->win_chat_cursor_y <= ptr_win->win_chat_height - 1)) { - gui_display_line (ptr_win, ptr_line, 0, 0); + count = gui_display_line (ptr_win, ptr_line, 0, 0); ptr_line = ptr_line->next_line; } + /* check if last line of buffer is entirely displayed and scrolling */ + /* if so, disable scroll (to remove status bar indicator) */ + if (!ptr_line && ptr_win->start_line) + { + if (count == gui_display_line (ptr_win, ptr_win->buffer->last_line, 0, 1)) + { + ptr_win->start_line = NULL; + ptr_win->start_line_pos = 0; + } + } + /* cursor is below end line of chat window? */ if (ptr_win->win_chat_cursor_y > ptr_win->win_chat_height - 1) { @@ -1360,7 +1466,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) if (x < 0) x = 0; gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); - if (ptr_win->sub_lines > 0) + if (ptr_win->start_line) mvwprintw (ptr_win->win_status, 0, x, "%s", string); else { @@ -1762,7 +1868,8 @@ gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer) else window->win_status = newwin (1, window->win_width, window->win_y + window->win_height - 2, window->win_x); - window->sub_lines = 0; + window->start_line = NULL; + window->start_line_pos = 0; buffer->num_displayed++; @@ -1774,7 +1881,7 @@ gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer) */ t_gui_buffer * -gui_get_dcc_buffer () +gui_get_dcc_buffer (t_gui_window *window) { t_gui_buffer *ptr_buffer; @@ -1787,7 +1894,7 @@ gui_get_dcc_buffer () if (ptr_buffer) return ptr_buffer; else - return gui_buffer_new (gui_current_window, NULL, NULL, 1, 0); + return gui_buffer_new (window, NULL, NULL, 1, 0); } /* @@ -1795,17 +1902,20 @@ gui_get_dcc_buffer () */ void -gui_input_page_up () +gui_input_page_up (t_gui_window *window) { if (!gui_ok) return; - if (!gui_current_window->first_line_displayed) + if (!window->first_line_displayed) { - gui_current_window->sub_lines += - gui_current_window->win_chat_height - 1; - gui_draw_buffer_chat (gui_current_window->buffer, 0); - gui_draw_buffer_status (gui_current_window->buffer, 0); + gui_calculate_line_diff (window, &window->start_line, + &window->start_line_pos, + (window->start_line) ? + (-1) * (window->win_chat_height - 1) : + (-1) * ((window->win_chat_height - 1) * 2)); + gui_draw_buffer_chat (window->buffer, 0); + gui_draw_buffer_status (window->buffer, 0); } } @@ -1814,19 +1924,34 @@ gui_input_page_up () */ void -gui_input_page_down () +gui_input_page_down (t_gui_window *window) { + t_gui_line *ptr_line; + int line_pos; + if (!gui_ok) return; - if (gui_current_window->sub_lines > 0) + if (window->start_line) { - gui_current_window->sub_lines -= - gui_current_window->win_chat_height - 1; - if (gui_current_window->sub_lines < 0) - gui_current_window->sub_lines = 0; - gui_draw_buffer_chat (gui_current_window->buffer, 0); - gui_draw_buffer_status (gui_current_window->buffer, 0); + gui_calculate_line_diff (window, &window->start_line, + &window->start_line_pos, + window->win_chat_height - 1); + + /* check if we can display all */ + ptr_line = window->start_line; + line_pos = window->start_line_pos; + gui_calculate_line_diff (window, &ptr_line, + &line_pos, + window->win_chat_height - 1); + if (!ptr_line) + { + window->start_line = NULL; + window->start_line_pos = 0; + } + + gui_draw_buffer_chat (window->buffer, 0); + gui_draw_buffer_status (window->buffer, 0); } } @@ -1835,17 +1960,17 @@ gui_input_page_down () */ void -gui_input_nick_beginning () +gui_input_nick_beginning (t_gui_window *window) { if (!gui_ok) return; - if (gui_buffer_has_nicklist (gui_current_window->buffer)) + if (gui_buffer_has_nicklist (window->buffer)) { - if (gui_current_window->win_nick_start > 0) + if (window->win_nick_start > 0) { - gui_current_window->win_nick_start = 0; - gui_draw_buffer_nick (gui_current_window->buffer, 1); + window->win_nick_start = 0; + gui_draw_buffer_nick (window->buffer, 1); } } } @@ -1855,27 +1980,26 @@ gui_input_nick_beginning () */ void -gui_input_nick_end () +gui_input_nick_end (t_gui_window *window) { int new_start; if (!gui_ok) return; - if (gui_buffer_has_nicklist (gui_current_window->buffer)) + if (gui_buffer_has_nicklist (window->buffer)) { new_start = - CHANNEL(gui_current_window->buffer)->nicks_count - - gui_current_window->win_nick_height; + CHANNEL(window->buffer)->nicks_count - window->win_nick_height; if (new_start < 0) new_start = 0; else if (new_start >= 1) new_start++; - if (new_start != gui_current_window->win_nick_start) + if (new_start != window->win_nick_start) { - gui_current_window->win_nick_start = new_start; - gui_draw_buffer_nick (gui_current_window->buffer, 1); + window->win_nick_start = new_start; + gui_draw_buffer_nick (window->buffer, 1); } } } @@ -1885,20 +2009,19 @@ gui_input_nick_end () */ void -gui_input_nick_page_up () +gui_input_nick_page_up (t_gui_window *window) { if (!gui_ok) return; - if (gui_buffer_has_nicklist (gui_current_window->buffer)) + if (gui_buffer_has_nicklist (window->buffer)) { - if (gui_current_window->win_nick_start > 0) + if (window->win_nick_start > 0) { - gui_current_window->win_nick_start -= - (gui_current_window->win_nick_height - 1); - if (gui_current_window->win_nick_start <= 1) - gui_current_window->win_nick_start = 0; - gui_draw_buffer_nick (gui_current_window->buffer, 1); + window->win_nick_start -= (window->win_nick_height - 1); + if (window->win_nick_start <= 1) + window->win_nick_start = 0; + gui_draw_buffer_nick (window->buffer, 1); } } } @@ -1908,26 +2031,22 @@ gui_input_nick_page_up () */ void -gui_input_nick_page_down () +gui_input_nick_page_down (t_gui_window *window) { if (!gui_ok) return; - if (gui_buffer_has_nicklist (gui_current_window->buffer)) + if (gui_buffer_has_nicklist (window->buffer)) { - if ((CHANNEL(gui_current_window->buffer)->nicks_count > - gui_current_window->win_nick_height) - && (gui_current_window->win_nick_start + - gui_current_window->win_nick_height - 1 - < CHANNEL(gui_current_window->buffer)->nicks_count)) + if ((CHANNEL(window->buffer)->nicks_count > window->win_nick_height) + && (window->win_nick_start + window->win_nick_height - 1 + < CHANNEL(window->buffer)->nicks_count)) { - if (gui_current_window->win_nick_start == 0) - gui_current_window->win_nick_start += - (gui_current_window->win_nick_height - 1); + if (window->win_nick_start == 0) + window->win_nick_start += (window->win_nick_height - 1); else - gui_current_window->win_nick_start += - (gui_current_window->win_nick_height - 2); - gui_draw_buffer_nick (gui_current_window->buffer, 1); + window->win_nick_start += (window->win_nick_height - 2); + gui_draw_buffer_nick (window->buffer, 1); } } } diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c index 814b6e0f1..b406053c8 100644 --- a/weechat/src/gui/gui-common.c +++ b/weechat/src/gui/gui-common.c @@ -115,7 +115,8 @@ gui_window_new (int x, int y, int width, int height) new_window->buffer = NULL; new_window->first_line_displayed = 0; - new_window->sub_lines = 0; + new_window->start_line = NULL; + new_window->start_line_pos = 0; /* add window to windows queue */ new_window->prev_window = last_gui_window; @@ -179,7 +180,8 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc, { window->buffer = new_buffer; window->first_line_displayed = 1; - window->sub_lines = 0; + window->start_line = NULL; + window->start_line_pos = 0; gui_calculate_pos_size (window); gui_window_init_subwindows (window); } @@ -284,7 +286,8 @@ gui_buffer_clear (t_gui_buffer *buffer) if (ptr_win->buffer == buffer) { ptr_win->first_line_displayed = 1; - ptr_win->sub_lines = 0; + ptr_win->start_line = NULL; + ptr_win->start_line_pos = 0; } } @@ -1867,7 +1870,8 @@ gui_window_print_log (t_gui_window *window) wee_log_printf (" dcc_last_displayed. : 0x%X\n", window->dcc_last_displayed); wee_log_printf (" buffer. . . . . . . : 0x%X\n", window->buffer); wee_log_printf (" first_line_displayed: %d\n", window->first_line_displayed); - wee_log_printf (" sub_lines . . . . . : %d\n", window->sub_lines); + wee_log_printf (" start_line. . . . . : 0x%X\n", window->start_line); + wee_log_printf (" start_line_pos. . . : %d\n", window->start_line_pos); wee_log_printf (" prev_window . . . . : 0x%X\n", window->prev_window); wee_log_printf (" next_window . . . . : 0x%X\n", window->next_window); diff --git a/weechat/src/gui/gui.h b/weechat/src/gui/gui.h index 5f1f2b6c8..43bbee0ab 100644 --- a/weechat/src/gui/gui.h +++ b/weechat/src/gui/gui.h @@ -260,7 +260,8 @@ struct t_gui_window t_gui_buffer *buffer; /* buffer currently displayed in window */ int first_line_displayed; /* = 1 if first line is displayed */ - int sub_lines; /* if > 0 then do not display until end */ + t_gui_line *start_line; /* pointer to line if scrolling */ + int start_line_pos; /* position in first line displayed */ t_gui_window *prev_window; /* link to previous window */ t_gui_window *next_window; /* link to next window */ @@ -391,13 +392,13 @@ extern void gui_draw_buffer_infobar (t_gui_buffer *, int); extern void gui_draw_buffer_input (t_gui_buffer *, int); extern void gui_redraw_buffer (t_gui_buffer *); extern void gui_switch_to_buffer (t_gui_window *, t_gui_buffer *); -extern t_gui_buffer *gui_get_dcc_buffer (); -extern void gui_input_page_up (); -extern void gui_input_page_down (); -extern void gui_input_nick_beginning (); -extern void gui_input_nick_end (); -extern void gui_input_nick_page_up (); -extern void gui_input_nick_page_down (); +extern t_gui_buffer *gui_get_dcc_buffer (t_gui_window *); +extern void gui_input_page_up (t_gui_window *); +extern void gui_input_page_down (t_gui_window *); +extern void gui_input_nick_beginning (t_gui_window *); +extern void gui_input_nick_end (t_gui_window *); +extern void gui_input_nick_page_up (t_gui_window *); +extern void gui_input_nick_page_down (t_gui_window *); extern void gui_curses_resize_handler (); extern void gui_window_init_subwindows (t_gui_window *); extern void gui_window_split_horiz (t_gui_window *); diff --git a/weechat/src/irc/irc-dcc.c b/weechat/src/irc/irc-dcc.c index 98252c4d6..443b97c22 100644 --- a/weechat/src/irc/irc-dcc.c +++ b/weechat/src/irc/irc-dcc.c @@ -57,10 +57,10 @@ char *dcc_status_string[] = /* strings for DCC status */ void dcc_redraw (int highlight) { - gui_redraw_buffer (gui_get_dcc_buffer ()); + gui_redraw_buffer (gui_get_dcc_buffer (gui_current_window)); if (highlight) { - hotlist_add (highlight, gui_get_dcc_buffer ()); + hotlist_add (highlight, gui_get_dcc_buffer (gui_current_window)); gui_draw_buffer_status (gui_current_window->buffer, 0); } } |