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.331 by sf-exg, Wed Jan 6 17:52:43 2010 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
288 { 289 {
289 p = MOD (p - 1, prev_total_rows); 290 p = MOD (p - 1, prev_total_rows);
290#ifdef DEBUG_STRICT
291 assert (old_buf [MOD (p, prev_total_rows)].t); 291 assert (old_buf [MOD (p, prev_total_rows)].t);
292#endif
293 int plines = 1; 292 int plines = 1;
294 int llen = old_buf [MOD (p, prev_total_rows)].l; 293 int llen = old_buf [MOD (p, prev_total_rows)].l;
295 294
296 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) 295 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
297 { 296 {
393 392
394 clamp_it (screen.cur.row, 0, nrow - 1); 393 clamp_it (screen.cur.row, 0, nrow - 1);
395 clamp_it (screen.cur.col, 0, ncol - 1); 394 clamp_it (screen.cur.col, 0, ncol - 1);
396 } 395 }
397 396
397 free (tabs);
398 tabs = (char *)rxvt_malloc (ncol);
399
400 for (int col = ncol; --col; )
401 tabs [col] = col % TABSIZE == 0;
402
398 CLEAR_ALL_SELECTION (); 403 CLEAR_ALL_SELECTION ();
399 404
400 prev_nrow = nrow; 405 prev_nrow = nrow;
401 prev_ncol = ncol; 406 prev_ncol = ncol;
402 407
434void 439void
435rxvt_term::scr_poweron () 440rxvt_term::scr_poweron ()
436{ 441{
437 scr_release (); 442 scr_release ();
438 prev_nrow = prev_ncol = 0; 443 prev_nrow = prev_ncol = 0;
444 rvideo_mode = false;
439 scr_soft_reset (); 445 scr_soft_reset ();
440 scr_reset (); 446 scr_reset ();
441 447
442 scr_clear (true); 448 scr_clear (true);
443 scr_refresh (); 449 scr_refresh ();
449 /* only affects modes, nothing drastic such as clearing the screen */ 455 /* only affects modes, nothing drastic such as clearing the screen */
450#if ENABLE_OVERLAY 456#if ENABLE_OVERLAY
451 scr_overlay_off (); 457 scr_overlay_off ();
452#endif 458#endif
453 459
454 rvideo_mode = false;
455
456 if (current_screen != PRIMARY) 460 if (current_screen != PRIMARY)
457 scr_swap_screen (); 461 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 462
465 scr_scroll_region (0, MAX_ROWS - 1); 463 scr_scroll_region (0, MAX_ROWS - 1);
466 scr_rendition (0, ~RS_None); 464 scr_rendition (0, ~RS_None);
467 scr_insert_mode (0); 465 scr_insert_mode (0);
468} 466}
510 } 508 }
511 509
512 /* boundary check in case screen size changed between SAVE and RESTORE */ 510 /* boundary check in case screen size changed between SAVE and RESTORE */
513 min_it (s->cur.row, nrow - 1); 511 min_it (s->cur.row, nrow - 1);
514 min_it (s->cur.col, ncol - 1); 512 min_it (s->cur.col, ncol - 1);
515#ifdef DEBUG_STRICT
516 assert (s->cur.row >= 0); 513 assert (s->cur.row >= 0);
517 assert (s->cur.col >= 0); 514 assert (s->cur.col >= 0);
518#endif
519} 515}
520 516
521void 517void
522rxvt_term::scr_swap_screen () 518rxvt_term::scr_swap_screen ()
523{ 519{
783 scr_scroll_text (screen.tscroll, screen.bscroll, minlines); 779 scr_scroll_text (screen.tscroll, screen.bscroll, minlines);
784 screen.cur.row -= minlines; 780 screen.cur.row -= minlines;
785 } 781 }
786 } 782 }
787 783
788#ifdef DEBUG_STRICT
789 assert (screen.cur.col < ncol); 784 assert (screen.cur.col < ncol);
790 assert (screen.cur.row < nrow 785 assert (screen.cur.row < nrow
791 && screen.cur.row >= top_row); 786 && screen.cur.row >= top_row);
792#endif
793 int row = screen.cur.row; 787 int row = screen.cur.row;
794 788
795 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 789 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
796 790
797 line_t *line = &ROW(row); 791 line_t *line = &ROW(row);
1001#endif 995#endif
1002 } 996 }
1003 997
1004 max_it (line->l, screen.cur.col); 998 max_it (line->l, screen.cur.col);
1005 999
1006#ifdef DEBUG_STRICT
1007 assert (screen.cur.row >= 0); 1000 assert (screen.cur.row >= 0);
1008#endif
1009} 1001}
1010 1002
1011/* ------------------------------------------------------------------------- */ 1003/* ------------------------------------------------------------------------- */
1012/* 1004/*
1013 * Process Backspace. Move back the cursor back a position, wrap if have to 1005 * Process Backspace. Move back the cursor back a position, wrap if have to
1341 if (row >= nrow) /* Out Of Bounds */ 1333 if (row >= nrow) /* Out Of Bounds */
1342 return; 1334 return;
1343 1335
1344 min_it (num, nrow - row); 1336 min_it (num, nrow - row);
1345 1337
1346 /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */ 1338 // TODO: the code below does not work when view_start != 0
1339 // the workaround is to disable the clear and use a normal refresh
1340 // when view_start != 0. mysterious.
1347 if (rstyle & (RS_RVid | RS_Uline)) 1341 if (rstyle & (RS_RVid | RS_Uline))
1348 ren = (rend_t) ~RS_None; 1342 ren = (rend_t) ~RS_None;
1349 else if (GET_BASEBG (rstyle) == Color_bg) 1343 else if (GET_BASEBG (rstyle) == Color_bg)
1350 { 1344 {
1351 ren = DEFAULT_RSTYLE; 1345 ren = DEFAULT_RSTYLE;
1352 1346
1353 if (mapped) 1347 if (mapped && !view_start)
1354 XClearArea (dpy, vt, 0, 1348 XClearArea (dpy, vt, 0,
1355 Row2Pixel (row), (unsigned int)width, 1349 Row2Pixel (row - view_start), (unsigned int)width,
1356 (unsigned int)Height2Pixel (num), False); 1350 (unsigned int)Height2Pixel (num), False);
1357 } 1351 }
1358 else 1352 else
1359 { 1353 {
1360 ren = rstyle & (RS_fgMask | RS_bgMask); 1354 ren = rstyle & (RS_fgMask | RS_bgMask);
1361 1355
1356 if (mapped && !view_start)
1357 {
1362 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1358 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1363 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1359 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1364 XFillRectangle (dpy, vt, gc, 1360 XFillRectangle (dpy, vt, gc,
1365 0, Row2Pixel (row), 1361 0, Row2Pixel (row - view_start),
1366 (unsigned int)width, 1362 (unsigned int)width,
1367 (unsigned int)Height2Pixel (num)); 1363 (unsigned int)Height2Pixel (num));
1368 gcvalue.foreground = pix_colors[Color_fg]; 1364 gcvalue.foreground = pix_colors[Color_fg];
1369 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1365 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1366 }
1370 } 1367 }
1371 1368
1372 for (; num--; row++) 1369 for (; num--; row++)
1373 { 1370 {
1374 scr_blank_screen_mem (ROW(row), rstyle); 1371 scr_blank_screen_mem (ROW(row), rstyle);
1372
1373 if (!view_start)
1375 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1374 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1376 } 1375 }
1377} 1376}
1378 1377
1379#if !ENABLE_MINIMAL 1378#if !ENABLE_MINIMAL
1380void 1379void
1533 { 1532 {
1534 line->t[col] = line->t[col + count]; 1533 line->t[col] = line->t[col + count];
1535 line->r[col] = line->r[col + count]; 1534 line->r[col] = line->r[col + count];
1536 } 1535 }
1537 1536
1538 scr_blank_line (*line, ncol - count, count, 1537 scr_blank_line (*line, ncol - count, count, rstyle);
1539 line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask));
1540 1538
1541 if (selection.op && current_screen == selection.screen 1539 if (selection.op && current_screen == selection.screen
1542 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1540 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1543 { 1541 {
1544 if (selection.end.row != screen.cur.row 1542 if (selection.end.row != screen.cur.row
1935 1933
1936 bell_ev.start (VISUAL_BELL_DURATION); 1934 bell_ev.start (VISUAL_BELL_DURATION);
1937 } 1935 }
1938 else 1936 else
1939 XBell (dpy, 0); 1937 XBell (dpy, 0);
1938 HOOK_INVOKE ((this, HOOK_BELL, DT_END));
1940#endif 1939#endif
1941} 1940}
1942 1941
1943/* ------------------------------------------------------------------------- */ 1942/* ------------------------------------------------------------------------- */
1944/* ARGSUSED */ 1943/* ARGSUSED */
1963 row_start = view_start; 1962 row_start = view_start;
1964 } 1963 }
1965 1964
1966 wctomb (0, 0); 1965 wctomb (0, 0);
1967 1966
1968 for (int r1 = 0; r1 < nrows; r1++) 1967 for (int r1 = row_start; r1 < row_start + nrows; r1++)
1969 { 1968 {
1970 text_t *tp = ROW(r1).t; 1969 text_t *tp = ROW(r1).t;
1971 int len = ROW(r1).l; 1970 int len = ROW(r1).l;
1972 1971
1973 for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN 1972 for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN
2002 * screen.text/screen.rend contain what the screen will change to. 2001 * screen.text/screen.rend contain what the screen will change to.
2003 */ 2002 */
2004void 2003void
2005rxvt_term::scr_refresh () NOTHROW 2004rxvt_term::scr_refresh () NOTHROW
2006{ 2005{
2007 unsigned char have_bg,
2008 showcursor; /* show the cursor */
2009 int16_t col, row, /* column/row we're processing */ 2006 int16_t col, row, /* column/row we're processing */
2010 ocrow; /* old cursor row */ 2007 ocrow; /* old cursor row */
2011 int i; /* tmp */ 2008 int i; /* tmp */
2012#ifndef NO_CURSORCOLOR 2009#ifndef NO_CURSORCOLOR
2013 rend_t cc1; /* store colours at cursor position (s) */ 2010 rend_t cc1; /* store colours at cursor position (s) */
2024 /* 2021 /*
2025 * A: set up vars 2022 * A: set up vars
2026 */ 2023 */
2027 refresh_count = 0; 2024 refresh_count = 0;
2028 2025
2026 unsigned int old_screen_flags = screen.flags;
2029 have_bg = 0; 2027 char have_bg = 0;
2030#ifdef HAVE_BG_PIXMAP 2028#ifdef HAVE_BG_PIXMAP
2031 have_bg = bgPixmap.pixmap != None; 2029 have_bg = bgPixmap.pixmap != None;
2032#endif 2030#endif
2033 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2031 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
2034 2032
2035 /* 2033 /*
2036 * B: reverse any characters which are selected 2034 * B: reverse any characters which are selected
2037 */ 2035 */
2038 scr_reverse_selection (); 2036 scr_reverse_selection ();
2037
2038 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2039#if ENABLE_OVERLAY
2040 scr_swap_overlay ();
2041#endif
2042
2043 char showcursor = screen.flags & Screen_VisibleCursor;
2039 2044
2040 /* 2045 /*
2041 * C: set the cursor character (s) 2046 * C: set the cursor character (s)
2042 */ 2047 */
2043 { 2048 {
2044 unsigned char setoldcursor; 2049 unsigned char setoldcursor;
2045 2050
2046 showcursor = (screen.flags & Screen_VisibleCursor);
2047#ifdef CURSOR_BLINK 2051#ifdef CURSOR_BLINK
2048 if (hidden_cursor) 2052 if (hidden_cursor)
2049 showcursor = 0; 2053 showcursor = 0;
2050#endif 2054#endif
2051 2055
2124 oldcursor.col = screen.cur.col; 2128 oldcursor.col = screen.cur.col;
2125 } 2129 }
2126 } 2130 }
2127 } 2131 }
2128 2132
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 2133#ifndef NO_SLOW_LINK_SUPPORT
2135 /* 2134 /*
2136 * D: CopyArea pass - very useful for slower links 2135 * D: CopyArea pass - very useful for slower links
2137 * This has been deliberately kept simple. 2136 * This has been deliberately kept simple.
2138 */ 2137 */
2244 for (i = 0; ++col < ncol; ) 2243 for (i = 0; ++col < ncol; )
2245 { 2244 {
2246 if (stp[col] == NOCHAR) 2245 if (stp[col] == NOCHAR)
2247 { 2246 {
2248 dtp[col] = stp[col]; 2247 dtp[col] = stp[col];
2249 drp[col] = rend; 2248 drp[col] = srp[col];
2249
2250 count++; 2250 count++;
2251 i++; 2251 i++;
2252 2252
2253 continue; 2253 continue;
2254 } 2254 }
2410 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2410 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2411 } 2411 }
2412 } /* for (col....) */ 2412 } /* for (col....) */
2413 } /* for (row....) */ 2413 } /* for (row....) */
2414 2414
2415#if ENABLE_OVERLAY
2416 scr_swap_overlay ();
2417#endif
2418 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2419
2420 /* 2415 /*
2421 * G: cleanup cursor and display outline cursor if necessary 2416 * G: cleanup cursor and display outline cursor if necessary
2422 */ 2417 */
2423 if (showcursor) 2418 if (showcursor)
2424 { 2419 {
2462 } 2457 }
2463 2458
2464 /* 2459 /*
2465 * H: cleanup selection 2460 * H: cleanup selection
2466 */ 2461 */
2462#if ENABLE_OVERLAY
2463 scr_swap_overlay ();
2464#endif
2465 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2466
2467 scr_reverse_selection (); 2467 scr_reverse_selection ();
2468 2468
2469 screen.flags = old_screen_flags;
2469 num_scr = 0; 2470 num_scr = 0;
2470 num_scr_allow = 1; 2471 num_scr_allow = 1;
2471} 2472}
2472 2473
2473void 2474void
3732 h += 2; min_it (h, nrow); 3733 h += 2; min_it (h, nrow);
3733 3734
3734 x -= 1; clamp_it (x, 0, ncol - w); 3735 x -= 1; clamp_it (x, 0, ncol - w);
3735 y -= 1; clamp_it (y, 0, nrow - h); 3736 y -= 1; clamp_it (y, 0, nrow - h);
3736 3737
3737 ov_x = x; ov_y = y; 3738 ov.x = x; ov.y = y;
3738 ov_w = w; ov_h = h; 3739 ov.w = w; ov.h = h;
3739 3740
3740 ov_text = new text_t *[h]; 3741 ov.text = new text_t *[h];
3741 ov_rend = new rend_t *[h]; 3742 ov.rend = new rend_t *[h];
3742 3743
3743 for (y = 0; y < h; y++) 3744 for (y = 0; y < h; y++)
3744 { 3745 {
3745 text_t *tp = ov_text[y] = new text_t[w]; 3746 text_t *tp = ov.text[y] = new text_t[w];
3746 rend_t *rp = ov_rend[y] = new rend_t[w]; 3747 rend_t *rp = ov.rend[y] = new rend_t[w];
3747 3748
3748 text_t t0, t1, t2; 3749 text_t t0, t1, t2;
3749 rend_t r = OVERLAY_RSTYLE; 3750 rend_t r = OVERLAY_RSTYLE;
3750 3751
3751 if (y == 0) 3752 if (y == 0)
3770} 3771}
3771 3772
3772void 3773void
3773rxvt_term::scr_overlay_off () NOTHROW 3774rxvt_term::scr_overlay_off () NOTHROW
3774{ 3775{
3775 if (!ov_text) 3776 if (!ov.text)
3776 return; 3777 return;
3777 3778
3778 want_refresh = 1; 3779 want_refresh = 1;
3779 3780
3780 for (int y = 0; y < ov_h; y++) 3781 for (int y = 0; y < ov.h; y++)
3781 { 3782 {
3782 delete [] ov_text[y]; 3783 delete [] ov.text[y];
3783 delete [] ov_rend[y]; 3784 delete [] ov.rend[y];
3784 } 3785 }
3785 3786
3786 delete [] ov_text; ov_text = 0; 3787 delete [] ov.text; ov.text = 0;
3787 delete [] ov_rend; ov_rend = 0; 3788 delete [] ov.rend; ov.rend = 0;
3788} 3789}
3789 3790
3790void 3791void
3791rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW 3792rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW
3792{ 3793{
3793 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) 3794 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2)
3794 return; 3795 return;
3795 3796
3796 x++, y++; 3797 x++, y++;
3797 3798
3798 ov_text[y][x] = text; 3799 ov.text[y][x] = text;
3799 ov_rend[y][x] = rend; 3800 ov.rend[y][x] = rend;
3800} 3801}
3801 3802
3802void 3803void
3803rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW 3804rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW
3804{ 3805{
3823} 3824}
3824 3825
3825void 3826void
3826rxvt_term::scr_swap_overlay () NOTHROW 3827rxvt_term::scr_swap_overlay () NOTHROW
3827{ 3828{
3828 if (!ov_text) 3829 if (!ov.text)
3829 return; 3830 return;
3830 3831
3832 // hide cursor if it is within the overlay area
3833 if (IN_RANGE_EXC (screen.cur.col - ov.x, 0, ov.w)
3834 && IN_RANGE_EXC (screen.cur.row - ov.y, 0, ov.h))
3835 screen.flags &= ~Screen_VisibleCursor;
3836
3831 // swap screen mem with overlay 3837 // swap screen mem with overlay
3832 for (int y = ov_h; y--; ) 3838 for (int y = ov.h; y--; )
3833 { 3839 {
3834 text_t *t1 = ov_text[y]; 3840 text_t *t1 = ov.text[y];
3835 rend_t *r1 = ov_rend[y]; 3841 rend_t *r1 = ov.rend[y];
3836 3842
3837 text_t *t2 = ROW(y + ov_y + view_start).t + ov_x; 3843 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; 3844 rend_t *r2 = ROW(y + ov.y + view_start).r + ov.x;
3839 3845
3840 for (int x = ov_w; x--; ) 3846 for (int x = ov.w; x--; )
3841 { 3847 {
3842 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3848 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3843 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3849 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t));
3844 } 3850 }
3845 } 3851 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines