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.35 by pcg, Tue Feb 24 11:48:40 2004 UTC vs.
Revision 1.39 by pcg, Wed Feb 25 15:06:05 2004 UTC

1/*--------------------------------*-C-*--------------------------------------* 1/*--------------------------------*-C-*--------------------------------------*
2 * File: screen.c 2 * File: screen.c
3 *---------------------------------------------------------------------------* 3 *---------------------------------------------------------------------------*
4 * 4 *
5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> 5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com>
6 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version. 11 * (at your option) any later version.
16 * 17 *
17 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *--------------------------------------------------------------------------*/ 21 *--------------------------------------------------------------------------*/
22
21/* 23/*
22 * We handle _all_ screen updates and selections 24 * This file handles _all_ screen updates and selections
23 */ 25 */
24 26
25#include "../config.h" /* NECESSARY */ 27#include "../config.h" /* NECESSARY */
26#define INTERN_SCREEN 28#define INTERN_SCREEN
27#include "rxvt.h" /* NECESSARY */ 29#include "rxvt.h" /* NECESSARY */
30#include <X11/Xmd.h> /* get the typedef for CARD32 */ 32#include <X11/Xmd.h> /* get the typedef for CARD32 */
31 33
32#include <stdint.h> 34#include <stdint.h>
33#include <wchar.h> 35#include <wchar.h>
34 36
35#include "salloc.C" // HACK!! 37#include "salloc.C" // HACK, should be a seperate compile!
36 38
37inline void fill_text (text_t *start, text_t value, int len) 39inline void fill_text (text_t *start, text_t value, int len)
38{ 40{
39 while (len--) 41 while (len--)
40 *start++ = value; 42 *start++ = value;
862 scr_insdel_chars (1, INSERT); 864 scr_insdel_chars (1, INSERT);
863 865
864 if (charsets[screen.charset] == '0') // DEC SPECIAL 866 if (charsets[screen.charset] == '0') // DEC SPECIAL
865 switch (c) 867 switch (c)
866 { 868 {
869 // dunno where these come from
870#if 0
867 case '+': c = 0x2192; break; case ',': c = 0x2190; break; case '-': c = 0x2191; break; 871 case '+': c = 0x2192; break; case ',': c = 0x2190; break; case '-': c = 0x2191; break;
868 case '.': c = 0x2193; break; case '0': c = 0x25ae; break; case '`': c = 0x25c6; break; 872 case '.': c = 0x2193; break; case '0': c = 0x25ae; break;
873#endif
874 // vt100 special graphics and line drawing
875 case '`': c = 0x25c6; break; case '_': c = 0x0020; break;
869 case 'a': c = 0x2592; break; case 'f': c = 0x00b0; break; case 'g': c = 0x00b1; break; 876 case 'a': c = 0x2592; break; case 'b': c = 0x2409; break; case 'c': c = 0x240c; break;
870 case 'h': c = 0x2592; break; case 'i': c = 0x2603; break; case 'j': c = 0x2518; break;
871 case 'k': c = 0x2510; break; case 'l': c = 0x250c; break; case 'm': c = 0x2514; break; 877 case 'd': c = 0x240d; break; case 'e': c = 0x240a; break; case 'f': c = 0x00b0; break;
878 case 'g': c = 0x00b1; break; case 'h': c = 0x2424; break; case 'i': c = 0x240b; break;
872 case 'n': c = 0x253c; break; case 'o': c = 0x23ba; break; case 'p': c = 0x23bb; break; 879 case 'j': c = 0x2518; break; case 'k': c = 0x2510; break; case 'l': c = 0x250c; break;
873 case 'q': c = 0x2500; break; case 'r': c = 0x23bc; break; case 's': c = 0x23bd; break; 880 case 'm': c = 0x2514; break; case 'n': c = 0x253c; break; case 'o': c = 0x23ba; break;
874 case 't': c = 0x251c; break; case 'u': c = 0x2524; break; case 'v': c = 0x2534; break; 881 case 'p': c = 0x23bb; break; case 'q': c = 0x2500; break; case 'r': c = 0x23bc; break;
875 case 'w': c = 0x252c; break; case 'x': c = 0x2502; break; case 'y': c = 0x2264; break; 882 case 's': c = 0x23bd; break; case 't': c = 0x251c; break; case 'u': c = 0x2524; break;
876 case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; 883 case 'v': c = 0x2534; break; case 'w': c = 0x252c; break; case 'x': c = 0x2502; break;
884 case 'y': c = 0x2264; break; case 'z': c = 0x2265; break; case '{': c = 0x03c0; break;
877 case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; 885 case '|': c = 0x2260; break; case '}': c = 0x00a3; break; case '~': c = 0x00b7; break;
878 } 886 }
879 887
880 rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c)); 888 rend_t rend = SET_FONT (rstyle, TermWin.fontset->find_font (c));
881 // rely on wcwidth to tell us the character width, at least for non-ascii 889 // rely on wcwidth to tell us the character width, at least for non-ascii
882 int width = c <= 128 ? 1 : wcwidth (c); 890 int width = c <= 128 ? 1 : wcwidth (c);
2114 int fore = GET_FGCOLOR (rend); // desired foreground 2122 int fore = GET_FGCOLOR (rend); // desired foreground
2115 int back = GET_BGCOLOR (rend); // desired background 2123 int back = GET_BGCOLOR (rend); // desired background
2116 2124
2117 rend = GET_ATTR (rend); 2125 rend = GET_ATTR (rend);
2118 2126
2119 rvid = !! (rend & RS_RVid); 2127 rvid = !!(rend & RS_RVid);
2128
2129#ifndef NO_BOLD_UNDERLINE_REVERSE
2130 if (rend & RS_Bold && fore == Color_fg)
2131 {
2132 if (ISSET_PIXCOLOR (Color_BD))
2133 fore = Color_BD;
2134 else
2135 rvid = !rvid;
2136 }
2137
2138 if (rend & RS_Uline)
2139 {
2140 if (ISSET_PIXCOLOR (Color_UL))
2141 fore = Color_UL;
2142 }
2143#endif
2144
2120 if (rvid) 2145 if (rvid)
2121 { 2146 {
2122 SWAP_IT (fore, back, int); 2147 SWAP_IT (fore, back, int);
2123 2148
2124#ifndef NO_BOLD_UNDERLINE_REVERSE 2149#ifndef NO_BOLD_UNDERLINE_REVERSE
2127 && !ISSET_PIXCOLOR (Color_cursor) 2152 && !ISSET_PIXCOLOR (Color_cursor)
2128# endif 2153# endif
2129 ) 2154 )
2130 back = Color_RV; 2155 back = Color_RV;
2131#endif 2156#endif
2132
2133 } 2157 }
2158
2134#ifdef TEXT_BLINK 2159#ifdef TEXT_BLINK
2135 if (rend & RS_Blink) 2160 if (rend & RS_Blink)
2136 { 2161 {
2137 if (!text_blink_ev.active) 2162 if (!text_blink_ev.active)
2138 { 2163 {
2139 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); 2164 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL);
2140 hidden_text = 0; 2165 hidden_text = 0;
2141 } 2166 }
2142 else if (hidden_text) 2167 else if (hidden_text)
2143 fore = back; 2168 fore = back;
2144 }
2145#endif
2146#ifndef NO_BOLD_UNDERLINE_REVERSE
2147 else if (rend & RS_Bold)
2148 {
2149 if (ISSET_PIXCOLOR (Color_BD))
2150 fore = Color_BD;
2151 else if (fore == Color_fg)
2152 fore = Color_White;
2153 }
2154 else if (rend & RS_Uline)
2155 {
2156 if (ISSET_PIXCOLOR (Color_UL))
2157 fore = Color_UL;
2158 } 2169 }
2159#endif 2170#endif
2160 2171
2161 /* 2172 /*
2162 * Actually do the drawing of the string here 2173 * Actually do the drawing of the string here
2479 } 2490 }
2480 2491
2481 for (;;) 2492 for (;;)
2482 { 2493 {
2483 if (XGetWindowProperty (display->display, win, prop, (long) (nread / 4), 2494 if (XGetWindowProperty (display->display, win, prop, (long) (nread / 4),
2484 (long) (PROP_SIZE / 4), delete_prop, 2495 (long) (PROP_SIZE / 4), delete_prop,
2485 AnyPropertyType, &ct.encoding, &ct.format, 2496 AnyPropertyType, &ct.encoding, &ct.format,
2486 &ct.nitems, &bytes_after, 2497 &ct.nitems, &bytes_after,
2487 &ct.value) != Success) 2498 &ct.value) != Success)
2488 break; 2499 break;
2489 2500
2490 if (ct.encoding == 0) 2501 if (ct.encoding == 0)
2491 { 2502 {
2492 D_SELECT ((stderr, "rxvt_selection_paste: property didn't exist!")); 2503 D_SELECT ((stderr, "rxvt_selection_paste: property didn't exist!"));
2500 } 2511 }
2501 2512
2502 if (ct.nitems == 0) 2513 if (ct.nitems == 0)
2503 { 2514 {
2504 D_SELECT ((stderr, "rxvt_selection_paste: property empty - also INCR end")); 2515 D_SELECT ((stderr, "rxvt_selection_paste: property empty - also INCR end"));
2505 if (selection_wait == Sel_normal && nread == 0) 2516 if (selection_wait == Sel_normal && nread == 0
2517 && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion
2506 { 2518 {
2507 /* 2519 /*
2508 * pass through again trying CUT_BUFFER0 if we've come from 2520 * pass through again trying CUT_BUFFER0 if we've come from
2509 * XConvertSelection () but nothing was presented 2521 * XConvertSelection () but nothing was presented
2510 */ 2522 */
2723 selection.op = SELECTION_DONE; 2735 selection.op = SELECTION_DONE;
2724 /* FALLTHROUGH */ 2736 /* FALLTHROUGH */
2725 default: 2737 default:
2726 return; 2738 return;
2727 } 2739 }
2740
2728 selection.op = SELECTION_DONE; 2741 selection.op = SELECTION_DONE;
2729 2742
2730 if (selection.clicks == 4) 2743 if (selection.clicks == 4)
2731 return; /* nothing selected, go away */ 2744 return; /* nothing selected, go away */
2732 2745
2783 { 2796 {
2784 free (new_selection_text); 2797 free (new_selection_text);
2785 return; 2798 return;
2786 } 2799 }
2787 2800
2788 // due to MB_MAX_CUR, selection wastage is usually high, so realloc 2801 // due to MB_CUR_MAX, selection wastage is usually high, so realloc
2789 if (str - (char *)new_selection_text > 1024) 2802 if (str - (char *)new_selection_text > 1024)
2790 new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); 2803 new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1);
2791 2804
2792 selection.len = i; 2805 selection.len = i;
2793 2806
2807 char *cl = (char *)selection.text; 2820 char *cl = (char *)selection.text;
2808 2821
2809 if (XmbTextListToTextProperty (display->display, &cl, 1, XStringStyle, &ct) >= 0) 2822 if (XmbTextListToTextProperty (display->display, &cl, 1, XStringStyle, &ct) >= 0)
2810 { 2823 {
2811 XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, 2824 XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8,
2812 PropModeReplace, ct.value, ct.nitems); 2825 PropModeReplace, ct.value, ct.nitems);
2813 XFree (ct.value); 2826 XFree (ct.value);
2814 } 2827 }
2815 else 2828 else
2816 XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, 2829 XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8,
2817 PropModeReplace, selection.text, (int)selection.len); 2830 PropModeReplace, selection.text, (int)selection.len);
2818 } 2831 }
2819 2832
2820 selection_time = tm; 2833 selection_time = tm;
2821 D_SELECT ((stderr, "rxvt_selection_make (): selection.len=%d", selection.len)); 2834 D_SELECT ((stderr, "rxvt_selection_make (): selection.len=%d", selection.len));
2822} 2835}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines