… | |
… | |
24 | * This file handles _all_ screen updates and selections |
24 | * This file handles _all_ screen updates and selections |
25 | */ |
25 | */ |
26 | |
26 | |
27 | #include "../config.h" /* NECESSARY */ |
27 | #include "../config.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
|
|
29 | #include "rxvtperl.h" /* NECESSARY */ |
29 | |
30 | |
30 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
31 | |
32 | |
32 | #include <inttypes.h> |
33 | #include <inttypes.h> |
33 | |
34 | |
… | |
… | |
46 | |
47 | |
47 | /* ------------------------------------------------------------------------- * |
48 | /* ------------------------------------------------------------------------- * |
48 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
49 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
49 | * ------------------------------------------------------------------------- */ |
50 | * ------------------------------------------------------------------------- */ |
50 | #define ZERO_SCROLLBACK() \ |
51 | #define ZERO_SCROLLBACK() \ |
51 | if (options & Opt_scrollTtyOutput) \ |
52 | if (OPTION (Opt_scrollTtyOutput)) \ |
52 | view_start = 0 |
53 | view_start = 0 |
53 | #define CLEAR_SELECTION() \ |
54 | #define CLEAR_SELECTION() \ |
54 | selection.beg.row = selection.beg.col \ |
55 | selection.beg.row = selection.beg.col \ |
55 | = selection.end.row = selection.end.col = 0 |
56 | = selection.end.row = selection.end.col = 0 |
56 | #define CLEAR_ALL_SELECTION() \ |
57 | #define CLEAR_ALL_SELECTION() \ |
… | |
… | |
351 | lofs += len; |
352 | lofs += len; |
352 | qcol += len; |
353 | qcol += len; |
353 | } |
354 | } |
354 | } |
355 | } |
355 | |
356 | |
356 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
357 | qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; |
|
|
358 | #ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY |
|
|
359 | if (qline->l < 0) |
|
|
360 | { |
|
|
361 | fprintf (stderr, "ERROR, PLEASE REPORT to rxvt-unicode@plan9.de: qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D |
|
|
362 | qline->l = 0; |
|
|
363 | } |
|
|
364 | #endif |
357 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
365 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
358 | } |
366 | } |
359 | while (p != pend && q > 0); |
367 | while (p != pend && q > 0); |
360 | |
368 | |
361 | term_start = total_rows - nrow; |
369 | term_start = total_rows - nrow; |
… | |
… | |
410 | |
418 | |
411 | for (int col = ncol; col--; ) |
419 | for (int col = ncol; col--; ) |
412 | tabs [col] = col % TABSIZE == 0; |
420 | tabs [col] = col % TABSIZE == 0; |
413 | |
421 | |
414 | tt_winch (); |
422 | tt_winch (); |
|
|
423 | |
|
|
424 | PERL_INVOKE ((this, HOOK_RESET, DT_END)); |
415 | } |
425 | } |
416 | |
426 | |
417 | /* ------------------------------------------------------------------------- */ |
427 | /* ------------------------------------------------------------------------- */ |
418 | /* |
428 | /* |
419 | * Free everything. That way malloc debugging can find leakage. |
429 | * Free everything. That way malloc debugging can find leakage. |
… | |
… | |
523 | |
533 | |
524 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
534 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
525 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
535 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
526 | |
536 | |
527 | #if NSCREENS |
537 | #if NSCREENS |
528 | if (options & Opt_secondaryScreen) |
538 | if (OPTION (Opt_secondaryScreen)) |
529 | { |
539 | { |
530 | num_scr = 0; |
540 | num_scr = 0; |
531 | |
541 | |
532 | for (int i = prev_nrow; i--; ) |
542 | for (int i = prev_nrow; i--; ) |
533 | ::swap (ROW(i), swap_buf [i]); |
543 | ::swap (ROW(i), swap_buf [i]); |
… | |
… | |
537 | screen.flags |= Screen_VisibleCursor; |
547 | screen.flags |= Screen_VisibleCursor; |
538 | swap.flags |= Screen_VisibleCursor; |
548 | swap.flags |= Screen_VisibleCursor; |
539 | } |
549 | } |
540 | else |
550 | else |
541 | #endif |
551 | #endif |
542 | if (options & Opt_secondaryScroll) |
552 | if (OPTION (Opt_secondaryScroll)) |
543 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
553 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
544 | |
554 | |
545 | return scrn; |
555 | return scrn; |
546 | } |
556 | } |
547 | |
557 | |
… | |
… | |
609 | num_scr += count; |
619 | num_scr += count; |
610 | |
620 | |
611 | if (count > 0 |
621 | if (count > 0 |
612 | && row1 == 0 |
622 | && row1 == 0 |
613 | && row2 == nrow - 1 |
623 | && row2 == nrow - 1 |
614 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
624 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
615 | { |
625 | { |
616 | nsaved = min (nsaved + count, saveLines); |
626 | nsaved = min (nsaved + count, saveLines); |
|
|
627 | |
|
|
628 | PERL_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END)); |
|
|
629 | |
617 | term_start = (term_start + count) % total_rows; |
630 | term_start = (term_start + count) % total_rows; |
618 | |
631 | |
619 | if (selection.op && current_screen == selection.screen) |
632 | if (selection.op && current_screen == selection.screen) |
620 | { |
633 | { |
621 | selection.beg.row -= count; |
634 | selection.beg.row -= count; |
… | |
… | |
630 | selection.op = SELECTION_CLEAR; |
643 | selection.op = SELECTION_CLEAR; |
631 | } |
644 | } |
632 | } |
645 | } |
633 | |
646 | |
634 | for (int i = count; i--; ) |
647 | for (int i = count; i--; ) |
|
|
648 | { |
|
|
649 | ROW(row2 - i).l = 0; |
635 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
650 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
|
|
651 | } |
636 | |
652 | |
637 | if ((options & Opt_scrollWithBuffer) |
653 | if (OPTION (Opt_scrollWithBuffer) |
638 | && view_start != 0 |
654 | && view_start != 0 |
639 | && view_start != saveLines) |
655 | && view_start != saveLines) |
640 | scr_page (UP, count); |
656 | scr_page (UP, count); |
641 | } |
657 | } |
642 | else |
658 | else |
… | |
… | |
706 | last_col = ncol; |
722 | last_col = ncol; |
707 | |
723 | |
708 | if (nlines > 0) |
724 | if (nlines > 0) |
709 | { |
725 | { |
710 | nlines += screen.cur.row - screen.bscroll; |
726 | nlines += screen.cur.row - screen.bscroll; |
|
|
727 | |
711 | if (nlines > 0 |
728 | if (nlines > 0 |
712 | && screen.tscroll == 0 |
729 | && screen.tscroll == 0 |
713 | && screen.bscroll == (nrow - 1)) |
730 | && screen.bscroll == (nrow - 1)) |
714 | { |
731 | { |
715 | /* _at least_ this many lines need to be scrolled */ |
732 | /* _at least_ this many lines need to be scrolled */ |
… | |
… | |
733 | { |
750 | { |
734 | c = *str++; |
751 | c = *str++; |
735 | |
752 | |
736 | if (c < 0x20) |
753 | if (c < 0x20) |
737 | if (c == C0_LF) |
754 | if (c == C0_LF) |
738 | { |
755 | { |
739 | if (!line->is_longer ()) /* XXX: think about this */ |
756 | if (!line->is_longer ()) /* XXX: think about this */ |
740 | max_it (line->l, screen.cur.col); |
757 | max_it (line->l, screen.cur.col); |
741 | |
758 | |
742 | screen.flags &= ~Screen_WrapNext; |
759 | screen.flags &= ~Screen_WrapNext; |
743 | |
760 | |
… | |
… | |
1008 | if (count) |
1025 | if (count) |
1009 | x = ncol - 1; |
1026 | x = ncol - 1; |
1010 | |
1027 | |
1011 | // store horizontal tab commands as characters inside the text |
1028 | // store horizontal tab commands as characters inside the text |
1012 | // buffer so they can be selected and pasted. |
1029 | // buffer so they can be selected and pasted. |
1013 | if (ht && options & Opt_pastableTabs) |
1030 | if (ht && OPTION (Opt_pastableTabs)) |
1014 | { |
1031 | { |
1015 | base_rend = SET_FONT (base_rend, 0); |
1032 | base_rend = SET_FONT (base_rend, 0); |
1016 | |
1033 | |
1017 | if (!l.is_longer ()) /* XXX: think about this */ |
1034 | if (!l.is_longer ()) /* XXX: think about this */ |
1018 | max_it (l.l, x); |
1035 | max_it (l.l, x); |
… | |
… | |
1274 | CLEAR_ROWS (row, num); |
1291 | CLEAR_ROWS (row, num); |
1275 | } |
1292 | } |
1276 | else |
1293 | else |
1277 | { |
1294 | { |
1278 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1295 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1279 | gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; |
1296 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1280 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1297 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1281 | ERASE_ROWS (row, num); |
1298 | ERASE_ROWS (row, num); |
1282 | gcvalue.foreground = pix_colors[Color_fg]; |
1299 | gcvalue.foreground = pix_colors[Color_fg]; |
1283 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1300 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1284 | } |
1301 | } |
1285 | |
1302 | |
1286 | for (; num--; row++) |
1303 | for (; num--; row++) |
1287 | { |
1304 | { |
|
|
1305 | ROW (row).l = 0; |
1288 | scr_blank_screen_mem (ROW (row), rstyle); |
1306 | scr_blank_screen_mem (ROW (row), rstyle); |
1289 | ROW (row).l = 0; |
|
|
1290 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1307 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1291 | } |
1308 | } |
1292 | } |
1309 | } |
1293 | |
1310 | |
1294 | #if ENABLE_FRILLS |
1311 | #if ENABLE_FRILLS |
… | |
… | |
1583 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1600 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1584 | #if XPM_BACKGROUND |
1601 | #if XPM_BACKGROUND |
1585 | if (bgPixmap.pixmap == None) |
1602 | if (bgPixmap.pixmap == None) |
1586 | #endif |
1603 | #endif |
1587 | #if TRANSPARENT |
1604 | #if TRANSPARENT |
1588 | if (! (options & Opt_transparent) || am_transparent == 0) |
1605 | if (! OPTION (Opt_transparent) || am_transparent == 0) |
1589 | #endif |
1606 | #endif |
1590 | XSetWindowBackground (display->display, vt, |
1607 | XSetWindowBackground (display->display, vt, |
1591 | pix_colors[Color_bg]); |
1608 | pix_colors[Color_bg]); |
1592 | |
1609 | |
1593 | gcvalue.foreground = pix_colors[Color_fg]; |
1610 | gcvalue.foreground = pix_colors[Color_fg]; |
… | |
… | |
1809 | } |
1826 | } |
1810 | |
1827 | |
1811 | int |
1828 | int |
1812 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1829 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1813 | { |
1830 | { |
|
|
1831 | PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
|
|
1832 | |
1814 | if (view_start != oldviewstart) |
1833 | if (view_start != oldviewstart) |
1815 | { |
1834 | { |
1816 | want_refresh = 1; |
1835 | want_refresh = 1; |
1817 | num_scr -= (view_start - oldviewstart); |
1836 | num_scr -= (view_start - oldviewstart); |
1818 | } |
1837 | } |
… | |
… | |
1826 | { |
1845 | { |
1827 | #ifndef NO_BELL |
1846 | #ifndef NO_BELL |
1828 | |
1847 | |
1829 | # ifndef NO_MAPALERT |
1848 | # ifndef NO_MAPALERT |
1830 | # ifdef MAPALERT_OPTION |
1849 | # ifdef MAPALERT_OPTION |
1831 | if (options & Opt_mapAlert) |
1850 | if (OPTION (Opt_mapAlert)) |
1832 | # endif |
1851 | # endif |
1833 | XMapWindow (display->display, parent[0]); |
1852 | XMapWindow (display->display, parent[0]); |
1834 | # endif |
1853 | # endif |
1835 | |
1854 | |
1836 | if (options & Opt_visualBell) |
1855 | if (OPTION (Opt_visualBell)) |
1837 | { |
1856 | { |
1838 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1857 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1839 | rxvt_usleep (VISUAL_BELL_DURATION); |
1858 | rxvt_usleep (VISUAL_BELL_DURATION); |
1840 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1859 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1841 | } |
1860 | } |
… | |
… | |
1932 | |
1951 | |
1933 | #if XPM_BACKGROUND |
1952 | #if XPM_BACKGROUND |
1934 | must_clear |= bgPixmap.pixmap != None; |
1953 | must_clear |= bgPixmap.pixmap != None; |
1935 | #endif |
1954 | #endif |
1936 | #if TRANSPARENT |
1955 | #if TRANSPARENT |
1937 | must_clear |= (options & Opt_transparent) && am_transparent; |
1956 | must_clear |= OPTION (Opt_transparent) && am_transparent; |
1938 | #endif |
1957 | #endif |
1939 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1958 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1940 | |
1959 | |
1941 | /* |
1960 | /* |
1942 | * B: reverse any characters which are selected |
1961 | * B: reverse any characters which are selected |
… | |
… | |
1966 | |
1985 | |
1967 | crp = &ROW(screen.cur.row).r[col]; |
1986 | crp = &ROW(screen.cur.row).r[col]; |
1968 | |
1987 | |
1969 | if (showcursor && focus) |
1988 | if (showcursor && focus) |
1970 | { |
1989 | { |
1971 | if (options & Opt_cursorUnderline) |
1990 | if (OPTION (Opt_cursorUnderline)) |
1972 | *crp ^= RS_Uline; |
1991 | *crp ^= RS_Uline; |
1973 | else |
1992 | else |
1974 | { |
1993 | { |
1975 | *crp ^= RS_RVid; |
1994 | *crp ^= RS_RVid; |
1976 | |
1995 | |
… | |
… | |
1978 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
1997 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
1979 | if (ISSET_PIXCOLOR (Color_cursor)) |
1998 | if (ISSET_PIXCOLOR (Color_cursor)) |
1980 | ccol1 = Color_cursor; |
1999 | ccol1 = Color_cursor; |
1981 | else |
2000 | else |
1982 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2001 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1983 | ccol1 = GET_FGCOLOR (rstyle); |
2002 | ccol1 = fgcolor_of (rstyle); |
1984 | #else |
2003 | #else |
1985 | ccol1 = Color_fg; |
2004 | ccol1 = Color_fg; |
1986 | #endif |
2005 | #endif |
1987 | if (ISSET_PIXCOLOR (Color_cursor2)) |
2006 | if (ISSET_PIXCOLOR (Color_cursor2)) |
1988 | ccol2 = Color_cursor2; |
2007 | ccol2 = Color_cursor2; |
1989 | else |
2008 | else |
1990 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2009 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1991 | ccol2 = GET_BGCOLOR (rstyle); |
2010 | ccol2 = bgcolor_of (rstyle); |
1992 | #else |
2011 | #else |
1993 | ccol2 = Color_bg; |
2012 | ccol2 = Color_bg; |
1994 | #endif |
2013 | #endif |
1995 | *crp = SET_FGCOLOR (*crp, ccol1); |
2014 | *crp = SET_FGCOLOR (*crp, ccol1); |
1996 | *crp = SET_BGCOLOR (*crp, ccol2); |
2015 | *crp = SET_BGCOLOR (*crp, ccol2); |
… | |
… | |
2029 | oldcursor.col = screen.cur.col; |
2048 | oldcursor.col = screen.cur.col; |
2030 | } |
2049 | } |
2031 | } |
2050 | } |
2032 | } |
2051 | } |
2033 | |
2052 | |
|
|
2053 | PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
2034 | #if ENABLE_OVERLAY |
2054 | #if ENABLE_OVERLAY |
2035 | scr_swap_overlay (); |
2055 | scr_swap_overlay (); |
2036 | #endif |
2056 | #endif |
2037 | |
2057 | |
2038 | #ifndef NO_SLOW_LINK_SUPPORT |
2058 | #ifndef NO_SLOW_LINK_SUPPORT |
… | |
… | |
2088 | if (wlen < len) |
2108 | if (wlen < len) |
2089 | ::swap (wlen, len); |
2109 | ::swap (wlen, len); |
2090 | |
2110 | |
2091 | XCopyArea (display->display, vt, vt, |
2111 | XCopyArea (display->display, vt, vt, |
2092 | gc, 0, Row2Pixel (len + i), |
2112 | gc, 0, Row2Pixel (len + i), |
2093 | (unsigned int)TermWin_TotalWidth (), |
2113 | (unsigned int)this->width, |
2094 | (unsigned int)Height2Pixel (wlen - len + 1), |
2114 | (unsigned int)Height2Pixel (wlen - len + 1), |
2095 | 0, Row2Pixel (len)); |
2115 | 0, Row2Pixel (len)); |
2096 | len = -1; |
2116 | len = -1; |
2097 | } |
2117 | } |
2098 | } |
2118 | } |
… | |
… | |
2177 | count++, i--; |
2197 | count++, i--; |
2178 | |
2198 | |
2179 | /* |
2199 | /* |
2180 | * Determine the attributes for the string |
2200 | * Determine the attributes for the string |
2181 | */ |
2201 | */ |
2182 | int fore = GET_FGCOLOR (rend); // desired foreground |
2202 | int fore = fgcolor_of (rend); // desired foreground |
2183 | int back = GET_BGCOLOR (rend); // desired background |
2203 | int back = bgcolor_of (rend); // desired background |
2184 | |
2204 | |
2185 | // only do special processing if any attributes are set, which is rare |
2205 | // only do special processing if any attributes are set, which is unlikely |
2186 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2206 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2187 | { |
2207 | { |
2188 | #if ENABLE_STYLES |
2208 | #if ENABLE_STYLES |
2189 | // force redraw after "careful" characters to avoid pixel droppings |
2209 | // force redraw after "careful" characters to avoid pixel droppings |
2190 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
2210 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
… | |
… | |
2301 | } /* for (row....) */ |
2321 | } /* for (row....) */ |
2302 | |
2322 | |
2303 | #if ENABLE_OVERLAY |
2323 | #if ENABLE_OVERLAY |
2304 | scr_swap_overlay (); |
2324 | scr_swap_overlay (); |
2305 | #endif |
2325 | #endif |
|
|
2326 | PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
2306 | |
2327 | |
2307 | /* |
2328 | /* |
2308 | * G: cleanup cursor and display outline cursor if necessary |
2329 | * G: cleanup cursor and display outline cursor if necessary |
2309 | */ |
2330 | */ |
2310 | if (showcursor) |
2331 | if (showcursor) |
2311 | { |
2332 | { |
2312 | if (focus) |
2333 | if (focus) |
2313 | { |
2334 | { |
2314 | if (options & Opt_cursorUnderline) |
2335 | if (OPTION (Opt_cursorUnderline)) |
2315 | *crp ^= RS_Uline; |
2336 | *crp ^= RS_Uline; |
2316 | else |
2337 | else |
2317 | { |
2338 | { |
2318 | *crp ^= RS_RVid; |
2339 | *crp ^= RS_RVid; |
2319 | #ifndef NO_CURSORCOLOR |
2340 | #ifndef NO_CURSORCOLOR |
… | |
… | |
2438 | |
2459 | |
2439 | #if ENABLE_FRILLS |
2460 | #if ENABLE_FRILLS |
2440 | if (selection.rect) |
2461 | if (selection.rect) |
2441 | { |
2462 | { |
2442 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
2463 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
|
|
2464 | { |
|
|
2465 | text_t *stp = ROW(row).t; |
|
|
2466 | rend_t *srp = ROW(row).r; |
|
|
2467 | |
2443 | for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) |
2468 | for (col = selection.beg.col; col < selection.end.col; col++) |
2444 | srp[col] ^= RS_RVid; |
2469 | srp[col] ^= RS_RVid; |
|
|
2470 | |
|
|
2471 | while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) |
|
|
2472 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2473 | |
|
|
2474 | if (++col < selection.end.col) |
|
|
2475 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2476 | } |
2445 | } |
2477 | } |
2446 | else |
2478 | else |
2447 | #endif |
2479 | #endif |
2448 | { |
2480 | { |
2449 | if (selection.beg.row >= -view_start) |
2481 | if (selection.beg.row >= -view_start) |
… | |
… | |
2452 | row = selection.beg.row; |
2484 | row = selection.beg.row; |
2453 | } |
2485 | } |
2454 | else |
2486 | else |
2455 | { |
2487 | { |
2456 | col = 0; |
2488 | col = 0; |
2457 | row = view_start; |
2489 | row = -view_start; |
2458 | } |
2490 | } |
2459 | |
2491 | |
2460 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2492 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2461 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2493 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2462 | srp[col] ^= RS_RVid; |
2494 | srp[col] ^= RS_RVid; |
… | |
… | |
2533 | /* ------------------------------------------------------------------------- */ |
2565 | /* ------------------------------------------------------------------------- */ |
2534 | /* |
2566 | /* |
2535 | * Paste a selection direct to the command fd |
2567 | * Paste a selection direct to the command fd |
2536 | */ |
2568 | */ |
2537 | void |
2569 | void |
2538 | rxvt_term::paste (unsigned char *data, unsigned int len) |
2570 | rxvt_term::paste (char *data, unsigned int len) |
2539 | { |
2571 | { |
2540 | /* convert normal newline chars into common keyboard Return key sequence */ |
2572 | /* convert normal newline chars into common keyboard Return key sequence */ |
2541 | for (unsigned int i = 0; i < len; i++) |
2573 | for (unsigned int i = 0; i < len; i++) |
2542 | if (data[i] == C0_LF) |
2574 | if (data[i] == C0_LF) |
2543 | data[i] = C0_CR; |
2575 | data[i] = C0_CR; |
… | |
… | |
2687 | { |
2719 | { |
2688 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2720 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2689 | char *s = rxvt_wcstombs (w); |
2721 | char *s = rxvt_wcstombs (w); |
2690 | free (w); |
2722 | free (w); |
2691 | // TODO: strlen == only the first element will be converted. well... |
2723 | // TODO: strlen == only the first element will be converted. well... |
2692 | paste ((unsigned char *)s, strlen (s)); |
2724 | paste (s, strlen (s)); |
2693 | free (s); |
2725 | free (s); |
2694 | } |
2726 | } |
2695 | else |
2727 | else |
2696 | #endif |
2728 | #endif |
2697 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2729 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2698 | && cl) |
2730 | && cl) |
2699 | { |
2731 | { |
2700 | for (int i = 0; i < cr; i++) |
2732 | for (int i = 0; i < cr; i++) |
2701 | paste ((unsigned char *)cl[i], strlen (cl[i])); |
2733 | paste (cl[i], strlen (cl[i])); |
2702 | |
2734 | |
2703 | XFreeStringList (cl); |
2735 | XFreeStringList (cl); |
2704 | } |
2736 | } |
2705 | else |
2737 | else |
2706 | paste (ct.value, ct.nitems); // paste raw |
2738 | paste ((char *)ct.value, ct.nitems); // paste raw |
2707 | |
2739 | |
2708 | bailout: |
2740 | bailout: |
2709 | XFree (ct.value); |
2741 | XFree (ct.value); |
2710 | |
2742 | |
2711 | if (selection_wait == Sel_normal) |
2743 | if (selection_wait == Sel_normal) |
… | |
… | |
2749 | return; /* outside window */ |
2781 | return; /* outside window */ |
2750 | |
2782 | |
2751 | if (selection.text) |
2783 | if (selection.text) |
2752 | { /* internal selection */ |
2784 | { /* internal selection */ |
2753 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2785 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2754 | paste ((unsigned char *)str, strlen (str)); |
2786 | paste (str, strlen (str)); |
2755 | free (str); |
2787 | free (str); |
2756 | return; |
2788 | return; |
2757 | } |
2789 | } |
2758 | else |
2790 | else |
2759 | { |
2791 | { |
… | |
… | |
2851 | selection.op = SELECTION_DONE; |
2883 | selection.op = SELECTION_DONE; |
2852 | |
2884 | |
2853 | if (selection.clicks == 4) |
2885 | if (selection.clicks == 4) |
2854 | return; /* nothing selected, go away */ |
2886 | return; /* nothing selected, go away */ |
2855 | |
2887 | |
|
|
2888 | if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) |
|
|
2889 | return; |
|
|
2890 | |
2856 | i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); |
2891 | i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); |
2857 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2892 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2858 | |
2893 | |
2859 | int ofs = 0; |
2894 | int ofs = 0; |
2860 | int extra = 0; |
2895 | int extra = 0; |
… | |
… | |
2876 | #endif |
2911 | #endif |
2877 | end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN |
2912 | end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN |
2878 | |
2913 | |
2879 | col = max (col, 0); |
2914 | col = max (col, 0); |
2880 | |
2915 | |
2881 | if (row == selection.end.row || selection.rect) |
2916 | if (row == selection.end.row |
|
|
2917 | #if ENABLE_FRILLS |
|
|
2918 | || selection.rect |
|
|
2919 | #endif |
|
|
2920 | ) |
2882 | end_col = min (end_col, selection.end.col); |
2921 | min_it (end_col, selection.end.col); |
2883 | |
2922 | |
2884 | t = ROW(row).t + col; |
2923 | t = ROW(row).t + col; |
2885 | for (; col < end_col; col++) |
2924 | for (; col < end_col; col++) |
2886 | { |
2925 | { |
2887 | if (*t == NOCHAR) |
2926 | if (*t == NOCHAR) |
… | |
… | |
2905 | #endif |
2944 | #endif |
2906 | else |
2945 | else |
2907 | new_selection_text[ofs++] = *t++; |
2946 | new_selection_text[ofs++] = *t++; |
2908 | } |
2947 | } |
2909 | |
2948 | |
|
|
2949 | #if ENABLE_FRILLS |
|
|
2950 | if (selection.rect) |
|
|
2951 | { |
|
|
2952 | while (ofs |
|
|
2953 | && new_selection_text[ofs - 1] != C0_LF |
|
|
2954 | && unicode::is_space (new_selection_text[ofs - 1])) |
|
|
2955 | --ofs; |
|
|
2956 | |
|
|
2957 | new_selection_text[ofs++] = C0_LF; |
|
|
2958 | } |
|
|
2959 | else |
|
|
2960 | #endif |
2910 | if (!ROW(row).is_longer () && row != selection.end.row) |
2961 | if (!ROW(row).is_longer () && row != selection.end.row) |
2911 | new_selection_text[ofs++] = C0_LF; |
2962 | new_selection_text[ofs++] = C0_LF; |
2912 | } |
2963 | } |
2913 | |
2964 | |
2914 | if (end_col != selection.end.col) |
2965 | if (end_col != selection.end.col) |
2915 | new_selection_text[ofs++] = C0_LF; |
2966 | new_selection_text[ofs++] = C0_LF; |
2916 | |
2967 | |
… | |
… | |
2926 | |
2977 | |
2927 | // we usually allocate much more than necessary, so realloc it smaller again |
2978 | // we usually allocate much more than necessary, so realloc it smaller again |
2928 | selection.len = ofs; |
2979 | selection.len = ofs; |
2929 | selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); |
2980 | selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); |
2930 | |
2981 | |
|
|
2982 | if (PERL_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END))) |
|
|
2983 | return; |
|
|
2984 | |
|
|
2985 | selection_grab (tm); |
|
|
2986 | } |
|
|
2987 | |
|
|
2988 | bool |
|
|
2989 | rxvt_term::selection_grab (Time tm) |
|
|
2990 | { |
|
|
2991 | selection_time = tm; |
|
|
2992 | |
2931 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
2993 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
2932 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
2994 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
|
|
2995 | { |
2933 | display->set_selection_owner (this); |
2996 | display->set_selection_owner (this); |
|
|
2997 | return true; |
|
|
2998 | } |
2934 | else |
2999 | else |
2935 | rxvt_warn ("can't get primary selection, ignoring.\n"); |
3000 | return false; |
2936 | |
3001 | |
2937 | #if 0 |
3002 | #if 0 |
2938 | XTextProperty ct; |
3003 | XTextProperty ct; |
2939 | |
3004 | |
2940 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3005 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
2941 | { |
3006 | { |
2942 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3007 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
2943 | XFree (ct.value); |
3008 | XFree (ct.value); |
2944 | } |
3009 | } |
2945 | #endif |
3010 | #endif |
2946 | |
|
|
2947 | selection_time = tm; |
|
|
2948 | } |
3011 | } |
2949 | |
3012 | |
2950 | /* ------------------------------------------------------------------------- */ |
3013 | /* ------------------------------------------------------------------------- */ |
2951 | /* |
3014 | /* |
2952 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3015 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
… | |
… | |
3074 | } |
3137 | } |
3075 | } |
3138 | } |
3076 | break; |
3139 | break; |
3077 | } |
3140 | } |
3078 | |
3141 | |
3079 | Old_Word_Selection_You_Die: |
|
|
3080 | if (dirn == DN) |
3142 | if (dirn == DN) |
3081 | col++; /* put us on one past the end */ |
3143 | col++; /* put us on one past the end */ |
3082 | |
3144 | |
3083 | /* Poke the values back in */ |
3145 | /* Poke the values back in */ |
3084 | ret->row = row; |
3146 | ret->row = row; |
… | |
… | |
3261 | else if (selection.clicks == 2) |
3323 | else if (selection.clicks == 2) |
3262 | { |
3324 | { |
3263 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3325 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3264 | selection.end.col--; |
3326 | selection.end.col--; |
3265 | |
3327 | |
|
|
3328 | if (!PERL_INVOKE ((this, HOOK_SEL_EXTEND, DT_END))) |
|
|
3329 | { |
3266 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3330 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3267 | selection_delimit_word (DN, &selection.end, &selection.end); |
3331 | selection_delimit_word (DN, &selection.end, &selection.end); |
|
|
3332 | } |
3268 | } |
3333 | } |
3269 | else if (selection.clicks == 3) |
3334 | else if (selection.clicks == 3) |
3270 | { |
3335 | { |
3271 | #if ENABLE_FRILLS |
3336 | #if ENABLE_FRILLS |
3272 | if (options & Opt_tripleclickwords) |
3337 | if (OPTION (Opt_tripleclickwords)) |
3273 | { |
3338 | { |
3274 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3339 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3275 | |
3340 | |
3276 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3341 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3277 | { |
3342 | { |
… | |
… | |
3338 | { |
3403 | { |
3339 | stp = ROW(end_row).t; |
3404 | stp = ROW(end_row).t; |
3340 | |
3405 | |
3341 | while (--end_col >= 0) |
3406 | while (--end_col >= 0) |
3342 | { |
3407 | { |
3343 | if (stp[end_col] != ' ' |
3408 | if (stp[end_col] != NOCHAR |
3344 | && stp[end_col] != '\t' |
3409 | && !unicode::is_space (stp[end_col])) |
3345 | && stp[end_col] != NOCHAR) |
|
|
3346 | break; |
3410 | break; |
3347 | } |
3411 | } |
3348 | |
3412 | |
3349 | if (end_col >= 0 |
3413 | if (end_col >= 0 |
3350 | || !ROW(end_row - 1).is_longer ()) |
3414 | || !ROW(end_row - 1).is_longer ()) |
… | |
… | |
3549 | |
3613 | |
3550 | #if ENABLE_OVERLAY |
3614 | #if ENABLE_OVERLAY |
3551 | void |
3615 | void |
3552 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3616 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3553 | { |
3617 | { |
3554 | if (nrow < 3 || ncol < 3) |
3618 | if (nrow < 1 || ncol < 1) |
3555 | return; |
3619 | return; |
3556 | |
3620 | |
3557 | want_refresh = 1; |
3621 | want_refresh = 1; |
3558 | |
3622 | |
3559 | scr_overlay_off (); |
3623 | scr_overlay_off (); |
… | |
… | |
3666 | for (int y = ov_h; y--; ) |
3730 | for (int y = ov_h; y--; ) |
3667 | { |
3731 | { |
3668 | text_t *t1 = ov_text[y]; |
3732 | text_t *t1 = ov_text[y]; |
3669 | rend_t *r1 = ov_rend[y]; |
3733 | rend_t *r1 = ov_rend[y]; |
3670 | |
3734 | |
3671 | text_t *t2 = ROW(y - view_start).t + ov_x; |
3735 | text_t *t2 = ROW(y + ov_y - view_start).t + ov_x; |
3672 | rend_t *r2 = ROW(y - view_start).r + ov_x; |
3736 | rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x; |
3673 | |
3737 | |
3674 | for (int x = ov_w; x--; ) |
3738 | for (int x = ov_w; x--; ) |
3675 | { |
3739 | { |
3676 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3740 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3677 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3741 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |