--- rxvt-unicode/src/screen.C 2011/05/30 18:39:04 1.384 +++ rxvt-unicode/src/screen.C 2011/11/01 00:04:46 1.395 @@ -205,7 +205,7 @@ talloc = new rxvt_salloc (ncol * sizeof (text_t)); ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); - row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); + row_buf = (line_t *)rxvt_calloc (total_rows , sizeof (line_t)); drawn_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); swap_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); @@ -277,7 +277,7 @@ } line_t *old_buf = row_buf; - row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); + row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row int pend = MOD (term_start + top_row , prev_total_rows); @@ -640,24 +640,38 @@ && row1 == 0 && (current_screen == PRIMARY || option (Opt_secondaryScroll))) { - top_row = max (top_row - count, -saveLines); + min_it (count, total_rows - (nrow - (row2 + 1))); - // scroll everything up 'count' lines - term_start = (term_start + count) % total_rows; + top_row = max (top_row - count, -saveLines); // sever bottommost line { - line_t &l = ROW(row2 - count); + line_t &l = ROW(row2); l.is_longer (0); l.touch (); } + // scroll everything up 'count' lines + term_start = (term_start + count) % total_rows; + + // now copy lines below the scroll region bottom to the + // bottom of the screen again, so they look as if they + // hadn't moved. + for (int i = nrow; --i > row2; ) + { + line_t &l1 = ROW(i - count); + line_t &l2 = ROW(i); + + ::swap (l1, l2); + l2.touch (); + } + // erase newly scrolled-in lines for (int i = count; i--; ) { - line_t &l = ROW(nrow - 1 - i); + line_t &l = ROW(row2 - i); - // optimize if already cleared, can be significant on slow machines + // optimise if already cleared, can be significant on slow machines // could be rolled into scr_blank_screen_mem if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask))) { @@ -669,18 +683,6 @@ scr_blank_screen_mem (l, rstyle); } - // now copy lines below the scroll region bottom to the - // bottom of the screen again, so they look as if they - // hadn't moved. - for (int i = nrow; --i > row2; ) - { - line_t &l1 = ROW(i - count); - line_t &l2 = ROW(i); - - ::swap (l1, l2); - l2.touch (); - } - // move and/or clear selection, if any if (selection.op && current_screen == selection.screen) { @@ -734,11 +736,19 @@ // use a simple and robust scrolling algorithm, this // part of scr_scroll_text is not time-critical. + // sever line above scroll region + if (row1) + { + line_t &l = ROW(row1 - 1); + l.is_longer (0); + l.touch (); + } + int rows = row2 - row1 + 1; min_it (count, rows); - line_t *temp_buf = row_buf + total_rows; + line_t *temp_buf = rxvt_temp_buf (rows); for (int row = 0; row < rows; row++) { @@ -750,6 +760,13 @@ for (int row = 0; row < rows; row++) ROW(row1 + row) = temp_buf [row]; + + // sever bottommost line + { + line_t &l = ROW(row2); + l.is_longer (0); + l.touch (); + } } return count; @@ -2548,7 +2565,7 @@ XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); else XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); - scrollBar.state = STATE_IDLE; + scrollBar.state = SB_STATE_IDLE; scrollBar.show (0); } @@ -2702,7 +2719,7 @@ || (check_more == 4 /* screen width change */ && (selection.beg.row != selection.end.row || selection.end.col > ncol))) - CLEAR_SELECTION (); + CLEAR_ALL_SELECTION (); } /* ------------------------------------------------------------------------- */