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.318 by root, Tue Nov 4 22:44:09 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 ();
448{ 456{
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
454 rvideo_mode = false;
455
456 if (current_screen != PRIMARY)
457 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 461
465 if (current_screen != PRIMARY) 462 if (current_screen != PRIMARY)
466 scr_swap_screen (); 463 scr_swap_screen ();
467 464
468 scr_scroll_region (0, MAX_ROWS - 1); 465 scr_scroll_region (0, MAX_ROWS - 1);
1344 if (row >= nrow) /* Out Of Bounds */ 1341 if (row >= nrow) /* Out Of Bounds */
1345 return; 1342 return;
1346 1343
1347 min_it (num, nrow - row); 1344 min_it (num, nrow - row);
1348 1345
1349 /*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.
1350 if (rstyle & (RS_RVid | RS_Uline)) 1349 if (rstyle & (RS_RVid | RS_Uline))
1351 ren = (rend_t) ~RS_None; 1350 ren = (rend_t) ~RS_None;
1352 else if (GET_BASEBG (rstyle) == Color_bg) 1351 else if (GET_BASEBG (rstyle) == Color_bg)
1353 { 1352 {
1354 ren = DEFAULT_RSTYLE; 1353 ren = DEFAULT_RSTYLE;
1355 1354
1356 if (mapped) 1355 if (mapped && !view_start)
1357 XClearArea (dpy, vt, 0, 1356 XClearArea (dpy, vt, 0,
1358 Row2Pixel (row), (unsigned int)width, 1357 Row2Pixel (row - view_start), (unsigned int)width,
1359 (unsigned int)Height2Pixel (num), False); 1358 (unsigned int)Height2Pixel (num), False);
1360 } 1359 }
1361 else 1360 else
1362 { 1361 {
1363 ren = rstyle & (RS_fgMask | RS_bgMask); 1362 ren = rstyle & (RS_fgMask | RS_bgMask);
1364 1363
1364 if (mapped && !view_start)
1365 {
1365 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1366 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1366 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1367 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1367 XFillRectangle (dpy, vt, gc, 1368 XFillRectangle (dpy, vt, gc,
1368 0, Row2Pixel (row), 1369 0, Row2Pixel (row - view_start),
1369 (unsigned int)width, 1370 (unsigned int)width,
1370 (unsigned int)Height2Pixel (num)); 1371 (unsigned int)Height2Pixel (num));
1371 gcvalue.foreground = pix_colors[Color_fg]; 1372 gcvalue.foreground = pix_colors[Color_fg];
1372 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1373 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1374 }
1373 } 1375 }
1374 1376
1375 for (; num--; row++) 1377 for (; num--; row++)
1376 { 1378 {
1377 scr_blank_screen_mem (ROW(row), rstyle); 1379 scr_blank_screen_mem (ROW(row), rstyle);
1380
1381 if (!view_start)
1378 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1382 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1379 } 1383 }
1380} 1384}
1381 1385
1382#if !ENABLE_MINIMAL 1386#if !ENABLE_MINIMAL
1383void 1387void
1536 { 1540 {
1537 line->t[col] = line->t[col + count]; 1541 line->t[col] = line->t[col + count];
1538 line->r[col] = line->r[col + count]; 1542 line->r[col] = line->r[col + count];
1539 } 1543 }
1540 1544
1541 scr_blank_line (*line, ncol - count, count, 1545 scr_blank_line (*line, ncol - count, count, rstyle);
1542 line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask));
1543 1546
1544 if (selection.op && current_screen == selection.screen 1547 if (selection.op && current_screen == selection.screen
1545 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1548 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1546 { 1549 {
1547 if (selection.end.row != screen.cur.row 1550 if (selection.end.row != screen.cur.row
2005 * screen.text/screen.rend contain what the screen will change to. 2008 * screen.text/screen.rend contain what the screen will change to.
2006 */ 2009 */
2007void 2010void
2008rxvt_term::scr_refresh () NOTHROW 2011rxvt_term::scr_refresh () NOTHROW
2009{ 2012{
2010 unsigned char have_bg,
2011 showcursor; /* show the cursor */
2012 int16_t col, row, /* column/row we're processing */ 2013 int16_t col, row, /* column/row we're processing */
2013 ocrow; /* old cursor row */ 2014 ocrow; /* old cursor row */
2014 int i; /* tmp */ 2015 int i; /* tmp */
2015#ifndef NO_CURSORCOLOR 2016#ifndef NO_CURSORCOLOR
2016 rend_t cc1; /* store colours at cursor position (s) */ 2017 rend_t cc1; /* store colours at cursor position (s) */
2027 /* 2028 /*
2028 * A: set up vars 2029 * A: set up vars
2029 */ 2030 */
2030 refresh_count = 0; 2031 refresh_count = 0;
2031 2032
2033 unsigned int old_screen_flags = screen.flags;
2032 have_bg = 0; 2034 char have_bg = 0;
2033#ifdef HAVE_BG_PIXMAP 2035#ifdef HAVE_BG_PIXMAP
2034 have_bg = bgPixmap.pixmap != None; 2036 have_bg = bgPixmap.pixmap != None;
2035#endif 2037#endif
2036 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2038 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
2037 2039
2038 /* 2040 /*
2039 * B: reverse any characters which are selected 2041 * B: reverse any characters which are selected
2040 */ 2042 */
2041 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;
2042 2051
2043 /* 2052 /*
2044 * C: set the cursor character (s) 2053 * C: set the cursor character (s)
2045 */ 2054 */
2046 { 2055 {
2047 unsigned char setoldcursor; 2056 unsigned char setoldcursor;
2048 2057
2049 showcursor = (screen.flags & Screen_VisibleCursor);
2050#ifdef CURSOR_BLINK 2058#ifdef CURSOR_BLINK
2051 if (hidden_cursor) 2059 if (hidden_cursor)
2052 showcursor = 0; 2060 showcursor = 0;
2053#endif 2061#endif
2054 2062
2127 oldcursor.col = screen.cur.col; 2135 oldcursor.col = screen.cur.col;
2128 } 2136 }
2129 } 2137 }
2130 } 2138 }
2131 2139
2132 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2133#if ENABLE_OVERLAY
2134 scr_swap_overlay ();
2135#endif
2136
2137#ifndef NO_SLOW_LINK_SUPPORT 2140#ifndef NO_SLOW_LINK_SUPPORT
2138 /* 2141 /*
2139 * D: CopyArea pass - very useful for slower links 2142 * D: CopyArea pass - very useful for slower links
2140 * This has been deliberately kept simple. 2143 * This has been deliberately kept simple.
2141 */ 2144 */
2413 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2416 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2414 } 2417 }
2415 } /* for (col....) */ 2418 } /* for (col....) */
2416 } /* for (row....) */ 2419 } /* for (row....) */
2417 2420
2418#if ENABLE_OVERLAY
2419 scr_swap_overlay ();
2420#endif
2421 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2422
2423 /* 2421 /*
2424 * G: cleanup cursor and display outline cursor if necessary 2422 * G: cleanup cursor and display outline cursor if necessary
2425 */ 2423 */
2426 if (showcursor) 2424 if (showcursor)
2427 { 2425 {
2465 } 2463 }
2466 2464
2467 /* 2465 /*
2468 * H: cleanup selection 2466 * H: cleanup selection
2469 */ 2467 */
2468#if ENABLE_OVERLAY
2469 scr_swap_overlay ();
2470#endif
2471 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2472
2470 scr_reverse_selection (); 2473 scr_reverse_selection ();
2471 2474
2475 screen.flags = old_screen_flags;
2472 num_scr = 0; 2476 num_scr = 0;
2473 num_scr_allow = 1; 2477 num_scr_allow = 1;
2474} 2478}
2475 2479
2476void 2480void
3735 h += 2; min_it (h, nrow); 3739 h += 2; min_it (h, nrow);
3736 3740
3737 x -= 1; clamp_it (x, 0, ncol - w); 3741 x -= 1; clamp_it (x, 0, ncol - w);
3738 y -= 1; clamp_it (y, 0, nrow - h); 3742 y -= 1; clamp_it (y, 0, nrow - h);
3739 3743
3740 ov_x = x; ov_y = y; 3744 ov.x = x; ov.y = y;
3741 ov_w = w; ov_h = h; 3745 ov.w = w; ov.h = h;
3742 3746
3743 ov_text = new text_t *[h]; 3747 ov.text = new text_t *[h];
3744 ov_rend = new rend_t *[h]; 3748 ov.rend = new rend_t *[h];
3745 3749
3746 for (y = 0; y < h; y++) 3750 for (y = 0; y < h; y++)
3747 { 3751 {
3748 text_t *tp = ov_text[y] = new text_t[w]; 3752 text_t *tp = ov.text[y] = new text_t[w];
3749 rend_t *rp = ov_rend[y] = new rend_t[w]; 3753 rend_t *rp = ov.rend[y] = new rend_t[w];
3750 3754
3751 text_t t0, t1, t2; 3755 text_t t0, t1, t2;
3752 rend_t r = OVERLAY_RSTYLE; 3756 rend_t r = OVERLAY_RSTYLE;
3753 3757
3754 if (y == 0) 3758 if (y == 0)
3773} 3777}
3774 3778
3775void 3779void
3776rxvt_term::scr_overlay_off () NOTHROW 3780rxvt_term::scr_overlay_off () NOTHROW
3777{ 3781{
3778 if (!ov_text) 3782 if (!ov.text)
3779 return; 3783 return;
3780 3784
3781 want_refresh = 1; 3785 want_refresh = 1;
3782 3786
3783 for (int y = 0; y < ov_h; y++) 3787 for (int y = 0; y < ov.h; y++)
3784 { 3788 {
3785 delete [] ov_text[y]; 3789 delete [] ov.text[y];
3786 delete [] ov_rend[y]; 3790 delete [] ov.rend[y];
3787 } 3791 }
3788 3792
3789 delete [] ov_text; ov_text = 0; 3793 delete [] ov.text; ov.text = 0;
3790 delete [] ov_rend; ov_rend = 0; 3794 delete [] ov.rend; ov.rend = 0;
3791} 3795}
3792 3796
3793void 3797void
3794rxvt_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
3795{ 3799{
3796 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) 3800 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2)
3797 return; 3801 return;
3798 3802
3799 x++, y++; 3803 x++, y++;
3800 3804
3801 ov_text[y][x] = text; 3805 ov.text[y][x] = text;
3802 ov_rend[y][x] = rend; 3806 ov.rend[y][x] = rend;
3803} 3807}
3804 3808
3805void 3809void
3806rxvt_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
3807{ 3811{
3826} 3830}
3827 3831
3828void 3832void
3829rxvt_term::scr_swap_overlay () NOTHROW 3833rxvt_term::scr_swap_overlay () NOTHROW
3830{ 3834{
3831 if (!ov_text) 3835 if (!ov.text)
3832 return; 3836 return;
3833 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
3834 // swap screen mem with overlay 3843 // swap screen mem with overlay
3835 for (int y = ov_h; y--; ) 3844 for (int y = ov.h; y--; )
3836 { 3845 {
3837 text_t *t1 = ov_text[y]; 3846 text_t *t1 = ov.text[y];
3838 rend_t *r1 = ov_rend[y]; 3847 rend_t *r1 = ov.rend[y];
3839 3848
3840 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;
3841 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;
3842 3851
3843 for (int x = ov_w; x--; ) 3852 for (int x = ov.w; x--; )
3844 { 3853 {
3845 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3854 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3846 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));
3847 } 3856 }
3848 } 3857 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines