X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fselect-x.c;h=6e1f344bcd473ac175cdcd14a87eca2349efe076;hb=2cbece6401b2279497293e6dc54cda607f49db2f;hp=cc6031a4cbec9f4429406970f1324ea725a72f95;hpb=140fb029a954e85e8e62e0ebd23e7bc43526b57b;p=chise%2Fxemacs-chise.git- diff --git a/src/select-x.c b/src/select-x.c index cc6031a..6e1f344 100644 --- a/src/select-x.c +++ b/src/select-x.c @@ -138,8 +138,10 @@ symbol_to_x_atom (struct device *d, Lisp_Object sym, int only_if_exists) #endif /* CUT_BUFFER_SUPPORT */ { - CONST char *nameext; - GET_C_STRING_CTEXT_DATA_ALLOCA (Fsymbol_name (sym), nameext); + const char *nameext; + TO_EXTERNAL_FORMAT (LISP_STRING, Fsymbol_name (sym), + C_STRING_ALLOCA, nameext, + Qctext); return XInternAtom (display, nameext, only_if_exists ? True : False); } } @@ -183,16 +185,16 @@ x_atom_to_symbol (struct device *d, Atom atom) #endif { - Lisp_Object newsym; - CONST Bufbyte *intstr; + char *intstr; char *str = XGetAtomName (display, atom); if (! str) return Qnil; - GET_C_CHARPTR_INT_CTEXT_DATA_ALLOCA (str, intstr); - newsym = intern ((char *) intstr); + TO_INTERNAL_FORMAT (C_STRING, str, + C_STRING_ALLOCA, intstr, + Qctext); XFree (str); - return newsym; + return intern (intstr); } } @@ -230,7 +232,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value) Opaque pointers are the clean way to go here. */ - selection_time = make_opaque (sizeof (thyme), (void *) &thyme); + selection_time = make_opaque (&thyme, sizeof (thyme)); #ifdef MOTIF_CLIPBOARDS hack_motif_clipboard_selection (selection_atom, selection_value, @@ -285,13 +287,13 @@ hack_motif_clipboard_selection (Atom selection_atom, #endif XmString fmh; String encoding = "STRING"; - CONST Extbyte *data = XSTRING_DATA (selection_value); + const Extbyte *data = XSTRING_DATA (selection_value); Extcount bytes = XSTRING_LENGTH (selection_value); #ifdef MULE { enum { ASCII, LATIN_1, WORLD } chartypes = ASCII; - CONST Bufbyte *ptr = data, *end = ptr + bytes; + const Bufbyte *ptr = data, *end = ptr + bytes; /* Optimize for the common ASCII case */ while (ptr <= end) { @@ -314,10 +316,14 @@ hack_motif_clipboard_selection (Atom selection_atom, } if (chartypes == LATIN_1) - GET_STRING_BINARY_DATA_ALLOCA (selection_value, data, bytes); + TO_EXTERNAL_FORMAT (LISP_STRING, selection_value, + ALLOCA, (data, bytes), + Qbinary); else if (chartypes == WORLD) { - GET_STRING_CTEXT_DATA_ALLOCA (selection_value, data, bytes); + TO_EXTERNAL_FORMAT (LISP_STRING, selection_value, + ALLOCA, (data, bytes), + Qctext); encoding = "COMPOUND_TEXT"; } } @@ -1164,7 +1170,7 @@ selection_data_to_lisp_data (struct device *d, return make_ext_string (data, size, type == DEVICE_XATOM_TEXT (d) || type == DEVICE_XATOM_COMPOUND_TEXT (d) - ? FORMAT_CTEXT : FORMAT_BINARY); + ? Qctext : Qbinary); /* Convert a single atom to a Lisp Symbol. Convert a set of atoms to a vector of symbols. */ @@ -1260,13 +1266,12 @@ lisp_data_to_selection_data (struct device *d, } else if (STRINGP (obj)) { - CONST Extbyte *extval; + const Extbyte *extval; Extcount extvallen; - if (NILP (type)) - GET_STRING_CTEXT_DATA_ALLOCA (obj, extval, extvallen); - else - GET_STRING_BINARY_DATA_ALLOCA (obj, extval, extvallen); + TO_EXTERNAL_FORMAT (LISP_STRING, obj, + ALLOCA, (extval, extvallen), + (NILP (type) ? Qctext : Qbinary)); *format_ret = 8; *size_ret = extvallen; *data_ret = (unsigned char *) xmalloc (*size_ret); @@ -1281,12 +1286,14 @@ lisp_data_to_selection_data (struct device *d, { Bufbyte buf[MAX_EMCHAR_LEN]; Bytecount len; - CONST Extbyte *extval; + const Extbyte *extval; Extcount extvallen; *format_ret = 8; len = set_charptr_emchar (buf, XCHAR (obj)); - GET_CHARPTR_EXT_CTEXT_DATA_ALLOCA (buf, len, extval, extvallen); + TO_EXTERNAL_FORMAT (DATA, (buf, len), + ALLOCA, (extval, extvallen), + Qctext); *size_ret = extvallen; *data_ret = (unsigned char *) xmalloc (*size_ret); memcpy (*data_ret, extval, *size_ret); @@ -1477,7 +1484,7 @@ static int cut_buffers_initialized; /* Whether we're sure they all exist */ static void initialize_cut_buffers (Display *display, Window window) { - static unsigned CONST char * CONST data = (unsigned CONST char *) ""; + static unsigned const char * const data = (unsigned const char *) ""; #define FROB(atom) XChangeProperty (display, window, atom, XA_STRING, 8, \ PropModeAppend, data, 0) FROB (XA_CUT_BUFFER0); @@ -1492,15 +1499,18 @@ initialize_cut_buffers (Display *display, Window window) cut_buffers_initialized = 1; } -#define CHECK_CUTBUFFER(symbol) \ - { CHECK_SYMBOL (symbol); \ - if (!EQ((symbol),QCUT_BUFFER0) && !EQ((symbol),QCUT_BUFFER1) && \ - !EQ((symbol),QCUT_BUFFER2) && !EQ((symbol),QCUT_BUFFER3) && \ - !EQ((symbol),QCUT_BUFFER4) && !EQ((symbol),QCUT_BUFFER5) && \ - !EQ((symbol),QCUT_BUFFER6) && !EQ((symbol),QCUT_BUFFER7)) \ - signal_error (Qerror, list2 (build_string ("Doesn't name a cutbuffer"), \ - (symbol))); \ - } +#define CHECK_CUTBUFFER(symbol) do { \ + CHECK_SYMBOL (symbol); \ + if (! (EQ (symbol, QCUT_BUFFER0) || \ + EQ (symbol, QCUT_BUFFER1) || \ + EQ (symbol, QCUT_BUFFER2) || \ + EQ (symbol, QCUT_BUFFER3) || \ + EQ (symbol, QCUT_BUFFER4) || \ + EQ (symbol, QCUT_BUFFER5) || \ + EQ (symbol, QCUT_BUFFER6) || \ + EQ (symbol, QCUT_BUFFER7))) \ + signal_simple_error ("Doesn't name a cutbuffer", symbol); \ +} while (0) DEFUN ("x-get-cutbuffer-internal", Fx_get_cutbuffer_internal, 1, 1, 0, /* Return the value of the named CUTBUFFER (typically CUT_BUFFER0). @@ -1537,7 +1547,7 @@ Return the value of the named CUTBUFFER (typically CUT_BUFFER0). ret = (bytes ? make_ext_string (data, bytes, memchr (data, 0x1b, bytes) ? - FORMAT_CTEXT : FORMAT_BINARY) + Qctext : Qbinary) : Qnil); xfree (data); return ret; @@ -1553,12 +1563,12 @@ Set the value of the named CUTBUFFER (typically CUT_BUFFER0) to STRING. Display *display = DEVICE_X_DISPLAY (d); Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */ Atom cut_buffer_atom; - CONST Extbyte *data = XSTRING_DATA (string); + const Extbyte *data = XSTRING_DATA (string); Extcount bytes = XSTRING_LENGTH (string); Extcount bytes_remaining; int max_bytes = SELECTION_QUANTUM (display); #ifdef MULE - CONST Bufbyte *ptr, *end; + const Bufbyte *ptr, *end; enum { ASCII, LATIN_1, WORLD } chartypes = ASCII; #endif @@ -1587,6 +1597,14 @@ Set the value of the named CUTBUFFER (typically CUT_BUFFER0) to STRING. continue; } +#ifdef UTF2000 + if ((*ptr) <= 0xC3) + { + chartypes = LATIN_1; + ptr += 2; + continue; + } +#else if ((*ptr) == LEADING_BYTE_LATIN_ISO8859_1 || (*ptr) == LEADING_BYTE_CONTROL_1) { @@ -1594,15 +1612,20 @@ Set the value of the named CUTBUFFER (typically CUT_BUFFER0) to STRING. ptr += 2; continue; } +#endif chartypes = WORLD; break; } if (chartypes == LATIN_1) - GET_STRING_BINARY_DATA_ALLOCA (string, data, bytes); + TO_EXTERNAL_FORMAT (LISP_STRING, string, + ALLOCA, (data, bytes), + Qbinary); else if (chartypes == WORLD) - GET_STRING_CTEXT_DATA_ALLOCA (string, data, bytes); + TO_EXTERNAL_FORMAT (LISP_STRING, string, + ALLOCA, (data, bytes), + Qctext); #endif /* MULE */ bytes_remaining = bytes; @@ -1658,7 +1681,7 @@ positive means move values forward, negative means backward. /************************************************************************/ void -syms_of_xselect (void) +syms_of_select_x (void) { #ifdef CUT_BUFFER_SUPPORT @@ -1694,18 +1717,24 @@ console_type_create_select_x (void) } void -vars_of_xselect (void) +reinit_vars_of_select_x (void) { -#ifdef CUT_BUFFER_SUPPORT - cut_buffers_initialized = 0; - Fprovide (intern ("cut-buffer")); -#endif - reading_selection_reply = 0; reading_which_selection = 0; selection_reply_timed_out = 0; for_whom_the_bell_tolls = 0; prop_location_tick = 0; +} + +void +vars_of_select_x (void) +{ + reinit_vars_of_select_x (); + +#ifdef CUT_BUFFER_SUPPORT + cut_buffers_initialized = 0; + Fprovide (intern ("cut-buffer")); +#endif DEFVAR_LISP ("x-sent-selection-hooks", &Vx_sent_selection_hooks /* A function or functions to be called after we have responded to some @@ -1732,7 +1761,7 @@ A value of 0 means wait as long as necessary. This is initialized from the } void -Xatoms_of_xselect (struct device *d) +Xatoms_of_select_x (struct device *d) { Display *D = DEVICE_X_DISPLAY (d);