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.352 by root, Fri Oct 15 20:52:15 2010 UTC vs.
Revision 1.367 by sf-exg, Mon Jan 31 15:40:22 2011 UTC

400 } 400 }
401 401
402 free (tabs); 402 free (tabs);
403 tabs = (char *)rxvt_malloc (ncol); 403 tabs = (char *)rxvt_malloc (ncol);
404 404
405 for (int col = ncol; --col; ) 405 for (int col = ncol; col--; )
406 tabs [col] = col % TABSIZE == 0; 406 tabs [col] = col % TABSIZE == 0;
407 407
408 CLEAR_ALL_SELECTION (); 408 CLEAR_ALL_SELECTION ();
409 409
410 prev_nrow = nrow; 410 prev_nrow = nrow;
917 else 917 else
918 screen.cur.col = ncol - width; 918 screen.cur.col = ncol - width;
919 } 919 }
920 920
921 // nuke the character at this position, if required 921 // nuke the character at this position, if required
922 if (expect_false ( 922 // due to wonderful coincidences everywhere else in this loop
923 // we never have to check for overwriting a wide char itself,
924 // only its tail.
923 line->t[screen.cur.col] == NOCHAR 925 if (expect_false (line->t[screen.cur.col] == NOCHAR))
924 || (screen.cur.col < ncol - 1
925 && line->t[screen.cur.col + 1] == NOCHAR)
926 ))
927 scr_kill_char (*line, screen.cur.col); 926 scr_kill_char (*line, screen.cur.col);
928 927
929 line->touch (); 928 line->touch ();
930 929
931 do 930 do
1686 { 1685 {
1687 rvideo_state = on; 1686 rvideo_state = on;
1688 1687
1689 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1688 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1690#ifdef HAVE_BG_PIXMAP 1689#ifdef HAVE_BG_PIXMAP
1691 if (bgPixmap.pixmap == None) 1690 if (bg_pixmap == None)
1692#endif 1691#endif
1693 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 1692 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
1694 1693
1695 XGCValues gcvalue; 1694 XGCValues gcvalue;
1696 gcvalue.foreground = pix_colors[Color_fg]; 1695 gcvalue.foreground = pix_colors[Color_fg];
2032 refresh_count = 0; 2031 refresh_count = 0;
2033 2032
2034 unsigned int old_screen_flags = screen.flags; 2033 unsigned int old_screen_flags = screen.flags;
2035 char have_bg = 0; 2034 char have_bg = 0;
2036#ifdef HAVE_BG_PIXMAP 2035#ifdef HAVE_BG_PIXMAP
2037 have_bg = bgPixmap.pixmap != None; 2036 have_bg = bg_pixmap != None;
2038#endif 2037#endif
2039 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2038 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
2040 2039
2041 /* 2040 /*
2042 * B: reverse any characters which are selected 2041 * B: reverse any characters which are selected
2509 scr_remap_chars (swap_buf [i]); 2508 scr_remap_chars (swap_buf [i]);
2510 } 2509 }
2511} 2510}
2512 2511
2513void 2512void
2514rxvt_term::scr_recolour () NOTHROW 2513rxvt_term::scr_recolour (bool refresh) NOTHROW
2515{ 2514{
2515 bool transparent = false;
2516
2516#ifdef HAVE_BG_PIXMAP 2517#ifdef HAVE_BG_PIXMAP
2517 bgPixmap.apply (); 2518 if (bg_pixmap != None)
2518#else 2519 {
2520# ifdef ENABLE_TRANSPARENCY
2521 if (bg_flags & BG_IS_TRANSPARENT)
2522 {
2523 XSetWindowBackgroundPixmap (dpy, parent[0], bg_pixmap);
2524 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2519 2525
2526 transparent = true;
2527 }
2528 else
2529# endif
2530 {
2531 XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]);
2532 XSetWindowBackgroundPixmap (dpy, vt, bg_pixmap);
2533 }
2534 }
2535 else
2536#endif
2537 {
2520 XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); 2538 XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]);
2539 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2540 }
2541
2521 XClearWindow (dpy, parent[0]); 2542 XClearWindow (dpy, parent[0]);
2522 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2523 2543
2524 if (scrollBar.win) 2544 if (scrollBar.win)
2525 { 2545 {
2546 if (transparent)
2547 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2548 else
2526 XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); 2549 XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]);
2527 scrollBar.state = STATE_IDLE; 2550 scrollBar.state = STATE_IDLE;
2528 scrollBar.show (0); 2551 scrollBar.show (0);
2529 } 2552 }
2530 2553
2531#endif 2554 if (refresh)
2532 2555 {
2533 /* bgPixmap.apply () does not do the following : */
2534 scr_clear (); 2556 scr_clear ();
2535 scr_touch (true); 2557 scr_touch (true);
2558 }
2536 want_refresh = 1; 2559 want_refresh = 1;
2537} 2560}
2538 2561
2539/* ------------------------------------------------------------------------- */ 2562/* ------------------------------------------------------------------------- */
2540void 2563void
2628void 2651void
2629rxvt_term::scr_dump (int fd) NOTHROW 2652rxvt_term::scr_dump (int fd) NOTHROW
2630{ 2653{
2631 int row, wrote; 2654 int row, wrote;
2632 unsigned int width, towrite; 2655 unsigned int width, towrite;
2633 char r1[] = "\n"; 2656 const char r1[] = "\n";
2634 2657
2635 for (row = saveLines + top_row; 2658 for (row = saveLines + top_row;
2636 row < saveLines + nrow - 1; row++) 2659 row < saveLines + nrow - 1; row++)
2637 { 2660 {
2638 width = row_buf[row].l >= 0 ? row_buf[row].l 2661 width = row_buf[row].l >= 0 ? row_buf[row].l
2719void 2742void
2720rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) NOTHROW 2743rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) NOTHROW
2721{ 2744{
2722 if (prop == None) /* check for failed XConvertSelection */ 2745 if (prop == None) /* check for failed XConvertSelection */
2723 { 2746 {
2747 int selnum = selection_type & Sel_whereMask;
2748
2749 if (selnum == Sel_direct)
2750 selection_type = 0;
2751
2724 if ((selection_type & Sel_CompoundText)) 2752 if ((selection_type & Sel_CompoundText))
2725 { 2753 {
2726 int selnum = selection_type & Sel_whereMask;
2727
2728 selection_type = 0; 2754 selection_type = 0;
2729 if (selnum != Sel_direct)
2730 selection_request_other (XA_STRING, selnum); 2755 selection_request_other (XA_STRING, selnum);
2731 } 2756 }
2732 2757
2733 if ((selection_type & Sel_UTF8String)) 2758 if ((selection_type & Sel_UTF8String))
2734 { 2759 {
2735 int selnum = selection_type & Sel_whereMask;
2736
2737 selection_type = Sel_CompoundText; 2760 selection_type = Sel_CompoundText;
2738 if (selnum != Sel_direct)
2739 selection_request_other (xa[XA_COMPOUND_TEXT], selnum); 2761 selection_request_other (xa[XA_COMPOUND_TEXT], selnum);
2740 else
2741 selection_type = 0;
2742 } 2762 }
2743 2763
2744 return; 2764 return;
2745 } 2765 }
2746 2766
2773 &ct2.nitems, &bytes_after, 2793 &ct2.nitems, &bytes_after,
2774 &ct2.value) != Success) 2794 &ct2.value) != Success)
2775 goto bailout; 2795 goto bailout;
2776 2796
2777 // realloc should be compatible to XFree, here, and elsewhere, too 2797 // realloc should be compatible to XFree, here, and elsewhere, too
2778 ct.value = (unsigned char *)realloc (ct.value, ct.nitems + ct2.nitems + 1); 2798 ct.value = (unsigned char *)rxvt_realloc (ct.value, ct.nitems + ct2.nitems + 1);
2779 memcpy (ct.value + ct.nitems, ct2.value, ct2.nitems + 1); 2799 memcpy (ct.value + ct.nitems, ct2.value, ct2.nitems + 1);
2780 ct.nitems += ct2.nitems; 2800 ct.nitems += ct2.nitems;
2781 2801
2782 XFree (ct2.value); 2802 XFree (ct2.value);
2783 } 2803 }
2832 incr_ev.start (10); 2852 incr_ev.start (10);
2833 2853
2834 while (incr_buf_fill + ct.nitems > incr_buf_size) 2854 while (incr_buf_fill + ct.nitems > incr_buf_size)
2835 { 2855 {
2836 incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; 2856 incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024;
2837 incr_buf = (char *)realloc (incr_buf, incr_buf_size); 2857 incr_buf = (char *)rxvt_realloc (incr_buf, incr_buf_size);
2838 } 2858 }
2839 2859
2840 memcpy (incr_buf + incr_buf_fill, ct.value, ct.nitems); 2860 memcpy (incr_buf + incr_buf_fill, ct.value, ct.nitems);
2841 incr_buf_fill += ct.nitems; 2861 incr_buf_fill += ct.nitems;
2842 2862
2999 * EXT: button 1 or 3 release 3019 * EXT: button 1 or 3 release
3000 */ 3020 */
3001void 3021void
3002rxvt_term::selection_make (Time tm) 3022rxvt_term::selection_make (Time tm)
3003{ 3023{
3004 int i; 3024 int size;
3005 wchar_t *new_selection_text; 3025 wchar_t *new_selection_text;
3006 text_t *t; 3026 text_t *t;
3007 3027
3008 switch (selection.op) 3028 switch (selection.op)
3009 { 3029 {
3025 return; /* nothing selected, go away */ 3045 return; /* nothing selected, go away */
3026 3046
3027 if (HOOK_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) 3047 if (HOOK_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
3028 return; 3048 return;
3029 3049
3030 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 3050 size = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
3031 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); 3051 new_selection_text = (wchar_t *)rxvt_malloc ((size + 4) * sizeof (wchar_t));
3032 3052
3033 int ofs = 0; 3053 int ofs = 0;
3034 int extra = 0; 3054 int extra = 0;
3035 3055
3036 int col = selection.beg.col; 3056 int col = selection.beg.col;
3042 { 3062 {
3043#if !ENABLE_MINIMAL 3063#if !ENABLE_MINIMAL
3044 if (selection.rect) 3064 if (selection.rect)
3045 { 3065 {
3046 col = selection.beg.col; 3066 col = selection.beg.col;
3047 end_col = ncol + 1; 3067 end_col = selection.end.col;
3048 } 3068 }
3049 else 3069 else
3050#endif 3070#endif
3051 end_col = ROW(row).l; 3071 end_col = ROW(row).l;
3052 3072
3053 col = max (col, 0); 3073 col = max (col, 0);
3054 3074
3055 if (row == selection.end.row 3075 if (row == selection.end.row)
3056#if !ENABLE_MINIMAL
3057 || selection.rect
3058#endif
3059 )
3060 min_it (end_col, selection.end.col); 3076 min_it (end_col, selection.end.col);
3061 3077
3062 t = ROW(row).t + col; 3078 t = ROW(row).t + col;
3063 3079
3064 for (; col < end_col; col++) 3080 for (; col < end_col; col++)
3072 3088
3073 extra -= (len - 1); 3089 extra -= (len - 1);
3074 3090
3075 if (extra < 0) 3091 if (extra < 0)
3076 { 3092 {
3077 extra += i; 3093 extra += size;
3078 i += i; 3094 size += size;
3079 new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (i + 4) * sizeof (wchar_t)); 3095 new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (size + 4) * sizeof (wchar_t));
3080 } 3096 }
3081 3097
3082 ofs += rxvt_composite.expand (*t++, new_selection_text + ofs); 3098 ofs += rxvt_composite.expand (*t++, new_selection_text + ofs);
3083 } 3099 }
3084#endif 3100#endif
3096 3112
3097 new_selection_text[ofs++] = C0_LF; 3113 new_selection_text[ofs++] = C0_LF;
3098 } 3114 }
3099 else 3115 else
3100#endif 3116#endif
3101 if (!ROW(row).is_longer () && row != selection.end.row) 3117 if (!ROW(row).is_longer ()
3118 && (row != selection.end.row || end_col != selection.end.col)
3119 && (row != selection.beg.row || selection.beg.col < ncol))
3102 new_selection_text[ofs++] = C0_LF; 3120 new_selection_text[ofs++] = C0_LF;
3103 } 3121 }
3104
3105 if (end_col != selection.end.col)
3106 new_selection_text[ofs++] = C0_LF;
3107 3122
3108 new_selection_text[ofs] = 0; 3123 new_selection_text[ofs] = 0;
3109 3124
3110 if (ofs == 0) 3125 if (ofs == 0)
3111 { 3126 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines