--- rxvt-unicode/src/screen.C 2006/01/05 21:21:49 1.210 +++ rxvt-unicode/src/screen.C 2006/01/09 19:01:56 1.217 @@ -3,7 +3,7 @@ *---------------------------------------------------------------------------* * * Copyright (c) 1997-2001 Geoff Wing - * Copyright (c) 2003-2004 Marc Lehmann + * Copyright (c) 2003-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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); @@ -416,7 +417,7 @@ tt_winch (); - PERL_INVOKE ((this, HOOK_RESET, DT_END)); + HOOK_INVOKE ((this, HOOK_RESET, DT_END)); } /* ------------------------------------------------------------------------- */ @@ -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 @@ -620,7 +620,7 @@ { nsaved = min (nsaved + count, saveLines); - PERL_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END)); + HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END)); term_start = (term_start + count) % total_rows; @@ -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); @@ -702,7 +710,7 @@ * Add text given in of length to screen struct */ void -rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) +rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) { if (len <= 0) /* sanity */ return; @@ -710,22 +718,22 @@ unsigned char checksel; unicode_t c; int ncol = this->ncol; - const unicode_t *strend = str + len; + const wchar_t *strend = str + len; want_refresh = 1; ZERO_SCROLLBACK (); - if (nlines > 0) + if (minlines > 0) { - nlines += screen.cur.row - screen.bscroll; + minlines += screen.cur.row - screen.bscroll; - if (nlines > 0 + if (minlines > 0 && screen.tscroll == 0 && screen.bscroll == nrow - 1) { /* _at least_ this many lines need to be scrolled */ - scr_scroll_text (screen.tscroll, screen.bscroll, nlines); - screen.cur.row -= nlines; + scr_scroll_text (screen.tscroll, screen.bscroll, minlines); + screen.cur.row -= minlines; } } @@ -742,7 +750,7 @@ while (str < strend) { - c = *str++; + c = (unicode_t)*str++; // convert to rxvt-unicodes representation if (c < 0x20) if (c == C0_LF) @@ -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); } } @@ -1835,7 +1840,7 @@ { if (view_start != oldviewstart) { - PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); + HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); want_refresh = 1; num_scr -= (view_start - oldviewstart); @@ -2055,7 +2060,7 @@ } } - PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); + HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); #if ENABLE_OVERLAY scr_swap_overlay (); #endif @@ -2328,7 +2333,7 @@ #if ENABLE_OVERLAY scr_swap_overlay (); #endif - PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END)); + HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END)); /* * G: cleanup cursor and display outline cursor if necessary @@ -2390,7 +2395,7 @@ if (!l.t) return; - l.touch (); // maybe a bit of an overkill, but its not performance-relevant + l.touch (); // maybe a bit of an overkill, but it's not performance-relevant for (int i = ncol; i--; ) l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); @@ -2892,7 +2897,7 @@ if (selection.clicks == 4) return; /* nothing selected, go away */ - if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) + if (HOOK_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) return; i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); @@ -2987,7 +2992,7 @@ selection.len = ofs; selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); - if (PERL_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END))) + if (HOOK_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END))) return; selection_grab (tm); @@ -3333,7 +3338,7 @@ if (ROWCOL_IS_AFTER (selection.end, selection.beg)) selection.end.col--; - if (!PERL_INVOKE ((this, HOOK_SEL_EXTEND, DT_END))) + 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);