diff options
author | Geoff Voelker <voelker@cs.washington.edu> | 1998-10-28 03:50:07 +0000 |
---|---|---|
committer | Geoff Voelker <voelker@cs.washington.edu> | 1998-10-28 03:50:07 +0000 |
commit | 93cbf229f9902f24ac85b1611a0b170654786778 (patch) | |
tree | be76dc1cdb3546172aaabfd98fa84eba867c3486 /src/w32select.c | |
parent | 931f525c9e95ffb9660a77e053ec409357fc4a27 (diff) | |
download | emacs-93cbf229f9902f24ac85b1611a0b170654786778.tar.gz |
(Vnext_selection_coding_system): New variable.
(syms_of_w32select): DEFVAR_LISP it.
(Fw32_set_clipboard_data): Use Vnext_selection_coding_system if
non-nil. Always convert multibyte strings.
(Fw32_get_clipboard_data): Use Vnext_selection_coding_system if
non-nil. Always convert a string that includes non-ASCII characters.
Diffstat (limited to 'src/w32select.c')
-rw-r--r-- | src/w32select.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/w32select.c b/src/w32select.c index 5191b2a2ed2..da01576ddf3 100644 --- a/src/w32select.c +++ b/src/w32select.c @@ -36,6 +36,9 @@ Lisp_Object QCLIPBOARD; clipboard. */ static Lisp_Object Vselection_coding_system; +/* Coding system for the next communicating with other X clients. */ +static Lisp_Object Vnext_selection_coding_system; + #if 0 DEFUN ("w32-open-clipboard", Fw32_open_clipboard, Sw32_open_clipboard, 0, 1, 0, "This opens the clipboard with the given frame pointer.") @@ -117,8 +120,9 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, Sw32_set_clipboard_dat int num; bzero (charsets, (MAX_CHARSET + 1) * sizeof (int)); - num = ((nbytes <= 2 /* Check the possibility of short cut. */ - || NILP (buffer_defaults.enable_multibyte_characters)) + num = ((nbytes <= 1 /* Check the possibility of short cut. */ + || !STRING_MULTIBYTE (string) + || nbytes == XSTRING (string)->size) ? 0 : find_charset_in_str (src, nbytes, charsets, Qnil, 0)); @@ -181,8 +185,11 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, Sw32_set_clipboard_dat struct coding_system coding; HANDLE htext2; + if (NILP (Vnext_selection_coding_system)) + Vnext_selection_coding_system = Vselection_coding_system; setup_coding_system - (Fcheck_coding_system (Vselection_coding_system), &coding); + (Fcheck_coding_system (Vnext_selection_coding_system), &coding); + Vnext_selection_coding_system = Qnil; coding.mode |= CODING_MODE_LAST_BLOCK; bufsize = encoding_buffer_size (&coding, nbytes); if ((htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, bufsize)) == NULL) @@ -242,20 +249,46 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data, Sw32_get_clipboard_dat unsigned char *dst; int nbytes; int truelen; + int require_encoding = 0; if ((src = (unsigned char *) GlobalLock (htext)) == NULL) goto closeclip; nbytes = strlen (src); - if (! NILP (buffer_defaults.enable_multibyte_characters)) + if ( +#if 1 + 1 +#else + ! NILP (buffer_defaults.enable_multibyte_characters) +#endif + ) + { + /* If the clipboard data contains any 8-bit Latin-1 code, we + need to decode it. */ + int i; + + for (i = 0; i < nbytes; i++) + { + if (src[i] >= 0x80) + { + require_encoding = 1; + break; + } + } + } + + if (require_encoding) { int bufsize; unsigned char *buf; struct coding_system coding; + if (NILP (Vnext_selection_coding_system)) + Vnext_selection_coding_system = Vselection_coding_system; setup_coding_system - (Fcheck_coding_system(Vselection_coding_system), &coding); + (Fcheck_coding_system (Vnext_selection_coding_system), &coding); + Vnext_selection_coding_system = Qnil; coding.mode |= CODING_MODE_LAST_BLOCK; bufsize = decoding_buffer_size (&coding, nbytes); buf = (unsigned char *) xmalloc (bufsize); @@ -378,5 +411,13 @@ the text is encoded or decoded by this coding system.\n\ A default value is `compound-text'"); Vselection_coding_system=intern ("iso-latin-1-dos"); + DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system, + "Coding system for the next communication with other X clients.\n\ +Usually, `selection-coding-system' is used for communicating with\n\ +other X clients. But, if this variable is set, it is used for the\n\ +next communication only. After the communication, this variable is\n\ +set to nil."); + Vnext_selection_coding_system = Qnil; + QCLIPBOARD = intern ("CLIPBOARD"); staticpro (&QCLIPBOARD); } |