--- rxvt-unicode/src/screen.C 2011/11/03 10:42:17 1.399 +++ rxvt-unicode/src/screen.C 2011/11/17 10:43:16 1.408 @@ -551,7 +551,12 @@ want_refresh = 1; view_start = 0; - selection_check (2); /* check for boundary cross */ + /* check for boundary cross */ + row_col_t pos; + pos.row = pos.col = 0; + if (ROWCOL_IS_BEFORE (selection.beg, pos) + && ROWCOL_IS_AFTER (selection.end, pos)) + CLEAR_SELECTION (); current_screen = scrn; @@ -683,6 +688,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 +710,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 +769,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; } @@ -764,7 +782,7 @@ if (len <= 0) /* sanity */ return; - unsigned char checksel; + bool checksel; unicode_t c; int ncol = this->ncol; const wchar_t *strend = str + len; @@ -1296,7 +1314,7 @@ /* ------------------------------------------------------------------------- */ /* - * Erase part of whole of the screen + * Erase part or whole of the screen * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J * XTERM_SEQ: Clear whole screen : ESC [ 2 J @@ -1315,19 +1333,16 @@ switch (mode) { case 0: /* erase to end of screen */ - selection_check (1); scr_erase_line (0); row = screen.cur.row + 1; /* possible OOB */ num = nrow - row; break; case 1: /* erase to beginning of screen */ - selection_check (3); scr_erase_line (1); row = 0; num = screen.cur.row; break; case 2: /* erase whole screen */ - selection_check (3); row = 0; num = nrow; break; @@ -1408,7 +1423,11 @@ ZERO_SCROLLBACK (); num_scr_allow = 0; - selection_check (3); + + row_col_t pos; + pos.row = pos.col = 0; + if (ROWCOL_IS_AFTER (selection.end, pos)) + CLEAR_SELECTION (); fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); for (int row = nrow; row--; ) @@ -2031,7 +2050,7 @@ refresh_count = 0; unsigned int old_screen_flags = screen.flags; - char have_bg = 0; + bool have_bg = 0; #ifdef HAVE_BG_PIXMAP have_bg = bg_pixmap != None; #endif @@ -2047,13 +2066,13 @@ scr_swap_overlay (); #endif - char showcursor = screen.flags & Screen_VisibleCursor; + bool showcursor = screen.flags & Screen_VisibleCursor; /* * C: set the cursor character (s) */ { - unsigned char setoldcursor; + bool setoldcursor; #ifdef CURSOR_BLINK if (hidden_cursor) @@ -2683,21 +2702,13 @@ 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) || (check_more == 1 && current_screen == selection.screen && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) - && ROWCOL_IS_BEFORE (screen.cur, selection.end)) - || (check_more == 2 - && ROWCOL_IS_BEFORE (selection.beg, pos) - && ROWCOL_IS_AFTER (selection.end, pos)) - || (check_more == 3 - && ROWCOL_IS_AFTER (selection.end, pos))) + && ROWCOL_IS_BEFORE (screen.cur, selection.end))) CLEAR_ALL_SELECTION (); }