diff options
| author | Geoff Voelker | 1998-10-28 03:50:07 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1998-10-28 03:50:07 +0000 |
| commit | 93cbf229f9902f24ac85b1611a0b170654786778 (patch) | |
| tree | be76dc1cdb3546172aaabfd98fa84eba867c3486 /src | |
| parent | 931f525c9e95ffb9660a77e053ec409357fc4a27 (diff) | |
| download | emacs-93cbf229f9902f24ac85b1611a0b170654786778.tar.gz emacs-93cbf229f9902f24ac85b1611a0b170654786778.zip | |
(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')
| -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; | |||
| 36 | clipboard. */ | 36 | clipboard. */ |
| 37 | static Lisp_Object Vselection_coding_system; | 37 | static Lisp_Object Vselection_coding_system; |
| 38 | 38 | ||
| 39 | /* Coding system for the next communicating with other X clients. */ | ||
| 40 | static Lisp_Object Vnext_selection_coding_system; | ||
| 41 | |||
| 39 | #if 0 | 42 | #if 0 |
| 40 | DEFUN ("w32-open-clipboard", Fw32_open_clipboard, Sw32_open_clipboard, 0, 1, 0, | 43 | DEFUN ("w32-open-clipboard", Fw32_open_clipboard, Sw32_open_clipboard, 0, 1, 0, |
| 41 | "This opens the clipboard with the given frame pointer.") | 44 | "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 | |||
| 117 | int num; | 120 | int num; |
| 118 | 121 | ||
| 119 | bzero (charsets, (MAX_CHARSET + 1) * sizeof (int)); | 122 | bzero (charsets, (MAX_CHARSET + 1) * sizeof (int)); |
| 120 | num = ((nbytes <= 2 /* Check the possibility of short cut. */ | 123 | num = ((nbytes <= 1 /* Check the possibility of short cut. */ |
| 121 | || NILP (buffer_defaults.enable_multibyte_characters)) | 124 | || !STRING_MULTIBYTE (string) |
| 125 | || nbytes == XSTRING (string)->size) | ||
| 122 | ? 0 | 126 | ? 0 |
| 123 | : find_charset_in_str (src, nbytes, charsets, Qnil, 0)); | 127 | : find_charset_in_str (src, nbytes, charsets, Qnil, 0)); |
| 124 | 128 | ||
| @@ -181,8 +185,11 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, Sw32_set_clipboard_dat | |||
| 181 | struct coding_system coding; | 185 | struct coding_system coding; |
| 182 | HANDLE htext2; | 186 | HANDLE htext2; |
| 183 | 187 | ||
| 188 | if (NILP (Vnext_selection_coding_system)) | ||
| 189 | Vnext_selection_coding_system = Vselection_coding_system; | ||
| 184 | setup_coding_system | 190 | setup_coding_system |
| 185 | (Fcheck_coding_system (Vselection_coding_system), &coding); | 191 | (Fcheck_coding_system (Vnext_selection_coding_system), &coding); |
| 192 | Vnext_selection_coding_system = Qnil; | ||
| 186 | coding.mode |= CODING_MODE_LAST_BLOCK; | 193 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 187 | bufsize = encoding_buffer_size (&coding, nbytes); | 194 | bufsize = encoding_buffer_size (&coding, nbytes); |
| 188 | if ((htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, bufsize)) == NULL) | 195 | 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 | |||
| 242 | unsigned char *dst; | 249 | unsigned char *dst; |
| 243 | int nbytes; | 250 | int nbytes; |
| 244 | int truelen; | 251 | int truelen; |
| 252 | int require_encoding = 0; | ||
| 245 | 253 | ||
| 246 | if ((src = (unsigned char *) GlobalLock (htext)) == NULL) | 254 | if ((src = (unsigned char *) GlobalLock (htext)) == NULL) |
| 247 | goto closeclip; | 255 | goto closeclip; |
| 248 | 256 | ||
| 249 | nbytes = strlen (src); | 257 | nbytes = strlen (src); |
| 250 | 258 | ||
| 251 | if (! NILP (buffer_defaults.enable_multibyte_characters)) | 259 | if ( |
| 260 | #if 1 | ||
| 261 | 1 | ||
| 262 | #else | ||
| 263 | ! NILP (buffer_defaults.enable_multibyte_characters) | ||
| 264 | #endif | ||
| 265 | ) | ||
| 266 | { | ||
| 267 | /* If the clipboard data contains any 8-bit Latin-1 code, we | ||
| 268 | need to decode it. */ | ||
| 269 | int i; | ||
| 270 | |||
| 271 | for (i = 0; i < nbytes; i++) | ||
| 272 | { | ||
| 273 | if (src[i] >= 0x80) | ||
| 274 | { | ||
| 275 | require_encoding = 1; | ||
| 276 | break; | ||
| 277 | } | ||
| 278 | } | ||
| 279 | } | ||
| 280 | |||
| 281 | if (require_encoding) | ||
| 252 | { | 282 | { |
| 253 | int bufsize; | 283 | int bufsize; |
| 254 | unsigned char *buf; | 284 | unsigned char *buf; |
| 255 | struct coding_system coding; | 285 | struct coding_system coding; |
| 256 | 286 | ||
| 287 | if (NILP (Vnext_selection_coding_system)) | ||
| 288 | Vnext_selection_coding_system = Vselection_coding_system; | ||
| 257 | setup_coding_system | 289 | setup_coding_system |
| 258 | (Fcheck_coding_system(Vselection_coding_system), &coding); | 290 | (Fcheck_coding_system (Vnext_selection_coding_system), &coding); |
| 291 | Vnext_selection_coding_system = Qnil; | ||
| 259 | coding.mode |= CODING_MODE_LAST_BLOCK; | 292 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 260 | bufsize = decoding_buffer_size (&coding, nbytes); | 293 | bufsize = decoding_buffer_size (&coding, nbytes); |
| 261 | buf = (unsigned char *) xmalloc (bufsize); | 294 | buf = (unsigned char *) xmalloc (bufsize); |
| @@ -378,5 +411,13 @@ the text is encoded or decoded by this coding system.\n\ | |||
| 378 | A default value is `compound-text'"); | 411 | A default value is `compound-text'"); |
| 379 | Vselection_coding_system=intern ("iso-latin-1-dos"); | 412 | Vselection_coding_system=intern ("iso-latin-1-dos"); |
| 380 | 413 | ||
| 414 | DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system, | ||
| 415 | "Coding system for the next communication with other X clients.\n\ | ||
| 416 | Usually, `selection-coding-system' is used for communicating with\n\ | ||
| 417 | other X clients. But, if this variable is set, it is used for the\n\ | ||
| 418 | next communication only. After the communication, this variable is\n\ | ||
| 419 | set to nil."); | ||
| 420 | Vnext_selection_coding_system = Qnil; | ||
| 421 | |||
| 381 | QCLIPBOARD = intern ("CLIPBOARD"); staticpro (&QCLIPBOARD); | 422 | QCLIPBOARD = intern ("CLIPBOARD"); staticpro (&QCLIPBOARD); |
| 382 | } | 423 | } |