--- rxvt-unicode/src/screen.C 2011/11/02 10:53:12 1.396 +++ rxvt-unicode/src/screen.C 2011/11/02 15:11:51 1.398 @@ -683,16 +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; - - selection_check (0); - } - // finally move the view window, if desired if (option (Opt_scrollWithBuffer) && view_start != 0 @@ -704,29 +694,6 @@ } 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. @@ -763,6 +730,27 @@ } } + // 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; } @@ -2692,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)