… | |
… | |
158 | * ------------------------------------------------------------------------- */ |
158 | * ------------------------------------------------------------------------- */ |
159 | |
159 | |
160 | void |
160 | void |
161 | rxvt_term::scr_reset () |
161 | rxvt_term::scr_reset () |
162 | { |
162 | { |
163 | scr_soft_reset (); |
|
|
164 | |
|
|
165 | view_start = 0; |
163 | view_start = 0; |
166 | num_scr = 0; |
164 | num_scr = 0; |
167 | |
165 | |
168 | if (ncol == 0) |
166 | if (ncol == 0) |
169 | ncol = 80; |
167 | ncol = 80; |
… | |
… | |
280 | |
278 | |
281 | if (top_row) |
279 | if (top_row) |
282 | { |
280 | { |
283 | // 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 |
284 | // 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 |
285 | |
284 | |
286 | row_col_t ocur = screen.cur; |
285 | row_col_t ocur = screen.cur; |
287 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
288 | |
287 | |
289 | do |
288 | do |
… | |
… | |
395 | |
394 | |
396 | clamp_it (screen.cur.row, 0, nrow - 1); |
395 | clamp_it (screen.cur.row, 0, nrow - 1); |
397 | clamp_it (screen.cur.col, 0, ncol - 1); |
396 | clamp_it (screen.cur.col, 0, ncol - 1); |
398 | } |
397 | } |
399 | |
398 | |
|
|
399 | free (tabs); |
|
|
400 | tabs = (char *)rxvt_malloc (ncol); |
|
|
401 | |
|
|
402 | for (int col = ncol; --col; ) |
|
|
403 | tabs [col] = col % TABSIZE == 0; |
|
|
404 | |
400 | CLEAR_ALL_SELECTION (); |
405 | CLEAR_ALL_SELECTION (); |
401 | |
406 | |
402 | prev_nrow = nrow; |
407 | prev_nrow = nrow; |
403 | prev_ncol = ncol; |
408 | prev_ncol = ncol; |
404 | |
409 | |
… | |
… | |
436 | void |
441 | void |
437 | rxvt_term::scr_poweron () |
442 | rxvt_term::scr_poweron () |
438 | { |
443 | { |
439 | scr_release (); |
444 | scr_release (); |
440 | prev_nrow = prev_ncol = 0; |
445 | prev_nrow = prev_ncol = 0; |
|
|
446 | rvideo_mode = false; |
|
|
447 | scr_soft_reset (); |
441 | scr_reset (); |
448 | scr_reset (); |
442 | |
449 | |
443 | scr_clear (true); |
450 | scr_clear (true); |
444 | scr_refresh (); |
451 | scr_refresh (); |
445 | } |
452 | } |
… | |
… | |
450 | /* only affects modes, nothing drastic such as clearing the screen */ |
457 | /* only affects modes, nothing drastic such as clearing the screen */ |
451 | #if ENABLE_OVERLAY |
458 | #if ENABLE_OVERLAY |
452 | scr_overlay_off (); |
459 | scr_overlay_off (); |
453 | #endif |
460 | #endif |
454 | |
461 | |
455 | rvideo_mode = false; |
|
|
456 | |
|
|
457 | if (current_screen != PRIMARY) |
462 | if (current_screen != PRIMARY) |
458 | scr_swap_screen (); |
463 | scr_swap_screen (); |
459 | |
|
|
460 | free (tabs); |
|
|
461 | tabs = (char *)rxvt_malloc (ncol); |
|
|
462 | |
|
|
463 | for (int col = ncol; --col; ) |
|
|
464 | tabs [col] = col % TABSIZE == 0; |
|
|
465 | |
464 | |
466 | scr_scroll_region (0, MAX_ROWS - 1); |
465 | scr_scroll_region (0, MAX_ROWS - 1); |
467 | scr_rendition (0, ~RS_None); |
466 | scr_rendition (0, ~RS_None); |
468 | scr_insert_mode (0); |
467 | scr_insert_mode (0); |
469 | } |
468 | } |
… | |
… | |
1342 | if (row >= nrow) /* Out Of Bounds */ |
1341 | if (row >= nrow) /* Out Of Bounds */ |
1343 | return; |
1342 | return; |
1344 | |
1343 | |
1345 | min_it (num, nrow - row); |
1344 | min_it (num, nrow - row); |
1346 | |
1345 | |
1347 | /*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. |
1348 | if (rstyle & (RS_RVid | RS_Uline)) |
1349 | if (rstyle & (RS_RVid | RS_Uline)) |
1349 | ren = (rend_t) ~RS_None; |
1350 | ren = (rend_t) ~RS_None; |
1350 | else if (GET_BASEBG (rstyle) == Color_bg) |
1351 | else if (GET_BASEBG (rstyle) == Color_bg) |
1351 | { |
1352 | { |
1352 | ren = DEFAULT_RSTYLE; |
1353 | ren = DEFAULT_RSTYLE; |
… | |
… | |
1374 | } |
1375 | } |
1375 | |
1376 | |
1376 | for (; num--; row++) |
1377 | for (; num--; row++) |
1377 | { |
1378 | { |
1378 | scr_blank_screen_mem (ROW(row), rstyle); |
1379 | scr_blank_screen_mem (ROW(row), rstyle); |
|
|
1380 | |
1379 | if (!view_start) |
1381 | if (!view_start) |
1380 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1382 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1381 | } |
1383 | } |
1382 | } |
1384 | } |
1383 | |
1385 | |
… | |
… | |
1538 | { |
1540 | { |
1539 | line->t[col] = line->t[col + count]; |
1541 | line->t[col] = line->t[col + count]; |
1540 | line->r[col] = line->r[col + count]; |
1542 | line->r[col] = line->r[col + count]; |
1541 | } |
1543 | } |
1542 | |
1544 | |
1543 | scr_blank_line (*line, ncol - count, count, |
1545 | scr_blank_line (*line, ncol - count, count, rstyle); |
1544 | line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask)); |
|
|
1545 | |
1546 | |
1546 | if (selection.op && current_screen == selection.screen |
1547 | if (selection.op && current_screen == selection.screen |
1547 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1548 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1548 | { |
1549 | { |
1549 | if (selection.end.row != screen.cur.row |
1550 | if (selection.end.row != screen.cur.row |
… | |
… | |
2007 | * screen.text/screen.rend contain what the screen will change to. |
2008 | * screen.text/screen.rend contain what the screen will change to. |
2008 | */ |
2009 | */ |
2009 | void |
2010 | void |
2010 | rxvt_term::scr_refresh () NOTHROW |
2011 | rxvt_term::scr_refresh () NOTHROW |
2011 | { |
2012 | { |
2012 | unsigned char have_bg, |
|
|
2013 | showcursor; /* show the cursor */ |
|
|
2014 | int16_t col, row, /* column/row we're processing */ |
2013 | int16_t col, row, /* column/row we're processing */ |
2015 | ocrow; /* old cursor row */ |
2014 | ocrow; /* old cursor row */ |
2016 | int i; /* tmp */ |
2015 | int i; /* tmp */ |
2017 | #ifndef NO_CURSORCOLOR |
2016 | #ifndef NO_CURSORCOLOR |
2018 | rend_t cc1; /* store colours at cursor position (s) */ |
2017 | rend_t cc1; /* store colours at cursor position (s) */ |
… | |
… | |
2029 | /* |
2028 | /* |
2030 | * A: set up vars |
2029 | * A: set up vars |
2031 | */ |
2030 | */ |
2032 | refresh_count = 0; |
2031 | refresh_count = 0; |
2033 | |
2032 | |
|
|
2033 | unsigned int old_screen_flags = screen.flags; |
2034 | have_bg = 0; |
2034 | char have_bg = 0; |
2035 | #ifdef HAVE_BG_PIXMAP |
2035 | #ifdef HAVE_BG_PIXMAP |
2036 | have_bg = bgPixmap.pixmap != None; |
2036 | have_bg = bgPixmap.pixmap != None; |
2037 | #endif |
2037 | #endif |
2038 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2038 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2039 | |
2039 | |
2040 | /* |
2040 | /* |
2041 | * B: reverse any characters which are selected |
2041 | * B: reverse any characters which are selected |
2042 | */ |
2042 | */ |
2043 | 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; |
2044 | |
2051 | |
2045 | /* |
2052 | /* |
2046 | * C: set the cursor character (s) |
2053 | * C: set the cursor character (s) |
2047 | */ |
2054 | */ |
2048 | { |
2055 | { |
2049 | unsigned char setoldcursor; |
2056 | unsigned char setoldcursor; |
2050 | |
2057 | |
2051 | showcursor = (screen.flags & Screen_VisibleCursor); |
|
|
2052 | #ifdef CURSOR_BLINK |
2058 | #ifdef CURSOR_BLINK |
2053 | if (hidden_cursor) |
2059 | if (hidden_cursor) |
2054 | showcursor = 0; |
2060 | showcursor = 0; |
2055 | #endif |
2061 | #endif |
2056 | |
2062 | |
… | |
… | |
2129 | oldcursor.col = screen.cur.col; |
2135 | oldcursor.col = screen.cur.col; |
2130 | } |
2136 | } |
2131 | } |
2137 | } |
2132 | } |
2138 | } |
2133 | |
2139 | |
2134 | HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
|
|
2135 | #if ENABLE_OVERLAY |
|
|
2136 | scr_swap_overlay (); |
|
|
2137 | #endif |
|
|
2138 | |
|
|
2139 | #ifndef NO_SLOW_LINK_SUPPORT |
2140 | #ifndef NO_SLOW_LINK_SUPPORT |
2140 | /* |
2141 | /* |
2141 | * D: CopyArea pass - very useful for slower links |
2142 | * D: CopyArea pass - very useful for slower links |
2142 | * This has been deliberately kept simple. |
2143 | * This has been deliberately kept simple. |
2143 | */ |
2144 | */ |
… | |
… | |
2249 | for (i = 0; ++col < ncol; ) |
2250 | for (i = 0; ++col < ncol; ) |
2250 | { |
2251 | { |
2251 | if (stp[col] == NOCHAR) |
2252 | if (stp[col] == NOCHAR) |
2252 | { |
2253 | { |
2253 | dtp[col] = stp[col]; |
2254 | dtp[col] = stp[col]; |
2254 | drp[col] = rend; |
2255 | drp[col] = srp[col]; |
|
|
2256 | |
2255 | count++; |
2257 | count++; |
2256 | i++; |
2258 | i++; |
2257 | |
2259 | |
2258 | continue; |
2260 | continue; |
2259 | } |
2261 | } |
… | |
… | |
2415 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2417 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2416 | } |
2418 | } |
2417 | } /* for (col....) */ |
2419 | } /* for (col....) */ |
2418 | } /* for (row....) */ |
2420 | } /* for (row....) */ |
2419 | |
2421 | |
2420 | #if ENABLE_OVERLAY |
|
|
2421 | scr_swap_overlay (); |
|
|
2422 | #endif |
|
|
2423 | HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
|
|
2424 | |
|
|
2425 | /* |
2422 | /* |
2426 | * G: cleanup cursor and display outline cursor if necessary |
2423 | * G: cleanup cursor and display outline cursor if necessary |
2427 | */ |
2424 | */ |
2428 | if (showcursor) |
2425 | if (showcursor) |
2429 | { |
2426 | { |
… | |
… | |
2467 | } |
2464 | } |
2468 | |
2465 | |
2469 | /* |
2466 | /* |
2470 | * H: cleanup selection |
2467 | * H: cleanup selection |
2471 | */ |
2468 | */ |
|
|
2469 | #if ENABLE_OVERLAY |
|
|
2470 | scr_swap_overlay (); |
|
|
2471 | #endif |
|
|
2472 | HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
|
|
2473 | |
2472 | scr_reverse_selection (); |
2474 | scr_reverse_selection (); |
2473 | |
2475 | |
|
|
2476 | screen.flags = old_screen_flags; |
2474 | num_scr = 0; |
2477 | num_scr = 0; |
2475 | num_scr_allow = 1; |
2478 | num_scr_allow = 1; |
2476 | } |
2479 | } |
2477 | |
2480 | |
2478 | void |
2481 | void |
… | |
… | |
3737 | h += 2; min_it (h, nrow); |
3740 | h += 2; min_it (h, nrow); |
3738 | |
3741 | |
3739 | x -= 1; clamp_it (x, 0, ncol - w); |
3742 | x -= 1; clamp_it (x, 0, ncol - w); |
3740 | y -= 1; clamp_it (y, 0, nrow - h); |
3743 | y -= 1; clamp_it (y, 0, nrow - h); |
3741 | |
3744 | |
3742 | ov_x = x; ov_y = y; |
3745 | ov.x = x; ov.y = y; |
3743 | ov_w = w; ov_h = h; |
3746 | ov.w = w; ov.h = h; |
3744 | |
3747 | |
3745 | ov_text = new text_t *[h]; |
3748 | ov.text = new text_t *[h]; |
3746 | ov_rend = new rend_t *[h]; |
3749 | ov.rend = new rend_t *[h]; |
3747 | |
3750 | |
3748 | for (y = 0; y < h; y++) |
3751 | for (y = 0; y < h; y++) |
3749 | { |
3752 | { |
3750 | text_t *tp = ov_text[y] = new text_t[w]; |
3753 | text_t *tp = ov.text[y] = new text_t[w]; |
3751 | rend_t *rp = ov_rend[y] = new rend_t[w]; |
3754 | rend_t *rp = ov.rend[y] = new rend_t[w]; |
3752 | |
3755 | |
3753 | text_t t0, t1, t2; |
3756 | text_t t0, t1, t2; |
3754 | rend_t r = OVERLAY_RSTYLE; |
3757 | rend_t r = OVERLAY_RSTYLE; |
3755 | |
3758 | |
3756 | if (y == 0) |
3759 | if (y == 0) |
… | |
… | |
3775 | } |
3778 | } |
3776 | |
3779 | |
3777 | void |
3780 | void |
3778 | rxvt_term::scr_overlay_off () NOTHROW |
3781 | rxvt_term::scr_overlay_off () NOTHROW |
3779 | { |
3782 | { |
3780 | if (!ov_text) |
3783 | if (!ov.text) |
3781 | return; |
3784 | return; |
3782 | |
3785 | |
3783 | want_refresh = 1; |
3786 | want_refresh = 1; |
3784 | |
3787 | |
3785 | for (int y = 0; y < ov_h; y++) |
3788 | for (int y = 0; y < ov.h; y++) |
3786 | { |
3789 | { |
3787 | delete [] ov_text[y]; |
3790 | delete [] ov.text[y]; |
3788 | delete [] ov_rend[y]; |
3791 | delete [] ov.rend[y]; |
3789 | } |
3792 | } |
3790 | |
3793 | |
3791 | delete [] ov_text; ov_text = 0; |
3794 | delete [] ov.text; ov.text = 0; |
3792 | delete [] ov_rend; ov_rend = 0; |
3795 | delete [] ov.rend; ov.rend = 0; |
3793 | } |
3796 | } |
3794 | |
3797 | |
3795 | void |
3798 | void |
3796 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW |
3799 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW |
3797 | { |
3800 | { |
3798 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
3801 | if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2) |
3799 | return; |
3802 | return; |
3800 | |
3803 | |
3801 | x++, y++; |
3804 | x++, y++; |
3802 | |
3805 | |
3803 | ov_text[y][x] = text; |
3806 | ov.text[y][x] = text; |
3804 | ov_rend[y][x] = rend; |
3807 | ov.rend[y][x] = rend; |
3805 | } |
3808 | } |
3806 | |
3809 | |
3807 | void |
3810 | void |
3808 | rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW |
3811 | rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW |
3809 | { |
3812 | { |
… | |
… | |
3828 | } |
3831 | } |
3829 | |
3832 | |
3830 | void |
3833 | void |
3831 | rxvt_term::scr_swap_overlay () NOTHROW |
3834 | rxvt_term::scr_swap_overlay () NOTHROW |
3832 | { |
3835 | { |
3833 | if (!ov_text) |
3836 | if (!ov.text) |
3834 | return; |
3837 | return; |
3835 | |
3838 | |
|
|
3839 | // hide cursor if it is within the overlay area |
|
|
3840 | if (IN_RANGE_EXC (screen.cur.col - ov.x, 0, ov.w) |
|
|
3841 | && IN_RANGE_EXC (screen.cur.row - ov.y, 0, ov.h)) |
|
|
3842 | screen.flags &= ~Screen_VisibleCursor; |
|
|
3843 | |
3836 | // swap screen mem with overlay |
3844 | // swap screen mem with overlay |
3837 | for (int y = ov_h; y--; ) |
3845 | for (int y = ov.h; y--; ) |
3838 | { |
3846 | { |
3839 | text_t *t1 = ov_text[y]; |
3847 | text_t *t1 = ov.text[y]; |
3840 | rend_t *r1 = ov_rend[y]; |
3848 | rend_t *r1 = ov.rend[y]; |
3841 | |
3849 | |
3842 | text_t *t2 = ROW(y + ov_y + view_start).t + ov_x; |
3850 | text_t *t2 = ROW(y + ov.y + view_start).t + ov.x; |
3843 | rend_t *r2 = ROW(y + ov_y + view_start).r + ov_x; |
3851 | rend_t *r2 = ROW(y + ov.y + view_start).r + ov.x; |
3844 | |
3852 | |
3845 | for (int x = ov_w; x--; ) |
3853 | for (int x = ov.w; x--; ) |
3846 | { |
3854 | { |
3847 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3855 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3848 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3856 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3849 | } |
3857 | } |
3850 | } |
3858 | } |