… | |
… | |
115 | * SCREEN `COMMON' ROUTINES * |
115 | * SCREEN `COMMON' ROUTINES * |
116 | * ------------------------------------------------------------------------- */ |
116 | * ------------------------------------------------------------------------- */ |
117 | |
117 | |
118 | /* Fill part/all of a line with blanks. */ |
118 | /* Fill part/all of a line with blanks. */ |
119 | void |
119 | void |
120 | rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) |
120 | rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const |
121 | { |
121 | { |
122 | if (!l.t) |
122 | if (!l.t) |
123 | { |
123 | { |
124 | lalloc (l); |
124 | lalloc (l); |
125 | col = 0; |
125 | col = 0; |
… | |
… | |
142 | } |
142 | } |
143 | |
143 | |
144 | /* ------------------------------------------------------------------------- */ |
144 | /* ------------------------------------------------------------------------- */ |
145 | /* Fill a full line with blanks - make sure it is allocated first */ |
145 | /* Fill a full line with blanks - make sure it is allocated first */ |
146 | void |
146 | void |
147 | rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) |
147 | rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const |
148 | { |
148 | { |
149 | scr_blank_line (l, 0, ncol, efs); |
149 | scr_blank_line (l, 0, ncol, efs); |
150 | |
150 | |
151 | l.l = 0; |
151 | l.l = 0; |
152 | l.f = 0; |
152 | l.f = 0; |
… | |
… | |
234 | selection.text = NULL; |
234 | selection.text = NULL; |
235 | selection.len = 0; |
235 | selection.len = 0; |
236 | selection.op = SELECTION_CLEAR; |
236 | selection.op = SELECTION_CLEAR; |
237 | selection.screen = PRIMARY; |
237 | selection.screen = PRIMARY; |
238 | selection.clicks = 0; |
238 | selection.clicks = 0; |
239 | CLEAR_ALL_SELECTION (); |
|
|
240 | rvideo = 0; |
239 | rvideo = 0; |
241 | } |
240 | } |
242 | else |
241 | else |
243 | { |
242 | { |
244 | /* |
243 | /* |
… | |
… | |
325 | qline->l = ncol; |
324 | qline->l = ncol; |
326 | qline->is_longer (1); |
325 | qline->is_longer (1); |
327 | |
326 | |
328 | int qcol = 0; |
327 | int qcol = 0; |
329 | |
328 | |
|
|
329 | // see below for cursor adjustment rationale |
|
|
330 | if (p == ocur.row) |
|
|
331 | screen.cur.row = q - (total_rows - nrow); |
|
|
332 | |
330 | // fill a single destination line |
333 | // fill a single destination line |
331 | while (lofs < llen && qcol < ncol) |
334 | while (lofs < llen && qcol < ncol) |
332 | { |
335 | { |
333 | int prow = lofs / prev_ncol; |
336 | int prow = lofs / prev_ncol; |
334 | int pcol = lofs % prev_ncol; |
337 | int pcol = lofs % prev_ncol; |
… | |
… | |
344 | |
347 | |
345 | line_t &pline = old_buf [prow]; |
348 | line_t &pline = old_buf [prow]; |
346 | |
349 | |
347 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
350 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
348 | |
351 | |
|
|
352 | #if DEBUG_STRICT |
349 | assert (len); |
353 | assert (len); |
350 | assert (pline.t); |
354 | assert (pline.t); |
|
|
355 | #endif |
351 | |
356 | |
352 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
357 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
353 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
358 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
354 | |
359 | |
355 | lofs += len; |
360 | lofs += len; |
… | |
… | |
389 | } |
394 | } |
390 | |
395 | |
391 | term_start = 0; |
396 | term_start = 0; |
392 | } |
397 | } |
393 | |
398 | |
394 | #ifdef DEBUG_STRICT //TODO: remove |
|
|
395 | for (int i = top_row; i < nrow; i++) |
|
|
396 | assert (ROW (i).t); |
|
|
397 | #endif |
|
|
398 | |
|
|
399 | free (old_buf); |
399 | free (old_buf); |
400 | delete old_ta; |
400 | delete old_ta; |
401 | delete old_ra; |
401 | delete old_ra; |
402 | |
402 | |
403 | clamp_it (screen.cur.row, 0, nrow - 1); |
403 | clamp_it (screen.cur.row, 0, nrow - 1); |
404 | clamp_it (screen.cur.col, 0, ncol - 1); |
404 | clamp_it (screen.cur.col, 0, ncol - 1); |
405 | |
405 | |
406 | if (tabs) |
406 | if (tabs) |
407 | free (tabs); |
407 | free (tabs); |
408 | } |
408 | } |
|
|
409 | |
|
|
410 | CLEAR_ALL_SELECTION (); |
409 | |
411 | |
410 | prev_nrow = nrow; |
412 | prev_nrow = nrow; |
411 | prev_ncol = ncol; |
413 | prev_ncol = ncol; |
412 | |
414 | |
413 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
415 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
… | |
… | |
448 | scr_release (); |
450 | scr_release (); |
449 | prev_nrow = prev_ncol = 0; |
451 | prev_nrow = prev_ncol = 0; |
450 | scr_reset (); |
452 | scr_reset (); |
451 | |
453 | |
452 | scr_clear (true); |
454 | scr_clear (true); |
453 | scr_refresh (SLOW_REFRESH); |
455 | scr_refresh (); |
454 | } |
456 | } |
455 | |
457 | |
456 | /* ------------------------------------------------------------------------- * |
458 | /* ------------------------------------------------------------------------- * |
457 | * PROCESS SCREEN COMMANDS * |
459 | * PROCESS SCREEN COMMANDS * |
458 | * ------------------------------------------------------------------------- */ |
460 | * ------------------------------------------------------------------------- */ |
… | |
… | |
617 | && row1 == 0 |
619 | && row1 == 0 |
618 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
620 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
619 | { |
621 | { |
620 | top_row = max (top_row - count, -saveLines); |
622 | top_row = max (top_row - count, -saveLines); |
621 | |
623 | |
622 | HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); |
|
|
623 | |
|
|
624 | // scroll everything up 'count' lines |
624 | // scroll everything up 'count' lines |
625 | term_start = (term_start + count) % total_rows; |
625 | term_start = (term_start + count) % total_rows; |
626 | |
626 | |
|
|
627 | // sever bottommost line |
627 | { |
628 | { |
628 | // severe bottommost scrolled line |
|
|
629 | line_t &l = ROW(row2 - count); |
629 | line_t &l = ROW(row2 - count); |
|
|
630 | l.is_longer (0); |
630 | l.touch (); |
631 | l.touch (); |
631 | l.is_longer (0); |
|
|
632 | } |
632 | } |
633 | |
633 | |
634 | // erase newly scorlled-in lines |
634 | // erase newly scrolled-in lines |
635 | for (int i = count; i; --i ) |
635 | for (int i = count; i--; ) |
636 | { |
636 | { |
637 | // basically this is a slightly optimized scr_blank_screen_mem |
637 | // basically this is a slightly optimized scr_blank_screen_mem |
638 | // it is worth the effort on slower machines |
638 | // it is worth the effort on slower machines |
639 | line_t &l = ROW(nrow - i); |
639 | line_t &l = ROW(nrow - 1 - i); |
640 | |
640 | |
641 | scr_blank_line (l, 0, l.l, rstyle); |
641 | scr_blank_line (l, 0, l.l, rstyle); |
642 | |
642 | |
643 | l.l = 0; |
643 | l.l = 0; |
644 | l.f = 0; |
644 | l.f = 0; |
… | |
… | |
675 | // finally move the view window, if desired |
675 | // finally move the view window, if desired |
676 | if (OPTION (Opt_scrollWithBuffer) |
676 | if (OPTION (Opt_scrollWithBuffer) |
677 | && view_start != 0 |
677 | && view_start != 0 |
678 | && view_start != -saveLines) |
678 | && view_start != -saveLines) |
679 | scr_page (UP, count); |
679 | scr_page (UP, count); |
|
|
680 | |
|
|
681 | if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) |
|
|
682 | HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); |
680 | } |
683 | } |
681 | else |
684 | else |
682 | { |
685 | { |
683 | if (selection.op && current_screen == selection.screen) |
686 | if (selection.op && current_screen == selection.screen) |
684 | { |
687 | { |
… | |
… | |
816 | CLEAR_SELECTION (); |
819 | CLEAR_SELECTION (); |
817 | } |
820 | } |
818 | |
821 | |
819 | if (screen.flags & Screen_WrapNext) |
822 | if (screen.flags & Screen_WrapNext) |
820 | { |
823 | { |
821 | max_it (line->l, ncol); |
|
|
822 | line->is_longer (1); |
|
|
823 | |
|
|
824 | scr_do_wrap (); |
824 | scr_do_wrap (); |
825 | |
825 | |
|
|
826 | line->l = ncol; |
|
|
827 | line->is_longer (1); |
|
|
828 | |
826 | row = screen.cur.row; |
829 | row = screen.cur.row; |
827 | line = &ROW(row); /* _must_ refresh */ |
830 | line = &ROW(row); /* _must_ refresh */ |
828 | } |
831 | } |
829 | |
832 | |
830 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
833 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
… | |
… | |
1789 | } |
1792 | } |
1790 | |
1793 | |
1791 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1794 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1792 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1795 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1793 | |
1796 | |
|
|
1797 | num_scr_allow = 0; |
|
|
1798 | |
1794 | if (refresh) |
1799 | if (refresh) |
1795 | scr_refresh (SLOW_REFRESH); |
1800 | scr_refresh (); |
1796 | } |
1801 | } |
1797 | |
1802 | |
1798 | /* ------------------------------------------------------------------------- */ |
1803 | /* ------------------------------------------------------------------------- */ |
1799 | /* |
1804 | /* |
1800 | * Refresh the entire screen |
1805 | * Refresh the entire screen |
… | |
… | |
1811 | * the top of the screen |
1816 | * the top of the screen |
1812 | */ |
1817 | */ |
1813 | void |
1818 | void |
1814 | rxvt_term::scr_move_to (int y, int len) |
1819 | rxvt_term::scr_move_to (int y, int len) |
1815 | { |
1820 | { |
1816 | int p = (top_row - nrow) * (len - y) / len + (nrow - 1); |
1821 | scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); |
1817 | |
|
|
1818 | scr_changeview (p); |
|
|
1819 | } |
1822 | } |
1820 | |
1823 | |
1821 | /* ------------------------------------------------------------------------- */ |
1824 | /* ------------------------------------------------------------------------- */ |
1822 | /* |
1825 | /* |
1823 | * Page the screen up/down nlines |
1826 | * Page the screen up/down nlines |
… | |
… | |
1836 | bool |
1839 | bool |
1837 | rxvt_term::scr_changeview (int new_view_start) |
1840 | rxvt_term::scr_changeview (int new_view_start) |
1838 | { |
1841 | { |
1839 | clamp_it (new_view_start, top_row, 0); |
1842 | clamp_it (new_view_start, top_row, 0); |
1840 | |
1843 | |
1841 | if (new_view_start != view_start) |
1844 | if (new_view_start == view_start) |
1842 | { |
|
|
1843 | num_scr += new_view_start - view_start; |
|
|
1844 | view_start = new_view_start; |
|
|
1845 | HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
|
|
1846 | want_refresh = 1; |
|
|
1847 | |
|
|
1848 | return true; |
|
|
1849 | } |
|
|
1850 | else |
|
|
1851 | return false; |
1845 | return false; |
|
|
1846 | |
|
|
1847 | num_scr += new_view_start - view_start; |
|
|
1848 | view_start = new_view_start; |
|
|
1849 | want_refresh = 1; |
|
|
1850 | |
|
|
1851 | HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
|
|
1852 | |
|
|
1853 | return true; |
1852 | } |
1854 | } |
1853 | |
1855 | |
1854 | /* ------------------------------------------------------------------------- */ |
1856 | /* ------------------------------------------------------------------------- */ |
1855 | void |
1857 | void |
1856 | rxvt_term::scr_bell () |
1858 | rxvt_term::scr_bell () |
… | |
… | |
1937 | * Refresh the screen |
1939 | * Refresh the screen |
1938 | * drawn_text/drawn_rend contain the screen information before the update. |
1940 | * drawn_text/drawn_rend contain the screen information before the update. |
1939 | * screen.text/screen.rend contain what the screen will change to. |
1941 | * screen.text/screen.rend contain what the screen will change to. |
1940 | */ |
1942 | */ |
1941 | void |
1943 | void |
1942 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1944 | rxvt_term::scr_refresh () |
1943 | { |
1945 | { |
1944 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1946 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1945 | showcursor; /* show the cursor */ |
1947 | showcursor; /* show the cursor */ |
1946 | int16_t col, row, /* column/row we're processing */ |
1948 | int16_t col, row, /* column/row we're processing */ |
1947 | ocrow; /* old cursor row */ |
1949 | ocrow; /* old cursor row */ |
… | |
… | |
2071 | #ifndef NO_SLOW_LINK_SUPPORT |
2073 | #ifndef NO_SLOW_LINK_SUPPORT |
2072 | /* |
2074 | /* |
2073 | * D: CopyArea pass - very useful for slower links |
2075 | * D: CopyArea pass - very useful for slower links |
2074 | * This has been deliberately kept simple. |
2076 | * This has been deliberately kept simple. |
2075 | */ |
2077 | */ |
2076 | i = num_scr; |
|
|
2077 | if (!display->is_local |
2078 | if (!display->is_local |
2078 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2079 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2079 | && abs (num_scr) < nrow && !must_clear) |
2080 | && abs (num_scr) < nrow && !must_clear) |
2080 | { |
2081 | { |
2081 | int16_t nits; |
2082 | int16_t nits; |
2082 | int j; |
2083 | int j; |
2083 | int len, wlen; |
2084 | int len, wlen; |
|
|
2085 | dLocal (int, num_scr); |
2084 | |
2086 | |
2085 | j = nrow; |
2087 | j = nrow; |
2086 | wlen = len = -1; |
2088 | wlen = len = -1; |
2087 | row = i > 0 ? 0 : j - 1; |
2089 | row = i > 0 ? 0 : j - 1; |
2088 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2090 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
… | |
… | |
2800 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2802 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2801 | * will auto fallback to CUT_BUFFER0 |
2803 | * will auto fallback to CUT_BUFFER0 |
2802 | * EXT: button 2 release |
2804 | * EXT: button 2 release |
2803 | */ |
2805 | */ |
2804 | void |
2806 | void |
2805 | rxvt_term::selection_request (Time tm, int x, int y) |
2807 | rxvt_term::selection_request (Time tm) |
2806 | { |
2808 | { |
2807 | if (x < 0 || x >= width || y < 0 || y >= height) |
|
|
2808 | return; /* outside window */ |
|
|
2809 | |
|
|
2810 | if (selection.text) |
2809 | if (selection.text) |
2811 | { /* internal selection */ |
2810 | { /* internal selection */ |
2812 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2811 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2813 | paste (str, strlen (str)); |
2812 | paste (str, strlen (str)); |
2814 | free (str); |
2813 | free (str); |