--- rxvt-unicode/src/screen.C 2006/01/08 00:07:18 1.214 +++ rxvt-unicode/src/screen.C 2006/01/12 03:32:56 1.224 @@ -147,6 +147,9 @@ rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) { scr_blank_line (l, 0, ncol, efs); + + l.l = 0; + l.f = 0; } /* ------------------------------------------------------------------------- * @@ -193,7 +196,6 @@ { /* * first time called so just malloc everything: don't rely on realloc - * Note: this is still needed so that all the scrollback lines are NULL */ nsaved = 0; /* no saved lines */ term_start = 0; @@ -201,10 +203,9 @@ talloc = new rxvt_salloc (ncol * sizeof (text_t)); ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); - row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); - temp_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)); + row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); + drawn_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); + swap_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); for (int row = nrow; row--; ) { @@ -259,7 +260,6 @@ #endif drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); - temp_buf = (line_t *)rxvt_realloc (temp_buf , nrow * sizeof (line_t)); swap_buf = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t)); for (int row = min (nrow, prev_nrow); row--; ) @@ -274,7 +274,8 @@ drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); } - line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); + line_t *old_buf = row_buf; + row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row int pend = MOD (term_start - nsaved , prev_total_rows); @@ -432,7 +433,6 @@ free (row_buf); free (swap_buf); free (drawn_buf); - free (temp_buf); free (tabs); row_buf = 0; // signal that we freed all the arrays @@ -574,7 +574,7 @@ void rxvt_term::scr_color (unsigned int color, int fgbg) { - if (color > maxTermCOLOR) + if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) color = fgbg; if (fgbg == Color_fg) @@ -641,8 +641,14 @@ for (int i = count; i--; ) { - ROW(row2 - i).l = 0; - scr_blank_screen_mem (ROW(row2 - i), rstyle); + // basically thi is a slightly optimized scr_blank_screen_mem + // it is worth the effort on slower machines + line_t &l = ROW(row2 - i); + + scr_blank_line (l, 0, l.l, rstyle); + + l.l = 0; + l.f = 0; } if (OPTION (Opt_scrollWithBuffer) @@ -682,6 +688,8 @@ min_it (count, rows); + line_t *temp_buf = row_buf + total_rows; + for (int row = 0; row < rows; row++) { temp_buf [row] = ROW(row1 + (row + count + rows) % rows); @@ -1305,10 +1313,7 @@ for (; num--; row++) { - line_t &l = ROW(row); - l.l = 0; - l.is_longer (0); - scr_blank_screen_mem (l, rstyle); + scr_blank_screen_mem (ROW(row), rstyle); scr_blank_line (drawn_buf [row], 0, ncol, ren); } } @@ -1860,6 +1865,7 @@ if (OPTION (Opt_visualBell)) { scr_rvideo_mode (!rvideo); /* refresh also done */ + display->flush (); rxvt_usleep (VISUAL_BELL_DURATION); scr_rvideo_mode (!rvideo); /* refresh also done */ } @@ -2377,9 +2383,6 @@ */ scr_reverse_selection (); - if (refresh_type & SMOOTH_REFRESH) - XFlush (display->display); - num_scr = 0; num_scr_allow = 1; } @@ -2453,6 +2456,54 @@ XClearWindow (display->display, vt); } +void +rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) +{ + int view_end = -view_start + nrow; + int row, col; + + for (row = max (beg_row, -view_start); row <= min (end_row, view_end); row++) + { + text_t *stp = ROW(row).t; + rend_t *srp = ROW(row).r; + + for (col = beg_col; col < end_col; col++) + srp[col] ^= rstyle1; + + while (col-- > beg_col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) + srp[col] ^= rstyle2; + + if (++col < end_col) + srp[col] ^= rstyle2; + } +} + +void +rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) +{ + int view_end = -view_start + nrow; + int row, col; + + if (beg_row >= -view_start) + { + col = beg_col; + row = beg_row; + } + else + { + col = 0; + row = -view_start; + } + + for (; row < min (end_row, view_end); row++, col = 0) + for (rend_t *srp = ROW(row).r; col < ncol; col++) + srp[col] ^= rstyle; + + if (row == end_row) + for (rend_t *srp = ROW(row).r; col < end_col; col++) + srp[col] ^= rstyle; +} + /* ------------------------------------------------------------------------- */ void rxvt_term::scr_reverse_selection () @@ -2461,49 +2512,16 @@ && current_screen == selection.screen && selection.end.row >= -view_start) { - int view_end = -view_start + nrow; - int row, col; - #if ENABLE_FRILLS if (selection.rect) - { - for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) - { - 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; - - if (++col < selection.end.col) - srp[col] ^= RS_RVid | RS_Uline; - } - } + scr_xor_rect (selection.beg.row, selection.beg.col, + selection.end.row, selection.end.col, + RS_RVid, RS_RVid | RS_Uline); else #endif - { - if (selection.beg.row >= -view_start) - { - col = selection.beg.col; - row = selection.beg.row; - } - else - { - col = 0; - row = -view_start; - } - - for (; row < min (selection.end.row, view_end); row++, col = 0) - for (rend_t *srp = ROW(row).r; col < ncol; col++) - srp[col] ^= RS_RVid; - - if (row == selection.end.row) - for (rend_t *srp = ROW(row).r; col < selection.end.col; col++) - srp[col] ^= RS_RVid; - } + scr_xor_span (selection.beg.row, selection.beg.col, + selection.end.row, selection.end.col, + RS_RVid); } } @@ -3029,6 +3047,13 @@ clicks = ((clicks - 1) % 3) + 1; selection.clicks = clicks; /* save clicks so extend will work */ + if (clicks == 2 && !selection.rect + && HOOK_INVOKE ((this, HOOK_SEL_EXTEND, DT_END))) + { + MEvent.clicks = 1; // what a mess + return; + } + selection_start_colrow (Pixel2Col (x), Pixel2Row (y)); if (clicks == 2 || clicks == 3) @@ -3333,11 +3358,8 @@ if (ROWCOL_IS_AFTER (selection.end, selection.beg)) selection.end.col--; - if (!HOOK_INVOKE ((this, HOOK_SEL_EXTEND, DT_END))) - { - selection_delimit_word (UP, &selection.beg, &selection.beg); - selection_delimit_word (DN, &selection.end, &selection.end); - } + selection_delimit_word (UP, &selection.beg, &selection.beg); + selection_delimit_word (DN, &selection.end, &selection.end); } else if (selection.clicks == 3) {