--- rxvt-unicode/src/screen.C 2005/12/22 19:25:58 1.192 +++ rxvt-unicode/src/screen.C 2005/12/27 01:54:08 1.200 @@ -353,7 +353,14 @@ } } - qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; + qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; +#ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY + if (qline->l < 0) + { + fprintf (stderr, "ERROR, PLEASE REPORT to rxvt-unicode@plan9.de: qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D + qline->l = 0; + } +#endif scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); } while (p != pend && q > 0); @@ -387,7 +394,7 @@ term_start = 0; } -#ifdef DEBUG_STRICT +#ifdef DEBUG_STRICT //TODO: remove for (int i = -nsaved; i < nrow; i++) assert (ROW (i).t); #endif @@ -622,11 +629,20 @@ selection.end.row -= count; selection.mark.row -= count; - selection_check (0); + if (selection.beg.row < -nsaved + || selection.end.row < -nsaved + || selection.mark.row < -nsaved) + { + CLEAR_ALL_SELECTION (); + selection.op = SELECTION_CLEAR; + } } for (int i = count; i--; ) - scr_blank_screen_mem (ROW(row2 - i), rstyle); + { + ROW(row2 - i).l = 0; + scr_blank_screen_mem (ROW(row2 - i), rstyle); + } if ((options & Opt_scrollWithBuffer) && view_start != 0 @@ -637,20 +653,17 @@ { if (selection.op && current_screen == selection.screen) { - int i = selection.beg.row; - int j = selection.end.row; - - if ((i < row1 && j > row1) - || (i < row2 && j > row2) - || (i - count < row1 && i >= row1) - || (i - count > row2 && i <= row2) - || (j - count < row1 && j >= row1) - || (j - count > row2 && j <= row2)) + 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; /* XXX: too aggressive? */ + selection.op = SELECTION_CLEAR; } - else if (j >= row1 && j <= row2) + else if (selection.end.row >= row1 && selection.end.row <= row2) { /* move selected region too */ selection.beg.row -= count; @@ -695,7 +708,7 @@ unsigned char checksel; unicode_t c; - int row, last_col; + int last_col; const unicode_t *strend = str + len; want_refresh = 1; @@ -720,7 +733,7 @@ assert (screen.cur.row < nrow && screen.cur.row >= -nsaved); #endif - row = screen.cur.row; + int row = screen.cur.row; checksel = selection.op && current_screen == selection.screen ? 1 : 0; @@ -732,7 +745,7 @@ if (c < 0x20) if (c == C0_LF) - { + { if (!line->is_longer ()) /* XXX: think about this */ max_it (line->l, screen.cur.col); @@ -987,9 +1000,7 @@ return; else if (count > 0) { - int row = screen.cur.row; - - line_t &l = ROW(row); + line_t &l = ROW(screen.cur.row); rend_t base_rend = l.r[i]; ht &= l.t[i] == ' '; @@ -1074,16 +1085,12 @@ void rxvt_term::scr_forwardindex () { - int row; - if (screen.cur.col < ncol - 1) scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); else { - row = screen.cur.row; - - if (ROW(row).is_longer ()) //TODO//FIXME//LEN - ROW(row).l = ncol; + if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN + ROW(screen.cur.row).l = ncol; scr_gotorc (0, 0, R_RELATIVE); scr_insdel_chars (1, DELETE); @@ -1176,21 +1183,21 @@ void rxvt_term::scr_erase_line (int mode) { - unsigned int row, col, num; + unsigned int col, num; want_refresh = 1; ZERO_SCROLLBACK (); selection_check (1); - row = screen.cur.row; + line_t &line = ROW(screen.cur.row); switch (mode) { case 0: /* erase to end of line */ col = screen.cur.col; num = ncol - col; - min_it (ROW(row).l, col); + min_it (line.l, col); if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) CLEAR_SELECTION (); @@ -1205,7 +1212,7 @@ case 2: /* erase whole line */ col = 0; num = ncol; - ROW(row).l = 0; + line.l = 0; if (selection.beg.row <= screen.cur.row && selection.end.row >= screen.cur.row) CLEAR_SELECTION (); @@ -1214,7 +1221,7 @@ return; } - scr_blank_line (ROW(row), col, num, rstyle); + scr_blank_line (line, col, num, rstyle); } /* ------------------------------------------------------------------------- */ @@ -1288,8 +1295,8 @@ for (; num--; row++) { - scr_blank_screen_mem (ROW (row), rstyle); ROW (row).l = 0; + scr_blank_screen_mem (ROW (row), rstyle); scr_blank_line (drawn_buf [row], 0, ncol, ren); } } @@ -2185,7 +2192,7 @@ int fore = GET_FGCOLOR (rend); // desired foreground int back = GET_BGCOLOR (rend); // desired background - // only do special processing if any attributes are set, which is rare + // only do special processing if any attributes are set, which is unlikely if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) { #if ENABLE_STYLES @@ -2443,8 +2450,16 @@ if (selection.rect) { for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) - for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) - srp[col] ^= RS_RVid; + { + text_t *stp = ROW(row).t; + rend_t *srp = ROW(row).r; + + for (col = selection.beg.col; col < selection.end.col; col++) + srp[col] ^= RS_RVid; + + while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) + srp[col] ^= RS_RVid | RS_Uline; + } } else #endif @@ -2457,7 +2472,7 @@ else { col = 0; - row = view_start; + row = -view_start; } for (; row < min (selection.end.row, view_end); row++, col = 0) @@ -2881,8 +2896,12 @@ col = max (col, 0); - if (row == selection.end.row || selection.rect) - end_col = min (end_col, selection.end.col); + if (row == selection.end.row +#if ENABLE_FRILLS + || selection.rect +#endif + ) + min_it (end_col, selection.end.col); t = ROW(row).t + col; for (; col < end_col; col++) @@ -2910,8 +2929,20 @@ new_selection_text[ofs++] = *t++; } - if (!ROW(row).is_longer () && row != selection.end.row) - new_selection_text[ofs++] = C0_LF; +#if ENABLE_FRILLS + if (selection.rect) + { + while (ofs + && new_selection_text[ofs - 1] != C0_LF + && unicode::is_space (new_selection_text[ofs - 1])) + --ofs; + + new_selection_text[ofs++] = C0_LF; + } + else +#endif + if (!ROW(row).is_longer () && row != selection.end.row) + new_selection_text[ofs++] = C0_LF; } if (end_col != selection.end.col) @@ -3343,9 +3374,8 @@ while (--end_col >= 0) { - if (stp[end_col] != ' ' - && stp[end_col] != '\t' - && stp[end_col] != NOCHAR) + if (stp[end_col] != NOCHAR + && !unicode::is_space (stp[end_col])) break; } @@ -3671,8 +3701,8 @@ text_t *t1 = ov_text[y]; rend_t *r1 = ov_rend[y]; - text_t *t2 = ROW(y - view_start).t + ov_x; - rend_t *r2 = ROW(y - view_start).r + ov_x; + text_t *t2 = ROW(y + ov_y - view_start).t + ov_x; + rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x; for (int x = ov_w; x--; ) {