ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.198 by root, Tue Dec 27 01:25:42 2005 UTC vs.
Revision 1.204 by root, Mon Jan 2 15:35:43 2006 UTC

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() \
417 418
418 for (int col = ncol; col--; ) 419 for (int col = ncol; col--; )
419 tabs [col] = col % TABSIZE == 0; 420 tabs [col] = col % TABSIZE == 0;
420 421
421 tt_winch (); 422 tt_winch ();
423
424 PERL_INVOKE ((this, HOOK_RESET, DT_END));
422} 425}
423 426
424/* ------------------------------------------------------------------------- */ 427/* ------------------------------------------------------------------------- */
425/* 428/*
426 * Free everything. That way malloc debugging can find leakage. 429 * Free everything. That way malloc debugging can find leakage.
530 533
531 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); 534 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
532 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); 535 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
533 536
534#if NSCREENS 537#if NSCREENS
535 if (options & Opt_secondaryScreen) 538 if (OPTION (Opt_secondaryScreen))
536 { 539 {
537 num_scr = 0; 540 num_scr = 0;
538 541
539 for (int i = prev_nrow; i--; ) 542 for (int i = prev_nrow; i--; )
540 ::swap (ROW(i), swap_buf [i]); 543 ::swap (ROW(i), swap_buf [i]);
544 screen.flags |= Screen_VisibleCursor; 547 screen.flags |= Screen_VisibleCursor;
545 swap.flags |= Screen_VisibleCursor; 548 swap.flags |= Screen_VisibleCursor;
546 } 549 }
547 else 550 else
548#endif 551#endif
549 if (options & Opt_secondaryScroll) 552 if (OPTION (Opt_secondaryScroll))
550 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 553 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
551 554
552 return scrn; 555 return scrn;
553} 556}
554 557
616 num_scr += count; 619 num_scr += count;
617 620
618 if (count > 0 621 if (count > 0
619 && row1 == 0 622 && row1 == 0
620 && row2 == nrow - 1 623 && row2 == nrow - 1
621 && (current_screen == PRIMARY || options & Opt_secondaryScroll)) 624 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll)))
622 { 625 {
623 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
624 term_start = (term_start + count) % total_rows; 630 term_start = (term_start + count) % total_rows;
625 631
626 if (selection.op && current_screen == selection.screen) 632 if (selection.op && current_screen == selection.screen)
627 { 633 {
628 selection.beg.row -= count; 634 selection.beg.row -= count;
642 { 648 {
643 ROW(row2 - i).l = 0; 649 ROW(row2 - i).l = 0;
644 scr_blank_screen_mem (ROW(row2 - i), rstyle); 650 scr_blank_screen_mem (ROW(row2 - i), rstyle);
645 } 651 }
646 652
647 if ((options & Opt_scrollWithBuffer) 653 if (OPTION (Opt_scrollWithBuffer)
648 && view_start != 0 654 && view_start != 0
649 && view_start != saveLines) 655 && view_start != saveLines)
650 scr_page (UP, count); 656 scr_page (UP, count);
651 } 657 }
652 else 658 else
1018 if (count) 1024 if (count)
1019 x = ncol - 1; 1025 x = ncol - 1;
1020 1026
1021 // store horizontal tab commands as characters inside the text 1027 // store horizontal tab commands as characters inside the text
1022 // buffer so they can be selected and pasted. 1028 // buffer so they can be selected and pasted.
1023 if (ht && options & Opt_pastableTabs) 1029 if (ht && OPTION (Opt_pastableTabs))
1024 { 1030 {
1025 base_rend = SET_FONT (base_rend, 0); 1031 base_rend = SET_FONT (base_rend, 0);
1026 1032
1027 if (!l.is_longer ()) /* XXX: think about this */ 1033 if (!l.is_longer ()) /* XXX: think about this */
1028 max_it (l.l, x); 1034 max_it (l.l, x);
1284 CLEAR_ROWS (row, num); 1290 CLEAR_ROWS (row, num);
1285 } 1291 }
1286 else 1292 else
1287 { 1293 {
1288 ren = rstyle & (RS_fgMask | RS_bgMask); 1294 ren = rstyle & (RS_fgMask | RS_bgMask);
1289 gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; 1295 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1290 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1296 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1291 ERASE_ROWS (row, num); 1297 ERASE_ROWS (row, num);
1292 gcvalue.foreground = pix_colors[Color_fg]; 1298 gcvalue.foreground = pix_colors[Color_fg];
1293 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1299 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1294 } 1300 }
1593 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1599 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1594#if XPM_BACKGROUND 1600#if XPM_BACKGROUND
1595 if (bgPixmap.pixmap == None) 1601 if (bgPixmap.pixmap == None)
1596#endif 1602#endif
1597#if TRANSPARENT 1603#if TRANSPARENT
1598 if (! (options & Opt_transparent) || am_transparent == 0) 1604 if (! OPTION (Opt_transparent) || am_transparent == 0)
1599#endif 1605#endif
1600 XSetWindowBackground (display->display, vt, 1606 XSetWindowBackground (display->display, vt,
1601 pix_colors[Color_bg]); 1607 pix_colors[Color_bg]);
1602 1608
1603 gcvalue.foreground = pix_colors[Color_fg]; 1609 gcvalue.foreground = pix_colors[Color_fg];
1819} 1825}
1820 1826
1821int 1827int
1822rxvt_term::scr_changeview (unsigned int oldviewstart) 1828rxvt_term::scr_changeview (unsigned int oldviewstart)
1823{ 1829{
1830 PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1831
1824 if (view_start != oldviewstart) 1832 if (view_start != oldviewstart)
1825 { 1833 {
1826 want_refresh = 1; 1834 want_refresh = 1;
1827 num_scr -= (view_start - oldviewstart); 1835 num_scr -= (view_start - oldviewstart);
1828 } 1836 }
1836{ 1844{
1837#ifndef NO_BELL 1845#ifndef NO_BELL
1838 1846
1839# ifndef NO_MAPALERT 1847# ifndef NO_MAPALERT
1840# ifdef MAPALERT_OPTION 1848# ifdef MAPALERT_OPTION
1841 if (options & Opt_mapAlert) 1849 if (OPTION (Opt_mapAlert))
1842# endif 1850# endif
1843 XMapWindow (display->display, parent[0]); 1851 XMapWindow (display->display, parent[0]);
1844# endif 1852# endif
1845 1853
1846 if (options & Opt_visualBell) 1854 if (OPTION (Opt_visualBell))
1847 { 1855 {
1848 scr_rvideo_mode (!rvideo); /* refresh also done */ 1856 scr_rvideo_mode (!rvideo); /* refresh also done */
1849 rxvt_usleep (VISUAL_BELL_DURATION); 1857 rxvt_usleep (VISUAL_BELL_DURATION);
1850 scr_rvideo_mode (!rvideo); /* refresh also done */ 1858 scr_rvideo_mode (!rvideo); /* refresh also done */
1851 } 1859 }
1942 1950
1943#if XPM_BACKGROUND 1951#if XPM_BACKGROUND
1944 must_clear |= bgPixmap.pixmap != None; 1952 must_clear |= bgPixmap.pixmap != None;
1945#endif 1953#endif
1946#if TRANSPARENT 1954#if TRANSPARENT
1947 must_clear |= (options & Opt_transparent) && am_transparent; 1955 must_clear |= OPTION (Opt_transparent) && am_transparent;
1948#endif 1956#endif
1949 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 1957 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1950 1958
1951 /* 1959 /*
1952 * B: reverse any characters which are selected 1960 * B: reverse any characters which are selected
1953 */ 1961 */
1962 PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
1954 scr_reverse_selection (); 1963 scr_reverse_selection ();
1955 1964
1956 /* 1965 /*
1957 * C: set the cursor character (s) 1966 * C: set the cursor character (s)
1958 */ 1967 */
1976 1985
1977 crp = &ROW(screen.cur.row).r[col]; 1986 crp = &ROW(screen.cur.row).r[col];
1978 1987
1979 if (showcursor && focus) 1988 if (showcursor && focus)
1980 { 1989 {
1981 if (options & Opt_cursorUnderline) 1990 if (OPTION (Opt_cursorUnderline))
1982 *crp ^= RS_Uline; 1991 *crp ^= RS_Uline;
1983 else 1992 else
1984 { 1993 {
1985 *crp ^= RS_RVid; 1994 *crp ^= RS_RVid;
1986 1995
1988 cc1 = *crp & (RS_fgMask | RS_bgMask); 1997 cc1 = *crp & (RS_fgMask | RS_bgMask);
1989 if (ISSET_PIXCOLOR (Color_cursor)) 1998 if (ISSET_PIXCOLOR (Color_cursor))
1990 ccol1 = Color_cursor; 1999 ccol1 = Color_cursor;
1991 else 2000 else
1992#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2001#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1993 ccol1 = GET_FGCOLOR (rstyle); 2002 ccol1 = fgcolor_of (rstyle);
1994#else 2003#else
1995 ccol1 = Color_fg; 2004 ccol1 = Color_fg;
1996#endif 2005#endif
1997 if (ISSET_PIXCOLOR (Color_cursor2)) 2006 if (ISSET_PIXCOLOR (Color_cursor2))
1998 ccol2 = Color_cursor2; 2007 ccol2 = Color_cursor2;
1999 else 2008 else
2000#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2009#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2001 ccol2 = GET_BGCOLOR (rstyle); 2010 ccol2 = bgcolor_of (rstyle);
2002#else 2011#else
2003 ccol2 = Color_bg; 2012 ccol2 = Color_bg;
2004#endif 2013#endif
2005 *crp = SET_FGCOLOR (*crp, ccol1); 2014 *crp = SET_FGCOLOR (*crp, ccol1);
2006 *crp = SET_BGCOLOR (*crp, ccol2); 2015 *crp = SET_BGCOLOR (*crp, ccol2);
2187 count++, i--; 2196 count++, i--;
2188 2197
2189 /* 2198 /*
2190 * Determine the attributes for the string 2199 * Determine the attributes for the string
2191 */ 2200 */
2192 int fore = GET_FGCOLOR (rend); // desired foreground 2201 int fore = fgcolor_of (rend); // desired foreground
2193 int back = GET_BGCOLOR (rend); // desired background 2202 int back = bgcolor_of (rend); // desired background
2194 2203
2195 // only do special processing if any attributes are set, which is unlikely 2204 // only do special processing if any attributes are set, which is unlikely
2196 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2205 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2197 { 2206 {
2198#if ENABLE_STYLES 2207#if ENABLE_STYLES
2319 */ 2328 */
2320 if (showcursor) 2329 if (showcursor)
2321 { 2330 {
2322 if (focus) 2331 if (focus)
2323 { 2332 {
2324 if (options & Opt_cursorUnderline) 2333 if (OPTION (Opt_cursorUnderline))
2325 *crp ^= RS_Uline; 2334 *crp ^= RS_Uline;
2326 else 2335 else
2327 { 2336 {
2328 *crp ^= RS_RVid; 2337 *crp ^= RS_RVid;
2329#ifndef NO_CURSORCOLOR 2338#ifndef NO_CURSORCOLOR
2358 2367
2359 /* 2368 /*
2360 * H: cleanup selection 2369 * H: cleanup selection
2361 */ 2370 */
2362 scr_reverse_selection (); 2371 scr_reverse_selection ();
2372 PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2363 2373
2364 if (refresh_type & SMOOTH_REFRESH) 2374 if (refresh_type & SMOOTH_REFRESH)
2365 XFlush (display->display); 2375 XFlush (display->display);
2366 2376
2367 num_scr = 0; 2377 num_scr = 0;
2448 2458
2449#if ENABLE_FRILLS 2459#if ENABLE_FRILLS
2450 if (selection.rect) 2460 if (selection.rect)
2451 { 2461 {
2452 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) 2462 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++)
2463 {
2464 text_t *stp = ROW(row).t;
2465 rend_t *srp = ROW(row).r;
2466
2453 for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) 2467 for (col = selection.beg.col; col < selection.end.col; col++)
2454 srp[col] ^= RS_RVid; 2468 srp[col] ^= RS_RVid;
2469
2470 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col])))
2471 srp[col] ^= RS_RVid | RS_Uline;
2472
2473 if (++col < selection.end.col)
2474 srp[col] ^= RS_RVid | RS_Uline;
2475 }
2455 } 2476 }
2456 else 2477 else
2457#endif 2478#endif
2458 { 2479 {
2459 if (selection.beg.row >= -view_start) 2480 if (selection.beg.row >= -view_start)
2861 selection.op = SELECTION_DONE; 2882 selection.op = SELECTION_DONE;
2862 2883
2863 if (selection.clicks == 4) 2884 if (selection.clicks == 4)
2864 return; /* nothing selected, go away */ 2885 return; /* nothing selected, go away */
2865 2886
2887 if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2888 return;
2889
2866 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 2890 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2867 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); 2891 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t));
2868 2892
2869 int ofs = 0; 2893 int ofs = 0;
2870 int extra = 0; 2894 int extra = 0;
2886#endif 2910#endif
2887 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN 2911 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN
2888 2912
2889 col = max (col, 0); 2913 col = max (col, 0);
2890 2914
2891 if (row == selection.end.row || selection.rect) 2915 if (row == selection.end.row
2916#if ENABLE_FRILLS
2917 || selection.rect
2918#endif
2919 )
2892 end_col = min (end_col, selection.end.col); 2920 min_it (end_col, selection.end.col);
2893 2921
2894 t = ROW(row).t + col; 2922 t = ROW(row).t + col;
2895 for (; col < end_col; col++) 2923 for (; col < end_col; col++)
2896 { 2924 {
2897 if (*t == NOCHAR) 2925 if (*t == NOCHAR)
2915#endif 2943#endif
2916 else 2944 else
2917 new_selection_text[ofs++] = *t++; 2945 new_selection_text[ofs++] = *t++;
2918 } 2946 }
2919 2947
2948#if ENABLE_FRILLS
2949 if (selection.rect)
2950 {
2951 while (ofs
2952 && new_selection_text[ofs - 1] != C0_LF
2953 && unicode::is_space (new_selection_text[ofs - 1]))
2954 --ofs;
2955
2956 new_selection_text[ofs++] = C0_LF;
2957 }
2958 else
2959#endif
2920 if (!ROW(row).is_longer () && row != selection.end.row) 2960 if (!ROW(row).is_longer () && row != selection.end.row)
2921 new_selection_text[ofs++] = C0_LF; 2961 new_selection_text[ofs++] = C0_LF;
2922 } 2962 }
2923 2963
2924 if (end_col != selection.end.col) 2964 if (end_col != selection.end.col)
2925 new_selection_text[ofs++] = C0_LF; 2965 new_selection_text[ofs++] = C0_LF;
2926 2966
2936 2976
2937 // we usually allocate much more than necessary, so realloc it smaller again 2977 // we usually allocate much more than necessary, so realloc it smaller again
2938 selection.len = ofs; 2978 selection.len = ofs;
2939 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); 2979 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t));
2940 2980
2981 if (PERL_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END)))
2982 return;
2983
2984 selection_grab (tm);
2985}
2986
2987bool
2988rxvt_term::selection_grab (Time tm)
2989{
2990 selection_time = tm;
2991
2941 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 2992 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm);
2942 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 2993 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt)
2994 {
2943 display->set_selection_owner (this); 2995 display->set_selection_owner (this);
2996 return true;
2997 }
2944 else 2998 else
2945 rxvt_warn ("can't get primary selection, ignoring.\n"); 2999 return false;
2946 3000
2947#if 0 3001#if 0
2948 XTextProperty ct; 3002 XTextProperty ct;
2949 3003
2950 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3004 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2951 { 3005 {
2952 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3006 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
2953 XFree (ct.value); 3007 XFree (ct.value);
2954 } 3008 }
2955#endif 3009#endif
2956
2957 selection_time = tm;
2958} 3010}
2959 3011
2960/* ------------------------------------------------------------------------- */ 3012/* ------------------------------------------------------------------------- */
2961/* 3013/*
2962 * Mark or select text based upon number of clicks: 1, 2, or 3 3014 * Mark or select text based upon number of clicks: 1, 2, or 3
3277 selection_delimit_word (DN, &selection.end, &selection.end); 3329 selection_delimit_word (DN, &selection.end, &selection.end);
3278 } 3330 }
3279 else if (selection.clicks == 3) 3331 else if (selection.clicks == 3)
3280 { 3332 {
3281#if ENABLE_FRILLS 3333#if ENABLE_FRILLS
3282 if (options & Opt_tripleclickwords) 3334 if (OPTION (Opt_tripleclickwords))
3283 { 3335 {
3284 selection_delimit_word (UP, &selection.beg, &selection.beg); 3336 selection_delimit_word (UP, &selection.beg, &selection.beg);
3285 3337
3286 for (int end_row = selection.mark.row; end_row < nrow; end_row++) 3338 for (int end_row = selection.mark.row; end_row < nrow; end_row++)
3287 { 3339 {
3348 { 3400 {
3349 stp = ROW(end_row).t; 3401 stp = ROW(end_row).t;
3350 3402
3351 while (--end_col >= 0) 3403 while (--end_col >= 0)
3352 { 3404 {
3353 if (stp[end_col] != ' ' 3405 if (stp[end_col] != NOCHAR
3354 && stp[end_col] != '\t' 3406 && !unicode::is_space (stp[end_col]))
3355 && stp[end_col] != NOCHAR)
3356 break; 3407 break;
3357 } 3408 }
3358 3409
3359 if (end_col >= 0 3410 if (end_col >= 0
3360 || !ROW(end_row - 1).is_longer ()) 3411 || !ROW(end_row - 1).is_longer ())
3559 3610
3560#if ENABLE_OVERLAY 3611#if ENABLE_OVERLAY
3561void 3612void
3562rxvt_term::scr_overlay_new (int x, int y, int w, int h) 3613rxvt_term::scr_overlay_new (int x, int y, int w, int h)
3563{ 3614{
3564 if (nrow < 3 || ncol < 3) 3615 if (nrow < 1 || ncol < 1)
3565 return; 3616 return;
3566 3617
3567 want_refresh = 1; 3618 want_refresh = 1;
3568 3619
3569 scr_overlay_off (); 3620 scr_overlay_off ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines