diff options
| author | Kenichi Handa | 2003-06-17 10:51:11 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-06-17 10:51:11 +0000 |
| commit | e57ad4d89482d575be1ee2edae863da8c0c509f3 (patch) | |
| tree | bb655f467c04736d1b4c61f970fefd04eec84016 /src/xselect.c | |
| parent | 4e57881d89e8d323dbdca9798a7d14549a2d2a36 (diff) | |
| download | emacs-e57ad4d89482d575be1ee2edae863da8c0c509f3.tar.gz emacs-e57ad4d89482d575be1ee2edae863da8c0c509f3.zip | |
Don't include cahrset.h, coding.h, composite.h.
(Qforeign_selection): New variable.
(syms_of_xselect): Intern and static it.
(selection_data_to_lisp_data): Return a unibyte string made from
data with `foreign-selection' text property.
Diffstat (limited to 'src/xselect.c')
| -rw-r--r-- | src/xselect.c | 88 |
1 files changed, 18 insertions, 70 deletions
diff --git a/src/xselect.c b/src/xselect.c index 5fd2c862cb7..21b7ecff8ab 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -29,10 +29,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 29 | #include "frame.h" /* Need this to get the X window of selected_frame */ | 29 | #include "frame.h" /* Need this to get the X window of selected_frame */ |
| 30 | #include "blockinput.h" | 30 | #include "blockinput.h" |
| 31 | #include "buffer.h" | 31 | #include "buffer.h" |
| 32 | #include "charset.h" | ||
| 33 | #include "coding.h" | ||
| 34 | #include "process.h" | 32 | #include "process.h" |
| 35 | #include "composite.h" | ||
| 36 | 33 | ||
| 37 | struct prop_location; | 34 | struct prop_location; |
| 38 | 35 | ||
| @@ -114,6 +111,8 @@ static Lisp_Object Vselection_coding_system; | |||
| 114 | /* Coding system for the next communicating with other X clients. */ | 111 | /* Coding system for the next communicating with other X clients. */ |
| 115 | static Lisp_Object Vnext_selection_coding_system; | 112 | static Lisp_Object Vnext_selection_coding_system; |
| 116 | 113 | ||
| 114 | static Lisp_Object Qforeign_selection; | ||
| 115 | |||
| 117 | /* If this is a smaller number than the max-request-size of the display, | 116 | /* If this is a smaller number than the max-request-size of the display, |
| 118 | emacs will use INCR selection transfer when the selection is larger | 117 | emacs will use INCR selection transfer when the selection is larger |
| 119 | than this. The max-request-size is usually around 64k, so if you want | 118 | than this. The max-request-size is usually around 64k, so if you want |
| @@ -1605,74 +1604,21 @@ selection_data_to_lisp_data (display, data, size, type, format) | |||
| 1605 | /* Convert any 8-bit data to a string, for compactness. */ | 1604 | /* Convert any 8-bit data to a string, for compactness. */ |
| 1606 | else if (format == 8) | 1605 | else if (format == 8) |
| 1607 | { | 1606 | { |
| 1608 | Lisp_Object str; | 1607 | Lisp_Object str, lispy_type; |
| 1609 | int require_encoding = 0; | 1608 | |
| 1610 | 1609 | str = make_unibyte_string ((char *) data, size); | |
| 1611 | if ( | 1610 | /* Indicate that this string is from foreign selection by a text |
| 1612 | #if 1 | 1611 | property `foreign-selection' so that the caller of |
| 1613 | 1 | 1612 | x-get-selection-internal (usually x-get-selection) can know |
| 1614 | #else | 1613 | that the string must be decode. */ |
| 1615 | ! NILP (buffer_defaults.enable_multibyte_characters) | 1614 | if (type == dpyinfo->Xatom_COMPOUND_TEXT) |
| 1616 | #endif | 1615 | lispy_type = QCOMPOUND_TEXT; |
| 1617 | ) | 1616 | else if (type == dpyinfo->Xatom_UTF8_STRING) |
| 1618 | { | 1617 | lispy_type = QUTF8_STRING; |
| 1619 | /* If TYPE is `TEXT' or `COMPOUND_TEXT', we should decode | ||
| 1620 | DATA to Emacs internal format because DATA may be encoded | ||
| 1621 | in compound text format. In addtion, if TYPE is `STRING' | ||
| 1622 | and DATA contains any 8-bit Latin-1 code, we should also | ||
| 1623 | decode it. */ | ||
| 1624 | if (type == dpyinfo->Xatom_TEXT | ||
| 1625 | || type == dpyinfo->Xatom_COMPOUND_TEXT) | ||
| 1626 | require_encoding = 1; | ||
| 1627 | else if (type == XA_STRING) | ||
| 1628 | { | ||
| 1629 | int i; | ||
| 1630 | for (i = 0; i < size; i++) | ||
| 1631 | { | ||
| 1632 | if (data[i] >= 0x80) | ||
| 1633 | { | ||
| 1634 | require_encoding = 1; | ||
| 1635 | break; | ||
| 1636 | } | ||
| 1637 | } | ||
| 1638 | } | ||
| 1639 | } | ||
| 1640 | if (!require_encoding) | ||
| 1641 | { | ||
| 1642 | str = make_unibyte_string ((char *) data, size); | ||
| 1643 | Vlast_coding_system_used = Qraw_text; | ||
| 1644 | } | ||
| 1645 | else | 1618 | else |
| 1646 | { | 1619 | lispy_type = QSTRING; |
| 1647 | int bufsize; | 1620 | Fput_text_property (make_number (0), make_number (size), |
| 1648 | unsigned char *buf; | 1621 | Qforeign_selection, lispy_type, str); |
| 1649 | struct coding_system coding; | ||
| 1650 | |||
| 1651 | if (NILP (Vnext_selection_coding_system)) | ||
| 1652 | Vnext_selection_coding_system = Vselection_coding_system; | ||
| 1653 | setup_coding_system | ||
| 1654 | (Fcheck_coding_system(Vnext_selection_coding_system), &coding); | ||
| 1655 | coding.src_multibyte = 0; | ||
| 1656 | coding.dst_multibyte = 1; | ||
| 1657 | Vnext_selection_coding_system = Qnil; | ||
| 1658 | coding.mode |= CODING_MODE_LAST_BLOCK; | ||
| 1659 | /* We explicitely disable composition handling because | ||
| 1660 | selection data should not contain any composition | ||
| 1661 | sequence. */ | ||
| 1662 | coding.composing = COMPOSITION_DISABLED; | ||
| 1663 | bufsize = decoding_buffer_size (&coding, size); | ||
| 1664 | buf = (unsigned char *) xmalloc (bufsize); | ||
| 1665 | decode_coding (&coding, data, buf, size, bufsize); | ||
| 1666 | str = make_string_from_bytes ((char *) buf, | ||
| 1667 | coding.produced_char, coding.produced); | ||
| 1668 | xfree (buf); | ||
| 1669 | |||
| 1670 | if (SYMBOLP (coding.post_read_conversion) | ||
| 1671 | && !NILP (Ffboundp (coding.post_read_conversion))) | ||
| 1672 | str = run_pre_post_conversion_on_str (str, &coding, 0); | ||
| 1673 | Vlast_coding_system_used = coding.symbol; | ||
| 1674 | } | ||
| 1675 | compose_chars_in_text (0, SCHARS (str), str); | ||
| 1676 | return str; | 1622 | return str; |
| 1677 | } | 1623 | } |
| 1678 | /* Convert a single atom to a Lisp_Symbol. Convert a set of atoms to | 1624 | /* Convert a single atom to a Lisp_Symbol. Convert a set of atoms to |
| @@ -2451,4 +2397,6 @@ A value of 0 means wait as long as necessary. This is initialized from the | |||
| 2451 | QCUT_BUFFER7 = intern ("CUT_BUFFER7"); staticpro (&QCUT_BUFFER7); | 2397 | QCUT_BUFFER7 = intern ("CUT_BUFFER7"); staticpro (&QCUT_BUFFER7); |
| 2452 | #endif | 2398 | #endif |
| 2453 | 2399 | ||
| 2400 | Qforeign_selection = intern ("foreign-selection"); | ||
| 2401 | staticpro (&Qforeign_selection); | ||
| 2454 | } | 2402 | } |