/[emacs]/emacs/src/xselect.c
ViewVC logotype

Diff of /emacs/src/xselect.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.128 by rms, Sun Apr 6 20:35:06 2003 UTC revision 1.129 by handa, Tue Jun 17 10:51:11 2003 UTC
# Line 29  Boston, MA 02111-1307, USA.  */ Line 29  Boston, MA 02111-1307, USA.  */
29  #include "frame.h"      /* Need this to get the X window of selected_frame */  #include "frame.h"      /* Need this to get the X window of selected_frame */
30  #include "blockinput.h"  #include "blockinput.h"
31  #include "buffer.h"  #include "buffer.h"
 #include "charset.h"  
 #include "coding.h"  
32  #include "process.h"  #include "process.h"
 #include "composite.h"  
33    
34  struct prop_location;  struct prop_location;
35    
# Line 114  static Lisp_Object Vselection_coding_sys Line 111  static Lisp_Object Vselection_coding_sys
111  /* Coding system for the next communicating with other X clients.  */  /* Coding system for the next communicating with other X clients.  */
112  static Lisp_Object Vnext_selection_coding_system;  static Lisp_Object Vnext_selection_coding_system;
113    
114    static Lisp_Object Qforeign_selection;
115    
116  /* If this is a smaller number than the max-request-size of the display,  /* If this is a smaller number than the max-request-size of the display,
117     emacs will use INCR selection transfer when the selection is larger     emacs will use INCR selection transfer when the selection is larger
118     than this.  The max-request-size is usually around 64k, so if you want     than this.  The max-request-size is usually around 64k, so if you want
# Line 1605  selection_data_to_lisp_data (display, da Line 1604  selection_data_to_lisp_data (display, da
1604    /* Convert any 8-bit data to a string, for compactness.  */    /* Convert any 8-bit data to a string, for compactness.  */
1605    else if (format == 8)    else if (format == 8)
1606      {      {
1607        Lisp_Object str;        Lisp_Object str, lispy_type;
       int require_encoding = 0;  
1608    
1609        if (        str = make_unibyte_string ((char *) data, size);
1610  #if 1        /* Indicate that this string is from foreign selection by a text
1611            1           property `foreign-selection' so that the caller of
1612  #else           x-get-selection-internal (usually x-get-selection) can know
1613            ! NILP (buffer_defaults.enable_multibyte_characters)           that the string must be decode.  */
1614  #endif        if (type == dpyinfo->Xatom_COMPOUND_TEXT)
1615            )          lispy_type = QCOMPOUND_TEXT;
1616          {        else if (type == dpyinfo->Xatom_UTF8_STRING)
1617            /* If TYPE is `TEXT' or `COMPOUND_TEXT', we should decode          lispy_type = QUTF8_STRING;
              DATA to Emacs internal format because DATA may be encoded  
              in compound text format.  In addtion, if TYPE is `STRING'  
              and DATA contains any 8-bit Latin-1 code, we should also  
              decode it.  */  
           if (type == dpyinfo->Xatom_TEXT  
               || type == dpyinfo->Xatom_COMPOUND_TEXT)  
             require_encoding = 1;  
           else if (type == XA_STRING)  
             {  
               int i;  
               for (i = 0; i < size; i++)  
                 {  
                   if (data[i] >= 0x80)  
                     {  
                       require_encoding = 1;  
                       break;  
                     }  
                 }  
             }  
         }  
       if (!require_encoding)  
         {  
           str = make_unibyte_string ((char *) data, size);  
           Vlast_coding_system_used = Qraw_text;  
         }  
1618        else        else
1619          {          lispy_type = QSTRING;
1620            int bufsize;        Fput_text_property (make_number (0), make_number (size),
1621            unsigned char *buf;                            Qforeign_selection, lispy_type, str);
           struct coding_system coding;  
   
           if (NILP (Vnext_selection_coding_system))  
             Vnext_selection_coding_system = Vselection_coding_system;  
           setup_coding_system  
             (Fcheck_coding_system(Vnext_selection_coding_system), &coding);  
           coding.src_multibyte = 0;  
           coding.dst_multibyte = 1;  
           Vnext_selection_coding_system = Qnil;  
           coding.mode |= CODING_MODE_LAST_BLOCK;  
           /* We explicitely disable composition handling because  
              selection data should not contain any composition  
              sequence.  */  
           coding.composing = COMPOSITION_DISABLED;  
           bufsize = decoding_buffer_size (&coding, size);  
           buf = (unsigned char *) xmalloc (bufsize);  
           decode_coding (&coding, data, buf, size, bufsize);  
           str = make_string_from_bytes ((char *) buf,  
                                         coding.produced_char, coding.produced);  
           xfree (buf);  
   
           if (SYMBOLP (coding.post_read_conversion)  
               && !NILP (Ffboundp (coding.post_read_conversion)))  
             str = run_pre_post_conversion_on_str (str, &coding, 0);  
           Vlast_coding_system_used = coding.symbol;  
         }  
       compose_chars_in_text (0, SCHARS (str), str);  
1622        return str;        return str;
1623      }      }
1624    /* Convert a single atom to a Lisp_Symbol.  Convert a set of atoms to    /* Convert a single atom to a Lisp_Symbol.  Convert a set of atoms to
# Line 2451  A value of 0 means wait as long as neces Line 2397  A value of 0 means wait as long as neces
2397    QCUT_BUFFER7 = intern ("CUT_BUFFER7"); staticpro (&QCUT_BUFFER7);    QCUT_BUFFER7 = intern ("CUT_BUFFER7"); staticpro (&QCUT_BUFFER7);
2398  #endif  #endif
2399    
2400      Qforeign_selection = intern ("foreign-selection");
2401      staticpro (&Qforeign_selection);
2402  }  }

Legend:
Removed from v.1.128  
changed lines
  Added in v.1.129

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26