--- rxvt-unicode/src/screen.C 2011/11/01 00:04:46 1.395 +++ rxvt-unicode/src/screen.C 2011/11/15 20:07:10 1.404 @@ -51,10 +51,8 @@ #define CLEAR_SELECTION() \ selection.beg.row = selection.beg.col \ = selection.end.row = selection.end.col = 0 -#define CLEAR_ALL_SELECTION() \ - selection.beg.row = selection.beg.col \ - = selection.mark.row = selection.mark.col \ - = selection.end.row = selection.end.col = 0 +#define CLEAR_SELECTION_MARK() \ + selection.mark.row = selection.mark.col = 0 #define ROW_AND_COL_IS_AFTER(A, B, C, D) \ (((A) > (C)) || (((A) == (C)) && ((B) > (D)))) @@ -407,7 +405,8 @@ for (int col = ncol; col--; ) tabs [col] = col % TABSIZE == 0; - CLEAR_ALL_SELECTION (); + CLEAR_SELECTION (); + CLEAR_SELECTION_MARK (); prev_nrow = nrow; prev_ncol = ncol; @@ -684,19 +683,14 @@ } // move and/or clear selection, if any - if (selection.op && current_screen == selection.screen) + if (selection.op && current_screen == selection.screen + && selection.beg.row <= row2) { 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; - } + selection_check (0); } // finally move the view window, if desired @@ -719,8 +713,9 @@ || (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; + CLEAR_SELECTION (); + if (!IN_RANGE_EXC (selection.mark.row, top_row, nrow)) + CLEAR_SELECTION_MARK (); } else if (selection.end.row >= row1 && selection.end.row <= row2) { @@ -782,7 +777,7 @@ if (len <= 0) /* sanity */ return; - unsigned char checksel; + bool checksel; unicode_t c; int ncol = this->ncol; const wchar_t *strend = str + len; @@ -2049,7 +2044,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 @@ -2065,13 +2060,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) @@ -2698,14 +2693,13 @@ 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) || (check_more == 1 && current_screen == selection.screen @@ -2715,11 +2709,11 @@ && 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))) - CLEAR_ALL_SELECTION (); + && ROWCOL_IS_AFTER (selection.end, pos))) + CLEAR_SELECTION (); + + if (!IN_RANGE_EXC (selection.mark.row, top_row, nrow)) + CLEAR_SELECTION_MARK (); } /* ------------------------------------------------------------------------- */