--- rxvt-unicode/src/screen.C 2011/07/08 00:08:40 1.388 +++ 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)))) @@ -205,7 +203,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 +275,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); @@ -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; @@ -646,7 +645,7 @@ // sever bottommost line { - line_t &l = ROW(row2 - 1); + line_t &l = ROW(row2); l.is_longer (0); l.touch (); } @@ -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) { @@ -736,11 +731,19 @@ // 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 +755,13 @@ 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 (); + } } return count; @@ -767,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; @@ -2034,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 @@ -2050,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) @@ -2550,7 +2560,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,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 @@ -2700,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))) + && ROWCOL_IS_AFTER (selection.end, pos))) CLEAR_SELECTION (); + + if (!IN_RANGE_EXC (selection.mark.row, top_row, nrow)) + CLEAR_SELECTION_MARK (); } /* ------------------------------------------------------------------------- */