--- rxvt-unicode/src/screen.C 2011/11/02 15:11:51 1.398 +++ rxvt-unicode/src/screen.C 2011/11/15 18:20:38 1.401 @@ -683,6 +683,17 @@ scr_blank_screen_mem (l, rstyle); } + // move and/or clear selection, if any + if (selection.op && current_screen == selection.screen + && selection.beg.row < row2) + { + 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 @@ -694,6 +705,29 @@ } 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. @@ -730,27 +764,6 @@ } } - // 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; } @@ -2697,10 +2710,7 @@ && ROWCOL_IS_BEFORE (selection.beg, pos) && ROWCOL_IS_AFTER (selection.end, pos)) || (check_more == 3 - && ROWCOL_IS_AFTER (selection.end, pos)) - || (check_more == 4 /* screen width change */ - && (selection.beg.row != selection.end.row - || selection.end.col > ncol))) + && ROWCOL_IS_AFTER (selection.end, pos))) CLEAR_ALL_SELECTION (); }