--- rxvt-unicode/src/screen.C 2006/01/15 06:02:41 1.228 +++ rxvt-unicode/src/screen.C 2006/01/19 23:15:21 1.243 @@ -117,7 +117,7 @@ /* Fill part/all of a line with blanks. */ void -rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) +rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const { if (!l.t) { @@ -144,7 +144,7 @@ /* ------------------------------------------------------------------------- */ /* Fill a full line with blanks - make sure it is allocated first */ void -rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) +rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const { scr_blank_line (l, 0, ncol, efs); @@ -236,7 +236,6 @@ selection.op = SELECTION_CLEAR; selection.screen = PRIMARY; selection.clicks = 0; - CLEAR_ALL_SELECTION (); rvideo = 0; } else @@ -327,6 +326,10 @@ int qcol = 0; + // see below for cursor adjustment rationale + if (p == ocur.row) + screen.cur.row = q - (total_rows - nrow); + // fill a single destination line while (lofs < llen && qcol < ncol) { @@ -346,8 +349,10 @@ int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); +#if DEBUG_STRICT assert (len); assert (pline.t); +#endif memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); @@ -391,11 +396,6 @@ term_start = 0; } -#ifdef DEBUG_STRICT //TODO: remove - for (int i = top_row; i < nrow; i++) - assert (ROW (i).t); -#endif - free (old_buf); delete old_ta; delete old_ra; @@ -407,6 +407,8 @@ free (tabs); } + CLEAR_ALL_SELECTION (); + prev_nrow = nrow; prev_ncol = ncol; @@ -450,7 +452,7 @@ scr_reset (); scr_clear (true); - scr_refresh (SLOW_REFRESH); + scr_refresh (); } /* ------------------------------------------------------------------------- * @@ -462,7 +464,7 @@ * XTERM_SEQ: Restore cursor: ESC 8 */ void -rxvt_term::scr_cursor (int mode) +rxvt_term::scr_cursor (cursor_mode mode) { screen_t *s; @@ -619,24 +621,22 @@ { top_row = max (top_row - count, -saveLines); - HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); - // scroll everything up 'count' lines term_start = (term_start + count) % total_rows; + // sever bottommost line { - // severe bottommost scrolled line line_t &l = ROW(row2 - count); - l.touch (); l.is_longer (0); + l.touch (); } - // erase newly scorlled-in lines - for (int i = count; i; --i ) + // erase newly scrolled-in lines + for (int i = count; i--; ) { // basically this is a slightly optimized scr_blank_screen_mem // it is worth the effort on slower machines - line_t &l = ROW(nrow - i); + line_t &l = ROW(nrow - 1 - i); scr_blank_line (l, 0, l.l, rstyle); @@ -677,6 +677,9 @@ && view_start != 0 && view_start != -saveLines) scr_page (UP, count); + + if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) + HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); } else { @@ -818,11 +821,11 @@ if (screen.flags & Screen_WrapNext) { - max_it (line->l, ncol); - line->is_longer (1); - scr_do_wrap (); + line->l = ncol; + line->is_longer (1); + row = screen.cur.row; line = &ROW(row); /* _must_ refresh */ } @@ -1791,8 +1794,10 @@ for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); + num_scr_allow = 0; + if (refresh) - scr_refresh (SLOW_REFRESH); + scr_refresh (); } /* ------------------------------------------------------------------------- */ @@ -1813,9 +1818,7 @@ void rxvt_term::scr_move_to (int y, int len) { - int p = (top_row - nrow) * (len - y) / len + (nrow - 1); - - scr_changeview (p); + scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); } /* ------------------------------------------------------------------------- */ @@ -1838,17 +1841,16 @@ { clamp_it (new_view_start, top_row, 0); - if (new_view_start != view_start) - { - num_scr += new_view_start - view_start; - view_start = new_view_start; - HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); - want_refresh = 1; - - return true; - } - else + if (new_view_start == view_start) return false; + + num_scr += new_view_start - view_start; + view_start = new_view_start; + want_refresh = 1; + + HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); + + return true; } /* ------------------------------------------------------------------------- */ @@ -1939,7 +1941,7 @@ * screen.text/screen.rend contain what the screen will change to. */ void -rxvt_term::scr_refresh (unsigned char refresh_type) +rxvt_term::scr_refresh () { unsigned char must_clear, /* use draw_string not draw_image_string */ showcursor; /* show the cursor */ @@ -2073,7 +2075,6 @@ * D: CopyArea pass - very useful for slower links * This has been deliberately kept simple. */ - i = num_scr; if (!display->is_local && refresh_type == FAST_REFRESH && num_scr_allow && num_scr && abs (num_scr) < nrow && !must_clear) @@ -2081,6 +2082,7 @@ int16_t nits; int j; int len, wlen; + dLocal (int, num_scr); j = nrow; wlen = len = -1; @@ -2802,11 +2804,13 @@ * EXT: button 2 release */ void -rxvt_term::selection_request (Time tm, int x, int y) +rxvt_term::selection_request (Time tm, int selnum) { - if (x < 0 || x >= width || y < 0 || y >= height) - return; /* outside window */ - +/* After making a selection with selection_make this function will always + * return the internal selection, which is not correct IMO, now much more since + * I added the selnum parameter. + */ +#if 0 if (selection.text) { /* internal selection */ char *str = rxvt_wcstombs (selection.text, selection.len); @@ -2815,24 +2819,20 @@ return; } else +#endif { - int i; - selection_request_time = tm; selection_wait = Sel_normal; - for (i = Sel_Primary; i <= Sel_Clipboard; i++) - { #if X_HAVE_UTF8_STRING - selection_type = Sel_UTF8String; - if (selection_request_other (xa[XA_UTF8_STRING], i)) - return; + selection_type = Sel_UTF8String; + if (selection_request_other (xa[XA_UTF8_STRING], selnum)) + return; #else - selection_type = Sel_CompoundText; - if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) - return; + selection_type = Sel_CompoundText; + if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum)) + return; #endif - } } selection_wait = Sel_none; /* don't loop in selection_paste () */