--- rxvt-unicode/src/screen.C 2011/07/08 00:08:40 1.388 +++ rxvt-unicode/src/screen.C 2011/11/02 15:11:51 1.398 @@ -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); @@ -646,7 +646,7 @@ // sever bottommost line { - line_t &l = ROW(row2 - 1); + line_t &l = ROW(row2); l.is_longer (0); l.touch (); } @@ -683,22 +683,6 @@ scr_blank_screen_mem (l, rstyle); } - // move and/or clear selection, if any - if (selection.op && current_screen == selection.screen) - { - selection.beg.row -= count; - selection.end.row -= count; - selection.mark.row -= count; - - if (selection.beg.row < top_row - || selection.end.row < top_row - || selection.mark.row < top_row) - { - CLEAR_ALL_SELECTION (); - selection.op = SELECTION_CLEAR; - } - } - // finally move the view window, if desired if (option (Opt_scrollWithBuffer) && view_start != 0 @@ -710,37 +694,22 @@ } else { - if (selection.op && current_screen == selection.screen) - { - if ((selection.beg.row < row1 && selection.end.row > row1) - || (selection.beg.row < row2 && selection.end.row > row2) - || (selection.beg.row - count < row1 && selection.beg.row >= row1) - || (selection.beg.row - count > row2 && selection.beg.row <= row2) - || (selection.end.row - count < row1 && selection.end.row >= row1) - || (selection.end.row - count > row2 && selection.end.row <= row2)) - { - CLEAR_ALL_SELECTION (); - selection.op = SELECTION_CLEAR; - } - else if (selection.end.row >= row1 && selection.end.row <= row2) - { - /* move selected region too */ - selection.beg.row -= count; - selection.end.row -= count; - selection.mark.row -= count; - - selection_check (0); - } - } - // 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++) { @@ -752,6 +721,34 @@ 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 (); + } + } + + // move and/or clear selection, if any + if (selection.op && current_screen == selection.screen) + { + if ((selection.beg.row < row1 && selection.end.row > row1) + || (selection.beg.row < row2 && selection.end.row > row2) + || (selection.beg.row - count < row1 && selection.beg.row >= row1) + || (selection.beg.row - count > row2 && selection.beg.row <= row2) + || (selection.end.row - count < row1 && selection.end.row >= row1) + || (selection.end.row - count > row2 && selection.end.row <= row2)) + CLEAR_ALL_SELECTION (); + else if (selection.end.row >= row1 && selection.end.row <= row2) + { + /* move selected region too */ + selection.beg.row -= count; + selection.end.row -= count; + selection.mark.row -= count; + + selection_check (0); + } } return count; @@ -2550,7 +2547,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); } @@ -2683,12 +2680,12 @@ void rxvt_term::selection_check (int check_more) NOTHROW { - row_col_t pos; - if (!selection.op) return; + row_col_t pos; pos.row = pos.col = 0; + if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) || !IN_RANGE_EXC (selection.mark.row, top_row, nrow) || !IN_RANGE_EXC (selection.end.row, top_row, nrow) @@ -2704,7 +2701,7 @@ || (check_more == 4 /* screen width change */ && (selection.beg.row != selection.end.row || selection.end.col > ncol))) - CLEAR_SELECTION (); + CLEAR_ALL_SELECTION (); } /* ------------------------------------------------------------------------- */