ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.319 by root, Tue Nov 4 23:08:44 2008 UTC vs.
Revision 1.327 by root, Wed Nov 5 14:43:54 2008 UTC

278 278
279 if (top_row) 279 if (top_row)
280 { 280 {
281 // Re-wrap lines. This is rather ugly, possibly because I am too dumb 281 // Re-wrap lines. This is rather ugly, possibly because I am too dumb
282 // to come up with a lean and mean algorithm. 282 // to come up with a lean and mean algorithm.
283 // TODO: maybe optimise when width didn't change
283 284
284 row_col_t ocur = screen.cur; 285 row_col_t ocur = screen.cur;
285 ocur.row = MOD (term_start + ocur.row, prev_total_rows); 286 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
286 287
287 do 288 do
393 394
394 clamp_it (screen.cur.row, 0, nrow - 1); 395 clamp_it (screen.cur.row, 0, nrow - 1);
395 clamp_it (screen.cur.col, 0, ncol - 1); 396 clamp_it (screen.cur.col, 0, ncol - 1);
396 } 397 }
397 398
399 free (tabs);
400 tabs = (char *)rxvt_malloc (ncol);
401
402 for (int col = ncol; --col; )
403 tabs [col] = col % TABSIZE == 0;
404
398 CLEAR_ALL_SELECTION (); 405 CLEAR_ALL_SELECTION ();
399 406
400 prev_nrow = nrow; 407 prev_nrow = nrow;
401 prev_ncol = ncol; 408 prev_ncol = ncol;
402 409
434void 441void
435rxvt_term::scr_poweron () 442rxvt_term::scr_poweron ()
436{ 443{
437 scr_release (); 444 scr_release ();
438 prev_nrow = prev_ncol = 0; 445 prev_nrow = prev_ncol = 0;
446 rvideo_mode = false;
439 scr_soft_reset (); 447 scr_soft_reset ();
440 scr_reset (); 448 scr_reset ();
441 449
442 scr_clear (true); 450 scr_clear (true);
443 scr_refresh (); 451 scr_refresh ();
449 /* only affects modes, nothing drastic such as clearing the screen */ 457 /* only affects modes, nothing drastic such as clearing the screen */
450#if ENABLE_OVERLAY 458#if ENABLE_OVERLAY
451 scr_overlay_off (); 459 scr_overlay_off ();
452#endif 460#endif
453 461
454 rvideo_mode = false;
455
456 if (current_screen != PRIMARY) 462 if (current_screen != PRIMARY)
457 scr_swap_screen (); 463 scr_swap_screen ();
458
459 free (tabs);
460 tabs = (char *)rxvt_malloc (ncol);
461
462 for (int col = ncol; --col; )
463 tabs [col] = col % TABSIZE == 0;
464 464
465 scr_scroll_region (0, MAX_ROWS - 1); 465 scr_scroll_region (0, MAX_ROWS - 1);
466 scr_rendition (0, ~RS_None); 466 scr_rendition (0, ~RS_None);
467 scr_insert_mode (0); 467 scr_insert_mode (0);
468} 468}
1341 if (row >= nrow) /* Out Of Bounds */ 1341 if (row >= nrow) /* Out Of Bounds */
1342 return; 1342 return;
1343 1343
1344 min_it (num, nrow - row); 1344 min_it (num, nrow - row);
1345 1345
1346 /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */ 1346 // TODO: the code below does not work when view_start != 0
1347 // the workaround is to disable the clear and use a normal refresh
1348 // when view_start != 0. mysterious.
1347 if (rstyle & (RS_RVid | RS_Uline)) 1349 if (rstyle & (RS_RVid | RS_Uline))
1348 ren = (rend_t) ~RS_None; 1350 ren = (rend_t) ~RS_None;
1349 else if (GET_BASEBG (rstyle) == Color_bg) 1351 else if (GET_BASEBG (rstyle) == Color_bg)
1350 { 1352 {
1351 ren = DEFAULT_RSTYLE; 1353 ren = DEFAULT_RSTYLE;
1352 1354
1353 if (mapped) 1355 if (mapped && !view_start)
1354 XClearArea (dpy, vt, 0, 1356 XClearArea (dpy, vt, 0,
1355 Row2Pixel (row), (unsigned int)width, 1357 Row2Pixel (row - view_start), (unsigned int)width,
1356 (unsigned int)Height2Pixel (num), False); 1358 (unsigned int)Height2Pixel (num), False);
1357 } 1359 }
1358 else 1360 else
1359 { 1361 {
1360 ren = rstyle & (RS_fgMask | RS_bgMask); 1362 ren = rstyle & (RS_fgMask | RS_bgMask);
1361 1363
1364 if (mapped && !view_start)
1365 {
1362 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1366 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1363 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1367 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1364 XFillRectangle (dpy, vt, gc, 1368 XFillRectangle (dpy, vt, gc,
1365 0, Row2Pixel (row), 1369 0, Row2Pixel (row - view_start),
1366 (unsigned int)width, 1370 (unsigned int)width,
1367 (unsigned int)Height2Pixel (num)); 1371 (unsigned int)Height2Pixel (num));
1368 gcvalue.foreground = pix_colors[Color_fg]; 1372 gcvalue.foreground = pix_colors[Color_fg];
1369 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1373 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1374 }
1370 } 1375 }
1371 1376
1372 for (; num--; row++) 1377 for (; num--; row++)
1373 { 1378 {
1374 scr_blank_screen_mem (ROW(row), rstyle); 1379 scr_blank_screen_mem (ROW(row), rstyle);
1380
1381 if (!view_start)
1375 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1382 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1376 } 1383 }
1377} 1384}
1378 1385
1379#if !ENABLE_MINIMAL 1386#if !ENABLE_MINIMAL
1380void 1387void
1533 { 1540 {
1534 line->t[col] = line->t[col + count]; 1541 line->t[col] = line->t[col + count];
1535 line->r[col] = line->r[col + count]; 1542 line->r[col] = line->r[col + count];
1536 } 1543 }
1537 1544
1538 scr_blank_line (*line, ncol - count, count, 1545 scr_blank_line (*line, ncol - count, count, rstyle);
1539 line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask));
1540 1546
1541 if (selection.op && current_screen == selection.screen 1547 if (selection.op && current_screen == selection.screen
1542 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1548 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1543 { 1549 {
1544 if (selection.end.row != screen.cur.row 1550 if (selection.end.row != screen.cur.row
2002 * screen.text/screen.rend contain what the screen will change to. 2008 * screen.text/screen.rend contain what the screen will change to.
2003 */ 2009 */
2004void 2010void
2005rxvt_term::scr_refresh () NOTHROW 2011rxvt_term::scr_refresh () NOTHROW
2006{ 2012{
2007 unsigned char have_bg,
2008 showcursor; /* show the cursor */
2009 int16_t col, row, /* column/row we're processing */ 2013 int16_t col, row, /* column/row we're processing */
2010 ocrow; /* old cursor row */ 2014 ocrow; /* old cursor row */
2011 int i; /* tmp */ 2015 int i; /* tmp */
2012#ifndef NO_CURSORCOLOR 2016#ifndef NO_CURSORCOLOR
2013 rend_t cc1; /* store colours at cursor position (s) */ 2017 rend_t cc1; /* store colours at cursor position (s) */
2024 /* 2028 /*
2025 * A: set up vars 2029 * A: set up vars
2026 */ 2030 */
2027 refresh_count = 0; 2031 refresh_count = 0;
2028 2032
2033 unsigned int old_screen_flags = screen.flags;
2029 have_bg = 0; 2034 char have_bg = 0;
2030#ifdef HAVE_BG_PIXMAP 2035#ifdef HAVE_BG_PIXMAP
2031 have_bg = bgPixmap.pixmap != None; 2036 have_bg = bgPixmap.pixmap != None;
2032#endif 2037#endif
2033 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2038 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
2034 2039
2035 /* 2040 /*
2036 * B: reverse any characters which are selected 2041 * B: reverse any characters which are selected
2037 */ 2042 */
2038 scr_reverse_selection (); 2043 scr_reverse_selection ();
2044
2045 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2046#if ENABLE_OVERLAY
2047 scr_swap_overlay ();
2048#endif
2049
2050 char showcursor = screen.flags & Screen_VisibleCursor;
2039 2051
2040 /* 2052 /*
2041 * C: set the cursor character (s) 2053 * C: set the cursor character (s)
2042 */ 2054 */
2043 { 2055 {
2044 unsigned char setoldcursor; 2056 unsigned char setoldcursor;
2045 2057
2046 showcursor = (screen.flags & Screen_VisibleCursor);
2047#ifdef CURSOR_BLINK 2058#ifdef CURSOR_BLINK
2048 if (hidden_cursor) 2059 if (hidden_cursor)
2049 showcursor = 0; 2060 showcursor = 0;
2050#endif 2061#endif
2051 2062
2124 oldcursor.col = screen.cur.col; 2135 oldcursor.col = screen.cur.col;
2125 } 2136 }
2126 } 2137 }
2127 } 2138 }
2128 2139
2129 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2130#if ENABLE_OVERLAY
2131 scr_swap_overlay ();
2132#endif
2133
2134#ifndef NO_SLOW_LINK_SUPPORT 2140#ifndef NO_SLOW_LINK_SUPPORT
2135 /* 2141 /*
2136 * D: CopyArea pass - very useful for slower links 2142 * D: CopyArea pass - very useful for slower links
2137 * This has been deliberately kept simple. 2143 * This has been deliberately kept simple.
2138 */ 2144 */
2410 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2416 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2411 } 2417 }
2412 } /* for (col....) */ 2418 } /* for (col....) */
2413 } /* for (row....) */ 2419 } /* for (row....) */
2414 2420
2415#if ENABLE_OVERLAY
2416 scr_swap_overlay ();
2417#endif
2418 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2419
2420 /* 2421 /*
2421 * G: cleanup cursor and display outline cursor if necessary 2422 * G: cleanup cursor and display outline cursor if necessary
2422 */ 2423 */
2423 if (showcursor) 2424 if (showcursor)
2424 { 2425 {
2462 } 2463 }
2463 2464
2464 /* 2465 /*
2465 * H: cleanup selection 2466 * H: cleanup selection
2466 */ 2467 */
2468#if ENABLE_OVERLAY
2469 scr_swap_overlay ();
2470#endif
2471 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2472
2467 scr_reverse_selection (); 2473 scr_reverse_selection ();
2468 2474
2475 screen.flags = old_screen_flags;
2469 num_scr = 0; 2476 num_scr = 0;
2470 num_scr_allow = 1; 2477 num_scr_allow = 1;
2471} 2478}
2472 2479
2473void 2480void
3732 h += 2; min_it (h, nrow); 3739 h += 2; min_it (h, nrow);
3733 3740
3734 x -= 1; clamp_it (x, 0, ncol - w); 3741 x -= 1; clamp_it (x, 0, ncol - w);
3735 y -= 1; clamp_it (y, 0, nrow - h); 3742 y -= 1; clamp_it (y, 0, nrow - h);
3736 3743
3737 ov_x = x; ov_y = y; 3744 ov.x = x; ov.y = y;
3738 ov_w = w; ov_h = h; 3745 ov.w = w; ov.h = h;
3739 3746
3740 ov_text = new text_t *[h]; 3747 ov.text = new text_t *[h];
3741 ov_rend = new rend_t *[h]; 3748 ov.rend = new rend_t *[h];
3742 3749
3743 for (y = 0; y < h; y++) 3750 for (y = 0; y < h; y++)
3744 { 3751 {
3745 text_t *tp = ov_text[y] = new text_t[w]; 3752 text_t *tp = ov.text[y] = new text_t[w];
3746 rend_t *rp = ov_rend[y] = new rend_t[w]; 3753 rend_t *rp = ov.rend[y] = new rend_t[w];
3747 3754
3748 text_t t0, t1, t2; 3755 text_t t0, t1, t2;
3749 rend_t r = OVERLAY_RSTYLE; 3756 rend_t r = OVERLAY_RSTYLE;
3750 3757
3751 if (y == 0) 3758 if (y == 0)
3770} 3777}
3771 3778
3772void 3779void
3773rxvt_term::scr_overlay_off () NOTHROW 3780rxvt_term::scr_overlay_off () NOTHROW
3774{ 3781{
3775 if (!ov_text) 3782 if (!ov.text)
3776 return; 3783 return;
3777 3784
3778 want_refresh = 1; 3785 want_refresh = 1;
3779 3786
3780 for (int y = 0; y < ov_h; y++) 3787 for (int y = 0; y < ov.h; y++)
3781 { 3788 {
3782 delete [] ov_text[y]; 3789 delete [] ov.text[y];
3783 delete [] ov_rend[y]; 3790 delete [] ov.rend[y];
3784 } 3791 }
3785 3792
3786 delete [] ov_text; ov_text = 0; 3793 delete [] ov.text; ov.text = 0;
3787 delete [] ov_rend; ov_rend = 0; 3794 delete [] ov.rend; ov.rend = 0;
3788} 3795}
3789 3796
3790void 3797void
3791rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW 3798rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW
3792{ 3799{
3793 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) 3800 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2)
3794 return; 3801 return;
3795 3802
3796 x++, y++; 3803 x++, y++;
3797 3804
3798 ov_text[y][x] = text; 3805 ov.text[y][x] = text;
3799 ov_rend[y][x] = rend; 3806 ov.rend[y][x] = rend;
3800} 3807}
3801 3808
3802void 3809void
3803rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW 3810rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW
3804{ 3811{
3823} 3830}
3824 3831
3825void 3832void
3826rxvt_term::scr_swap_overlay () NOTHROW 3833rxvt_term::scr_swap_overlay () NOTHROW
3827{ 3834{
3828 if (!ov_text) 3835 if (!ov.text)
3829 return; 3836 return;
3830 3837
3838 // hide cursor if it is within the overlay area
3839 if (IN_RANGE_EXC (screen.cur.col - ov.x, 0, ov.w)
3840 && IN_RANGE_EXC (screen.cur.row - ov.y, 0, ov.h))
3841 screen.flags &= ~Screen_VisibleCursor;
3842
3831 // swap screen mem with overlay 3843 // swap screen mem with overlay
3832 for (int y = ov_h; y--; ) 3844 for (int y = ov.h; y--; )
3833 { 3845 {
3834 text_t *t1 = ov_text[y]; 3846 text_t *t1 = ov.text[y];
3835 rend_t *r1 = ov_rend[y]; 3847 rend_t *r1 = ov.rend[y];
3836 3848
3837 text_t *t2 = ROW(y + ov_y + view_start).t + ov_x; 3849 text_t *t2 = ROW(y + ov.y + view_start).t + ov.x;
3838 rend_t *r2 = ROW(y + ov_y + view_start).r + ov_x; 3850 rend_t *r2 = ROW(y + ov.y + view_start).r + ov.x;
3839 3851
3840 for (int x = ov_w; x--; ) 3852 for (int x = ov.w; x--; )
3841 { 3853 {
3842 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3854 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3843 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3855 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t));
3844 } 3856 }
3845 } 3857 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines