Mercurial > emacs
comparison src/xselect.c @ 110145:c403c2e0a620
Removed cut-buffer code.
* lisp/mouse-sel.el (mouse-sel-get-selection-function):
x-cut-buffer-or-selection-value renamed to x-selection-value.
(x-select-text): Optional push removed.
* lisp/select.el (x-get-cut-buffer, x-set-cut-buffer): Remove.
* lisp/simple.el (interprogram-cut-function): Remove mention of PUSH.
* lisp/w32-fns.el (x-last-selected-text):
x-cut-buffer-or-selection-value renamed to x-selection-value.
(x-cut-buffer-max): Remove.
(x-select-text): Remove argument PUSH, update documentation.
* lisp/emacs-lisp/cl-macs.el (x-get-cutbuffer, x-get-cut-buffer): Remove.
* lisp/term/ns-win.el (x-setup-function-keys, ns-last-selected-text):
x-cut-buffer-or-selection-value renamed to x-selection-value
(x-selection-value): Renamed from x-cut-buffer-or-selection-value.
(x-select-text): Remove argument PUSH, update documentation.
* lisp/term/pc-win.el (x-last-selected-text):
x-cut-buffer-or-selection-value renamed to x-selection-value
(x-select-text): Remove argument PUSH, update documentation.
* lisp/term/x-win.el: Update documentation for x-last-selected-text-*.
(x-last-selected-text-cut, x-last-selected-text-cut-encoded)
(x-last-cut-buffer-coding, x-cut-buffer-max): Remove.
(x-select-text): Remove argument PUSH, update documentation. Remove
cut-buffer code.
(x-selection-value-internal): Was previously x-selection-value.
(x-selection-value): Renamed from x-cut-buffer-or-selection-value.
Update documentation, remove cut-buffer code. Call
x-selection-value-internal.
(x-clipboard-yank): Call x-selection-value-internal.
(x-initialize-window-system): Remove setting of x-cut-buffer-max.
* src/xselect.c: Remove declaration of cut-buffer objects and functions.
(symbol_to_x_atom): Remove mapping to XA_CUT_BUFFERn.
(x_atom_to_symbol): Remove mapping to QCUT_BUFFERn.
(Fx_get_cut_buffer_internal, Fx_store_cut_buffer_internal)
(Fx_rotate_cut_buffers_internal): Remove.
(syms_of_xselect): Remove defsubr of above.
Remove intern of QCUT_BUFFERn.
* src/xterm.c (x_term_init): Don't set dpyinfo->cut_buffers_initialized.
* src/xterm.h (struct dpyinfo): Remove cut_buffers_initialized.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Thu, 02 Sep 2010 11:47:08 +0200 |
parents | 25de0a80ce75 |
children | 4f757d8e8ed7 |
comparison
equal
deleted
inserted
replaced
110144:6b5dc2e2565e | 110145:c403c2e0a620 |
---|---|
81 int, Atom, int); | 81 int, Atom, int); |
82 static void lisp_data_to_selection_data (Display *, Lisp_Object, | 82 static void lisp_data_to_selection_data (Display *, Lisp_Object, |
83 unsigned char **, Atom *, | 83 unsigned char **, Atom *, |
84 unsigned *, int *, int *); | 84 unsigned *, int *, int *); |
85 static Lisp_Object clean_local_selection_data (Lisp_Object); | 85 static Lisp_Object clean_local_selection_data (Lisp_Object); |
86 static void initialize_cut_buffers (Display *, Window); | |
87 | |
88 | 86 |
89 /* Printing traces to stderr. */ | 87 /* Printing traces to stderr. */ |
90 | 88 |
91 #ifdef TRACE_SELECTION | 89 #ifdef TRACE_SELECTION |
92 #define TRACE0(fmt) \ | 90 #define TRACE0(fmt) \ |
103 #define TRACE2(fmt, a0, a1) (void) 0 | 101 #define TRACE2(fmt, a0, a1) (void) 0 |
104 #define TRACE3(fmt, a0, a1) (void) 0 | 102 #define TRACE3(fmt, a0, a1) (void) 0 |
105 #endif | 103 #endif |
106 | 104 |
107 | 105 |
108 #define CUT_BUFFER_SUPPORT | |
109 | |
110 Lisp_Object QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP, | 106 Lisp_Object QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP, |
111 QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL, | 107 QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL, |
112 QATOM_PAIR; | 108 QATOM_PAIR; |
113 | 109 |
114 Lisp_Object QCOMPOUND_TEXT; /* This is a type of selection. */ | 110 Lisp_Object QCOMPOUND_TEXT; /* This is a type of selection. */ |
115 Lisp_Object QUTF8_STRING; /* This is a type of selection. */ | 111 Lisp_Object QUTF8_STRING; /* This is a type of selection. */ |
116 | 112 |
117 Lisp_Object Qcompound_text_with_extensions; | 113 Lisp_Object Qcompound_text_with_extensions; |
118 | |
119 #ifdef CUT_BUFFER_SUPPORT | |
120 Lisp_Object QCUT_BUFFER0, QCUT_BUFFER1, QCUT_BUFFER2, QCUT_BUFFER3, | |
121 QCUT_BUFFER4, QCUT_BUFFER5, QCUT_BUFFER6, QCUT_BUFFER7; | |
122 #endif | |
123 | 114 |
124 static Lisp_Object Vx_lost_selection_functions; | 115 static Lisp_Object Vx_lost_selection_functions; |
125 static Lisp_Object Vx_sent_selection_functions; | 116 static Lisp_Object Vx_sent_selection_functions; |
126 static Lisp_Object Qforeign_selection; | 117 static Lisp_Object Qforeign_selection; |
127 | 118 |
268 if (EQ (sym, QMULTIPLE)) return dpyinfo->Xatom_MULTIPLE; | 259 if (EQ (sym, QMULTIPLE)) return dpyinfo->Xatom_MULTIPLE; |
269 if (EQ (sym, QINCR)) return dpyinfo->Xatom_INCR; | 260 if (EQ (sym, QINCR)) return dpyinfo->Xatom_INCR; |
270 if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP; | 261 if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP; |
271 if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS; | 262 if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS; |
272 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL; | 263 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL; |
273 #ifdef CUT_BUFFER_SUPPORT | |
274 if (EQ (sym, QCUT_BUFFER0)) return XA_CUT_BUFFER0; | |
275 if (EQ (sym, QCUT_BUFFER1)) return XA_CUT_BUFFER1; | |
276 if (EQ (sym, QCUT_BUFFER2)) return XA_CUT_BUFFER2; | |
277 if (EQ (sym, QCUT_BUFFER3)) return XA_CUT_BUFFER3; | |
278 if (EQ (sym, QCUT_BUFFER4)) return XA_CUT_BUFFER4; | |
279 if (EQ (sym, QCUT_BUFFER5)) return XA_CUT_BUFFER5; | |
280 if (EQ (sym, QCUT_BUFFER6)) return XA_CUT_BUFFER6; | |
281 if (EQ (sym, QCUT_BUFFER7)) return XA_CUT_BUFFER7; | |
282 #endif | |
283 if (!SYMBOLP (sym)) abort (); | 264 if (!SYMBOLP (sym)) abort (); |
284 | 265 |
285 TRACE1 (" XInternAtom %s", (char *) SDATA (SYMBOL_NAME (sym))); | 266 TRACE1 (" XInternAtom %s", (char *) SDATA (SYMBOL_NAME (sym))); |
286 BLOCK_INPUT; | 267 BLOCK_INPUT; |
287 val = XInternAtom (display, (char *) SDATA (SYMBOL_NAME (sym)), False); | 268 val = XInternAtom (display, (char *) SDATA (SYMBOL_NAME (sym)), False); |
313 return QSTRING; | 294 return QSTRING; |
314 case XA_INTEGER: | 295 case XA_INTEGER: |
315 return QINTEGER; | 296 return QINTEGER; |
316 case XA_ATOM: | 297 case XA_ATOM: |
317 return QATOM; | 298 return QATOM; |
318 #ifdef CUT_BUFFER_SUPPORT | |
319 case XA_CUT_BUFFER0: | |
320 return QCUT_BUFFER0; | |
321 case XA_CUT_BUFFER1: | |
322 return QCUT_BUFFER1; | |
323 case XA_CUT_BUFFER2: | |
324 return QCUT_BUFFER2; | |
325 case XA_CUT_BUFFER3: | |
326 return QCUT_BUFFER3; | |
327 case XA_CUT_BUFFER4: | |
328 return QCUT_BUFFER4; | |
329 case XA_CUT_BUFFER5: | |
330 return QCUT_BUFFER5; | |
331 case XA_CUT_BUFFER6: | |
332 return QCUT_BUFFER6; | |
333 case XA_CUT_BUFFER7: | |
334 return QCUT_BUFFER7; | |
335 #endif | |
336 } | 299 } |
337 | 300 |
338 dpyinfo = x_display_info_for_display (dpy); | 301 dpyinfo = x_display_info_for_display (dpy); |
339 if (atom == dpyinfo->Xatom_CLIPBOARD) | 302 if (atom == dpyinfo->Xatom_CLIPBOARD) |
340 return QCLIPBOARD; | 303 return QCLIPBOARD; |
2256 UNBLOCK_INPUT; | 2219 UNBLOCK_INPUT; |
2257 return (owner ? Qt : Qnil); | 2220 return (owner ? Qt : Qnil); |
2258 } | 2221 } |
2259 | 2222 |
2260 | 2223 |
2261 #ifdef CUT_BUFFER_SUPPORT | |
2262 | |
2263 /* Ensure that all 8 cut buffers exist. ICCCM says we gotta... */ | |
2264 static void | |
2265 initialize_cut_buffers (Display *display, Window window) | |
2266 { | |
2267 unsigned char *data = (unsigned char *) ""; | |
2268 BLOCK_INPUT; | |
2269 #define FROB(atom) XChangeProperty (display, window, atom, XA_STRING, 8, \ | |
2270 PropModeAppend, data, 0) | |
2271 FROB (XA_CUT_BUFFER0); | |
2272 FROB (XA_CUT_BUFFER1); | |
2273 FROB (XA_CUT_BUFFER2); | |
2274 FROB (XA_CUT_BUFFER3); | |
2275 FROB (XA_CUT_BUFFER4); | |
2276 FROB (XA_CUT_BUFFER5); | |
2277 FROB (XA_CUT_BUFFER6); | |
2278 FROB (XA_CUT_BUFFER7); | |
2279 #undef FROB | |
2280 UNBLOCK_INPUT; | |
2281 } | |
2282 | |
2283 | |
2284 #define CHECK_CUT_BUFFER(symbol) \ | |
2285 do { CHECK_SYMBOL ((symbol)); \ | |
2286 if (!EQ((symbol), QCUT_BUFFER0) && !EQ((symbol), QCUT_BUFFER1) \ | |
2287 && !EQ((symbol), QCUT_BUFFER2) && !EQ((symbol), QCUT_BUFFER3) \ | |
2288 && !EQ((symbol), QCUT_BUFFER4) && !EQ((symbol), QCUT_BUFFER5) \ | |
2289 && !EQ((symbol), QCUT_BUFFER6) && !EQ((symbol), QCUT_BUFFER7)) \ | |
2290 signal_error ("Doesn't name a cut buffer", (symbol)); \ | |
2291 } while (0) | |
2292 | |
2293 DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal, | |
2294 Sx_get_cut_buffer_internal, 1, 1, 0, | |
2295 doc: /* Returns the value of the named cut buffer (typically CUT_BUFFER0). */) | |
2296 (Lisp_Object buffer) | |
2297 { | |
2298 Window window; | |
2299 Atom buffer_atom; | |
2300 unsigned char *data = NULL; | |
2301 int bytes; | |
2302 Atom type; | |
2303 int format; | |
2304 unsigned long size; | |
2305 Lisp_Object ret; | |
2306 Display *display; | |
2307 struct x_display_info *dpyinfo; | |
2308 struct frame *sf = SELECTED_FRAME (); | |
2309 | |
2310 check_x (); | |
2311 | |
2312 if (! FRAME_X_P (sf)) | |
2313 return Qnil; | |
2314 | |
2315 display = FRAME_X_DISPLAY (sf); | |
2316 dpyinfo = FRAME_X_DISPLAY_INFO (sf); | |
2317 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ | |
2318 CHECK_CUT_BUFFER (buffer); | |
2319 buffer_atom = symbol_to_x_atom (dpyinfo, display, buffer); | |
2320 | |
2321 x_get_window_property (display, window, buffer_atom, &data, &bytes, | |
2322 &type, &format, &size, 0); | |
2323 | |
2324 if (!data || !format) | |
2325 { | |
2326 xfree (data); | |
2327 return Qnil; | |
2328 } | |
2329 | |
2330 if (format != 8 || type != XA_STRING) | |
2331 signal_error ("Cut buffer doesn't contain 8-bit data", | |
2332 list2 (x_atom_to_symbol (display, type), | |
2333 make_number (format))); | |
2334 | |
2335 ret = (bytes ? make_unibyte_string ((char *) data, bytes) : Qnil); | |
2336 /* Use xfree, not XFree, because x_get_window_property | |
2337 calls xmalloc itself. */ | |
2338 xfree (data); | |
2339 return ret; | |
2340 } | |
2341 | |
2342 | |
2343 DEFUN ("x-store-cut-buffer-internal", Fx_store_cut_buffer_internal, | |
2344 Sx_store_cut_buffer_internal, 2, 2, 0, | |
2345 doc: /* Sets the value of the named cut buffer (typically CUT_BUFFER0). */) | |
2346 (Lisp_Object buffer, Lisp_Object string) | |
2347 { | |
2348 Window window; | |
2349 Atom buffer_atom; | |
2350 unsigned char *data; | |
2351 int bytes; | |
2352 int bytes_remaining; | |
2353 int max_bytes; | |
2354 Display *display; | |
2355 struct frame *sf = SELECTED_FRAME (); | |
2356 | |
2357 check_x (); | |
2358 | |
2359 if (! FRAME_X_P (sf)) | |
2360 return Qnil; | |
2361 | |
2362 display = FRAME_X_DISPLAY (sf); | |
2363 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ | |
2364 | |
2365 max_bytes = SELECTION_QUANTUM (display); | |
2366 if (max_bytes > MAX_SELECTION_QUANTUM) | |
2367 max_bytes = MAX_SELECTION_QUANTUM; | |
2368 | |
2369 CHECK_CUT_BUFFER (buffer); | |
2370 CHECK_STRING (string); | |
2371 buffer_atom = symbol_to_x_atom (FRAME_X_DISPLAY_INFO (sf), | |
2372 display, buffer); | |
2373 data = (unsigned char *) SDATA (string); | |
2374 bytes = SBYTES (string); | |
2375 bytes_remaining = bytes; | |
2376 | |
2377 if (! FRAME_X_DISPLAY_INFO (sf)->cut_buffers_initialized) | |
2378 { | |
2379 initialize_cut_buffers (display, window); | |
2380 FRAME_X_DISPLAY_INFO (sf)->cut_buffers_initialized = 1; | |
2381 } | |
2382 | |
2383 BLOCK_INPUT; | |
2384 | |
2385 /* Don't mess up with an empty value. */ | |
2386 if (!bytes_remaining) | |
2387 XChangeProperty (display, window, buffer_atom, XA_STRING, 8, | |
2388 PropModeReplace, data, 0); | |
2389 | |
2390 while (bytes_remaining) | |
2391 { | |
2392 int chunk = (bytes_remaining < max_bytes | |
2393 ? bytes_remaining : max_bytes); | |
2394 XChangeProperty (display, window, buffer_atom, XA_STRING, 8, | |
2395 (bytes_remaining == bytes | |
2396 ? PropModeReplace | |
2397 : PropModeAppend), | |
2398 data, chunk); | |
2399 data += chunk; | |
2400 bytes_remaining -= chunk; | |
2401 } | |
2402 UNBLOCK_INPUT; | |
2403 return string; | |
2404 } | |
2405 | |
2406 | |
2407 DEFUN ("x-rotate-cut-buffers-internal", Fx_rotate_cut_buffers_internal, | |
2408 Sx_rotate_cut_buffers_internal, 1, 1, 0, | |
2409 doc: /* Rotate the values of the cut buffers by N steps. | |
2410 Positive N means shift the values forward, negative means backward. */) | |
2411 (Lisp_Object n) | |
2412 { | |
2413 Window window; | |
2414 Atom props[8]; | |
2415 Display *display; | |
2416 struct frame *sf = SELECTED_FRAME (); | |
2417 | |
2418 check_x (); | |
2419 | |
2420 if (! FRAME_X_P (sf)) | |
2421 return Qnil; | |
2422 | |
2423 display = FRAME_X_DISPLAY (sf); | |
2424 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ | |
2425 CHECK_NUMBER (n); | |
2426 if (XINT (n) == 0) | |
2427 return n; | |
2428 if (! FRAME_X_DISPLAY_INFO (sf)->cut_buffers_initialized) | |
2429 { | |
2430 initialize_cut_buffers (display, window); | |
2431 FRAME_X_DISPLAY_INFO (sf)->cut_buffers_initialized = 1; | |
2432 } | |
2433 | |
2434 props[0] = XA_CUT_BUFFER0; | |
2435 props[1] = XA_CUT_BUFFER1; | |
2436 props[2] = XA_CUT_BUFFER2; | |
2437 props[3] = XA_CUT_BUFFER3; | |
2438 props[4] = XA_CUT_BUFFER4; | |
2439 props[5] = XA_CUT_BUFFER5; | |
2440 props[6] = XA_CUT_BUFFER6; | |
2441 props[7] = XA_CUT_BUFFER7; | |
2442 BLOCK_INPUT; | |
2443 XRotateWindowProperties (display, window, props, 8, XINT (n)); | |
2444 UNBLOCK_INPUT; | |
2445 return n; | |
2446 } | |
2447 | |
2448 #endif | |
2449 | |
2450 /*********************************************************************** | 2224 /*********************************************************************** |
2451 Drag and drop support | 2225 Drag and drop support |
2452 ***********************************************************************/ | 2226 ***********************************************************************/ |
2453 /* Check that lisp values are of correct type for x_fill_property_data. | 2227 /* Check that lisp values are of correct type for x_fill_property_data. |
2454 That is, number, string or a cons with two numbers (low and high 16 | 2228 That is, number, string or a cons with two numbers (low and high 16 |
2848 defsubr (&Sx_own_selection_internal); | 2622 defsubr (&Sx_own_selection_internal); |
2849 defsubr (&Sx_disown_selection_internal); | 2623 defsubr (&Sx_disown_selection_internal); |
2850 defsubr (&Sx_selection_owner_p); | 2624 defsubr (&Sx_selection_owner_p); |
2851 defsubr (&Sx_selection_exists_p); | 2625 defsubr (&Sx_selection_exists_p); |
2852 | 2626 |
2853 #ifdef CUT_BUFFER_SUPPORT | |
2854 defsubr (&Sx_get_cut_buffer_internal); | |
2855 defsubr (&Sx_store_cut_buffer_internal); | |
2856 defsubr (&Sx_rotate_cut_buffers_internal); | |
2857 #endif | |
2858 | |
2859 defsubr (&Sx_get_atom_name); | 2627 defsubr (&Sx_get_atom_name); |
2860 defsubr (&Sx_send_client_message); | 2628 defsubr (&Sx_send_client_message); |
2861 defsubr (&Sx_register_dnd_atom); | 2629 defsubr (&Sx_register_dnd_atom); |
2862 | 2630 |
2863 reading_selection_reply = Fcons (Qnil, Qnil); | 2631 reading_selection_reply = Fcons (Qnil, Qnil); |
2935 QATOM_PAIR = intern_c_string ("ATOM_PAIR"); staticpro (&QATOM_PAIR); | 2703 QATOM_PAIR = intern_c_string ("ATOM_PAIR"); staticpro (&QATOM_PAIR); |
2936 QNULL = intern_c_string ("NULL"); staticpro (&QNULL); | 2704 QNULL = intern_c_string ("NULL"); staticpro (&QNULL); |
2937 Qcompound_text_with_extensions = intern_c_string ("compound-text-with-extensions"); | 2705 Qcompound_text_with_extensions = intern_c_string ("compound-text-with-extensions"); |
2938 staticpro (&Qcompound_text_with_extensions); | 2706 staticpro (&Qcompound_text_with_extensions); |
2939 | 2707 |
2940 #ifdef CUT_BUFFER_SUPPORT | |
2941 QCUT_BUFFER0 = intern_c_string ("CUT_BUFFER0"); staticpro (&QCUT_BUFFER0); | |
2942 QCUT_BUFFER1 = intern_c_string ("CUT_BUFFER1"); staticpro (&QCUT_BUFFER1); | |
2943 QCUT_BUFFER2 = intern_c_string ("CUT_BUFFER2"); staticpro (&QCUT_BUFFER2); | |
2944 QCUT_BUFFER3 = intern_c_string ("CUT_BUFFER3"); staticpro (&QCUT_BUFFER3); | |
2945 QCUT_BUFFER4 = intern_c_string ("CUT_BUFFER4"); staticpro (&QCUT_BUFFER4); | |
2946 QCUT_BUFFER5 = intern_c_string ("CUT_BUFFER5"); staticpro (&QCUT_BUFFER5); | |
2947 QCUT_BUFFER6 = intern_c_string ("CUT_BUFFER6"); staticpro (&QCUT_BUFFER6); | |
2948 QCUT_BUFFER7 = intern_c_string ("CUT_BUFFER7"); staticpro (&QCUT_BUFFER7); | |
2949 #endif | |
2950 | |
2951 Qforeign_selection = intern_c_string ("foreign-selection"); | 2708 Qforeign_selection = intern_c_string ("foreign-selection"); |
2952 staticpro (&Qforeign_selection); | 2709 staticpro (&Qforeign_selection); |
2953 } | 2710 } |
2954 | 2711 |
2955 /* arch-tag: 7c293b0f-9918-4f69-8ac7-03e142307236 | 2712 /* arch-tag: 7c293b0f-9918-4f69-8ac7-03e142307236 |