… | |
… | |
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; |
… | |
… | |
239 | CLEAR_ALL_SELECTION (); |
239 | CLEAR_ALL_SELECTION (); |
240 | rvideo = 0; |
240 | rvideo = 0; |
241 | } |
241 | } |
242 | else |
242 | else |
243 | { |
243 | { |
|
|
244 | CLEAR_ALL_SELECTION (); |
|
|
245 | |
244 | /* |
246 | /* |
245 | * add or delete rows as appropriate |
247 | * add or delete rows as appropriate |
246 | */ |
248 | */ |
247 | |
249 | |
248 | rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
250 | rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
… | |
… | |
325 | qline->l = ncol; |
327 | qline->l = ncol; |
326 | qline->is_longer (1); |
328 | qline->is_longer (1); |
327 | |
329 | |
328 | int qcol = 0; |
330 | int qcol = 0; |
329 | |
331 | |
|
|
332 | // see below for cursor adjustment rationale |
|
|
333 | if (p == ocur.row) |
|
|
334 | screen.cur.row = q - (total_rows - nrow); |
|
|
335 | |
330 | // fill a single destination line |
336 | // fill a single destination line |
331 | while (lofs < llen && qcol < ncol) |
337 | while (lofs < llen && qcol < ncol) |
332 | { |
338 | { |
333 | int prow = lofs / prev_ncol; |
339 | int prow = lofs / prev_ncol; |
334 | int pcol = lofs % prev_ncol; |
340 | int pcol = lofs % prev_ncol; |
… | |
… | |
389 | } |
395 | } |
390 | |
396 | |
391 | term_start = 0; |
397 | term_start = 0; |
392 | } |
398 | } |
393 | |
399 | |
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); |
400 | free (old_buf); |
400 | delete old_ta; |
401 | delete old_ta; |
401 | delete old_ra; |
402 | delete old_ra; |
402 | |
403 | |
403 | clamp_it (screen.cur.row, 0, nrow - 1); |
404 | clamp_it (screen.cur.row, 0, nrow - 1); |
… | |
… | |
448 | scr_release (); |
449 | scr_release (); |
449 | prev_nrow = prev_ncol = 0; |
450 | prev_nrow = prev_ncol = 0; |
450 | scr_reset (); |
451 | scr_reset (); |
451 | |
452 | |
452 | scr_clear (true); |
453 | scr_clear (true); |
453 | scr_refresh (SLOW_REFRESH); |
454 | scr_refresh (); |
454 | } |
455 | } |
455 | |
456 | |
456 | /* ------------------------------------------------------------------------- * |
457 | /* ------------------------------------------------------------------------- * |
457 | * PROCESS SCREEN COMMANDS * |
458 | * PROCESS SCREEN COMMANDS * |
458 | * ------------------------------------------------------------------------- */ |
459 | * ------------------------------------------------------------------------- */ |
… | |
… | |
617 | && row1 == 0 |
618 | && row1 == 0 |
618 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
619 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
619 | { |
620 | { |
620 | top_row = max (top_row - count, -saveLines); |
621 | top_row = max (top_row - count, -saveLines); |
621 | |
622 | |
622 | HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); |
|
|
623 | |
|
|
624 | // scroll everything up 'count' lines |
623 | // scroll everything up 'count' lines |
625 | term_start = (term_start + count) % total_rows; |
624 | term_start = (term_start + count) % total_rows; |
626 | |
625 | |
|
|
626 | // sever bottommost line |
627 | { |
627 | { |
628 | // severe bottommost scrolled line |
|
|
629 | line_t &l = ROW(row2 - count); |
628 | line_t &l = ROW(row2 - count); |
|
|
629 | l.is_longer (0); |
630 | l.touch (); |
630 | l.touch (); |
631 | l.is_longer (0); |
|
|
632 | } |
631 | } |
633 | |
632 | |
634 | // erase newly scorlled-in lines |
633 | // erase newly scrolled-in lines |
635 | for (int i = count; i; --i ) |
634 | for (int i = count; i--; ) |
636 | { |
635 | { |
637 | // basically this is a slightly optimized scr_blank_screen_mem |
636 | // basically this is a slightly optimized scr_blank_screen_mem |
638 | // it is worth the effort on slower machines |
637 | // it is worth the effort on slower machines |
639 | line_t &l = ROW(nrow - i); |
638 | line_t &l = ROW(nrow - 1 - i); |
640 | |
639 | |
641 | scr_blank_line (l, 0, l.l, rstyle); |
640 | scr_blank_line (l, 0, l.l, rstyle); |
642 | |
641 | |
643 | l.l = 0; |
642 | l.l = 0; |
644 | l.f = 0; |
643 | l.f = 0; |
… | |
… | |
675 | // finally move the view window, if desired |
674 | // finally move the view window, if desired |
676 | if (OPTION (Opt_scrollWithBuffer) |
675 | if (OPTION (Opt_scrollWithBuffer) |
677 | && view_start != 0 |
676 | && view_start != 0 |
678 | && view_start != -saveLines) |
677 | && view_start != -saveLines) |
679 | scr_page (UP, count); |
678 | scr_page (UP, count); |
|
|
679 | |
|
|
680 | if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) |
|
|
681 | HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); |
680 | } |
682 | } |
681 | else |
683 | else |
682 | { |
684 | { |
683 | if (selection.op && current_screen == selection.screen) |
685 | if (selection.op && current_screen == selection.screen) |
684 | { |
686 | { |
… | |
… | |
816 | CLEAR_SELECTION (); |
818 | CLEAR_SELECTION (); |
817 | } |
819 | } |
818 | |
820 | |
819 | if (screen.flags & Screen_WrapNext) |
821 | if (screen.flags & Screen_WrapNext) |
820 | { |
822 | { |
821 | max_it (line->l, ncol); |
|
|
822 | line->is_longer (1); |
|
|
823 | |
|
|
824 | scr_do_wrap (); |
823 | scr_do_wrap (); |
825 | |
824 | |
|
|
825 | line->l = ncol; |
|
|
826 | line->is_longer (1); |
|
|
827 | |
826 | row = screen.cur.row; |
828 | row = screen.cur.row; |
827 | line = &ROW(row); /* _must_ refresh */ |
829 | line = &ROW(row); /* _must_ refresh */ |
828 | } |
830 | } |
829 | |
831 | |
830 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
832 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
… | |
… | |
1789 | } |
1791 | } |
1790 | |
1792 | |
1791 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1793 | 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); |
1794 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1793 | |
1795 | |
|
|
1796 | num_scr_allow = 0; |
|
|
1797 | |
1794 | if (refresh) |
1798 | if (refresh) |
1795 | scr_refresh (SLOW_REFRESH); |
1799 | scr_refresh (); |
1796 | } |
1800 | } |
1797 | |
1801 | |
1798 | /* ------------------------------------------------------------------------- */ |
1802 | /* ------------------------------------------------------------------------- */ |
1799 | /* |
1803 | /* |
1800 | * Refresh the entire screen |
1804 | * Refresh the entire screen |
… | |
… | |
1811 | * the top of the screen |
1815 | * the top of the screen |
1812 | */ |
1816 | */ |
1813 | void |
1817 | void |
1814 | rxvt_term::scr_move_to (int y, int len) |
1818 | rxvt_term::scr_move_to (int y, int len) |
1815 | { |
1819 | { |
1816 | int p = (top_row - nrow) * (len - y) / len + (nrow - 1); |
1820 | scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); |
1817 | |
|
|
1818 | scr_changeview (p); |
|
|
1819 | } |
1821 | } |
1820 | |
1822 | |
1821 | /* ------------------------------------------------------------------------- */ |
1823 | /* ------------------------------------------------------------------------- */ |
1822 | /* |
1824 | /* |
1823 | * Page the screen up/down nlines |
1825 | * Page the screen up/down nlines |
… | |
… | |
1841 | if (new_view_start == view_start) |
1843 | if (new_view_start == view_start) |
1842 | return false; |
1844 | return false; |
1843 | |
1845 | |
1844 | num_scr += new_view_start - view_start; |
1846 | num_scr += new_view_start - view_start; |
1845 | view_start = new_view_start; |
1847 | view_start = new_view_start; |
|
|
1848 | want_refresh = 1; |
|
|
1849 | |
1846 | HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
1850 | HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
1847 | want_refresh = 1; |
|
|
1848 | |
1851 | |
1849 | return true; |
1852 | return true; |
1850 | } |
1853 | } |
1851 | |
1854 | |
1852 | /* ------------------------------------------------------------------------- */ |
1855 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1935 | * Refresh the screen |
1938 | * Refresh the screen |
1936 | * drawn_text/drawn_rend contain the screen information before the update. |
1939 | * drawn_text/drawn_rend contain the screen information before the update. |
1937 | * screen.text/screen.rend contain what the screen will change to. |
1940 | * screen.text/screen.rend contain what the screen will change to. |
1938 | */ |
1941 | */ |
1939 | void |
1942 | void |
1940 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1943 | rxvt_term::scr_refresh () |
1941 | { |
1944 | { |
1942 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1945 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1943 | showcursor; /* show the cursor */ |
1946 | showcursor; /* show the cursor */ |
1944 | int16_t col, row, /* column/row we're processing */ |
1947 | int16_t col, row, /* column/row we're processing */ |
1945 | ocrow; /* old cursor row */ |
1948 | ocrow; /* old cursor row */ |
… | |
… | |
2069 | #ifndef NO_SLOW_LINK_SUPPORT |
2072 | #ifndef NO_SLOW_LINK_SUPPORT |
2070 | /* |
2073 | /* |
2071 | * D: CopyArea pass - very useful for slower links |
2074 | * D: CopyArea pass - very useful for slower links |
2072 | * This has been deliberately kept simple. |
2075 | * This has been deliberately kept simple. |
2073 | */ |
2076 | */ |
2074 | i = num_scr; |
|
|
2075 | if (!display->is_local |
2077 | if (!display->is_local |
2076 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2078 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2077 | && abs (num_scr) < nrow && !must_clear) |
2079 | && abs (num_scr) < nrow && !must_clear) |
2078 | { |
2080 | { |
2079 | int16_t nits; |
2081 | int16_t nits; |
2080 | int j; |
2082 | int j; |
2081 | int len, wlen; |
2083 | int len, wlen; |
|
|
2084 | dLocal (int, num_scr); |
2082 | |
2085 | |
2083 | j = nrow; |
2086 | j = nrow; |
2084 | wlen = len = -1; |
2087 | wlen = len = -1; |
2085 | row = i > 0 ? 0 : j - 1; |
2088 | row = i > 0 ? 0 : j - 1; |
2086 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2089 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
… | |
… | |
2798 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2801 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2799 | * will auto fallback to CUT_BUFFER0 |
2802 | * will auto fallback to CUT_BUFFER0 |
2800 | * EXT: button 2 release |
2803 | * EXT: button 2 release |
2801 | */ |
2804 | */ |
2802 | void |
2805 | void |
2803 | rxvt_term::selection_request (Time tm, int x, int y) |
2806 | rxvt_term::selection_request (Time tm) |
2804 | { |
2807 | { |
2805 | if (x < 0 || x >= width || y < 0 || y >= height) |
|
|
2806 | return; /* outside window */ |
|
|
2807 | |
|
|
2808 | if (selection.text) |
2808 | if (selection.text) |
2809 | { /* internal selection */ |
2809 | { /* internal selection */ |
2810 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2810 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2811 | paste (str, strlen (str)); |
2811 | paste (str, strlen (str)); |
2812 | free (str); |
2812 | free (str); |