… | |
… | |
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 |
290 | { |
289 | { |
291 | p = MOD (p - 1, prev_total_rows); |
290 | p = MOD (p - 1, prev_total_rows); |
292 | #ifdef DEBUG_STRICT |
|
|
293 | assert (old_buf [MOD (p, prev_total_rows)].t); |
291 | assert (old_buf [MOD (p, prev_total_rows)].t); |
294 | #endif |
|
|
295 | int plines = 1; |
292 | int plines = 1; |
296 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
293 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
297 | |
294 | |
298 | 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 ()) |
299 | { |
296 | { |
… | |
… | |
395 | |
392 | |
396 | clamp_it (screen.cur.row, 0, nrow - 1); |
393 | clamp_it (screen.cur.row, 0, nrow - 1); |
397 | clamp_it (screen.cur.col, 0, ncol - 1); |
394 | clamp_it (screen.cur.col, 0, ncol - 1); |
398 | } |
395 | } |
399 | |
396 | |
|
|
397 | free (tabs); |
|
|
398 | tabs = (char *)rxvt_malloc (ncol); |
|
|
399 | |
|
|
400 | for (int col = ncol; --col; ) |
|
|
401 | tabs [col] = col % TABSIZE == 0; |
|
|
402 | |
400 | CLEAR_ALL_SELECTION (); |
403 | CLEAR_ALL_SELECTION (); |
401 | |
404 | |
402 | prev_nrow = nrow; |
405 | prev_nrow = nrow; |
403 | prev_ncol = ncol; |
406 | prev_ncol = ncol; |
404 | |
407 | |
… | |
… | |
436 | void |
439 | void |
437 | rxvt_term::scr_poweron () |
440 | rxvt_term::scr_poweron () |
438 | { |
441 | { |
439 | scr_release (); |
442 | scr_release (); |
440 | prev_nrow = prev_ncol = 0; |
443 | prev_nrow = prev_ncol = 0; |
|
|
444 | rvideo_mode = false; |
|
|
445 | scr_soft_reset (); |
441 | scr_reset (); |
446 | scr_reset (); |
442 | |
447 | |
443 | scr_clear (true); |
448 | scr_clear (true); |
444 | scr_refresh (); |
449 | scr_refresh (); |
445 | } |
450 | } |
… | |
… | |
450 | /* only affects modes, nothing drastic such as clearing the screen */ |
455 | /* only affects modes, nothing drastic such as clearing the screen */ |
451 | #if ENABLE_OVERLAY |
456 | #if ENABLE_OVERLAY |
452 | scr_overlay_off (); |
457 | scr_overlay_off (); |
453 | #endif |
458 | #endif |
454 | |
459 | |
455 | rvideo_mode = false; |
|
|
456 | |
|
|
457 | if (current_screen != PRIMARY) |
460 | if (current_screen != PRIMARY) |
458 | scr_swap_screen (); |
461 | 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 | |
462 | |
466 | scr_scroll_region (0, MAX_ROWS - 1); |
463 | scr_scroll_region (0, MAX_ROWS - 1); |
467 | scr_rendition (0, ~RS_None); |
464 | scr_rendition (0, ~RS_None); |
468 | scr_insert_mode (0); |
465 | scr_insert_mode (0); |
469 | } |
466 | } |
… | |
… | |
511 | } |
508 | } |
512 | |
509 | |
513 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
510 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
514 | min_it (s->cur.row, nrow - 1); |
511 | min_it (s->cur.row, nrow - 1); |
515 | min_it (s->cur.col, ncol - 1); |
512 | min_it (s->cur.col, ncol - 1); |
516 | #ifdef DEBUG_STRICT |
|
|
517 | assert (s->cur.row >= 0); |
513 | assert (s->cur.row >= 0); |
518 | assert (s->cur.col >= 0); |
514 | assert (s->cur.col >= 0); |
519 | #endif |
|
|
520 | } |
515 | } |
521 | |
516 | |
522 | void |
517 | void |
523 | rxvt_term::scr_swap_screen () |
518 | rxvt_term::scr_swap_screen () |
524 | { |
519 | { |
… | |
… | |
784 | scr_scroll_text (screen.tscroll, screen.bscroll, minlines); |
779 | scr_scroll_text (screen.tscroll, screen.bscroll, minlines); |
785 | screen.cur.row -= minlines; |
780 | screen.cur.row -= minlines; |
786 | } |
781 | } |
787 | } |
782 | } |
788 | |
783 | |
789 | #ifdef DEBUG_STRICT |
|
|
790 | assert (screen.cur.col < ncol); |
784 | assert (screen.cur.col < ncol); |
791 | assert (screen.cur.row < nrow |
785 | assert (screen.cur.row < nrow |
792 | && screen.cur.row >= top_row); |
786 | && screen.cur.row >= top_row); |
793 | #endif |
|
|
794 | int row = screen.cur.row; |
787 | int row = screen.cur.row; |
795 | |
788 | |
796 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
789 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
797 | |
790 | |
798 | line_t *line = &ROW(row); |
791 | line_t *line = &ROW(row); |
… | |
… | |
1002 | #endif |
995 | #endif |
1003 | } |
996 | } |
1004 | |
997 | |
1005 | max_it (line->l, screen.cur.col); |
998 | max_it (line->l, screen.cur.col); |
1006 | |
999 | |
1007 | #ifdef DEBUG_STRICT |
|
|
1008 | assert (screen.cur.row >= 0); |
1000 | assert (screen.cur.row >= 0); |
1009 | #endif |
|
|
1010 | } |
1001 | } |
1011 | |
1002 | |
1012 | /* ------------------------------------------------------------------------- */ |
1003 | /* ------------------------------------------------------------------------- */ |
1013 | /* |
1004 | /* |
1014 | * 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 |
… | |
… | |
1541 | { |
1532 | { |
1542 | line->t[col] = line->t[col + count]; |
1533 | line->t[col] = line->t[col + count]; |
1543 | line->r[col] = line->r[col + count]; |
1534 | line->r[col] = line->r[col + count]; |
1544 | } |
1535 | } |
1545 | |
1536 | |
1546 | scr_blank_line (*line, ncol - count, count, |
1537 | scr_blank_line (*line, ncol - count, count, rstyle); |
1547 | line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask)); |
|
|
1548 | |
1538 | |
1549 | if (selection.op && current_screen == selection.screen |
1539 | if (selection.op && current_screen == selection.screen |
1550 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1540 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1551 | { |
1541 | { |
1552 | if (selection.end.row != screen.cur.row |
1542 | if (selection.end.row != screen.cur.row |
… | |
… | |
1971 | row_start = view_start; |
1961 | row_start = view_start; |
1972 | } |
1962 | } |
1973 | |
1963 | |
1974 | wctomb (0, 0); |
1964 | wctomb (0, 0); |
1975 | |
1965 | |
1976 | for (int r1 = 0; r1 < nrows; r1++) |
1966 | for (int r1 = row_start; r1 < row_start + nrows; r1++) |
1977 | { |
1967 | { |
1978 | text_t *tp = ROW(r1).t; |
1968 | text_t *tp = ROW(r1).t; |
1979 | int len = ROW(r1).l; |
1969 | int len = ROW(r1).l; |
1980 | |
1970 | |
1981 | for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN |
1971 | for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN |
… | |
… | |
2010 | * screen.text/screen.rend contain what the screen will change to. |
2000 | * screen.text/screen.rend contain what the screen will change to. |
2011 | */ |
2001 | */ |
2012 | void |
2002 | void |
2013 | rxvt_term::scr_refresh () NOTHROW |
2003 | rxvt_term::scr_refresh () NOTHROW |
2014 | { |
2004 | { |
2015 | unsigned char have_bg, |
|
|
2016 | showcursor; /* show the cursor */ |
|
|
2017 | int16_t col, row, /* column/row we're processing */ |
2005 | int16_t col, row, /* column/row we're processing */ |
2018 | ocrow; /* old cursor row */ |
2006 | ocrow; /* old cursor row */ |
2019 | int i; /* tmp */ |
2007 | int i; /* tmp */ |
2020 | #ifndef NO_CURSORCOLOR |
2008 | #ifndef NO_CURSORCOLOR |
2021 | rend_t cc1; /* store colours at cursor position (s) */ |
2009 | rend_t cc1; /* store colours at cursor position (s) */ |
… | |
… | |
2032 | /* |
2020 | /* |
2033 | * A: set up vars |
2021 | * A: set up vars |
2034 | */ |
2022 | */ |
2035 | refresh_count = 0; |
2023 | refresh_count = 0; |
2036 | |
2024 | |
|
|
2025 | unsigned int old_screen_flags = screen.flags; |
2037 | have_bg = 0; |
2026 | char have_bg = 0; |
2038 | #ifdef HAVE_BG_PIXMAP |
2027 | #ifdef HAVE_BG_PIXMAP |
2039 | have_bg = bgPixmap.pixmap != None; |
2028 | have_bg = bgPixmap.pixmap != None; |
2040 | #endif |
2029 | #endif |
2041 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2030 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2042 | |
2031 | |
2043 | /* |
2032 | /* |
2044 | * B: reverse any characters which are selected |
2033 | * B: reverse any characters which are selected |
2045 | */ |
2034 | */ |
2046 | scr_reverse_selection (); |
2035 | scr_reverse_selection (); |
|
|
2036 | |
|
|
2037 | HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
|
|
2038 | #if ENABLE_OVERLAY |
|
|
2039 | scr_swap_overlay (); |
|
|
2040 | #endif |
|
|
2041 | |
|
|
2042 | char showcursor = screen.flags & Screen_VisibleCursor; |
2047 | |
2043 | |
2048 | /* |
2044 | /* |
2049 | * C: set the cursor character (s) |
2045 | * C: set the cursor character (s) |
2050 | */ |
2046 | */ |
2051 | { |
2047 | { |
2052 | unsigned char setoldcursor; |
2048 | unsigned char setoldcursor; |
2053 | |
2049 | |
2054 | showcursor = (screen.flags & Screen_VisibleCursor); |
|
|
2055 | #ifdef CURSOR_BLINK |
2050 | #ifdef CURSOR_BLINK |
2056 | if (hidden_cursor) |
2051 | if (hidden_cursor) |
2057 | showcursor = 0; |
2052 | showcursor = 0; |
2058 | #endif |
2053 | #endif |
2059 | |
2054 | |
… | |
… | |
2132 | oldcursor.col = screen.cur.col; |
2127 | oldcursor.col = screen.cur.col; |
2133 | } |
2128 | } |
2134 | } |
2129 | } |
2135 | } |
2130 | } |
2136 | |
2131 | |
2137 | HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
|
|
2138 | #if ENABLE_OVERLAY |
|
|
2139 | scr_swap_overlay (); |
|
|
2140 | #endif |
|
|
2141 | |
|
|
2142 | #ifndef NO_SLOW_LINK_SUPPORT |
2132 | #ifndef NO_SLOW_LINK_SUPPORT |
2143 | /* |
2133 | /* |
2144 | * D: CopyArea pass - very useful for slower links |
2134 | * D: CopyArea pass - very useful for slower links |
2145 | * This has been deliberately kept simple. |
2135 | * This has been deliberately kept simple. |
2146 | */ |
2136 | */ |
… | |
… | |
2252 | for (i = 0; ++col < ncol; ) |
2242 | for (i = 0; ++col < ncol; ) |
2253 | { |
2243 | { |
2254 | if (stp[col] == NOCHAR) |
2244 | if (stp[col] == NOCHAR) |
2255 | { |
2245 | { |
2256 | dtp[col] = stp[col]; |
2246 | dtp[col] = stp[col]; |
2257 | drp[col] = rend; |
2247 | drp[col] = srp[col]; |
|
|
2248 | |
2258 | count++; |
2249 | count++; |
2259 | i++; |
2250 | i++; |
2260 | |
2251 | |
2261 | continue; |
2252 | continue; |
2262 | } |
2253 | } |
… | |
… | |
2418 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2409 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2419 | } |
2410 | } |
2420 | } /* for (col....) */ |
2411 | } /* for (col....) */ |
2421 | } /* for (row....) */ |
2412 | } /* for (row....) */ |
2422 | |
2413 | |
2423 | #if ENABLE_OVERLAY |
|
|
2424 | scr_swap_overlay (); |
|
|
2425 | #endif |
|
|
2426 | HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
|
|
2427 | |
|
|
2428 | /* |
2414 | /* |
2429 | * G: cleanup cursor and display outline cursor if necessary |
2415 | * G: cleanup cursor and display outline cursor if necessary |
2430 | */ |
2416 | */ |
2431 | if (showcursor) |
2417 | if (showcursor) |
2432 | { |
2418 | { |
… | |
… | |
2470 | } |
2456 | } |
2471 | |
2457 | |
2472 | /* |
2458 | /* |
2473 | * H: cleanup selection |
2459 | * H: cleanup selection |
2474 | */ |
2460 | */ |
|
|
2461 | #if ENABLE_OVERLAY |
|
|
2462 | scr_swap_overlay (); |
|
|
2463 | #endif |
|
|
2464 | HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
|
|
2465 | |
2475 | scr_reverse_selection (); |
2466 | scr_reverse_selection (); |
2476 | |
2467 | |
|
|
2468 | screen.flags = old_screen_flags; |
2477 | num_scr = 0; |
2469 | num_scr = 0; |
2478 | num_scr_allow = 1; |
2470 | num_scr_allow = 1; |
2479 | } |
2471 | } |
2480 | |
2472 | |
2481 | void |
2473 | void |
… | |
… | |
3740 | h += 2; min_it (h, nrow); |
3732 | h += 2; min_it (h, nrow); |
3741 | |
3733 | |
3742 | x -= 1; clamp_it (x, 0, ncol - w); |
3734 | x -= 1; clamp_it (x, 0, ncol - w); |
3743 | y -= 1; clamp_it (y, 0, nrow - h); |
3735 | y -= 1; clamp_it (y, 0, nrow - h); |
3744 | |
3736 | |
3745 | ov_x = x; ov_y = y; |
3737 | ov.x = x; ov.y = y; |
3746 | ov_w = w; ov_h = h; |
3738 | ov.w = w; ov.h = h; |
3747 | |
3739 | |
3748 | ov_text = new text_t *[h]; |
3740 | ov.text = new text_t *[h]; |
3749 | ov_rend = new rend_t *[h]; |
3741 | ov.rend = new rend_t *[h]; |
3750 | |
3742 | |
3751 | for (y = 0; y < h; y++) |
3743 | for (y = 0; y < h; y++) |
3752 | { |
3744 | { |
3753 | text_t *tp = ov_text[y] = new text_t[w]; |
3745 | text_t *tp = ov.text[y] = new text_t[w]; |
3754 | rend_t *rp = ov_rend[y] = new rend_t[w]; |
3746 | rend_t *rp = ov.rend[y] = new rend_t[w]; |
3755 | |
3747 | |
3756 | text_t t0, t1, t2; |
3748 | text_t t0, t1, t2; |
3757 | rend_t r = OVERLAY_RSTYLE; |
3749 | rend_t r = OVERLAY_RSTYLE; |
3758 | |
3750 | |
3759 | if (y == 0) |
3751 | if (y == 0) |
… | |
… | |
3778 | } |
3770 | } |
3779 | |
3771 | |
3780 | void |
3772 | void |
3781 | rxvt_term::scr_overlay_off () NOTHROW |
3773 | rxvt_term::scr_overlay_off () NOTHROW |
3782 | { |
3774 | { |
3783 | if (!ov_text) |
3775 | if (!ov.text) |
3784 | return; |
3776 | return; |
3785 | |
3777 | |
3786 | want_refresh = 1; |
3778 | want_refresh = 1; |
3787 | |
3779 | |
3788 | for (int y = 0; y < ov_h; y++) |
3780 | for (int y = 0; y < ov.h; y++) |
3789 | { |
3781 | { |
3790 | delete [] ov_text[y]; |
3782 | delete [] ov.text[y]; |
3791 | delete [] ov_rend[y]; |
3783 | delete [] ov.rend[y]; |
3792 | } |
3784 | } |
3793 | |
3785 | |
3794 | delete [] ov_text; ov_text = 0; |
3786 | delete [] ov.text; ov.text = 0; |
3795 | delete [] ov_rend; ov_rend = 0; |
3787 | delete [] ov.rend; ov.rend = 0; |
3796 | } |
3788 | } |
3797 | |
3789 | |
3798 | void |
3790 | void |
3799 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW |
3791 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW |
3800 | { |
3792 | { |
3801 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
3793 | if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2) |
3802 | return; |
3794 | return; |
3803 | |
3795 | |
3804 | x++, y++; |
3796 | x++, y++; |
3805 | |
3797 | |
3806 | ov_text[y][x] = text; |
3798 | ov.text[y][x] = text; |
3807 | ov_rend[y][x] = rend; |
3799 | ov.rend[y][x] = rend; |
3808 | } |
3800 | } |
3809 | |
3801 | |
3810 | void |
3802 | void |
3811 | rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW |
3803 | rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW |
3812 | { |
3804 | { |
… | |
… | |
3831 | } |
3823 | } |
3832 | |
3824 | |
3833 | void |
3825 | void |
3834 | rxvt_term::scr_swap_overlay () NOTHROW |
3826 | rxvt_term::scr_swap_overlay () NOTHROW |
3835 | { |
3827 | { |
3836 | if (!ov_text) |
3828 | if (!ov.text) |
3837 | return; |
3829 | return; |
3838 | |
3830 | |
|
|
3831 | // hide cursor if it is within the overlay area |
|
|
3832 | if (IN_RANGE_EXC (screen.cur.col - ov.x, 0, ov.w) |
|
|
3833 | && IN_RANGE_EXC (screen.cur.row - ov.y, 0, ov.h)) |
|
|
3834 | screen.flags &= ~Screen_VisibleCursor; |
|
|
3835 | |
3839 | // swap screen mem with overlay |
3836 | // swap screen mem with overlay |
3840 | for (int y = ov_h; y--; ) |
3837 | for (int y = ov.h; y--; ) |
3841 | { |
3838 | { |
3842 | text_t *t1 = ov_text[y]; |
3839 | text_t *t1 = ov.text[y]; |
3843 | rend_t *r1 = ov_rend[y]; |
3840 | rend_t *r1 = ov.rend[y]; |
3844 | |
3841 | |
3845 | text_t *t2 = ROW(y + ov_y + view_start).t + ov_x; |
3842 | text_t *t2 = ROW(y + ov.y + view_start).t + ov.x; |
3846 | rend_t *r2 = ROW(y + ov_y + view_start).r + ov_x; |
3843 | rend_t *r2 = ROW(y + ov.y + view_start).r + ov.x; |
3847 | |
3844 | |
3848 | for (int x = ov_w; x--; ) |
3845 | for (int x = ov.w; x--; ) |
3849 | { |
3846 | { |
3850 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3847 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3851 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3848 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3852 | } |
3849 | } |
3853 | } |
3850 | } |