0
|
1 /* Generic glyph/image implementation + display tables
|
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1995 Tinker Systems
|
|
4 Copyright (C) 1995, 1996 Ben Wing
|
|
5 Copyright (C) 1995 Sun Microsystems
|
173
|
6
|
0
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Synched up with: Not in FSF. */
|
|
25
|
|
26 /* Written by Ben Wing and Chuck Thompson */
|
|
27
|
|
28 #include <config.h>
|
|
29 #include "lisp.h"
|
|
30
|
|
31 #include "buffer.h"
|
|
32 #include "device.h"
|
|
33 #include "elhash.h"
|
|
34 #include "faces.h"
|
|
35 #include "frame.h"
|
276
|
36 #include "insdel.h"
|
0
|
37 #include "glyphs.h"
|
|
38 #include "objects.h"
|
|
39 #include "redisplay.h"
|
|
40 #include "window.h"
|
361
|
41 #include "chartab.h"
|
|
42 #include "rangetab.h"
|
0
|
43
|
276
|
44 #ifdef HAVE_XPM
|
|
45 #include <X11/xpm.h>
|
|
46 #endif
|
|
47
|
269
|
48 Lisp_Object Qimage_conversion_error;
|
|
49
|
0
|
50 Lisp_Object Qglyphp, Qcontrib_p, Qbaseline;
|
|
51 Lisp_Object Qbuffer_glyph_p, Qpointer_glyph_p, Qicon_glyph_p;
|
|
52 Lisp_Object Qnothing_image_instance_p, Qtext_image_instance_p;
|
|
53 Lisp_Object Qmono_pixmap_image_instance_p;
|
|
54 Lisp_Object Qcolor_pixmap_image_instance_p;
|
|
55 Lisp_Object Qpointer_image_instance_p;
|
|
56 Lisp_Object Qsubwindow_image_instance_p;
|
|
57 Lisp_Object Qconst_glyph_variable;
|
|
58 Lisp_Object Qmono_pixmap, Qcolor_pixmap, Qsubwindow;
|
272
|
59 Lisp_Object Q_file, Q_data, Q_face;
|
|
60 Lisp_Object Qformatted_string;
|
0
|
61
|
|
62 Lisp_Object Vcurrent_display_table;
|
|
63 Lisp_Object Vtruncation_glyph, Vcontinuation_glyph, Voctal_escape_glyph;
|
|
64 Lisp_Object Vcontrol_arrow_glyph, Vinvisible_text_glyph, Vhscroll_glyph;
|
|
65 Lisp_Object Vxemacs_logo;
|
|
66 Lisp_Object Vthe_nothing_vector;
|
272
|
67 Lisp_Object Vimage_instantiator_format_list;
|
|
68 Lisp_Object Vimage_instance_type_list;
|
|
69 Lisp_Object Vglyph_type_list;
|
|
70
|
0
|
71 DEFINE_IMAGE_INSTANTIATOR_FORMAT (nothing);
|
|
72 DEFINE_IMAGE_INSTANTIATOR_FORMAT (inherit);
|
|
73 DEFINE_IMAGE_INSTANTIATOR_FORMAT (string);
|
|
74 DEFINE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
|
|
75
|
288
|
76 #ifdef HAVE_WINDOW_SYSTEM
|
|
77 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xbm);
|
|
78 Lisp_Object Qxbm;
|
|
79
|
|
80 Lisp_Object Q_mask_file, Q_mask_data, Q_hotspot_x, Q_hotspot_y;
|
|
81 Lisp_Object Q_foreground, Q_background;
|
|
82 #ifndef BitmapSuccess
|
|
83 #define BitmapSuccess 0
|
|
84 #define BitmapOpenFailed 1
|
|
85 #define BitmapFileInvalid 2
|
|
86 #define BitmapNoMemory 3
|
|
87 #endif
|
|
88 #endif
|
278
|
89
|
276
|
90 #ifdef HAVE_XPM
|
|
91 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xpm);
|
|
92 Lisp_Object Qxpm;
|
|
93 Lisp_Object Q_color_symbols;
|
|
94 #endif
|
|
95
|
185
|
96 typedef struct image_instantiator_format_entry image_instantiator_format_entry;
|
0
|
97 struct image_instantiator_format_entry
|
|
98 {
|
|
99 Lisp_Object symbol;
|
|
100 struct image_instantiator_methods *meths;
|
|
101 };
|
|
102
|
185
|
103 typedef struct
|
0
|
104 {
|
|
105 Dynarr_declare (struct image_instantiator_format_entry);
|
|
106 } image_instantiator_format_entry_dynarr;
|
|
107
|
|
108 image_instantiator_format_entry_dynarr *
|
|
109 the_image_instantiator_format_entry_dynarr;
|
|
110
|
|
111 static Lisp_Object allocate_image_instance (Lisp_Object device);
|
|
112 static void image_validate (Lisp_Object instantiator);
|
|
113 static void glyph_property_was_changed (Lisp_Object glyph,
|
|
114 Lisp_Object property,
|
|
115 Lisp_Object locale);
|
272
|
116 EXFUN (Fimage_instance_type, 1);
|
|
117 EXFUN (Fglyph_type, 1);
|
0
|
118
|
|
119
|
|
120 /****************************************************************************
|
|
121 * Image Instantiators *
|
|
122 ****************************************************************************/
|
|
123
|
|
124 static struct image_instantiator_methods *
|
|
125 decode_image_instantiator_format (Lisp_Object format, Error_behavior errb)
|
|
126 {
|
|
127 int i;
|
|
128
|
|
129 if (!SYMBOLP (format))
|
|
130 {
|
|
131 if (ERRB_EQ (errb, ERROR_ME))
|
|
132 CHECK_SYMBOL (format);
|
|
133 return 0;
|
|
134 }
|
|
135
|
|
136 for (i = 0; i < Dynarr_length (the_image_instantiator_format_entry_dynarr);
|
|
137 i++)
|
|
138 {
|
|
139 if (EQ (format,
|
|
140 Dynarr_at (the_image_instantiator_format_entry_dynarr, i).
|
|
141 symbol))
|
|
142 return Dynarr_at (the_image_instantiator_format_entry_dynarr, i).meths;
|
|
143 }
|
|
144
|
|
145 maybe_signal_simple_error ("Invalid image-instantiator format", format,
|
|
146 Qimage, errb);
|
|
147
|
|
148 return 0;
|
|
149 }
|
|
150
|
|
151 static int
|
|
152 valid_image_instantiator_format_p (Lisp_Object format)
|
|
153 {
|
272
|
154 return (decode_image_instantiator_format (format, ERROR_ME_NOT) != 0);
|
0
|
155 }
|
|
156
|
284
|
157 DEFUN ("valid-image-instantiator-format-p", Fvalid_image_instantiator_format_p,
|
|
158 1, 1, 0, /*
|
0
|
159 Given an IMAGE-INSTANTIATOR-FORMAT, return non-nil if it is valid.
|
120
|
160 Valid formats are some subset of 'nothing, 'string, 'formatted-string,
|
|
161 'xpm, 'xbm, 'xface, 'gif, 'jpeg, 'png, 'tiff, 'cursor-font, 'font,
|
272
|
162 'autodetect, and 'subwindow, depending on how XEmacs was compiled.
|
20
|
163 */
|
|
164 (image_instantiator_format))
|
0
|
165 {
|
272
|
166 return valid_image_instantiator_format_p (image_instantiator_format) ?
|
|
167 Qt : Qnil;
|
0
|
168 }
|
|
169
|
284
|
170 DEFUN ("image-instantiator-format-list", Fimage_instantiator_format_list,
|
|
171 0, 0, 0, /*
|
0
|
172 Return a list of valid image-instantiator formats.
|
20
|
173 */
|
|
174 ())
|
0
|
175 {
|
|
176 return Fcopy_sequence (Vimage_instantiator_format_list);
|
|
177 }
|
|
178
|
|
179 void
|
|
180 add_entry_to_image_instantiator_format_list (Lisp_Object symbol,
|
|
181 struct
|
|
182 image_instantiator_methods *meths)
|
|
183 {
|
|
184 struct image_instantiator_format_entry entry;
|
|
185
|
|
186 entry.symbol = symbol;
|
|
187 entry.meths = meths;
|
|
188 Dynarr_add (the_image_instantiator_format_entry_dynarr, entry);
|
|
189 Vimage_instantiator_format_list =
|
|
190 Fcons (symbol, Vimage_instantiator_format_list);
|
|
191 }
|
|
192
|
|
193 static Lisp_Object *
|
|
194 get_image_conversion_list (Lisp_Object console_type)
|
|
195 {
|
|
196 return &decode_console_type (console_type, ERROR_ME)->image_conversion_list;
|
|
197 }
|
|
198
|
284
|
199 DEFUN ("set-console-type-image-conversion-list", Fset_console_type_image_conversion_list,
|
|
200 2, 2, 0, /*
|
0
|
201 Set the image-conversion-list for consoles of the given TYPE.
|
|
202 The image-conversion-list specifies how image instantiators that
|
|
203 are strings should be interpreted. Each element of the list should be
|
|
204 a list of two elements (a regular expression string and a vector) or
|
|
205 a list of three elements (the preceding two plus an integer index into
|
|
206 the vector). The string is converted to the vector associated with the
|
|
207 first matching regular expression. If a vector index is specified, the
|
|
208 string itself is substituted into that position in the vector.
|
|
209
|
|
210 Note: The conversion above is applied when the image instantiator is
|
|
211 added to an image specifier, not when the specifier is actually
|
|
212 instantiated. Therefore, changing the image-conversion-list only affects
|
|
213 newly-added instantiators. Existing instantiators in glyphs and image
|
|
214 specifiers will not be affected.
|
20
|
215 */
|
|
216 (console_type, list))
|
0
|
217 {
|
|
218 Lisp_Object tail;
|
|
219 Lisp_Object *imlist = get_image_conversion_list (console_type);
|
|
220
|
|
221 /* Check the list to make sure that it only has valid entries. */
|
|
222
|
|
223 EXTERNAL_LIST_LOOP (tail, list)
|
|
224 {
|
|
225 Lisp_Object mapping = XCAR (tail);
|
|
226
|
|
227 /* Mapping form should be (STRING VECTOR) or (STRING VECTOR INTEGER) */
|
|
228 if (!CONSP (mapping) ||
|
|
229 !CONSP (XCDR (mapping)) ||
|
|
230 (!NILP (XCDR (XCDR (mapping))) &&
|
|
231 (!CONSP (XCDR (XCDR (mapping))) ||
|
|
232 !NILP (XCDR (XCDR (XCDR (mapping)))))))
|
|
233 signal_simple_error ("Invalid mapping form", mapping);
|
|
234 else
|
|
235 {
|
|
236 Lisp_Object exp = XCAR (mapping);
|
|
237 Lisp_Object typevec = XCAR (XCDR (mapping));
|
|
238 Lisp_Object pos = Qnil;
|
|
239 Lisp_Object newvec;
|
|
240 struct gcpro gcpro1;
|
|
241
|
|
242 CHECK_STRING (exp);
|
|
243 CHECK_VECTOR (typevec);
|
|
244 if (!NILP (XCDR (XCDR (mapping))))
|
|
245 {
|
|
246 pos = XCAR (XCDR (XCDR (mapping)));
|
|
247 CHECK_INT (pos);
|
|
248 if (XINT (pos) < 0 ||
|
173
|
249 XINT (pos) >= XVECTOR_LENGTH (typevec))
|
0
|
250 args_out_of_range_3
|
173
|
251 (pos, Qzero, make_int (XVECTOR_LENGTH (typevec) - 1));
|
0
|
252 }
|
173
|
253
|
0
|
254 newvec = Fcopy_sequence (typevec);
|
|
255 if (INTP (pos))
|
173
|
256 XVECTOR_DATA (newvec)[XINT (pos)] = exp;
|
0
|
257 GCPRO1 (newvec);
|
|
258 image_validate (newvec);
|
|
259 UNGCPRO;
|
|
260 }
|
|
261 }
|
|
262
|
|
263 *imlist = Fcopy_tree (list, Qt);
|
|
264 return list;
|
|
265 }
|
|
266
|
284
|
267 DEFUN ("console-type-image-conversion-list", Fconsole_type_image_conversion_list,
|
|
268 1, 1, 0, /*
|
0
|
269 Return the image-conversion-list for devices of the given TYPE.
|
|
270 The image-conversion-list specifies how to interpret image string
|
|
271 instantiators for the specified console type. See
|
|
272 `set-console-type-image-conversion-list' for a description of its syntax.
|
20
|
273 */
|
|
274 (console_type))
|
0
|
275 {
|
|
276 return Fcopy_tree (*get_image_conversion_list (console_type), Qt);
|
|
277 }
|
|
278
|
185
|
279 /* Process a string instantiator according to the image-conversion-list for
|
0
|
280 CONSOLE_TYPE. Returns a vector. */
|
|
281
|
|
282 static Lisp_Object
|
|
283 process_image_string_instantiator (Lisp_Object data,
|
|
284 Lisp_Object console_type,
|
|
285 int dest_mask)
|
|
286 {
|
|
287 Lisp_Object tail;
|
|
288
|
|
289 LIST_LOOP (tail, *get_image_conversion_list (console_type))
|
|
290 {
|
|
291 Lisp_Object mapping = XCAR (tail);
|
|
292 Lisp_Object exp = XCAR (mapping);
|
|
293 Lisp_Object typevec = XCAR (XCDR (mapping));
|
|
294
|
|
295 /* if the result is of a type that can't be instantiated
|
|
296 (e.g. a string when we're dealing with a pointer glyph),
|
|
297 skip it. */
|
|
298 if (!(dest_mask &
|
|
299 IIFORMAT_METH (decode_image_instantiator_format
|
173
|
300 (XVECTOR_DATA (typevec)[0], ERROR_ME),
|
0
|
301 possible_dest_types, ())))
|
|
302 continue;
|
|
303 if (fast_string_match (exp, 0, data, 0, -1, 0, ERROR_ME, 0) >= 0)
|
|
304 {
|
|
305 if (!NILP (XCDR (XCDR (mapping))))
|
|
306 {
|
|
307 int pos = XINT (XCAR (XCDR (XCDR (mapping))));
|
|
308 Lisp_Object newvec = Fcopy_sequence (typevec);
|
173
|
309 XVECTOR_DATA (newvec)[pos] = data;
|
0
|
310 return newvec;
|
|
311 }
|
|
312 else
|
|
313 return typevec;
|
|
314 }
|
|
315 }
|
|
316
|
|
317 /* Oh well. */
|
|
318 signal_simple_error ("Unable to interpret glyph instantiator",
|
|
319 data);
|
173
|
320
|
0
|
321 return Qnil;
|
|
322 }
|
|
323
|
|
324 Lisp_Object
|
|
325 find_keyword_in_vector_or_given (Lisp_Object vector, Lisp_Object keyword,
|
173
|
326 Lisp_Object default_)
|
0
|
327 {
|
|
328 Lisp_Object *elt;
|
|
329 int instantiator_len;
|
|
330
|
173
|
331 elt = XVECTOR_DATA (vector);
|
|
332 instantiator_len = XVECTOR_LENGTH (vector);
|
0
|
333
|
|
334 elt++;
|
|
335 instantiator_len--;
|
|
336
|
|
337 while (instantiator_len > 0)
|
|
338 {
|
|
339 if (EQ (elt[0], keyword))
|
|
340 return elt[1];
|
|
341 elt += 2;
|
|
342 instantiator_len -= 2;
|
|
343 }
|
|
344
|
173
|
345 return default_;
|
0
|
346 }
|
|
347
|
|
348 Lisp_Object
|
|
349 find_keyword_in_vector (Lisp_Object vector, Lisp_Object keyword)
|
|
350 {
|
|
351 return find_keyword_in_vector_or_given (vector, keyword, Qnil);
|
|
352 }
|
|
353
|
|
354 void
|
|
355 check_valid_string (Lisp_Object data)
|
|
356 {
|
|
357 CHECK_STRING (data);
|
|
358 }
|
|
359
|
|
360 static void
|
|
361 check_valid_face (Lisp_Object data)
|
|
362 {
|
|
363 Fget_face (data);
|
|
364 }
|
|
365
|
|
366 void
|
|
367 check_valid_int (Lisp_Object data)
|
|
368 {
|
|
369 CHECK_INT (data);
|
|
370 }
|
|
371
|
|
372 void
|
|
373 file_or_data_must_be_present (Lisp_Object instantiator)
|
|
374 {
|
|
375 if (NILP (find_keyword_in_vector (instantiator, Q_file)) &&
|
|
376 NILP (find_keyword_in_vector (instantiator, Q_data)))
|
|
377 signal_simple_error ("Must supply either :file or :data",
|
|
378 instantiator);
|
|
379 }
|
|
380
|
|
381 void
|
|
382 data_must_be_present (Lisp_Object instantiator)
|
|
383 {
|
|
384 if (NILP (find_keyword_in_vector (instantiator, Q_data)))
|
|
385 signal_simple_error ("Must supply :data", instantiator);
|
|
386 }
|
|
387
|
|
388 static void
|
|
389 face_must_be_present (Lisp_Object instantiator)
|
|
390 {
|
|
391 if (NILP (find_keyword_in_vector (instantiator, Q_face)))
|
|
392 signal_simple_error ("Must supply :face", instantiator);
|
|
393 }
|
|
394
|
|
395 /* utility function useful in retrieving data from a file. */
|
|
396
|
|
397 Lisp_Object
|
|
398 make_string_from_file (Lisp_Object file)
|
|
399 {
|
116
|
400 /* This function can call lisp */
|
0
|
401 int count = specpdl_depth ();
|
|
402 Lisp_Object temp_buffer;
|
|
403 struct gcpro gcpro1;
|
|
404 Lisp_Object data;
|
173
|
405
|
0
|
406 specbind (Qinhibit_quit, Qt);
|
|
407 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
|
|
408 temp_buffer = Fget_buffer_create (build_string (" *pixmap conversion*"));
|
|
409 GCPRO1 (temp_buffer);
|
|
410 set_buffer_internal (XBUFFER (temp_buffer));
|
223
|
411 Ferase_buffer (Qnil);
|
169
|
412 specbind (intern ("format-alist"), Qnil);
|
70
|
413 Finsert_file_contents_internal (file, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil);
|
223
|
414 data = Fbuffer_substring (Qnil, Qnil, Qnil);
|
0
|
415 unbind_to (count, Qnil);
|
|
416 UNGCPRO;
|
|
417 return data;
|
|
418 }
|
|
419
|
|
420 /* The following two functions are provided to make it easier for
|
|
421 the normalize methods to work with keyword-value vectors.
|
|
422 Hash tables are kind of heavyweight for this purpose.
|
|
423 (If vectors were resizable, we could avoid this problem;
|
|
424 but they're not.) An alternative approach that might be
|
|
425 more efficient but require more work is to use a type of
|
|
426 assoc-Dynarr and provide primitives for deleting elements out
|
|
427 of it. (However, you'd also have to add an unwind-protect
|
|
428 to make sure the Dynarr got freed in case of an error in
|
|
429 the normalization process.) */
|
|
430
|
|
431 Lisp_Object
|
|
432 tagged_vector_to_alist (Lisp_Object vector)
|
|
433 {
|
173
|
434 Lisp_Object *elt = XVECTOR_DATA (vector);
|
|
435 int len = XVECTOR_LENGTH (vector);
|
0
|
436 Lisp_Object result = Qnil;
|
|
437
|
|
438 assert (len & 1);
|
|
439 for (len -= 2; len >= 1; len -= 2)
|
|
440 result = Fcons (Fcons (elt[len], elt[len+1]), result);
|
|
441
|
|
442 return result;
|
|
443 }
|
|
444
|
|
445 Lisp_Object
|
|
446 alist_to_tagged_vector (Lisp_Object tag, Lisp_Object alist)
|
|
447 {
|
|
448 int len = 1 + 2 * XINT (Flength (alist));
|
185
|
449 Lisp_Object *elt = alloca_array (Lisp_Object, len);
|
0
|
450 int i;
|
|
451 Lisp_Object rest;
|
|
452
|
|
453 i = 0;
|
|
454 elt[i++] = tag;
|
|
455 LIST_LOOP (rest, alist)
|
|
456 {
|
|
457 Lisp_Object pair = XCAR (rest);
|
|
458 elt[i] = XCAR (pair);
|
|
459 elt[i+1] = XCDR (pair);
|
|
460 i += 2;
|
|
461 }
|
|
462
|
|
463 return Fvector (len, elt);
|
|
464 }
|
|
465
|
|
466 static Lisp_Object
|
|
467 normalize_image_instantiator (Lisp_Object instantiator,
|
|
468 Lisp_Object contype,
|
|
469 Lisp_Object dest_mask)
|
|
470 {
|
327
|
471 struct gcpro gcpro1;
|
|
472
|
|
473 GCPRO1(instantiator);
|
|
474
|
0
|
475 if (IMAGE_INSTANCEP (instantiator))
|
327
|
476 RETURN_UNGCPRO (instantiator);
|
0
|
477
|
|
478 if (STRINGP (instantiator))
|
|
479 instantiator = process_image_string_instantiator (instantiator, contype,
|
|
480 XINT (dest_mask));
|
|
481
|
|
482 assert (VECTORP (instantiator));
|
|
483 /* We have to always store the actual pixmap data and not the
|
|
484 filename even though this is a potential memory pig. We have to
|
|
485 do this because it is quite possible that we will need to
|
|
486 instantiate a new instance of the pixmap and the file will no
|
|
487 longer exist (e.g. w3 pixmaps are almost always from temporary
|
|
488 files). */
|
272
|
489 {
|
|
490 struct image_instantiator_methods * meths =
|
|
491 decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0],
|
|
492 ERROR_ME);
|
327
|
493 RETURN_UNGCPRO (IIFORMAT_METH_OR_GIVEN (meths, normalize,
|
272
|
494 (instantiator, contype),
|
327
|
495 instantiator));
|
272
|
496 }
|
0
|
497 }
|
|
498
|
|
499 static Lisp_Object
|
124
|
500 instantiate_image_instantiator (Lisp_Object device, Lisp_Object domain,
|
|
501 Lisp_Object instantiator,
|
0
|
502 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
|
503 int dest_mask)
|
|
504 {
|
272
|
505 Lisp_Object ii = allocate_image_instance (device);
|
|
506 struct image_instantiator_methods *meths;
|
0
|
507 struct gcpro gcpro1;
|
|
508
|
|
509 GCPRO1 (ii);
|
272
|
510 meths = decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0],
|
|
511 ERROR_ME);
|
|
512 if (!HAS_IIFORMAT_METH_P (meths, instantiate))
|
|
513 signal_simple_error
|
|
514 ("Don't know how to instantiate this image instantiator?",
|
|
515 instantiator);
|
|
516 IIFORMAT_METH (meths, instantiate, (ii, instantiator, pointer_fg,
|
|
517 pointer_bg, dest_mask, domain));
|
0
|
518 UNGCPRO;
|
|
519
|
|
520 return ii;
|
|
521 }
|
|
522
|
|
523
|
|
524 /****************************************************************************
|
|
525 * Image-Instance Object *
|
|
526 ****************************************************************************/
|
|
527
|
|
528 Lisp_Object Qimage_instancep;
|
272
|
529
|
0
|
530 static Lisp_Object
|
|
531 mark_image_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
532 {
|
|
533 struct Lisp_Image_Instance *i = XIMAGE_INSTANCE (obj);
|
|
534
|
|
535 (markobj) (i->name);
|
|
536 switch (IMAGE_INSTANCE_TYPE (i))
|
|
537 {
|
|
538 case IMAGE_TEXT:
|
|
539 (markobj) (IMAGE_INSTANCE_TEXT_STRING (i));
|
|
540 break;
|
|
541 case IMAGE_MONO_PIXMAP:
|
|
542 case IMAGE_COLOR_PIXMAP:
|
|
543 (markobj) (IMAGE_INSTANCE_PIXMAP_FILENAME (i));
|
|
544 (markobj) (IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (i));
|
|
545 (markobj) (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (i));
|
|
546 (markobj) (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (i));
|
|
547 (markobj) (IMAGE_INSTANCE_PIXMAP_FG (i));
|
|
548 (markobj) (IMAGE_INSTANCE_PIXMAP_BG (i));
|
|
549 break;
|
|
550 case IMAGE_SUBWINDOW:
|
|
551 /* #### implement me */
|
|
552 break;
|
|
553 default:
|
|
554 break;
|
|
555 }
|
|
556
|
|
557 MAYBE_DEVMETH (XDEVICE (i->device), mark_image_instance, (i, markobj));
|
|
558
|
173
|
559 return i->device;
|
0
|
560 }
|
|
561
|
|
562 static void
|
|
563 print_image_instance (Lisp_Object obj, Lisp_Object printcharfun,
|
|
564 int escapeflag)
|
|
565 {
|
|
566 char buf[100];
|
|
567 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (obj);
|
|
568
|
|
569 if (print_readably)
|
|
570 error ("printing unreadable object #<image-instance 0x%x>",
|
|
571 ii->header.uid);
|
|
572 write_c_string ("#<image-instance (", printcharfun);
|
|
573 print_internal (Fimage_instance_type (obj), printcharfun, 0);
|
|
574 write_c_string (") ", printcharfun);
|
|
575 if (!NILP (ii->name))
|
|
576 {
|
|
577 print_internal (ii->name, printcharfun, 1);
|
|
578 write_c_string (" ", printcharfun);
|
|
579 }
|
|
580 write_c_string ("on ", printcharfun);
|
|
581 print_internal (ii->device, printcharfun, 0);
|
|
582 write_c_string (" ", printcharfun);
|
|
583 switch (IMAGE_INSTANCE_TYPE (ii))
|
|
584 {
|
|
585 case IMAGE_NOTHING:
|
|
586 break;
|
|
587
|
|
588 case IMAGE_TEXT:
|
|
589 print_internal (IMAGE_INSTANCE_TEXT_STRING (ii), printcharfun, 1);
|
|
590 break;
|
|
591
|
|
592 case IMAGE_MONO_PIXMAP:
|
|
593 case IMAGE_COLOR_PIXMAP:
|
|
594 case IMAGE_POINTER:
|
|
595 if (STRINGP (IMAGE_INSTANCE_PIXMAP_FILENAME (ii)))
|
|
596 {
|
|
597 char *s;
|
|
598 Lisp_Object filename = IMAGE_INSTANCE_PIXMAP_FILENAME (ii);
|
14
|
599 s = strrchr ((char *) XSTRING_DATA (filename), '/');
|
0
|
600 if (s)
|
|
601 print_internal (build_string (s + 1), printcharfun, 1);
|
|
602 else
|
|
603 print_internal (filename, printcharfun, 1);
|
|
604 }
|
|
605 if (IMAGE_INSTANCE_PIXMAP_DEPTH (ii) > 1)
|
|
606 sprintf (buf, " %dx%dx%d", IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
|
|
607 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
|
|
608 IMAGE_INSTANCE_PIXMAP_DEPTH (ii));
|
|
609 else
|
|
610 sprintf (buf, " %dx%d", IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
|
|
611 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii));
|
|
612 write_c_string (buf, printcharfun);
|
|
613 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)) ||
|
|
614 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)))
|
|
615 {
|
|
616 write_c_string (" @", printcharfun);
|
|
617 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)))
|
|
618 {
|
276
|
619 long_to_string (buf, XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)));
|
0
|
620 write_c_string (buf, printcharfun);
|
|
621 }
|
|
622 else
|
|
623 write_c_string ("??", printcharfun);
|
|
624 write_c_string (",", printcharfun);
|
|
625 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)))
|
|
626 {
|
276
|
627 long_to_string (buf, XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)));
|
0
|
628 write_c_string (buf, printcharfun);
|
|
629 }
|
|
630 else
|
|
631 write_c_string ("??", printcharfun);
|
|
632 }
|
|
633 if (!NILP (IMAGE_INSTANCE_PIXMAP_FG (ii)) ||
|
|
634 !NILP (IMAGE_INSTANCE_PIXMAP_BG (ii)))
|
|
635 {
|
|
636 write_c_string (" (", printcharfun);
|
|
637 if (!NILP (IMAGE_INSTANCE_PIXMAP_FG (ii)))
|
|
638 {
|
|
639 print_internal
|
|
640 (XCOLOR_INSTANCE
|
|
641 (IMAGE_INSTANCE_PIXMAP_FG (ii))->name, printcharfun, 0);
|
|
642 }
|
|
643 write_c_string ("/", printcharfun);
|
|
644 if (!NILP (IMAGE_INSTANCE_PIXMAP_BG (ii)))
|
|
645 {
|
|
646 print_internal
|
|
647 (XCOLOR_INSTANCE
|
|
648 (IMAGE_INSTANCE_PIXMAP_BG (ii))->name, printcharfun, 0);
|
|
649 }
|
|
650 write_c_string (")", printcharfun);
|
|
651 }
|
|
652 break;
|
|
653
|
|
654 case IMAGE_SUBWINDOW:
|
|
655 /* #### implement me */
|
|
656 break;
|
|
657
|
|
658 default:
|
|
659 abort ();
|
|
660 }
|
|
661
|
|
662 MAYBE_DEVMETH (XDEVICE (ii->device), print_image_instance,
|
|
663 (ii, printcharfun, escapeflag));
|
|
664 sprintf (buf, " 0x%x>", ii->header.uid);
|
|
665 write_c_string (buf, printcharfun);
|
|
666 }
|
|
667
|
|
668 static void
|
|
669 finalize_image_instance (void *header, int for_disksave)
|
|
670 {
|
|
671 struct Lisp_Image_Instance *i = (struct Lisp_Image_Instance *) header;
|
|
672
|
|
673 if (IMAGE_INSTANCE_TYPE (i) == IMAGE_NOTHING)
|
|
674 /* objects like this exist at dump time, so don't bomb out. */
|
|
675 return;
|
|
676 if (for_disksave) finalose (i);
|
|
677
|
|
678 MAYBE_DEVMETH (XDEVICE (i->device), finalize_image_instance, (i));
|
|
679 }
|
|
680
|
|
681 static int
|
|
682 image_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth)
|
|
683 {
|
|
684 struct Lisp_Image_Instance *i1 = XIMAGE_INSTANCE (o1);
|
|
685 struct Lisp_Image_Instance *i2 = XIMAGE_INSTANCE (o2);
|
|
686 struct device *d1 = XDEVICE (i1->device);
|
|
687 struct device *d2 = XDEVICE (i2->device);
|
|
688
|
|
689 if (d1 != d2)
|
|
690 return 0;
|
|
691 if (IMAGE_INSTANCE_TYPE (i1) != IMAGE_INSTANCE_TYPE (i2))
|
|
692 return 0;
|
|
693 if (!internal_equal (IMAGE_INSTANCE_NAME (i1), IMAGE_INSTANCE_NAME (i2),
|
|
694 depth + 1))
|
|
695 return 0;
|
|
696
|
|
697 switch (IMAGE_INSTANCE_TYPE (i1))
|
|
698 {
|
|
699 case IMAGE_NOTHING:
|
|
700 break;
|
|
701
|
|
702 case IMAGE_TEXT:
|
|
703 if (!internal_equal (IMAGE_INSTANCE_TEXT_STRING (i1),
|
|
704 IMAGE_INSTANCE_TEXT_STRING (i2),
|
|
705 depth + 1))
|
|
706 return 0;
|
|
707 break;
|
|
708
|
|
709 case IMAGE_MONO_PIXMAP:
|
|
710 case IMAGE_COLOR_PIXMAP:
|
|
711 case IMAGE_POINTER:
|
|
712 if (!(IMAGE_INSTANCE_PIXMAP_WIDTH (i1) ==
|
|
713 IMAGE_INSTANCE_PIXMAP_WIDTH (i2) &&
|
|
714 IMAGE_INSTANCE_PIXMAP_HEIGHT (i1) ==
|
|
715 IMAGE_INSTANCE_PIXMAP_HEIGHT (i2) &&
|
|
716 IMAGE_INSTANCE_PIXMAP_DEPTH (i1) ==
|
|
717 IMAGE_INSTANCE_PIXMAP_DEPTH (i2) &&
|
|
718 EQ (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (i1),
|
|
719 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (i2)) &&
|
|
720 EQ (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (i1),
|
|
721 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (i2)) &&
|
|
722 internal_equal (IMAGE_INSTANCE_PIXMAP_FILENAME (i1),
|
|
723 IMAGE_INSTANCE_PIXMAP_FILENAME (i2),
|
|
724 depth + 1) &&
|
|
725 internal_equal (IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (i1),
|
|
726 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (i2),
|
|
727 depth + 1)))
|
|
728 return 0;
|
|
729 break;
|
|
730
|
|
731 case IMAGE_SUBWINDOW:
|
|
732 /* #### implement me */
|
|
733 break;
|
|
734
|
|
735 default:
|
|
736 abort ();
|
|
737 }
|
|
738
|
|
739 return DEVMETH_OR_GIVEN (d1, image_instance_equal, (i1, i2, depth), 1);
|
|
740 }
|
|
741
|
|
742 static unsigned long
|
|
743 image_instance_hash (Lisp_Object obj, int depth)
|
|
744 {
|
|
745 struct Lisp_Image_Instance *i = XIMAGE_INSTANCE (obj);
|
|
746 struct device *d = XDEVICE (i->device);
|
|
747 unsigned long hash = (unsigned long) d;
|
|
748
|
|
749 switch (IMAGE_INSTANCE_TYPE (i))
|
|
750 {
|
|
751 case IMAGE_NOTHING:
|
|
752 break;
|
|
753
|
|
754 case IMAGE_TEXT:
|
|
755 hash = HASH2 (hash, internal_hash (IMAGE_INSTANCE_TEXT_STRING (i),
|
|
756 depth + 1));
|
|
757 break;
|
|
758
|
|
759 case IMAGE_MONO_PIXMAP:
|
|
760 case IMAGE_COLOR_PIXMAP:
|
|
761 case IMAGE_POINTER:
|
|
762 hash = HASH5 (hash, IMAGE_INSTANCE_PIXMAP_WIDTH (i),
|
|
763 IMAGE_INSTANCE_PIXMAP_HEIGHT (i),
|
|
764 IMAGE_INSTANCE_PIXMAP_DEPTH (i),
|
|
765 internal_hash (IMAGE_INSTANCE_PIXMAP_FILENAME (i),
|
|
766 depth + 1));
|
|
767 break;
|
|
768
|
|
769 case IMAGE_SUBWINDOW:
|
|
770 /* #### implement me */
|
|
771 break;
|
|
772
|
|
773 default:
|
|
774 abort ();
|
|
775 }
|
|
776
|
|
777 return HASH2 (hash, DEVMETH_OR_GIVEN (d, image_instance_hash, (i, depth),
|
|
778 0));
|
|
779 }
|
|
780
|
272
|
781 DEFINE_LRECORD_IMPLEMENTATION ("image-instance", image_instance,
|
|
782 mark_image_instance, print_image_instance,
|
|
783 finalize_image_instance, image_instance_equal,
|
|
784 image_instance_hash,
|
|
785 struct Lisp_Image_Instance);
|
|
786
|
0
|
787 static Lisp_Object
|
|
788 allocate_image_instance (Lisp_Object device)
|
|
789 {
|
|
790 struct Lisp_Image_Instance *lp =
|
185
|
791 alloc_lcrecord_type (struct Lisp_Image_Instance, lrecord_image_instance);
|
272
|
792 Lisp_Object val;
|
0
|
793
|
|
794 zero_lcrecord (lp);
|
|
795 lp->device = device;
|
|
796 lp->type = IMAGE_NOTHING;
|
|
797 lp->name = Qnil;
|
|
798 XSETIMAGE_INSTANCE (val, lp);
|
|
799 return val;
|
|
800 }
|
|
801
|
|
802 static enum image_instance_type
|
|
803 decode_image_instance_type (Lisp_Object type, Error_behavior errb)
|
|
804 {
|
|
805 if (ERRB_EQ (errb, ERROR_ME))
|
|
806 CHECK_SYMBOL (type);
|
|
807
|
185
|
808 if (EQ (type, Qnothing)) return IMAGE_NOTHING;
|
|
809 if (EQ (type, Qtext)) return IMAGE_TEXT;
|
|
810 if (EQ (type, Qmono_pixmap)) return IMAGE_MONO_PIXMAP;
|
|
811 if (EQ (type, Qcolor_pixmap)) return IMAGE_COLOR_PIXMAP;
|
|
812 if (EQ (type, Qpointer)) return IMAGE_POINTER;
|
|
813 if (EQ (type, Qsubwindow)) return IMAGE_SUBWINDOW;
|
0
|
814
|
|
815 maybe_signal_simple_error ("Invalid image-instance type", type,
|
|
816 Qimage, errb);
|
185
|
817
|
|
818 return IMAGE_UNKNOWN; /* not reached */
|
0
|
819 }
|
|
820
|
|
821 static Lisp_Object
|
|
822 encode_image_instance_type (enum image_instance_type type)
|
|
823 {
|
|
824 switch (type)
|
|
825 {
|
185
|
826 case IMAGE_NOTHING: return Qnothing;
|
|
827 case IMAGE_TEXT: return Qtext;
|
|
828 case IMAGE_MONO_PIXMAP: return Qmono_pixmap;
|
|
829 case IMAGE_COLOR_PIXMAP: return Qcolor_pixmap;
|
|
830 case IMAGE_POINTER: return Qpointer;
|
|
831 case IMAGE_SUBWINDOW: return Qsubwindow;
|
0
|
832 default:
|
|
833 abort ();
|
|
834 }
|
|
835
|
|
836 return Qnil; /* not reached */
|
|
837 }
|
|
838
|
|
839 static int
|
|
840 image_instance_type_to_mask (enum image_instance_type type)
|
|
841 {
|
|
842 /* This depends on the fact that enums are assigned consecutive
|
|
843 integers starting at 0. (Remember that IMAGE_UNKNOWN is the
|
|
844 first enum.) I'm fairly sure this behavior in ANSI-mandated,
|
|
845 so there should be no portability problems here. */
|
|
846 return (1 << ((int) (type) - 1));
|
|
847 }
|
|
848
|
|
849 static int
|
|
850 decode_image_instance_type_list (Lisp_Object list)
|
|
851 {
|
|
852 Lisp_Object rest;
|
|
853 int mask = 0;
|
|
854
|
|
855 if (NILP (list))
|
|
856 return ~0;
|
|
857
|
|
858 if (!CONSP (list))
|
|
859 {
|
|
860 enum image_instance_type type =
|
|
861 decode_image_instance_type (list, ERROR_ME);
|
|
862 return image_instance_type_to_mask (type);
|
|
863 }
|
|
864
|
|
865 EXTERNAL_LIST_LOOP (rest, list)
|
|
866 {
|
|
867 enum image_instance_type type =
|
|
868 decode_image_instance_type (XCAR (rest), ERROR_ME);
|
|
869 mask |= image_instance_type_to_mask (type);
|
|
870 }
|
|
871
|
|
872 return mask;
|
|
873 }
|
|
874
|
|
875 static Lisp_Object
|
|
876 encode_image_instance_type_list (int mask)
|
|
877 {
|
|
878 int count = 0;
|
|
879 Lisp_Object result = Qnil;
|
|
880
|
|
881 while (mask)
|
|
882 {
|
|
883 count++;
|
|
884 if (mask & 1)
|
|
885 result = Fcons (encode_image_instance_type
|
|
886 ((enum image_instance_type) count), result);
|
|
887 mask >>= 1;
|
|
888 }
|
|
889
|
|
890 return Fnreverse (result);
|
|
891 }
|
|
892
|
|
893 DOESNT_RETURN
|
|
894 incompatible_image_types (Lisp_Object instantiator, int given_dest_mask,
|
|
895 int desired_dest_mask)
|
|
896 {
|
|
897 signal_error
|
|
898 (Qerror,
|
|
899 list2
|
|
900 (emacs_doprnt_string_lisp_2
|
|
901 ((CONST Bufbyte *)
|
|
902 "No compatible image-instance types given: wanted one of %s, got %s",
|
|
903 Qnil, -1, 2,
|
|
904 encode_image_instance_type_list (desired_dest_mask),
|
|
905 encode_image_instance_type_list (given_dest_mask)),
|
|
906 instantiator));
|
|
907 }
|
|
908
|
|
909 static int
|
|
910 valid_image_instance_type_p (Lisp_Object type)
|
|
911 {
|
185
|
912 return !NILP (memq_no_quit (type, Vimage_instance_type_list));
|
0
|
913 }
|
|
914
|
20
|
915 DEFUN ("valid-image-instance-type-p", Fvalid_image_instance_type_p, 1, 1, 0, /*
|
0
|
916 Given an IMAGE-INSTANCE-TYPE, return non-nil if it is valid.
|
|
917 Valid types are some subset of 'nothing, 'text, 'mono-pixmap, 'color-pixmap,
|
|
918 'pointer, and 'subwindow, depending on how XEmacs was compiled.
|
20
|
919 */
|
|
920 (image_instance_type))
|
0
|
921 {
|
185
|
922 return valid_image_instance_type_p (image_instance_type) ? Qt : Qnil;
|
0
|
923 }
|
|
924
|
20
|
925 DEFUN ("image-instance-type-list", Fimage_instance_type_list, 0, 0, 0, /*
|
0
|
926 Return a list of valid image-instance types.
|
20
|
927 */
|
|
928 ())
|
0
|
929 {
|
|
930 return Fcopy_sequence (Vimage_instance_type_list);
|
|
931 }
|
|
932
|
|
933 Error_behavior
|
|
934 decode_error_behavior_flag (Lisp_Object no_error)
|
|
935 {
|
185
|
936 if (NILP (no_error)) return ERROR_ME;
|
|
937 else if (EQ (no_error, Qt)) return ERROR_ME_NOT;
|
|
938 else return ERROR_ME_WARN;
|
0
|
939 }
|
|
940
|
|
941 Lisp_Object
|
|
942 encode_error_behavior_flag (Error_behavior errb)
|
|
943 {
|
|
944 if (ERRB_EQ (errb, ERROR_ME))
|
|
945 return Qnil;
|
|
946 else if (ERRB_EQ (errb, ERROR_ME_NOT))
|
|
947 return Qt;
|
|
948 else
|
|
949 {
|
|
950 assert (ERRB_EQ (errb, ERROR_ME_WARN));
|
|
951 return Qwarning;
|
|
952 }
|
|
953 }
|
|
954
|
|
955 static Lisp_Object
|
|
956 make_image_instance_1 (Lisp_Object data, Lisp_Object device,
|
|
957 Lisp_Object dest_types)
|
|
958 {
|
|
959 Lisp_Object ii;
|
|
960 struct gcpro gcpro1;
|
|
961 int dest_mask;
|
|
962
|
|
963 XSETDEVICE (device, decode_device (device));
|
|
964 /* instantiate_image_instantiator() will abort if given an
|
|
965 image instance ... */
|
|
966 if (IMAGE_INSTANCEP (data))
|
|
967 signal_simple_error ("image instances not allowed here", data);
|
|
968 image_validate (data);
|
|
969 dest_mask = decode_image_instance_type_list (dest_types);
|
|
970 data = normalize_image_instantiator (data, DEVICE_TYPE (XDEVICE (device)),
|
|
971 make_int (dest_mask));
|
|
972 GCPRO1 (data);
|
173
|
973 if (VECTORP (data) && EQ (XVECTOR_DATA (data)[0], Qinherit))
|
0
|
974 signal_simple_error ("inheritance not allowed here", data);
|
124
|
975 ii = instantiate_image_instantiator (device, device, data,
|
|
976 Qnil, Qnil, dest_mask);
|
0
|
977 RETURN_UNGCPRO (ii);
|
|
978 }
|
|
979
|
20
|
980 DEFUN ("make-image-instance", Fmake_image_instance, 1, 4, 0, /*
|
272
|
981 Return a new `image-instance' object.
|
0
|
982
|
|
983 Image-instance objects encapsulate the way a particular image (pixmap,
|
|
984 etc.) is displayed on a particular device. In most circumstances, you
|
|
985 do not need to directly create image instances; use a glyph instead.
|
|
986 However, it may occasionally be useful to explicitly create image
|
|
987 instances, if you want more control over the instantiation process.
|
|
988
|
|
989 DATA is an image instantiator, which describes the image; see
|
|
990 `image-specifier-p' for a description of the allowed values.
|
|
991
|
|
992 DEST-TYPES should be a list of allowed image instance types that can
|
|
993 be generated. The recognized image instance types are
|
|
994
|
|
995 'nothing
|
|
996 Nothing is displayed.
|
|
997 'text
|
|
998 Displayed as text. The foreground and background colors and the
|
|
999 font of the text are specified independent of the pixmap. Typically
|
|
1000 these attributes will come from the face of the surrounding text,
|
|
1001 unless a face is specified for the glyph in which the image appears.
|
|
1002 'mono-pixmap
|
|
1003 Displayed as a mono pixmap (a pixmap with only two colors where the
|
|
1004 foreground and background can be specified independent of the pixmap;
|
|
1005 typically the pixmap assumes the foreground and background colors of
|
|
1006 the text around it, unless a face is specified for the glyph in which
|
|
1007 the image appears).
|
|
1008 'color-pixmap
|
|
1009 Displayed as a color pixmap.
|
|
1010 'pointer
|
|
1011 Used as the mouse pointer for a window.
|
|
1012 'subwindow
|
|
1013 A child window that is treated as an image. This allows (e.g.)
|
|
1014 another program to be responsible for drawing into the window.
|
|
1015 Not currently implemented.
|
|
1016
|
|
1017 The DEST-TYPES list is unordered. If multiple destination types
|
185
|
1018 are possible for a given instantiator, the "most natural" type
|
0
|
1019 for the instantiator's format is chosen. (For XBM, the most natural
|
|
1020 types are `mono-pixmap', followed by `color-pixmap', followed by
|
|
1021 `pointer'. For the other normal image formats, the most natural
|
|
1022 types are `color-pixmap', followed by `mono-pixmap', followed by
|
|
1023 `pointer'. For the string and formatted-string formats, the most
|
|
1024 natural types are `text', followed by `mono-pixmap' (not currently
|
|
1025 implemented), followed by `color-pixmap' (not currently implemented).
|
|
1026 The other formats can only be instantiated as one type. (If you
|
|
1027 want to control more specifically the order of the types into which
|
|
1028 an image is instantiated, just call `make-image-instance' repeatedly
|
|
1029 until it succeeds, passing less and less preferred destination types
|
|
1030 each time.
|
|
1031
|
|
1032 If DEST-TYPES is omitted, all possible types are allowed.
|
|
1033
|
|
1034 NO-ERROR controls what happens when the image cannot be generated.
|
|
1035 If nil, an error message is generated. If t, no messages are
|
|
1036 generated and this function returns nil. If anything else, a warning
|
|
1037 message is generated and this function returns nil.
|
20
|
1038 */
|
|
1039 (data, device, dest_types, no_error))
|
0
|
1040 {
|
|
1041 Error_behavior errb = decode_error_behavior_flag (no_error);
|
|
1042
|
74
|
1043 return call_with_suspended_errors ((lisp_fn_t) make_image_instance_1,
|
0
|
1044 Qnil, Qimage, errb,
|
|
1045 3, data, device, dest_types);
|
|
1046 }
|
|
1047
|
20
|
1048 DEFUN ("image-instance-p", Fimage_instance_p, 1, 1, 0, /*
|
0
|
1049 Return non-nil if OBJECT is an image instance.
|
20
|
1050 */
|
|
1051 (object))
|
0
|
1052 {
|
173
|
1053 return IMAGE_INSTANCEP (object) ? Qt : Qnil;
|
0
|
1054 }
|
|
1055
|
20
|
1056 DEFUN ("image-instance-type", Fimage_instance_type, 1, 1, 0, /*
|
0
|
1057 Return the type of the given image instance.
|
|
1058 The return value will be one of 'nothing, 'text, 'mono-pixmap,
|
|
1059 'color-pixmap, 'pointer, or 'subwindow.
|
20
|
1060 */
|
|
1061 (image_instance))
|
0
|
1062 {
|
|
1063 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1064 return encode_image_instance_type (XIMAGE_INSTANCE_TYPE (image_instance));
|
|
1065 }
|
|
1066
|
20
|
1067 DEFUN ("image-instance-name", Fimage_instance_name, 1, 1, 0, /*
|
0
|
1068 Return the name of the given image instance.
|
20
|
1069 */
|
|
1070 (image_instance))
|
0
|
1071 {
|
|
1072 CHECK_IMAGE_INSTANCE (image_instance);
|
173
|
1073 return XIMAGE_INSTANCE_NAME (image_instance);
|
0
|
1074 }
|
|
1075
|
20
|
1076 DEFUN ("image-instance-string", Fimage_instance_string, 1, 1, 0, /*
|
0
|
1077 Return the string of the given image instance.
|
|
1078 This will only be non-nil for text image instances.
|
20
|
1079 */
|
|
1080 (image_instance))
|
0
|
1081 {
|
|
1082 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1083 if (XIMAGE_INSTANCE_TYPE (image_instance) == IMAGE_TEXT)
|
173
|
1084 return XIMAGE_INSTANCE_TEXT_STRING (image_instance);
|
0
|
1085 else
|
|
1086 return Qnil;
|
|
1087 }
|
|
1088
|
20
|
1089 DEFUN ("image-instance-file-name", Fimage_instance_file_name, 1, 1, 0, /*
|
0
|
1090 Return the file name from which IMAGE-INSTANCE was read, if known.
|
20
|
1091 */
|
|
1092 (image_instance))
|
0
|
1093 {
|
|
1094 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1095
|
|
1096 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1097 {
|
|
1098 case IMAGE_MONO_PIXMAP:
|
|
1099 case IMAGE_COLOR_PIXMAP:
|
|
1100 case IMAGE_POINTER:
|
|
1101 return XIMAGE_INSTANCE_PIXMAP_FILENAME (image_instance);
|
|
1102
|
|
1103 default:
|
|
1104 return Qnil;
|
|
1105 }
|
|
1106 }
|
|
1107
|
20
|
1108 DEFUN ("image-instance-mask-file-name", Fimage_instance_mask_file_name, 1, 1, 0, /*
|
0
|
1109 Return the file name from which IMAGE-INSTANCE's mask was read, if known.
|
20
|
1110 */
|
|
1111 (image_instance))
|
0
|
1112 {
|
|
1113 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1114
|
|
1115 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1116 {
|
|
1117 case IMAGE_MONO_PIXMAP:
|
|
1118 case IMAGE_COLOR_PIXMAP:
|
|
1119 case IMAGE_POINTER:
|
|
1120 return XIMAGE_INSTANCE_PIXMAP_MASK_FILENAME (image_instance);
|
|
1121
|
|
1122 default:
|
|
1123 return Qnil;
|
|
1124 }
|
|
1125 }
|
|
1126
|
20
|
1127 DEFUN ("image-instance-depth", Fimage_instance_depth, 1, 1, 0, /*
|
0
|
1128 Return the depth of the image instance.
|
|
1129 This is 0 for a bitmap, or a positive integer for a pixmap.
|
20
|
1130 */
|
|
1131 (image_instance))
|
0
|
1132 {
|
|
1133 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1134
|
|
1135 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1136 {
|
|
1137 case IMAGE_MONO_PIXMAP:
|
|
1138 case IMAGE_COLOR_PIXMAP:
|
|
1139 case IMAGE_POINTER:
|
173
|
1140 return make_int (XIMAGE_INSTANCE_PIXMAP_DEPTH (image_instance));
|
0
|
1141
|
|
1142 default:
|
|
1143 return Qnil;
|
|
1144 }
|
|
1145 }
|
|
1146
|
20
|
1147 DEFUN ("image-instance-height", Fimage_instance_height, 1, 1, 0, /*
|
0
|
1148 Return the height of the image instance, in pixels.
|
20
|
1149 */
|
|
1150 (image_instance))
|
0
|
1151 {
|
|
1152 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1153
|
|
1154 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1155 {
|
|
1156 case IMAGE_MONO_PIXMAP:
|
|
1157 case IMAGE_COLOR_PIXMAP:
|
|
1158 case IMAGE_POINTER:
|
173
|
1159 return make_int (XIMAGE_INSTANCE_PIXMAP_HEIGHT (image_instance));
|
0
|
1160
|
|
1161 default:
|
|
1162 return Qnil;
|
|
1163 }
|
|
1164 }
|
|
1165
|
20
|
1166 DEFUN ("image-instance-width", Fimage_instance_width, 1, 1, 0, /*
|
0
|
1167 Return the width of the image instance, in pixels.
|
20
|
1168 */
|
|
1169 (image_instance))
|
0
|
1170 {
|
|
1171 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1172
|
|
1173 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1174 {
|
|
1175 case IMAGE_MONO_PIXMAP:
|
|
1176 case IMAGE_COLOR_PIXMAP:
|
|
1177 case IMAGE_POINTER:
|
173
|
1178 return make_int (XIMAGE_INSTANCE_PIXMAP_WIDTH (image_instance));
|
0
|
1179
|
|
1180 default:
|
|
1181 return Qnil;
|
|
1182 }
|
|
1183 }
|
|
1184
|
20
|
1185 DEFUN ("image-instance-hotspot-x", Fimage_instance_hotspot_x, 1, 1, 0, /*
|
0
|
1186 Return the X coordinate of the image instance's hotspot, if known.
|
|
1187 This is a point relative to the origin of the pixmap. When an image is
|
|
1188 used as a mouse pointer, the hotspot is the point on the image that sits
|
|
1189 over the location that the pointer points to. This is, for example, the
|
|
1190 tip of the arrow or the center of the crosshairs.
|
|
1191 This will always be nil for a non-pointer image instance.
|
20
|
1192 */
|
|
1193 (image_instance))
|
0
|
1194 {
|
|
1195 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1196
|
|
1197 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1198 {
|
|
1199 case IMAGE_MONO_PIXMAP:
|
|
1200 case IMAGE_COLOR_PIXMAP:
|
|
1201 case IMAGE_POINTER:
|
|
1202 return XIMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image_instance);
|
|
1203
|
|
1204 default:
|
|
1205 return Qnil;
|
|
1206 }
|
|
1207 }
|
|
1208
|
20
|
1209 DEFUN ("image-instance-hotspot-y", Fimage_instance_hotspot_y, 1, 1, 0, /*
|
0
|
1210 Return the Y coordinate of the image instance's hotspot, if known.
|
|
1211 This is a point relative to the origin of the pixmap. When an image is
|
|
1212 used as a mouse pointer, the hotspot is the point on the image that sits
|
|
1213 over the location that the pointer points to. This is, for example, the
|
|
1214 tip of the arrow or the center of the crosshairs.
|
|
1215 This will always be nil for a non-pointer image instance.
|
20
|
1216 */
|
|
1217 (image_instance))
|
0
|
1218 {
|
|
1219 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1220
|
|
1221 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1222 {
|
|
1223 case IMAGE_MONO_PIXMAP:
|
|
1224 case IMAGE_COLOR_PIXMAP:
|
|
1225 case IMAGE_POINTER:
|
|
1226 return XIMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image_instance);
|
|
1227
|
|
1228 default:
|
|
1229 return Qnil;
|
|
1230 }
|
|
1231 }
|
|
1232
|
20
|
1233 DEFUN ("image-instance-foreground", Fimage_instance_foreground, 1, 1, 0, /*
|
0
|
1234 Return the foreground color of IMAGE-INSTANCE, if applicable.
|
|
1235 This will be a color instance or nil. (It will only be non-nil for
|
|
1236 colorized mono pixmaps and for pointers.)
|
20
|
1237 */
|
|
1238 (image_instance))
|
0
|
1239 {
|
|
1240 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1241
|
|
1242 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1243 {
|
|
1244 case IMAGE_MONO_PIXMAP:
|
|
1245 case IMAGE_COLOR_PIXMAP:
|
|
1246 case IMAGE_POINTER:
|
|
1247 return XIMAGE_INSTANCE_PIXMAP_FG (image_instance);
|
|
1248
|
|
1249 default:
|
|
1250 return Qnil;
|
|
1251 }
|
|
1252 }
|
|
1253
|
20
|
1254 DEFUN ("image-instance-background", Fimage_instance_background, 1, 1, 0, /*
|
0
|
1255 Return the background color of IMAGE-INSTANCE, if applicable.
|
|
1256 This will be a color instance or nil. (It will only be non-nil for
|
|
1257 colorized mono pixmaps and for pointers.)
|
20
|
1258 */
|
|
1259 (image_instance))
|
0
|
1260 {
|
|
1261 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1262
|
|
1263 switch (XIMAGE_INSTANCE_TYPE (image_instance))
|
|
1264 {
|
|
1265 case IMAGE_MONO_PIXMAP:
|
|
1266 case IMAGE_COLOR_PIXMAP:
|
|
1267 case IMAGE_POINTER:
|
|
1268 return XIMAGE_INSTANCE_PIXMAP_BG (image_instance);
|
|
1269
|
|
1270 default:
|
|
1271 return Qnil;
|
|
1272 }
|
|
1273 }
|
|
1274
|
|
1275
|
20
|
1276 DEFUN ("colorize-image-instance", Fcolorize_image_instance, 3, 3, 0, /*
|
0
|
1277 Make the image instance be displayed in the given colors.
|
|
1278 This function returns a new image instance that is exactly like the
|
|
1279 specified one except that (if possible) the foreground and background
|
|
1280 colors and as specified. Currently, this only does anything if the image
|
|
1281 instance is a mono pixmap; otherwise, the same image instance is returned.
|
20
|
1282 */
|
|
1283 (image_instance, foreground, background))
|
0
|
1284 {
|
|
1285 Lisp_Object new;
|
|
1286 Lisp_Object device;
|
|
1287
|
|
1288 CHECK_IMAGE_INSTANCE (image_instance);
|
|
1289 CHECK_COLOR_INSTANCE (foreground);
|
|
1290 CHECK_COLOR_INSTANCE (background);
|
|
1291
|
|
1292 device = XIMAGE_INSTANCE_DEVICE (image_instance);
|
|
1293 if (!HAS_DEVMETH_P (XDEVICE (device), colorize_image_instance))
|
|
1294 return image_instance;
|
|
1295
|
|
1296 new = allocate_image_instance (device);
|
|
1297 copy_lcrecord (XIMAGE_INSTANCE (new), XIMAGE_INSTANCE (image_instance));
|
|
1298 /* note that if this method returns non-zero, this method MUST
|
|
1299 copy any window-system resources, so that when one image instance is
|
|
1300 freed, the other one is not hosed. */
|
|
1301 if (!DEVMETH (XDEVICE (device), colorize_image_instance, (new, foreground,
|
|
1302 background)))
|
|
1303 return image_instance;
|
|
1304 return new;
|
|
1305 }
|
|
1306
|
|
1307
|
276
|
1308 /************************************************************************/
|
|
1309 /* error helpers */
|
|
1310 /************************************************************************/
|
|
1311 DOESNT_RETURN
|
|
1312 signal_image_error (CONST char *reason, Lisp_Object frob)
|
|
1313 {
|
|
1314 signal_error (Qimage_conversion_error,
|
|
1315 list2 (build_translated_string (reason), frob));
|
|
1316 }
|
|
1317
|
|
1318 DOESNT_RETURN
|
|
1319 signal_image_error_2 (CONST char *reason, Lisp_Object frob0, Lisp_Object frob1)
|
|
1320 {
|
|
1321 signal_error (Qimage_conversion_error,
|
|
1322 list3 (build_translated_string (reason), frob0, frob1));
|
|
1323 }
|
|
1324
|
0
|
1325 /****************************************************************************
|
|
1326 * nothing *
|
|
1327 ****************************************************************************/
|
|
1328
|
|
1329 static int
|
74
|
1330 nothing_possible_dest_types (void)
|
0
|
1331 {
|
|
1332 return IMAGE_NOTHING_MASK;
|
|
1333 }
|
|
1334
|
|
1335 static void
|
|
1336 nothing_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
1337 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
124
|
1338 int dest_mask, Lisp_Object domain)
|
0
|
1339 {
|
|
1340 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1341
|
|
1342 if (dest_mask & IMAGE_NOTHING_MASK)
|
|
1343 IMAGE_INSTANCE_TYPE (ii) = IMAGE_NOTHING;
|
|
1344 else
|
|
1345 incompatible_image_types (instantiator, dest_mask, IMAGE_NOTHING_MASK);
|
|
1346 }
|
|
1347
|
|
1348
|
|
1349 /****************************************************************************
|
|
1350 * inherit *
|
|
1351 ****************************************************************************/
|
|
1352
|
|
1353 static void
|
|
1354 inherit_validate (Lisp_Object instantiator)
|
|
1355 {
|
|
1356 face_must_be_present (instantiator);
|
|
1357 }
|
|
1358
|
|
1359 static Lisp_Object
|
|
1360 inherit_normalize (Lisp_Object inst, Lisp_Object console_type)
|
|
1361 {
|
|
1362 Lisp_Object face;
|
|
1363
|
173
|
1364 assert (XVECTOR_LENGTH (inst) == 3);
|
|
1365 face = XVECTOR_DATA (inst)[2];
|
0
|
1366 if (!FACEP (face))
|
|
1367 inst = vector3 (Qinherit, Q_face, Fget_face (face));
|
|
1368 return inst;
|
|
1369 }
|
|
1370
|
|
1371 static int
|
74
|
1372 inherit_possible_dest_types (void)
|
0
|
1373 {
|
|
1374 return IMAGE_MONO_PIXMAP_MASK;
|
|
1375 }
|
|
1376
|
|
1377 static void
|
|
1378 inherit_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
1379 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
124
|
1380 int dest_mask, Lisp_Object domain)
|
0
|
1381 {
|
|
1382 /* handled specially in image_instantiate */
|
|
1383 abort ();
|
|
1384 }
|
|
1385
|
|
1386
|
|
1387 /****************************************************************************
|
|
1388 * string *
|
|
1389 ****************************************************************************/
|
|
1390
|
|
1391 static void
|
|
1392 string_validate (Lisp_Object instantiator)
|
|
1393 {
|
|
1394 data_must_be_present (instantiator);
|
|
1395 }
|
|
1396
|
|
1397 static int
|
74
|
1398 string_possible_dest_types (void)
|
0
|
1399 {
|
|
1400 return IMAGE_TEXT_MASK;
|
|
1401 }
|
|
1402
|
|
1403 /* called from autodetect_instantiate() */
|
|
1404 void
|
|
1405 string_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
1406 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
124
|
1407 int dest_mask, Lisp_Object domain)
|
0
|
1408 {
|
|
1409 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
|
|
1410 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1411
|
|
1412 assert (!NILP (data));
|
|
1413 if (dest_mask & IMAGE_TEXT_MASK)
|
|
1414 {
|
|
1415 IMAGE_INSTANCE_TYPE (ii) = IMAGE_TEXT;
|
|
1416 IMAGE_INSTANCE_TEXT_STRING (ii) = data;
|
|
1417 }
|
|
1418 else
|
|
1419 incompatible_image_types (instantiator, dest_mask, IMAGE_TEXT_MASK);
|
|
1420 }
|
|
1421
|
|
1422
|
|
1423 /****************************************************************************
|
|
1424 * formatted-string *
|
|
1425 ****************************************************************************/
|
|
1426
|
|
1427 static void
|
|
1428 formatted_string_validate (Lisp_Object instantiator)
|
|
1429 {
|
|
1430 data_must_be_present (instantiator);
|
|
1431 }
|
|
1432
|
|
1433 static int
|
74
|
1434 formatted_string_possible_dest_types (void)
|
0
|
1435 {
|
|
1436 return IMAGE_TEXT_MASK;
|
|
1437 }
|
|
1438
|
|
1439 static void
|
|
1440 formatted_string_instantiate (Lisp_Object image_instance,
|
|
1441 Lisp_Object instantiator,
|
|
1442 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
124
|
1443 int dest_mask, Lisp_Object domain)
|
0
|
1444 {
|
|
1445 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
|
|
1446 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
|
|
1447
|
|
1448 assert (!NILP (data));
|
|
1449 /* #### implement this */
|
|
1450 warn_when_safe (Qunimplemented, Qnotice,
|
|
1451 "`formatted-string' not yet implemented; assuming `string'");
|
|
1452 if (dest_mask & IMAGE_TEXT_MASK)
|
|
1453 {
|
|
1454 IMAGE_INSTANCE_TYPE (ii) = IMAGE_TEXT;
|
|
1455 IMAGE_INSTANCE_TEXT_STRING (ii) = data;
|
|
1456 }
|
|
1457 else
|
|
1458 incompatible_image_types (instantiator, dest_mask, IMAGE_TEXT_MASK);
|
|
1459 }
|
|
1460
|
|
1461
|
278
|
1462 /************************************************************************/
|
|
1463 /* pixmap file functions */
|
|
1464 /************************************************************************/
|
|
1465
|
|
1466 /* If INSTANTIATOR refers to inline data, return Qnil.
|
|
1467 If INSTANTIATOR refers to data in a file, return the full filename
|
|
1468 if it exists; otherwise, return a cons of (filename).
|
|
1469
|
|
1470 FILE_KEYWORD and DATA_KEYWORD are symbols specifying the
|
|
1471 keywords used to look up the file and inline data,
|
|
1472 respectively, in the instantiator. Normally these would
|
|
1473 be Q_file and Q_data, but might be different for mask data. */
|
|
1474
|
|
1475 Lisp_Object
|
|
1476 potential_pixmap_file_instantiator (Lisp_Object instantiator,
|
|
1477 Lisp_Object file_keyword,
|
|
1478 Lisp_Object data_keyword,
|
|
1479 Lisp_Object console_type)
|
|
1480 {
|
|
1481 Lisp_Object file;
|
|
1482 Lisp_Object data;
|
|
1483
|
|
1484 assert (VECTORP (instantiator));
|
|
1485
|
|
1486 data = find_keyword_in_vector (instantiator, data_keyword);
|
|
1487 file = find_keyword_in_vector (instantiator, file_keyword);
|
|
1488
|
|
1489 if (!NILP (file) && NILP (data))
|
|
1490 {
|
|
1491 Lisp_Object retval = MAYBE_LISP_CONTYPE_METH
|
|
1492 (decode_console_type(console_type, ERROR_ME),
|
|
1493 locate_pixmap_file, (file));
|
|
1494
|
|
1495 if (!NILP (retval))
|
|
1496 return retval;
|
|
1497 else
|
|
1498 return Fcons (file, Qnil); /* should have been file */
|
|
1499 }
|
|
1500
|
|
1501 return Qnil;
|
|
1502 }
|
|
1503
|
|
1504 Lisp_Object
|
|
1505 simple_image_type_normalize (Lisp_Object inst, Lisp_Object console_type,
|
|
1506 Lisp_Object image_type_tag)
|
|
1507 {
|
|
1508 /* This function can call lisp */
|
|
1509 Lisp_Object file = Qnil;
|
|
1510 struct gcpro gcpro1, gcpro2;
|
|
1511 Lisp_Object alist = Qnil;
|
|
1512
|
|
1513 GCPRO2 (file, alist);
|
|
1514
|
|
1515 /* Now, convert any file data into inline data. At the end of this,
|
|
1516 `data' will contain the inline data (if any) or Qnil, and `file'
|
|
1517 will contain the name this data was derived from (if known) or
|
|
1518 Qnil.
|
|
1519
|
|
1520 Note that if we cannot generate any regular inline data, we
|
|
1521 skip out. */
|
|
1522
|
|
1523 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
|
|
1524 console_type);
|
|
1525
|
|
1526 if (CONSP (file)) /* failure locating filename */
|
|
1527 signal_double_file_error ("Opening pixmap file",
|
|
1528 "no such file or directory",
|
|
1529 Fcar (file));
|
|
1530
|
|
1531 if (NILP (file)) /* no conversion necessary */
|
|
1532 RETURN_UNGCPRO (inst);
|
|
1533
|
|
1534 alist = tagged_vector_to_alist (inst);
|
|
1535
|
|
1536 {
|
|
1537 Lisp_Object data = make_string_from_file (file);
|
|
1538 alist = remassq_no_quit (Q_file, alist);
|
|
1539 /* there can't be a :data at this point. */
|
|
1540 alist = Fcons (Fcons (Q_file, file),
|
|
1541 Fcons (Fcons (Q_data, data), alist));
|
|
1542 }
|
|
1543
|
|
1544 {
|
|
1545 Lisp_Object result = alist_to_tagged_vector (image_type_tag, alist);
|
|
1546 free_alist (alist);
|
|
1547 RETURN_UNGCPRO (result);
|
|
1548 }
|
|
1549 }
|
|
1550
|
|
1551
|
288
|
1552 #ifdef HAVE_WINDOW_SYSTEM
|
|
1553 /**********************************************************************
|
|
1554 * XBM *
|
|
1555 **********************************************************************/
|
|
1556
|
|
1557 /* Check if DATA represents a valid inline XBM spec (i.e. a list
|
|
1558 of (width height bits), with checking done on the dimensions).
|
|
1559 If not, signal an error. */
|
|
1560
|
|
1561 static void
|
|
1562 check_valid_xbm_inline (Lisp_Object data)
|
|
1563 {
|
|
1564 Lisp_Object width, height, bits;
|
|
1565
|
|
1566 if (!CONSP (data) ||
|
|
1567 !CONSP (XCDR (data)) ||
|
|
1568 !CONSP (XCDR (XCDR (data))) ||
|
|
1569 !NILP (XCDR (XCDR (XCDR (data)))))
|
|
1570 signal_simple_error ("Must be list of 3 elements", data);
|
|
1571
|
|
1572 width = XCAR (data);
|
|
1573 height = XCAR (XCDR (data));
|
|
1574 bits = XCAR (XCDR (XCDR (data)));
|
|
1575
|
|
1576 CHECK_STRING (bits);
|
|
1577
|
|
1578 if (!NATNUMP (width))
|
|
1579 signal_simple_error ("Width must be a natural number", width);
|
|
1580
|
|
1581 if (!NATNUMP (height))
|
|
1582 signal_simple_error ("Height must be a natural number", height);
|
|
1583
|
|
1584 if (((XINT (width) * XINT (height)) / 8) > XSTRING_CHAR_LENGTH (bits))
|
|
1585 signal_simple_error ("data is too short for width and height",
|
|
1586 vector3 (width, height, bits));
|
|
1587 }
|
|
1588
|
|
1589 /* Validate method for XBM's. */
|
|
1590
|
|
1591 static void
|
|
1592 xbm_validate (Lisp_Object instantiator)
|
|
1593 {
|
|
1594 file_or_data_must_be_present (instantiator);
|
|
1595 }
|
|
1596
|
|
1597 /* Given a filename that is supposed to contain XBM data, return
|
|
1598 the inline representation of it as (width height bits). Return
|
|
1599 the hotspot through XHOT and YHOT, if those pointers are not 0.
|
|
1600 If there is no hotspot, XHOT and YHOT will contain -1.
|
|
1601
|
|
1602 If the function fails:
|
|
1603
|
|
1604 -- if OK_IF_DATA_INVALID is set and the data was invalid,
|
|
1605 return Qt.
|
|
1606 -- maybe return an error, or return Qnil.
|
|
1607 */
|
|
1608
|
290
|
1609 #ifndef HAVE_X_WINDOWS
|
|
1610 #define XFree(data) free(data)
|
|
1611 #endif
|
288
|
1612
|
|
1613 Lisp_Object
|
|
1614 bitmap_to_lisp_data (Lisp_Object name, int *xhot, int *yhot,
|
|
1615 int ok_if_data_invalid)
|
|
1616 {
|
|
1617 unsigned int w, h;
|
|
1618 Extbyte *data;
|
|
1619 int result;
|
|
1620 CONST char *filename_ext;
|
|
1621
|
|
1622 GET_C_STRING_FILENAME_DATA_ALLOCA (name, filename_ext);
|
|
1623 result = read_bitmap_data_from_file (filename_ext, &w, &h,
|
|
1624 &data, xhot, yhot);
|
|
1625
|
|
1626 if (result == BitmapSuccess)
|
|
1627 {
|
|
1628 Lisp_Object retval;
|
|
1629 int len = (w + 7) / 8 * h;
|
|
1630
|
|
1631 retval = list3 (make_int (w), make_int (h),
|
|
1632 make_ext_string (data, len, FORMAT_BINARY));
|
|
1633 XFree ((char *) data);
|
|
1634 return retval;
|
|
1635 }
|
|
1636
|
|
1637 switch (result)
|
|
1638 {
|
|
1639 case BitmapOpenFailed:
|
|
1640 {
|
|
1641 /* should never happen */
|
|
1642 signal_double_file_error ("Opening bitmap file",
|
|
1643 "no such file or directory",
|
|
1644 name);
|
|
1645 }
|
|
1646 case BitmapFileInvalid:
|
|
1647 {
|
|
1648 if (ok_if_data_invalid)
|
|
1649 return Qt;
|
|
1650 signal_double_file_error ("Reading bitmap file",
|
|
1651 "invalid data in file",
|
|
1652 name);
|
|
1653 }
|
|
1654 case BitmapNoMemory:
|
|
1655 {
|
|
1656 signal_double_file_error ("Reading bitmap file",
|
|
1657 "out of memory",
|
|
1658 name);
|
|
1659 }
|
|
1660 default:
|
|
1661 {
|
|
1662 signal_double_file_error_2 ("Reading bitmap file",
|
|
1663 "unknown error code",
|
|
1664 make_int (result), name);
|
|
1665 }
|
|
1666 }
|
|
1667
|
|
1668 return Qnil; /* not reached */
|
|
1669 }
|
|
1670
|
|
1671 Lisp_Object
|
|
1672 xbm_mask_file_munging (Lisp_Object alist, Lisp_Object file,
|
|
1673 Lisp_Object mask_file, Lisp_Object console_type)
|
|
1674 {
|
|
1675 /* This is unclean but it's fairly standard -- a number of the
|
|
1676 bitmaps in /usr/include/X11/bitmaps use it -- so we support
|
|
1677 it. */
|
|
1678 if (NILP (mask_file)
|
|
1679 /* don't override explicitly specified mask data. */
|
|
1680 && NILP (assq_no_quit (Q_mask_data, alist))
|
|
1681 && !NILP (file))
|
|
1682 {
|
|
1683 mask_file = MAYBE_LISP_CONTYPE_METH
|
|
1684 (decode_console_type(console_type, ERROR_ME),
|
|
1685 locate_pixmap_file, (concat2 (file, build_string ("Mask"))));
|
|
1686 if (NILP (mask_file))
|
|
1687 mask_file = MAYBE_LISP_CONTYPE_METH
|
|
1688 (decode_console_type(console_type, ERROR_ME),
|
|
1689 locate_pixmap_file, (concat2 (file, build_string ("msk"))));
|
|
1690 }
|
|
1691
|
|
1692 if (!NILP (mask_file))
|
|
1693 {
|
|
1694 Lisp_Object mask_data =
|
|
1695 bitmap_to_lisp_data (mask_file, 0, 0, 0);
|
|
1696 alist = remassq_no_quit (Q_mask_file, alist);
|
|
1697 /* there can't be a :mask-data at this point. */
|
|
1698 alist = Fcons (Fcons (Q_mask_file, mask_file),
|
|
1699 Fcons (Fcons (Q_mask_data, mask_data), alist));
|
|
1700 }
|
|
1701
|
|
1702 return alist;
|
|
1703 }
|
|
1704
|
|
1705 /* Normalize method for XBM's. */
|
|
1706
|
|
1707 static Lisp_Object
|
|
1708 xbm_normalize (Lisp_Object inst, Lisp_Object console_type)
|
|
1709 {
|
|
1710 Lisp_Object file = Qnil, mask_file = Qnil;
|
|
1711 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1712 Lisp_Object alist = Qnil;
|
|
1713
|
|
1714 GCPRO3 (file, mask_file, alist);
|
|
1715
|
|
1716 /* Now, convert any file data into inline data for both the regular
|
|
1717 data and the mask data. At the end of this, `data' will contain
|
|
1718 the inline data (if any) or Qnil, and `file' will contain
|
|
1719 the name this data was derived from (if known) or Qnil.
|
|
1720 Likewise for `mask_file' and `mask_data'.
|
|
1721
|
|
1722 Note that if we cannot generate any regular inline data, we
|
|
1723 skip out. */
|
|
1724
|
|
1725 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
|
|
1726 console_type);
|
|
1727 mask_file = potential_pixmap_file_instantiator (inst, Q_mask_file,
|
|
1728 Q_mask_data, console_type);
|
|
1729
|
|
1730 if (CONSP (file)) /* failure locating filename */
|
|
1731 signal_double_file_error ("Opening bitmap file",
|
|
1732 "no such file or directory",
|
|
1733 Fcar (file));
|
|
1734
|
|
1735 if (NILP (file) && NILP (mask_file)) /* no conversion necessary */
|
|
1736 RETURN_UNGCPRO (inst);
|
|
1737
|
|
1738 alist = tagged_vector_to_alist (inst);
|
|
1739
|
|
1740 if (!NILP (file))
|
|
1741 {
|
|
1742 int xhot, yhot;
|
|
1743 Lisp_Object data = bitmap_to_lisp_data (file, &xhot, &yhot, 0);
|
|
1744 alist = remassq_no_quit (Q_file, alist);
|
|
1745 /* there can't be a :data at this point. */
|
|
1746 alist = Fcons (Fcons (Q_file, file),
|
|
1747 Fcons (Fcons (Q_data, data), alist));
|
|
1748
|
|
1749 if (xhot != -1 && NILP (assq_no_quit (Q_hotspot_x, alist)))
|
|
1750 alist = Fcons (Fcons (Q_hotspot_x, make_int (xhot)),
|
|
1751 alist);
|
|
1752 if (yhot != -1 && NILP (assq_no_quit (Q_hotspot_y, alist)))
|
|
1753 alist = Fcons (Fcons (Q_hotspot_y, make_int (yhot)),
|
|
1754 alist);
|
|
1755 }
|
|
1756
|
|
1757 alist = xbm_mask_file_munging (alist, file, mask_file, console_type);
|
|
1758
|
|
1759 {
|
|
1760 Lisp_Object result = alist_to_tagged_vector (Qxbm, alist);
|
|
1761 free_alist (alist);
|
|
1762 RETURN_UNGCPRO (result);
|
|
1763 }
|
|
1764 }
|
|
1765
|
|
1766
|
|
1767 static int
|
|
1768 xbm_possible_dest_types (void)
|
|
1769 {
|
|
1770 return
|
|
1771 IMAGE_MONO_PIXMAP_MASK |
|
|
1772 IMAGE_COLOR_PIXMAP_MASK |
|
|
1773 IMAGE_POINTER_MASK;
|
|
1774 }
|
|
1775
|
|
1776 static void
|
|
1777 xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
1778 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
|
1779 int dest_mask, Lisp_Object domain)
|
|
1780 {
|
|
1781 Lisp_Object device= IMAGE_INSTANCE_DEVICE (XIMAGE_INSTANCE (image_instance));
|
|
1782
|
|
1783 MAYBE_DEVMETH (XDEVICE (device),
|
|
1784 xbm_instantiate,
|
|
1785 (image_instance, instantiator, pointer_fg,
|
|
1786 pointer_bg, dest_mask, domain));
|
|
1787 }
|
|
1788
|
|
1789 #endif
|
|
1790
|
|
1791
|
276
|
1792 #ifdef HAVE_XPM
|
|
1793
|
|
1794 /**********************************************************************
|
|
1795 * XPM *
|
|
1796 **********************************************************************/
|
|
1797
|
280
|
1798 Lisp_Object
|
|
1799 pixmap_to_lisp_data (Lisp_Object name, int ok_if_data_invalid)
|
|
1800 {
|
|
1801 char **data;
|
|
1802 int result;
|
|
1803
|
|
1804 result = XpmReadFileToData ((char *) XSTRING_DATA (name), &data);
|
|
1805
|
|
1806 if (result == XpmSuccess)
|
|
1807 {
|
|
1808 Lisp_Object retval = Qnil;
|
|
1809 struct buffer *old_buffer = current_buffer;
|
|
1810 Lisp_Object temp_buffer =
|
|
1811 Fget_buffer_create (build_string (" *pixmap conversion*"));
|
|
1812 int elt;
|
|
1813 int height, width, ncolors;
|
|
1814 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1815 int speccount = specpdl_depth ();
|
|
1816
|
|
1817 GCPRO3 (name, retval, temp_buffer);
|
|
1818
|
|
1819 specbind (Qinhibit_quit, Qt);
|
|
1820 set_buffer_internal (XBUFFER (temp_buffer));
|
|
1821 Ferase_buffer (Qnil);
|
|
1822
|
|
1823 buffer_insert_c_string (current_buffer, "/* XPM */\r");
|
|
1824 buffer_insert_c_string (current_buffer, "static char *pixmap[] = {\r");
|
|
1825
|
|
1826 sscanf (data[0], "%d %d %d", &height, &width, &ncolors);
|
|
1827 for (elt = 0; elt <= width + ncolors; elt++)
|
|
1828 {
|
|
1829 buffer_insert_c_string (current_buffer, "\"");
|
|
1830 buffer_insert_c_string (current_buffer, data[elt]);
|
|
1831
|
|
1832 if (elt < width + ncolors)
|
|
1833 buffer_insert_c_string (current_buffer, "\",\r");
|
|
1834 else
|
|
1835 buffer_insert_c_string (current_buffer, "\"};\r");
|
|
1836 }
|
|
1837
|
|
1838 retval = Fbuffer_substring (Qnil, Qnil, Qnil);
|
|
1839 XpmFree (data);
|
|
1840
|
|
1841 set_buffer_internal (old_buffer);
|
|
1842 unbind_to (speccount, Qnil);
|
|
1843
|
|
1844 RETURN_UNGCPRO (retval);
|
|
1845 }
|
|
1846
|
|
1847 switch (result)
|
|
1848 {
|
|
1849 case XpmFileInvalid:
|
|
1850 {
|
|
1851 if (ok_if_data_invalid)
|
|
1852 return Qt;
|
|
1853 signal_image_error ("invalid XPM data in file", name);
|
|
1854 }
|
|
1855 case XpmNoMemory:
|
|
1856 {
|
|
1857 signal_double_file_error ("Reading pixmap file",
|
|
1858 "out of memory", name);
|
|
1859 }
|
|
1860 case XpmOpenFailed:
|
|
1861 {
|
|
1862 /* should never happen? */
|
|
1863 signal_double_file_error ("Opening pixmap file",
|
|
1864 "no such file or directory", name);
|
|
1865 }
|
|
1866 default:
|
|
1867 {
|
|
1868 signal_double_file_error_2 ("Parsing pixmap file",
|
|
1869 "unknown error code",
|
|
1870 make_int (result), name);
|
|
1871 break;
|
|
1872 }
|
|
1873 }
|
|
1874
|
|
1875 return Qnil; /* not reached */
|
|
1876 }
|
|
1877
|
276
|
1878 static void
|
|
1879 check_valid_xpm_color_symbols (Lisp_Object data)
|
|
1880 {
|
|
1881 Lisp_Object rest;
|
|
1882
|
|
1883 for (rest = data; !NILP (rest); rest = XCDR (rest))
|
|
1884 {
|
|
1885 if (!CONSP (rest) ||
|
|
1886 !CONSP (XCAR (rest)) ||
|
|
1887 !STRINGP (XCAR (XCAR (rest))) ||
|
|
1888 (!STRINGP (XCDR (XCAR (rest))) &&
|
|
1889 !COLOR_SPECIFIERP (XCDR (XCAR (rest)))))
|
|
1890 signal_simple_error ("Invalid color symbol alist", data);
|
|
1891 }
|
|
1892 }
|
|
1893
|
|
1894 static void
|
|
1895 xpm_validate (Lisp_Object instantiator)
|
|
1896 {
|
|
1897 file_or_data_must_be_present (instantiator);
|
|
1898 }
|
|
1899
|
|
1900 Lisp_Object Vxpm_color_symbols;
|
|
1901
|
|
1902 Lisp_Object
|
|
1903 evaluate_xpm_color_symbols (void)
|
|
1904 {
|
|
1905 Lisp_Object rest, results = Qnil;
|
|
1906 struct gcpro gcpro1, gcpro2;
|
|
1907
|
|
1908 GCPRO2 (rest, results);
|
|
1909 for (rest = Vxpm_color_symbols; !NILP (rest); rest = XCDR (rest))
|
|
1910 {
|
|
1911 Lisp_Object name, value, cons;
|
|
1912
|
|
1913 CHECK_CONS (rest);
|
|
1914 cons = XCAR (rest);
|
|
1915 CHECK_CONS (cons);
|
|
1916 name = XCAR (cons);
|
|
1917 CHECK_STRING (name);
|
|
1918 value = XCDR (cons);
|
|
1919 CHECK_CONS (value);
|
|
1920 value = XCAR (value);
|
|
1921 value = Feval (value);
|
|
1922 if (NILP (value))
|
|
1923 continue;
|
|
1924 if (!STRINGP (value) && !COLOR_SPECIFIERP (value))
|
|
1925 signal_simple_error
|
|
1926 ("Result from xpm-color-symbols eval must be nil, string, or color",
|
|
1927 value);
|
|
1928 results = Fcons (Fcons (name, value), results);
|
|
1929 }
|
|
1930 UNGCPRO; /* no more evaluation */
|
|
1931 return results;
|
|
1932 }
|
|
1933
|
|
1934 static Lisp_Object
|
|
1935 xpm_normalize (Lisp_Object inst, Lisp_Object console_type)
|
|
1936 {
|
280
|
1937 Lisp_Object file = Qnil;
|
|
1938 Lisp_Object color_symbols;
|
|
1939 struct gcpro gcpro1, gcpro2;
|
|
1940 Lisp_Object alist = Qnil;
|
|
1941
|
|
1942 GCPRO2 (file, alist);
|
|
1943
|
|
1944 /* Now, convert any file data into inline data. At the end of this,
|
|
1945 `data' will contain the inline data (if any) or Qnil, and
|
|
1946 `file' will contain the name this data was derived from (if
|
|
1947 known) or Qnil.
|
|
1948
|
|
1949 Note that if we cannot generate any regular inline data, we
|
|
1950 skip out. */
|
|
1951
|
|
1952 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
|
|
1953 console_type);
|
|
1954
|
|
1955 if (CONSP (file)) /* failure locating filename */
|
|
1956 signal_double_file_error ("Opening pixmap file",
|
|
1957 "no such file or directory",
|
|
1958 Fcar (file));
|
|
1959
|
|
1960 color_symbols = find_keyword_in_vector_or_given (inst, Q_color_symbols,
|
|
1961 Qunbound);
|
|
1962
|
|
1963 if (NILP (file) && !UNBOUNDP (color_symbols))
|
|
1964 /* no conversion necessary */
|
|
1965 RETURN_UNGCPRO (inst);
|
|
1966
|
|
1967 alist = tagged_vector_to_alist (inst);
|
|
1968
|
|
1969 if (!NILP (file))
|
|
1970 {
|
|
1971 Lisp_Object data = pixmap_to_lisp_data (file, 0);
|
|
1972 alist = remassq_no_quit (Q_file, alist);
|
|
1973 /* there can't be a :data at this point. */
|
|
1974 alist = Fcons (Fcons (Q_file, file),
|
|
1975 Fcons (Fcons (Q_data, data), alist));
|
|
1976 }
|
|
1977
|
|
1978 if (UNBOUNDP (color_symbols))
|
|
1979 {
|
|
1980 color_symbols = evaluate_xpm_color_symbols ();
|
|
1981 alist = Fcons (Fcons (Q_color_symbols, color_symbols),
|
|
1982 alist);
|
|
1983 }
|
|
1984
|
|
1985 {
|
|
1986 Lisp_Object result = alist_to_tagged_vector (Qxpm, alist);
|
|
1987 free_alist (alist);
|
|
1988 RETURN_UNGCPRO (result);
|
|
1989 }
|
276
|
1990 }
|
|
1991
|
|
1992 static int
|
|
1993 xpm_possible_dest_types (void)
|
|
1994 {
|
|
1995 return
|
|
1996 IMAGE_MONO_PIXMAP_MASK |
|
|
1997 IMAGE_COLOR_PIXMAP_MASK |
|
|
1998 IMAGE_POINTER_MASK;
|
|
1999 }
|
|
2000
|
|
2001 static void
|
|
2002 xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
|
|
2003 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
|
|
2004 int dest_mask, Lisp_Object domain)
|
|
2005 {
|
|
2006 Lisp_Object device= IMAGE_INSTANCE_DEVICE (XIMAGE_INSTANCE (image_instance));
|
280
|
2007
|
|
2008 MAYBE_DEVMETH (XDEVICE (device),
|
|
2009 xpm_instantiate,
|
|
2010 (image_instance, instantiator, pointer_fg,
|
|
2011 pointer_bg, dest_mask, domain));
|
276
|
2012 }
|
|
2013
|
|
2014 #endif /* HAVE_XPM */
|
|
2015
|
|
2016
|
0
|
2017 /****************************************************************************
|
|
2018 * Image Specifier Object *
|
|
2019 ****************************************************************************/
|
|
2020
|
|
2021 DEFINE_SPECIFIER_TYPE (image);
|
|
2022
|
|
2023 static void
|
|
2024 image_create (Lisp_Object obj)
|
|
2025 {
|
|
2026 struct Lisp_Specifier *image = XIMAGE_SPECIFIER (obj);
|
|
2027
|
|
2028 IMAGE_SPECIFIER_ALLOWED (image) = ~0; /* all are allowed */
|
|
2029 IMAGE_SPECIFIER_ATTACHEE (image) = Qnil;
|
|
2030 IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image) = Qnil;
|
|
2031 }
|
|
2032
|
|
2033 static void
|
|
2034 image_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
2035 {
|
|
2036 struct Lisp_Specifier *image = XIMAGE_SPECIFIER (obj);
|
|
2037
|
|
2038 ((markobj) (IMAGE_SPECIFIER_ATTACHEE (image)));
|
|
2039 ((markobj) (IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image)));
|
|
2040 }
|
|
2041
|
|
2042 static Lisp_Object
|
|
2043 image_instantiate_cache_result (Lisp_Object locative)
|
|
2044 {
|
272
|
2045 /* locative = (instance instantiator . subtable) */
|
|
2046 Fputhash (XCAR (XCDR (locative)), XCAR (locative), XCDR (XCDR (locative)));
|
0
|
2047 free_cons (XCONS (XCDR (locative)));
|
|
2048 free_cons (XCONS (locative));
|
|
2049 return Qnil;
|
|
2050 }
|
|
2051
|
|
2052 /* Given a specification for an image, return an instance of
|
|
2053 the image which matches the given instantiator and which can be
|
|
2054 displayed in the given domain. */
|
|
2055
|
|
2056 static Lisp_Object
|
|
2057 image_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
|
|
2058 Lisp_Object domain, Lisp_Object instantiator,
|
|
2059 Lisp_Object depth)
|
|
2060 {
|
|
2061 Lisp_Object device = DFW_DEVICE (domain);
|
|
2062 struct device *d = XDEVICE (device);
|
|
2063 int dest_mask = XIMAGE_SPECIFIER_ALLOWED (specifier);
|
|
2064 int pointerp = dest_mask & image_instance_type_to_mask (IMAGE_POINTER);
|
|
2065
|
|
2066 if (IMAGE_INSTANCEP (instantiator))
|
|
2067 {
|
|
2068 /* make sure that the image instance's device and type are
|
|
2069 matching. */
|
|
2070
|
|
2071 if (EQ (device, XIMAGE_INSTANCE_DEVICE (instantiator)))
|
|
2072 {
|
|
2073 int mask =
|
|
2074 image_instance_type_to_mask (XIMAGE_INSTANCE_TYPE (instantiator));
|
|
2075 if (mask & dest_mask)
|
|
2076 return instantiator;
|
|
2077 else
|
|
2078 signal_simple_error ("Type of image instance not allowed here",
|
|
2079 instantiator);
|
|
2080 }
|
|
2081 else
|
|
2082 signal_simple_error_2 ("Wrong device for image instance",
|
|
2083 instantiator, device);
|
|
2084 }
|
|
2085 else if (VECTORP (instantiator)
|
173
|
2086 && EQ (XVECTOR_DATA (instantiator)[0], Qinherit))
|
0
|
2087 {
|
173
|
2088 assert (XVECTOR_LENGTH (instantiator) == 3);
|
0
|
2089 return (FACE_PROPERTY_INSTANCE
|
173
|
2090 (Fget_face (XVECTOR_DATA (instantiator)[2]),
|
0
|
2091 Qbackground_pixmap, domain, 0, depth));
|
|
2092 }
|
|
2093 else
|
|
2094 {
|
|
2095 Lisp_Object instance;
|
|
2096 Lisp_Object subtable;
|
|
2097 Lisp_Object ls3 = Qnil;
|
|
2098 Lisp_Object pointer_fg = Qnil;
|
|
2099 Lisp_Object pointer_bg = Qnil;
|
|
2100
|
|
2101 if (pointerp)
|
|
2102 {
|
|
2103 pointer_fg = FACE_FOREGROUND (Vpointer_face, domain);
|
|
2104 pointer_bg = FACE_BACKGROUND (Vpointer_face, domain);
|
|
2105 ls3 = list3 (instantiator, pointer_fg, pointer_bg);
|
|
2106 }
|
|
2107
|
|
2108 /* First look in the hash table. */
|
|
2109 subtable = Fgethash (make_int (dest_mask), d->image_instance_cache,
|
|
2110 Qunbound);
|
|
2111 if (UNBOUNDP (subtable))
|
|
2112 {
|
|
2113 /* For the image instance cache, we do comparisons with EQ rather
|
|
2114 than with EQUAL, as we do for color and font names.
|
|
2115 The reasons are:
|
|
2116
|
|
2117 1) pixmap data can be very long, and thus the hashing and
|
|
2118 comparing will take awhile.
|
|
2119 2) It's not so likely that we'll run into things that are EQUAL
|
|
2120 but not EQ (that can happen a lot with faces, because their
|
|
2121 specifiers are copied around); but pixmaps tend not to be
|
|
2122 in faces.
|
|
2123
|
|
2124 However, if the image-instance could be a pointer, we have to
|
|
2125 use EQUAL because we massaged the instantiator into a cons3
|
|
2126 also containing the foreground and background of the
|
|
2127 pointer face.
|
|
2128 */
|
|
2129
|
|
2130 subtable = make_lisp_hashtable (20,
|
|
2131 pointerp ? HASHTABLE_KEY_CAR_WEAK
|
|
2132 : HASHTABLE_KEY_WEAK,
|
|
2133 pointerp ? HASHTABLE_EQUAL
|
|
2134 : HASHTABLE_EQ);
|
|
2135 Fputhash (make_int (dest_mask), subtable,
|
|
2136 d->image_instance_cache);
|
|
2137 instance = Qunbound;
|
|
2138 }
|
|
2139 else
|
|
2140 instance = Fgethash (pointerp ? ls3 : instantiator,
|
|
2141 subtable, Qunbound);
|
|
2142
|
|
2143 if (UNBOUNDP (instance))
|
|
2144 {
|
|
2145 Lisp_Object locative =
|
|
2146 noseeum_cons (Qnil,
|
|
2147 noseeum_cons (pointerp ? ls3 : instantiator,
|
|
2148 subtable));
|
|
2149 int speccount = specpdl_depth ();
|
|
2150
|
|
2151 /* make sure we cache the failures, too.
|
|
2152 Use an unwind-protect to catch such errors.
|
|
2153 If we fail, the unwind-protect records nil in
|
|
2154 the hash table. If we succeed, we change the
|
|
2155 car of the locative to the resulting instance,
|
|
2156 which gets recorded instead. */
|
|
2157 record_unwind_protect (image_instantiate_cache_result,
|
|
2158 locative);
|
|
2159 instance = instantiate_image_instantiator (device,
|
124
|
2160 domain,
|
0
|
2161 instantiator,
|
|
2162 pointer_fg, pointer_bg,
|
|
2163 dest_mask);
|
|
2164 Fsetcar (locative, instance);
|
|
2165 unbind_to (speccount, Qnil);
|
|
2166 }
|
|
2167 else
|
|
2168 free_list (ls3);
|
|
2169
|
|
2170 if (NILP (instance))
|
|
2171 signal_simple_error ("Can't instantiate image (probably cached)",
|
|
2172 instantiator);
|
|
2173 return instance;
|
|
2174 }
|
|
2175
|
|
2176 abort ();
|
|
2177 return Qnil; /* not reached */
|
|
2178 }
|
|
2179
|
|
2180 /* Validate an image instantiator. */
|
|
2181
|
|
2182 static void
|
|
2183 image_validate (Lisp_Object instantiator)
|
|
2184 {
|
|
2185 if (IMAGE_INSTANCEP (instantiator) || STRINGP (instantiator))
|
|
2186 return;
|
|
2187 else if (VECTORP (instantiator))
|
|
2188 {
|
173
|
2189 Lisp_Object *elt = XVECTOR_DATA (instantiator);
|
|
2190 int instantiator_len = XVECTOR_LENGTH (instantiator);
|
0
|
2191 struct image_instantiator_methods *meths;
|
|
2192 Lisp_Object already_seen = Qnil;
|
|
2193 struct gcpro gcpro1;
|
|
2194 int i;
|
|
2195
|
|
2196 if (instantiator_len < 1)
|
|
2197 signal_simple_error ("Vector length must be at least 1",
|
|
2198 instantiator);
|
|
2199
|
|
2200 meths = decode_image_instantiator_format (elt[0], ERROR_ME);
|
|
2201 if (!(instantiator_len & 1))
|
|
2202 signal_simple_error
|
|
2203 ("Must have alternating keyword/value pairs", instantiator);
|
|
2204
|
|
2205 GCPRO1 (already_seen);
|
|
2206
|
|
2207 for (i = 1; i < instantiator_len; i += 2)
|
|
2208 {
|
|
2209 Lisp_Object keyword = elt[i];
|
|
2210 Lisp_Object value = elt[i+1];
|
|
2211 int j;
|
|
2212
|
|
2213 CHECK_SYMBOL (keyword);
|
|
2214 if (!SYMBOL_IS_KEYWORD (keyword))
|
|
2215 signal_simple_error ("Symbol must begin with a colon", keyword);
|
|
2216
|
|
2217 for (j = 0; j < Dynarr_length (meths->keywords); j++)
|
|
2218 if (EQ (keyword, Dynarr_at (meths->keywords, j).keyword))
|
|
2219 break;
|
|
2220
|
|
2221 if (j == Dynarr_length (meths->keywords))
|
|
2222 signal_simple_error ("Unrecognized keyword", keyword);
|
|
2223
|
|
2224 if (!Dynarr_at (meths->keywords, j).multiple_p)
|
|
2225 {
|
|
2226 if (!NILP (memq_no_quit (keyword, already_seen)))
|
|
2227 signal_simple_error
|
|
2228 ("Keyword may not appear more than once", keyword);
|
|
2229 already_seen = Fcons (keyword, already_seen);
|
|
2230 }
|
|
2231
|
|
2232 (Dynarr_at (meths->keywords, j).validate) (value);
|
|
2233 }
|
|
2234
|
|
2235 UNGCPRO;
|
|
2236
|
|
2237 MAYBE_IIFORMAT_METH (meths, validate, (instantiator));
|
|
2238 }
|
|
2239 else
|
|
2240 signal_simple_error ("Must be string or vector", instantiator);
|
|
2241 }
|
|
2242
|
|
2243 static void
|
|
2244 image_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
2245 {
|
|
2246 Lisp_Object attachee =
|
|
2247 IMAGE_SPECIFIER_ATTACHEE (XIMAGE_SPECIFIER (specifier));
|
|
2248 Lisp_Object property =
|
|
2249 IMAGE_SPECIFIER_ATTACHEE_PROPERTY (XIMAGE_SPECIFIER (specifier));
|
|
2250 if (FACEP (attachee))
|
|
2251 face_property_was_changed (attachee, property, locale);
|
|
2252 else if (GLYPHP (attachee))
|
|
2253 glyph_property_was_changed (attachee, property, locale);
|
|
2254 }
|
|
2255
|
|
2256 void
|
|
2257 set_image_attached_to (Lisp_Object obj, Lisp_Object face_or_glyph,
|
|
2258 Lisp_Object property)
|
|
2259 {
|
|
2260 struct Lisp_Specifier *image = XIMAGE_SPECIFIER (obj);
|
|
2261
|
|
2262 IMAGE_SPECIFIER_ATTACHEE (image) = face_or_glyph;
|
|
2263 IMAGE_SPECIFIER_ATTACHEE_PROPERTY (image) = property;
|
|
2264 }
|
|
2265
|
|
2266 static Lisp_Object
|
|
2267 image_going_to_add (Lisp_Object specifier, Lisp_Object locale,
|
|
2268 Lisp_Object tag_set, Lisp_Object instantiator)
|
|
2269 {
|
|
2270 Lisp_Object possible_console_types = Qnil;
|
|
2271 Lisp_Object rest;
|
|
2272 Lisp_Object retlist = Qnil;
|
|
2273 struct gcpro gcpro1, gcpro2;
|
|
2274
|
|
2275 LIST_LOOP (rest, Vconsole_type_list)
|
|
2276 {
|
|
2277 Lisp_Object contype = XCAR (rest);
|
|
2278 if (!NILP (memq_no_quit (contype, tag_set)))
|
|
2279 possible_console_types = Fcons (contype, possible_console_types);
|
|
2280 }
|
|
2281
|
|
2282 if (XINT (Flength (possible_console_types)) > 1)
|
|
2283 /* two conflicting console types specified */
|
|
2284 return Qnil;
|
|
2285
|
|
2286 if (NILP (possible_console_types))
|
|
2287 possible_console_types = Vconsole_type_list;
|
|
2288
|
|
2289 GCPRO2 (retlist, possible_console_types);
|
|
2290
|
|
2291 LIST_LOOP (rest, possible_console_types)
|
|
2292 {
|
|
2293 Lisp_Object contype = XCAR (rest);
|
272
|
2294 Lisp_Object newinst = call_with_suspended_errors
|
74
|
2295 ((lisp_fn_t) normalize_image_instantiator,
|
|
2296 Qnil, Qimage, ERROR_ME_NOT, 3, instantiator, contype,
|
|
2297 make_int (XIMAGE_SPECIFIER_ALLOWED (specifier)));
|
84
|
2298
|
0
|
2299 if (!NILP (newinst))
|
|
2300 {
|
|
2301 Lisp_Object newtag;
|
|
2302 if (NILP (memq_no_quit (contype, tag_set)))
|
|
2303 newtag = Fcons (contype, tag_set);
|
|
2304 else
|
|
2305 newtag = tag_set;
|
|
2306 retlist = Fcons (Fcons (newtag, newinst), retlist);
|
|
2307 }
|
|
2308 }
|
|
2309
|
|
2310 UNGCPRO;
|
|
2311
|
|
2312 return retlist;
|
|
2313 }
|
|
2314
|
20
|
2315 DEFUN ("image-specifier-p", Fimage_specifier_p, 1, 1, 0, /*
|
0
|
2316 Return non-nil if OBJECT is an image specifier.
|
|
2317
|
|
2318 An image specifier is used for images (pixmaps and the like). It is used
|
|
2319 to describe the actual image in a glyph. It is instanced as an image-
|
|
2320 instance.
|
|
2321
|
|
2322 Image instantiators come in many formats: `xbm', `xpm', `gif', `jpeg',
|
|
2323 etc. This describes the format of the data describing the image. The
|
|
2324 resulting image instances also come in many types -- `mono-pixmap',
|
|
2325 `color-pixmap', `text', `pointer', etc. This refers to the behavior of
|
|
2326 the image and the sorts of places it can appear. (For example, a
|
|
2327 color-pixmap image has fixed colors specified for it, while a
|
185
|
2328 mono-pixmap image comes in two unspecified shades "foreground" and
|
|
2329 "background" that are determined from the face of the glyph or
|
0
|
2330 surrounding text; a text image appears as a string of text and has an
|
|
2331 unspecified foreground, background, and font; a pointer image behaves
|
|
2332 like a mono-pixmap image but can only be used as a mouse pointer
|
|
2333 \[mono-pixmap images cannot be used as mouse pointers]; etc.) It is
|
|
2334 important to keep the distinction between image instantiator format and
|
|
2335 image instance type in mind. Typically, a given image instantiator
|
|
2336 format can result in many different image instance types (for example,
|
|
2337 `xpm' can be instanced as `color-pixmap', `mono-pixmap', or `pointer';
|
|
2338 whereas `cursor-font' can be instanced only as `pointer'), and a
|
|
2339 particular image instance type can be generated by many different
|
|
2340 image instantiator formats (e.g. `color-pixmap' can be generated by `xpm',
|
|
2341 `gif', `jpeg', etc.).
|
|
2342
|
|
2343 See `make-image-instance' for a more detailed discussion of image
|
|
2344 instance types.
|
|
2345
|
|
2346 An image instantiator should be a string or a vector of the form
|
|
2347
|
|
2348 [FORMAT :KEYWORD VALUE ...]
|
|
2349
|
|
2350 i.e. a format symbol followed by zero or more alternating keyword-value
|
|
2351 pairs. FORMAT should be one of
|
|
2352
|
|
2353 'nothing
|
|
2354 (Don't display anything; no keywords are valid for this.
|
|
2355 Can only be instanced as `nothing'.)
|
|
2356 'string
|
|
2357 (Display this image as a text string. Can only be instanced
|
|
2358 as `text', although support for instancing as `mono-pixmap'
|
|
2359 should be added.)
|
|
2360 'formatted-string
|
|
2361 (Display this image as a text string, with replaceable fields;
|
|
2362 not currently implemented.)
|
|
2363 'xbm
|
|
2364 (An X bitmap; only if X support was compiled into this XEmacs.
|
|
2365 Can be instanced as `mono-pixmap', `color-pixmap', or `pointer'.)
|
|
2366 'xpm
|
|
2367 (An XPM pixmap; only if XPM support was compiled into this XEmacs.
|
|
2368 Can be instanced as `color-pixmap', `mono-pixmap', or `pointer'.)
|
|
2369 'xface
|
|
2370 (An X-Face bitmap, used to encode people's faces in e-mail messages;
|
|
2371 only if X-Face support was compiled into this XEmacs. Can be
|
|
2372 instanced as `mono-pixmap', `color-pixmap', or `pointer'.)
|
|
2373 'gif
|
|
2374 (A GIF87 or GIF89 image; only if GIF support was compiled into this
|
308
|
2375 XEmacs. NOTE: only the first frame of animated gifs will be displayed.
|
|
2376 Can be instanced as `color-pixmap'.)
|
0
|
2377 'jpeg
|
|
2378 (A JPEG image; only if JPEG support was compiled into this XEmacs.
|
|
2379 Can be instanced as `color-pixmap'.)
|
|
2380 'png
|
308
|
2381 (A PNG image; only if PNG support was compiled into this XEmacs.
|
0
|
2382 Can be instanced as `color-pixmap'.)
|
|
2383 'tiff
|
308
|
2384 (A TIFF image; only if TIFF support was compiled into this XEmacs.
|
|
2385 Can be instanced as `color-pixmap'.)
|
0
|
2386 'cursor-font
|
185
|
2387 (One of the standard cursor-font names, such as "watch" or
|
|
2388 "right_ptr" under X. Under X, this is, more specifically, any
|
0
|
2389 of the standard cursor names from appendix B of the Xlib manual
|
|
2390 [also known as the file <X11/cursorfont.h>] minus the XC_ prefix.
|
|
2391 On other window systems, the valid names will be specific to the
|
|
2392 type of window system. Can only be instanced as `pointer'.)
|
|
2393 'font
|
|
2394 (A glyph from a font; i.e. the name of a font, and glyph index into it
|
185
|
2395 of the form "FONT fontname index [[mask-font] mask-index]".
|
0
|
2396 Currently can only be instanced as `pointer', although this should
|
|
2397 probably be fixed.)
|
|
2398 'subwindow
|
|
2399 (An embedded X window; not currently implemented.)
|
122
|
2400 'autodetect
|
0
|
2401 (XEmacs tries to guess what format the data is in. If X support
|
|
2402 exists, the data string will be checked to see if it names a filename.
|
|
2403 If so, and this filename contains XBM or XPM data, the appropriate
|
|
2404 sort of pixmap or pointer will be created. [This includes picking up
|
|
2405 any specified hotspot or associated mask file.] Otherwise, if `pointer'
|
|
2406 is one of the allowable image-instance types and the string names a
|
|
2407 valid cursor-font name, the image will be created as a pointer.
|
|
2408 Otherwise, the image will be displayed as text. If no X support
|
|
2409 exists, the image will always be displayed as text.)
|
|
2410 'inherit
|
|
2411 Inherit from the background-pixmap property of a face.
|
|
2412
|
|
2413 The valid keywords are:
|
|
2414
|
|
2415 :data
|
|
2416 (Inline data. For most formats above, this should be a string. For
|
|
2417 XBM images, this should be a list of three elements: width, height, and
|
|
2418 a string of bit data. This keyword is not valid for instantiator
|
|
2419 formats `nothing' and `inherit'.)
|
|
2420 :file
|
|
2421 (Data is contained in a file. The value is the name of this file.
|
|
2422 If both :data and :file are specified, the image is created from
|
|
2423 what is specified in :data and the string in :file becomes the
|
|
2424 value of the `image-instance-file-name' function when applied to
|
|
2425 the resulting image-instance. This keyword is not valid for
|
|
2426 instantiator formats `nothing', `string', `formatted-string',
|
122
|
2427 `cursor-font', `font', `autodetect', and `inherit'.)
|
0
|
2428 :foreground
|
|
2429 :background
|
|
2430 (For `xbm', `xface', `cursor-font', and `font'. These keywords
|
|
2431 allow you to explicitly specify foreground and background colors.
|
|
2432 The argument should be anything acceptable to `make-color-instance'.
|
|
2433 This will cause what would be a `mono-pixmap' to instead be colorized
|
|
2434 as a two-color color-pixmap, and specifies the foreground and/or
|
|
2435 background colors for a pointer instead of black and white.)
|
|
2436 :mask-data
|
|
2437 (For `xbm' and `xface'. This specifies a mask to be used with the
|
|
2438 bitmap. The format is a list of width, height, and bits, like for
|
|
2439 :data.)
|
|
2440 :mask-file
|
|
2441 (For `xbm' and `xface'. This specifies a file containing the mask data.
|
|
2442 If neither a mask file nor inline mask data is given for an XBM image,
|
|
2443 and the XBM image comes from a file, XEmacs will look for a mask file
|
185
|
2444 with the same name as the image file but with "Mask" or "msk"
|
|
2445 appended. For example, if you specify the XBM file "left_ptr"
|
|
2446 [usually located in "/usr/include/X11/bitmaps"], the associated
|
|
2447 mask file "left_ptrmsk" will automatically be picked up.)
|
0
|
2448 :hotspot-x
|
|
2449 :hotspot-y
|
|
2450 (For `xbm' and `xface'. These keywords specify a hotspot if the image
|
|
2451 is instantiated as a `pointer'. Note that if the XBM image file
|
|
2452 specifies a hotspot, it will automatically be picked up if no
|
|
2453 explicit hotspot is given.)
|
|
2454 :color-symbols
|
|
2455 (Only for `xpm'. This specifies an alist that maps strings
|
|
2456 that specify symbolic color names to the actual color to be used
|
|
2457 for that symbolic color (in the form of a string or a color-specifier
|
|
2458 object). If this is not specified, the contents of `xpm-color-symbols'
|
|
2459 are used to generate the alist.)
|
|
2460 :face
|
|
2461 (Only for `inherit'. This specifies the face to inherit from.)
|
|
2462
|
|
2463 If instead of a vector, the instantiator is a string, it will be
|
|
2464 converted into a vector by looking it up according to the specs in the
|
|
2465 `console-type-image-conversion-list' (q.v.) for the console type of
|
|
2466 the domain (usually a window; sometimes a frame or device) over which
|
|
2467 the image is being instantiated.
|
|
2468
|
|
2469 If the instantiator specifies data from a file, the data will be read
|
|
2470 in at the time that the instantiator is added to the image (which may
|
|
2471 be well before when the image is actually displayed), and the
|
|
2472 instantiator will be converted into one of the inline-data forms, with
|
|
2473 the filename retained using a :file keyword. This implies that the
|
|
2474 file must exist when the instantiator is added to the image, but does
|
|
2475 not need to exist at any other time (e.g. it may safely be a temporary
|
|
2476 file).
|
20
|
2477 */
|
|
2478 (object))
|
0
|
2479 {
|
173
|
2480 return IMAGE_SPECIFIERP (object) ? Qt : Qnil;
|
0
|
2481 }
|
|
2482
|
|
2483
|
|
2484 /****************************************************************************
|
|
2485 * Glyph Object *
|
|
2486 ****************************************************************************/
|
|
2487
|
|
2488 static Lisp_Object
|
|
2489 mark_glyph (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
2490 {
|
272
|
2491 struct Lisp_Glyph *glyph = XGLYPH (obj);
|
0
|
2492
|
|
2493 ((markobj) (glyph->image));
|
|
2494 ((markobj) (glyph->contrib_p));
|
|
2495 ((markobj) (glyph->baseline));
|
|
2496 ((markobj) (glyph->face));
|
|
2497
|
173
|
2498 return glyph->plist;
|
0
|
2499 }
|
|
2500
|
|
2501 static void
|
|
2502 print_glyph (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
2503 {
|
|
2504 struct Lisp_Glyph *glyph = XGLYPH (obj);
|
|
2505 char buf[20];
|
|
2506
|
|
2507 if (print_readably)
|
|
2508 error ("printing unreadable object #<glyph 0x%x>", glyph->header.uid);
|
|
2509
|
|
2510 write_c_string ("#<glyph (", printcharfun);
|
|
2511 print_internal (Fglyph_type (obj), printcharfun, 0);
|
|
2512 write_c_string (") ", printcharfun);
|
|
2513 print_internal (glyph->image, printcharfun, 1);
|
|
2514 sprintf (buf, "0x%x>", glyph->header.uid);
|
|
2515 write_c_string (buf, printcharfun);
|
|
2516 }
|
|
2517
|
|
2518 /* Glyphs are equal if all of their display attributes are equal. We
|
|
2519 don't compare names or doc-strings, because that would make equal
|
|
2520 be eq.
|
|
2521
|
|
2522 This isn't concerned with "unspecified" attributes, that's what
|
|
2523 #'glyph-differs-from-default-p is for. */
|
|
2524 static int
|
|
2525 glyph_equal (Lisp_Object o1, Lisp_Object o2, int depth)
|
|
2526 {
|
|
2527 struct Lisp_Glyph *g1 = XGLYPH (o1);
|
|
2528 struct Lisp_Glyph *g2 = XGLYPH (o2);
|
|
2529
|
|
2530 depth++;
|
|
2531
|
185
|
2532 return (internal_equal (g1->image, g2->image, depth) &&
|
|
2533 internal_equal (g1->contrib_p, g2->contrib_p, depth) &&
|
|
2534 internal_equal (g1->baseline, g2->baseline, depth) &&
|
|
2535 internal_equal (g1->face, g2->face, depth) &&
|
|
2536 !plists_differ (g1->plist, g2->plist, 0, 0, depth + 1));
|
0
|
2537 }
|
|
2538
|
|
2539 static unsigned long
|
|
2540 glyph_hash (Lisp_Object obj, int depth)
|
|
2541 {
|
|
2542 depth++;
|
|
2543
|
|
2544 /* No need to hash all of the elements; that would take too long.
|
|
2545 Just hash the most common ones. */
|
185
|
2546 return HASH2 (internal_hash (XGLYPH (obj)->image, depth),
|
|
2547 internal_hash (XGLYPH (obj)->face, depth));
|
0
|
2548 }
|
|
2549
|
|
2550 static Lisp_Object
|
|
2551 glyph_getprop (Lisp_Object obj, Lisp_Object prop)
|
|
2552 {
|
|
2553 struct Lisp_Glyph *g = XGLYPH (obj);
|
272
|
2554
|
185
|
2555 if (EQ (prop, Qimage)) return g->image;
|
|
2556 if (EQ (prop, Qcontrib_p)) return g->contrib_p;
|
|
2557 if (EQ (prop, Qbaseline)) return g->baseline;
|
|
2558 if (EQ (prop, Qface)) return g->face;
|
0
|
2559
|
|
2560 return external_plist_get (&g->plist, prop, 0, ERROR_ME);
|
|
2561 }
|
|
2562
|
|
2563 static int
|
|
2564 glyph_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value)
|
|
2565 {
|
185
|
2566 if ((EQ (prop, Qimage)) ||
|
|
2567 (EQ (prop, Qcontrib_p)) ||
|
|
2568 (EQ (prop, Qbaseline)))
|
|
2569 return 0;
|
0
|
2570
|
|
2571 if (EQ (prop, Qface))
|
|
2572 {
|
185
|
2573 XGLYPH (obj)->face = Fget_face (value);
|
0
|
2574 return 1;
|
|
2575 }
|
|
2576
|
185
|
2577 external_plist_put (&XGLYPH (obj)->plist, prop, value, 0, ERROR_ME);
|
0
|
2578 return 1;
|
|
2579 }
|
|
2580
|
|
2581 static int
|
|
2582 glyph_remprop (Lisp_Object obj, Lisp_Object prop)
|
|
2583 {
|
185
|
2584 if ((EQ (prop, Qimage)) ||
|
|
2585 (EQ (prop, Qcontrib_p)) ||
|
|
2586 (EQ (prop, Qbaseline)))
|
|
2587 return -1;
|
0
|
2588
|
|
2589 if (EQ (prop, Qface))
|
|
2590 {
|
185
|
2591 XGLYPH (obj)->face = Qnil;
|
0
|
2592 return 1;
|
|
2593 }
|
|
2594
|
185
|
2595 return external_remprop (&XGLYPH (obj)->plist, prop, 0, ERROR_ME);
|
0
|
2596 }
|
|
2597
|
|
2598 static Lisp_Object
|
|
2599 glyph_plist (Lisp_Object obj)
|
|
2600 {
|
272
|
2601 struct Lisp_Glyph *glyph = XGLYPH (obj);
|
|
2602 Lisp_Object result = glyph->plist;
|
|
2603
|
|
2604 result = cons3 (Qface, glyph->face, result);
|
|
2605 result = cons3 (Qbaseline, glyph->baseline, result);
|
|
2606 result = cons3 (Qcontrib_p, glyph->contrib_p, result);
|
|
2607 result = cons3 (Qimage, glyph->image, result);
|
|
2608
|
|
2609 return result;
|
0
|
2610 }
|
|
2611
|
272
|
2612 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("glyph", glyph,
|
|
2613 mark_glyph, print_glyph, 0,
|
|
2614 glyph_equal, glyph_hash,
|
|
2615 glyph_getprop, glyph_putprop,
|
|
2616 glyph_remprop, glyph_plist,
|
|
2617 struct Lisp_Glyph);
|
|
2618
|
0
|
2619 Lisp_Object
|
|
2620 allocate_glyph (enum glyph_type type,
|
|
2621 void (*after_change) (Lisp_Object glyph, Lisp_Object property,
|
|
2622 Lisp_Object locale))
|
|
2623 {
|
249
|
2624 /* This function can GC */
|
0
|
2625 Lisp_Object obj = Qnil;
|
|
2626 struct Lisp_Glyph *g =
|
185
|
2627 alloc_lcrecord_type (struct Lisp_Glyph, lrecord_glyph);
|
173
|
2628
|
0
|
2629 g->type = type;
|
249
|
2630 g->image = Fmake_specifier (Qimage); /* This function can GC */
|
0
|
2631 switch (g->type)
|
|
2632 {
|
|
2633 case GLYPH_BUFFER:
|
|
2634 XIMAGE_SPECIFIER_ALLOWED (g->image) =
|
|
2635 IMAGE_NOTHING_MASK | IMAGE_TEXT_MASK | IMAGE_MONO_PIXMAP_MASK |
|
|
2636 IMAGE_COLOR_PIXMAP_MASK | IMAGE_SUBWINDOW_MASK;
|
|
2637 break;
|
|
2638 case GLYPH_POINTER:
|
|
2639 XIMAGE_SPECIFIER_ALLOWED (g->image) =
|
|
2640 IMAGE_NOTHING_MASK | IMAGE_POINTER_MASK;
|
|
2641 break;
|
|
2642 case GLYPH_ICON:
|
|
2643 XIMAGE_SPECIFIER_ALLOWED (g->image) =
|
|
2644 IMAGE_NOTHING_MASK | IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK;
|
|
2645 break;
|
|
2646 default:
|
|
2647 abort ();
|
|
2648 }
|
|
2649
|
249
|
2650 /* I think Fmake_specifier can GC. I think set_specifier_fallback can GC. */
|
|
2651 /* We're getting enough reports of odd behavior in this area it seems */
|
|
2652 /* best to GCPRO everything. */
|
|
2653 {
|
|
2654 Lisp_Object tem1 = list1 (Fcons (Qnil, Vthe_nothing_vector));
|
|
2655 Lisp_Object tem2 = list1 (Fcons (Qnil, Qt));
|
|
2656 Lisp_Object tem3 = list1 (Fcons (Qnil, Qnil));
|
|
2657 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
|
|
2658
|
|
2659 GCPRO4 (obj, tem1, tem2, tem3);
|
|
2660
|
|
2661 set_specifier_fallback (g->image, tem1);
|
|
2662 g->contrib_p = Fmake_specifier (Qboolean);
|
|
2663 set_specifier_fallback (g->contrib_p, tem2);
|
|
2664 /* #### should have a specifier for the following */
|
|
2665 g->baseline = Fmake_specifier (Qgeneric);
|
|
2666 set_specifier_fallback (g->baseline, tem3);
|
|
2667 g->face = Qnil;
|
|
2668 g->plist = Qnil;
|
|
2669 g->after_change = after_change;
|
|
2670 XSETGLYPH (obj, g);
|
|
2671
|
|
2672 set_image_attached_to (g->image, obj, Qimage);
|
|
2673 UNGCPRO;
|
|
2674 }
|
0
|
2675
|
|
2676 return obj;
|
|
2677 }
|
|
2678
|
|
2679 static enum glyph_type
|
|
2680 decode_glyph_type (Lisp_Object type, Error_behavior errb)
|
|
2681 {
|
|
2682 if (NILP (type))
|
|
2683 return GLYPH_BUFFER;
|
|
2684
|
|
2685 if (ERRB_EQ (errb, ERROR_ME))
|
|
2686 CHECK_SYMBOL (type);
|
|
2687
|
185
|
2688 if (EQ (type, Qbuffer)) return GLYPH_BUFFER;
|
|
2689 if (EQ (type, Qpointer)) return GLYPH_POINTER;
|
|
2690 if (EQ (type, Qicon)) return GLYPH_ICON;
|
0
|
2691
|
|
2692 maybe_signal_simple_error ("Invalid glyph type", type, Qimage, errb);
|
185
|
2693
|
0
|
2694 return GLYPH_UNKNOWN;
|
|
2695 }
|
|
2696
|
|
2697 static int
|
|
2698 valid_glyph_type_p (Lisp_Object type)
|
|
2699 {
|
185
|
2700 return !NILP (memq_no_quit (type, Vglyph_type_list));
|
0
|
2701 }
|
|
2702
|
20
|
2703 DEFUN ("valid-glyph-type-p", Fvalid_glyph_type_p, 1, 1, 0, /*
|
0
|
2704 Given a GLYPH-TYPE, return non-nil if it is valid.
|
|
2705 Valid types are `buffer', `pointer', and `icon'.
|
20
|
2706 */
|
|
2707 (glyph_type))
|
0
|
2708 {
|
185
|
2709 return valid_glyph_type_p (glyph_type) ? Qt : Qnil;
|
0
|
2710 }
|
|
2711
|
20
|
2712 DEFUN ("glyph-type-list", Fglyph_type_list, 0, 0, 0, /*
|
0
|
2713 Return a list of valid glyph types.
|
20
|
2714 */
|
|
2715 ())
|
0
|
2716 {
|
|
2717 return Fcopy_sequence (Vglyph_type_list);
|
|
2718 }
|
|
2719
|
20
|
2720 DEFUN ("make-glyph-internal", Fmake_glyph_internal, 0, 1, 0, /*
|
272
|
2721 Create and return a new uninitialized glyph or type TYPE.
|
0
|
2722
|
|
2723 TYPE specifies the type of the glyph; this should be one of `buffer',
|
|
2724 `pointer', or `icon', and defaults to `buffer'. The type of the glyph
|
|
2725 specifies in which contexts the glyph can be used, and controls the
|
|
2726 allowable image types into which the glyph's image can be
|
|
2727 instantiated.
|
|
2728
|
|
2729 `buffer' glyphs can be used as the begin-glyph or end-glyph of an
|
|
2730 extent, in the modeline, and in the toolbar. Their image can be
|
|
2731 instantiated as `nothing', `mono-pixmap', `color-pixmap', `text',
|
|
2732 and `subwindow'.
|
|
2733
|
|
2734 `pointer' glyphs can be used to specify the mouse pointer. Their
|
|
2735 image can be instantiated as `pointer'.
|
|
2736
|
|
2737 `icon' glyphs can be used to specify the icon used when a frame is
|
|
2738 iconified. Their image can be instantiated as `mono-pixmap' and
|
|
2739 `color-pixmap'.
|
20
|
2740 */
|
|
2741 (type))
|
0
|
2742 {
|
|
2743 enum glyph_type typeval = decode_glyph_type (type, ERROR_ME);
|
|
2744 return allocate_glyph (typeval, 0);
|
|
2745 }
|
|
2746
|
20
|
2747 DEFUN ("glyphp", Fglyphp, 1, 1, 0, /*
|
0
|
2748 Return non-nil if OBJECT is a glyph.
|
|
2749
|
|
2750 A glyph is an object used for pixmaps and the like. It is used
|
|
2751 in begin-glyphs and end-glyphs attached to extents, in marginal and textual
|
|
2752 annotations, in overlay arrows (overlay-arrow-* variables), in toolbar
|
|
2753 buttons, and the like. Its image is described using an image specifier --
|
|
2754 see `image-specifier-p'.
|
20
|
2755 */
|
|
2756 (object))
|
0
|
2757 {
|
|
2758 return GLYPHP (object) ? Qt : Qnil;
|
|
2759 }
|
|
2760
|
20
|
2761 DEFUN ("glyph-type", Fglyph_type, 1, 1, 0, /*
|
0
|
2762 Return the type of the given glyph.
|
|
2763 The return value will be one of 'buffer, 'pointer, or 'icon.
|
20
|
2764 */
|
|
2765 (glyph))
|
0
|
2766 {
|
|
2767 CHECK_GLYPH (glyph);
|
|
2768 switch (XGLYPH_TYPE (glyph))
|
|
2769 {
|
185
|
2770 case GLYPH_BUFFER: return Qbuffer;
|
|
2771 case GLYPH_POINTER: return Qpointer;
|
|
2772 case GLYPH_ICON: return Qicon;
|
0
|
2773 default:
|
|
2774 abort ();
|
185
|
2775 return Qnil; /* not reached */
|
0
|
2776 }
|
|
2777 }
|
|
2778
|
|
2779 /*****************************************************************************
|
|
2780 glyph_width
|
|
2781
|
|
2782 Return the width of the given GLYPH on the given WINDOW. If the
|
|
2783 instance is a string then the width is calculated using the font of
|
|
2784 the given FACE, unless a face is defined by the glyph itself.
|
|
2785 ****************************************************************************/
|
|
2786 unsigned short
|
|
2787 glyph_width (Lisp_Object glyph, Lisp_Object frame_face,
|
|
2788 face_index window_findex, Lisp_Object window)
|
|
2789 {
|
|
2790 Lisp_Object instance;
|
|
2791 Lisp_Object frame = XWINDOW (window)->frame;
|
|
2792
|
|
2793 /* #### We somehow need to distinguish between the user causing this
|
|
2794 error condition and a bug causing it. */
|
|
2795 if (!GLYPHP (glyph))
|
|
2796 return 0;
|
|
2797 else
|
|
2798 instance = glyph_image_instance (glyph, window, ERROR_ME_NOT, 1);
|
|
2799
|
|
2800 if (!IMAGE_INSTANCEP (instance))
|
|
2801 return 0;
|
|
2802
|
|
2803 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
2804 {
|
|
2805 case IMAGE_TEXT:
|
|
2806 {
|
|
2807 Lisp_Object str = XIMAGE_INSTANCE_TEXT_STRING (instance);
|
|
2808 Lisp_Object private_face = XGLYPH_FACE(glyph);
|
|
2809
|
|
2810 if (!NILP (private_face))
|
173
|
2811 return redisplay_frame_text_width_string (XFRAME (frame),
|
|
2812 private_face,
|
|
2813 0, str, 0, -1);
|
0
|
2814 else
|
|
2815 if (!NILP (frame_face))
|
173
|
2816 return redisplay_frame_text_width_string (XFRAME (frame),
|
|
2817 frame_face,
|
|
2818 0, str, 0, -1);
|
0
|
2819 else
|
173
|
2820 return redisplay_text_width_string (XWINDOW (window),
|
|
2821 window_findex,
|
|
2822 0, str, 0, -1);
|
0
|
2823 }
|
|
2824
|
|
2825 case IMAGE_MONO_PIXMAP:
|
|
2826 case IMAGE_COLOR_PIXMAP:
|
|
2827 case IMAGE_POINTER:
|
|
2828 return XIMAGE_INSTANCE_PIXMAP_WIDTH (instance);
|
|
2829
|
|
2830 case IMAGE_NOTHING:
|
|
2831 return 0;
|
|
2832
|
|
2833 case IMAGE_SUBWINDOW:
|
|
2834 /* #### implement me */
|
|
2835 return 0;
|
|
2836
|
|
2837 default:
|
|
2838 abort ();
|
|
2839 return 0;
|
|
2840 }
|
|
2841 }
|
|
2842
|
20
|
2843 DEFUN ("glyph-width", Fglyph_width, 1, 2, 0, /*
|
0
|
2844 Return the width of GLYPH on WINDOW.
|
|
2845 This may not be exact as it does not take into account all of the context
|
|
2846 that redisplay will.
|
20
|
2847 */
|
|
2848 (glyph, window))
|
0
|
2849 {
|
|
2850 XSETWINDOW (window, decode_window (window));
|
|
2851 CHECK_GLYPH (glyph);
|
|
2852
|
173
|
2853 return make_int (glyph_width (glyph, Qnil, DEFAULT_INDEX, window));
|
0
|
2854 }
|
|
2855
|
|
2856 #define RETURN_ASCENT 0
|
|
2857 #define RETURN_DESCENT 1
|
|
2858 #define RETURN_HEIGHT 2
|
|
2859
|
|
2860 Lisp_Object
|
|
2861 glyph_image_instance (Lisp_Object glyph, Lisp_Object domain,
|
|
2862 Error_behavior errb, int no_quit)
|
|
2863 {
|
|
2864 Lisp_Object specifier = GLYPH_IMAGE (XGLYPH (glyph));
|
|
2865
|
|
2866 /* This can never return Qunbound. All glyphs have 'nothing as
|
|
2867 a fallback. */
|
|
2868 return specifier_instance (specifier, Qunbound, domain, errb, no_quit, 0,
|
|
2869 Qzero);
|
|
2870 }
|
|
2871
|
|
2872 static unsigned short
|
|
2873 glyph_height_internal (Lisp_Object glyph, Lisp_Object frame_face,
|
|
2874 face_index window_findex, Lisp_Object window,
|
|
2875 int function)
|
|
2876 {
|
|
2877 Lisp_Object instance;
|
|
2878 Lisp_Object frame = XWINDOW (window)->frame;
|
|
2879
|
|
2880 if (!GLYPHP (glyph))
|
|
2881 return 0;
|
|
2882 else
|
|
2883 instance = glyph_image_instance (glyph, window, ERROR_ME_NOT, 1);
|
|
2884
|
|
2885 if (!IMAGE_INSTANCEP (instance))
|
|
2886 return 0;
|
|
2887
|
|
2888 switch (XIMAGE_INSTANCE_TYPE (instance))
|
|
2889 {
|
|
2890 case IMAGE_TEXT:
|
|
2891 {
|
|
2892 struct font_metric_info fm;
|
|
2893 Lisp_Object string = XIMAGE_INSTANCE_TEXT_STRING (instance);
|
|
2894 unsigned char charsets[NUM_LEADING_BYTES];
|
|
2895 struct face_cachel frame_cachel;
|
|
2896 struct face_cachel *cachel;
|
|
2897
|
|
2898 find_charsets_in_bufbyte_string (charsets,
|
82
|
2899 XSTRING_DATA (string),
|
14
|
2900 XSTRING_LENGTH (string));
|
0
|
2901
|
|
2902 if (!NILP (frame_face))
|
|
2903 {
|
|
2904 reset_face_cachel (&frame_cachel);
|
|
2905 update_face_cachel_data (&frame_cachel, frame, frame_face);
|
|
2906 cachel = &frame_cachel;
|
|
2907 }
|
|
2908 else
|
|
2909 cachel = WINDOW_FACE_CACHEL (XWINDOW (window), window_findex);
|
|
2910 ensure_face_cachel_complete (cachel, window, charsets);
|
|
2911
|
|
2912 face_cachel_charset_font_metric_info (cachel, charsets, &fm);
|
173
|
2913
|
185
|
2914 switch (function)
|
|
2915 {
|
|
2916 case RETURN_ASCENT: return fm.ascent;
|
|
2917 case RETURN_DESCENT: return fm.descent;
|
|
2918 case RETURN_HEIGHT: return fm.ascent + fm.descent;
|
|
2919 default:
|
|
2920 abort ();
|
|
2921 return 0; /* not reached */
|
|
2922 }
|
0
|
2923 }
|
|
2924
|
|
2925 case IMAGE_MONO_PIXMAP:
|
|
2926 case IMAGE_COLOR_PIXMAP:
|
|
2927 case IMAGE_POINTER:
|
|
2928 /* #### Ugh ugh ugh -- temporary crap */
|
|
2929 if (function == RETURN_ASCENT || function == RETURN_HEIGHT)
|
|
2930 return XIMAGE_INSTANCE_PIXMAP_HEIGHT (instance);
|
|
2931 else
|
|
2932 return 0;
|
|
2933
|
|
2934 case IMAGE_NOTHING:
|
|
2935 return 0;
|
|
2936
|
|
2937 case IMAGE_SUBWINDOW:
|
|
2938 /* #### implement me */
|
|
2939 return 0;
|
|
2940
|
|
2941 default:
|
|
2942 abort ();
|
|
2943 return 0;
|
|
2944 }
|
|
2945 }
|
|
2946
|
|
2947 unsigned short
|
|
2948 glyph_ascent (Lisp_Object glyph, Lisp_Object frame_face,
|
|
2949 face_index window_findex, Lisp_Object window)
|
|
2950 {
|
|
2951 return glyph_height_internal (glyph, frame_face, window_findex, window,
|
|
2952 RETURN_ASCENT);
|
|
2953 }
|
|
2954
|
|
2955 unsigned short
|
|
2956 glyph_descent (Lisp_Object glyph, Lisp_Object frame_face,
|
|
2957 face_index window_findex, Lisp_Object window)
|
|
2958 {
|
|
2959 return glyph_height_internal (glyph, frame_face, window_findex, window,
|
|
2960 RETURN_DESCENT);
|
|
2961 }
|
|
2962
|
|
2963 /* strictly a convenience function. */
|
|
2964 unsigned short
|
|
2965 glyph_height (Lisp_Object glyph, Lisp_Object frame_face,
|
|
2966 face_index window_findex, Lisp_Object window)
|
|
2967 {
|
|
2968 return glyph_height_internal (glyph, frame_face, window_findex, window,
|
|
2969 RETURN_HEIGHT);
|
|
2970 }
|
|
2971
|
20
|
2972 DEFUN ("glyph-ascent", Fglyph_ascent, 1, 2, 0, /*
|
0
|
2973 Return the ascent value of GLYPH on WINDOW.
|
|
2974 This may not be exact as it does not take into account all of the context
|
|
2975 that redisplay will.
|
20
|
2976 */
|
|
2977 (glyph, window))
|
0
|
2978 {
|
|
2979 XSETWINDOW (window, decode_window (window));
|
|
2980 CHECK_GLYPH (glyph);
|
|
2981
|
173
|
2982 return make_int (glyph_ascent (glyph, Qnil, DEFAULT_INDEX, window));
|
0
|
2983 }
|
|
2984
|
20
|
2985 DEFUN ("glyph-descent", Fglyph_descent, 1, 2, 0, /*
|
0
|
2986 Return the descent value of GLYPH on WINDOW.
|
|
2987 This may not be exact as it does not take into account all of the context
|
|
2988 that redisplay will.
|
20
|
2989 */
|
|
2990 (glyph, window))
|
0
|
2991 {
|
|
2992 XSETWINDOW (window, decode_window (window));
|
|
2993 CHECK_GLYPH (glyph);
|
|
2994
|
173
|
2995 return make_int (glyph_descent (glyph, Qnil, DEFAULT_INDEX, window));
|
0
|
2996 }
|
|
2997
|
|
2998 /* This is redundant but I bet a lot of people expect it to exist. */
|
20
|
2999 DEFUN ("glyph-height", Fglyph_height, 1, 2, 0, /*
|
0
|
3000 Return the height of GLYPH on WINDOW.
|
|
3001 This may not be exact as it does not take into account all of the context
|
|
3002 that redisplay will.
|
20
|
3003 */
|
|
3004 (glyph, window))
|
0
|
3005 {
|
|
3006 XSETWINDOW (window, decode_window (window));
|
|
3007 CHECK_GLYPH (glyph);
|
|
3008
|
173
|
3009 return make_int (glyph_height (glyph, Qnil, DEFAULT_INDEX, window));
|
0
|
3010 }
|
|
3011
|
|
3012 #undef RETURN_ASCENT
|
|
3013 #undef RETURN_DESCENT
|
|
3014 #undef RETURN_HEIGHT
|
|
3015
|
|
3016 /* #### do we need to cache this info to speed things up? */
|
|
3017
|
|
3018 Lisp_Object
|
|
3019 glyph_baseline (Lisp_Object glyph, Lisp_Object domain)
|
|
3020 {
|
|
3021 if (!GLYPHP (glyph))
|
|
3022 return Qnil;
|
|
3023 else
|
|
3024 {
|
|
3025 Lisp_Object retval =
|
|
3026 specifier_instance_no_quit (GLYPH_BASELINE (XGLYPH (glyph)),
|
|
3027 /* #### look into ERROR_ME_NOT */
|
|
3028 Qunbound, domain, ERROR_ME_NOT,
|
|
3029 0, Qzero);
|
|
3030 if (!NILP (retval) && !INTP (retval))
|
|
3031 retval = Qnil;
|
|
3032 else if (INTP (retval))
|
|
3033 {
|
|
3034 if (XINT (retval) < 0)
|
|
3035 retval = Qzero;
|
|
3036 if (XINT (retval) > 100)
|
|
3037 retval = make_int (100);
|
|
3038 }
|
|
3039 return retval;
|
|
3040 }
|
|
3041 }
|
|
3042
|
|
3043 Lisp_Object
|
|
3044 glyph_face (Lisp_Object glyph, Lisp_Object domain)
|
|
3045 {
|
|
3046 /* #### Domain parameter not currently used but it will be */
|
185
|
3047 return GLYPHP (glyph) ? GLYPH_FACE (XGLYPH (glyph)) : Qnil;
|
0
|
3048 }
|
|
3049
|
|
3050 int
|
|
3051 glyph_contrib_p (Lisp_Object glyph, Lisp_Object domain)
|
|
3052 {
|
|
3053 if (!GLYPHP (glyph))
|
|
3054 return 0;
|
|
3055 else
|
173
|
3056 return !NILP (specifier_instance_no_quit
|
|
3057 (GLYPH_CONTRIB_P (XGLYPH (glyph)), Qunbound, domain,
|
|
3058 /* #### look into ERROR_ME_NOT */
|
|
3059 ERROR_ME_NOT, 0, Qzero));
|
0
|
3060 }
|
|
3061
|
|
3062 static void
|
|
3063 glyph_property_was_changed (Lisp_Object glyph, Lisp_Object property,
|
|
3064 Lisp_Object locale)
|
|
3065 {
|
|
3066 if (XGLYPH (glyph)->after_change)
|
|
3067 (XGLYPH (glyph)->after_change) (glyph, property, locale);
|
|
3068 }
|
|
3069
|
|
3070
|
|
3071 /*****************************************************************************
|
|
3072 * glyph cachel functions *
|
|
3073 *****************************************************************************/
|
|
3074
|
|
3075 /*
|
|
3076 #### All of this is 95% copied from face cachels.
|
|
3077 Consider consolidating.
|
|
3078 #### We need to add a dirty flag to the glyphs.
|
|
3079 */
|
|
3080
|
|
3081 void
|
|
3082 mark_glyph_cachels (glyph_cachel_dynarr *elements,
|
|
3083 void (*markobj) (Lisp_Object))
|
|
3084 {
|
|
3085 int elt;
|
|
3086
|
|
3087 if (!elements)
|
|
3088 return;
|
|
3089
|
|
3090 for (elt = 0; elt < Dynarr_length (elements); elt++)
|
|
3091 {
|
|
3092 struct glyph_cachel *cachel = Dynarr_atp (elements, elt);
|
|
3093 ((markobj) (cachel->glyph));
|
|
3094 }
|
|
3095 }
|
|
3096
|
|
3097 static void
|
|
3098 update_glyph_cachel_data (struct window *w, Lisp_Object glyph,
|
|
3099 struct glyph_cachel *cachel)
|
|
3100 {
|
|
3101 /* #### This should be || !cachel->updated */
|
|
3102 if (NILP (cachel->glyph) || !EQ (cachel->glyph, glyph))
|
|
3103 {
|
272
|
3104 Lisp_Object window;
|
0
|
3105
|
|
3106 XSETWINDOW (window, w);
|
|
3107
|
|
3108 /* #### This could be sped up if we redid things to grab the glyph
|
|
3109 instantiation and passed it to the size functions. */
|
185
|
3110 cachel->glyph = glyph;
|
|
3111 cachel->width = glyph_width (glyph, Qnil, DEFAULT_INDEX, window);
|
|
3112 cachel->ascent = glyph_ascent (glyph, Qnil, DEFAULT_INDEX, window);
|
|
3113 cachel->descent = glyph_descent (glyph, Qnil, DEFAULT_INDEX, window);
|
0
|
3114 }
|
|
3115
|
|
3116 cachel->updated = 1;
|
|
3117 }
|
|
3118
|
|
3119 static void
|
|
3120 add_glyph_cachel (struct window *w, Lisp_Object glyph)
|
|
3121 {
|
|
3122 struct glyph_cachel new_cachel;
|
|
3123
|
272
|
3124 xzero (new_cachel);
|
0
|
3125 new_cachel.glyph = Qnil;
|
|
3126
|
|
3127 update_glyph_cachel_data (w, glyph, &new_cachel);
|
|
3128 Dynarr_add (w->glyph_cachels, new_cachel);
|
|
3129 }
|
|
3130
|
|
3131 static glyph_index
|
|
3132 get_glyph_cachel_index (struct window *w, Lisp_Object glyph)
|
|
3133 {
|
|
3134 int elt;
|
|
3135
|
|
3136 if (noninteractive)
|
|
3137 return 0;
|
|
3138
|
|
3139 for (elt = 0; elt < Dynarr_length (w->glyph_cachels); elt++)
|
|
3140 {
|
|
3141 struct glyph_cachel *cachel =
|
|
3142 Dynarr_atp (w->glyph_cachels, elt);
|
|
3143
|
|
3144 if (EQ (cachel->glyph, glyph) && !NILP (glyph))
|
|
3145 {
|
|
3146 if (!cachel->updated)
|
|
3147 update_glyph_cachel_data (w, glyph, cachel);
|
|
3148 return elt;
|
|
3149 }
|
|
3150 }
|
|
3151
|
|
3152 /* If we didn't find the glyph, add it and then return its index. */
|
|
3153 add_glyph_cachel (w, glyph);
|
|
3154 return elt;
|
|
3155 }
|
|
3156
|
|
3157 void
|
|
3158 reset_glyph_cachels (struct window *w)
|
|
3159 {
|
|
3160 Dynarr_reset (w->glyph_cachels);
|
|
3161 get_glyph_cachel_index (w, Vcontinuation_glyph);
|
|
3162 get_glyph_cachel_index (w, Vtruncation_glyph);
|
|
3163 get_glyph_cachel_index (w, Vhscroll_glyph);
|
|
3164 get_glyph_cachel_index (w, Vcontrol_arrow_glyph);
|
|
3165 get_glyph_cachel_index (w, Voctal_escape_glyph);
|
|
3166 get_glyph_cachel_index (w, Vinvisible_text_glyph);
|
|
3167 }
|
|
3168
|
|
3169 void
|
|
3170 mark_glyph_cachels_as_not_updated (struct window *w)
|
|
3171 {
|
|
3172 int elt;
|
|
3173
|
|
3174 /* We need to have a dirty flag to tell if the glyph has changed.
|
|
3175 We can check to see if each glyph variable is actually a
|
|
3176 completely different glyph, though. */
|
|
3177 #define FROB(glyph_obj, gindex) \
|
|
3178 update_glyph_cachel_data (w, glyph_obj, \
|
|
3179 Dynarr_atp (w->glyph_cachels, gindex))
|
|
3180
|
|
3181 FROB (Vcontinuation_glyph, CONT_GLYPH_INDEX);
|
|
3182 FROB (Vtruncation_glyph, TRUN_GLYPH_INDEX);
|
|
3183 FROB (Vhscroll_glyph, HSCROLL_GLYPH_INDEX);
|
|
3184 FROB (Vcontrol_arrow_glyph, CONTROL_GLYPH_INDEX);
|
|
3185 FROB (Voctal_escape_glyph, OCT_ESC_GLYPH_INDEX);
|
|
3186 FROB (Vinvisible_text_glyph, INVIS_GLYPH_INDEX);
|
|
3187 #undef FROB
|
|
3188
|
|
3189 for (elt = 0; elt < Dynarr_length (w->glyph_cachels); elt++)
|
|
3190 Dynarr_atp (w->glyph_cachels, elt)->updated = 0;
|
|
3191 }
|
|
3192
|
|
3193 #ifdef MEMORY_USAGE_STATS
|
|
3194
|
|
3195 int
|
|
3196 compute_glyph_cachel_usage (glyph_cachel_dynarr *glyph_cachels,
|
|
3197 struct overhead_stats *ovstats)
|
|
3198 {
|
|
3199 int total = 0;
|
|
3200
|
|
3201 if (glyph_cachels)
|
|
3202 total += Dynarr_memory_usage (glyph_cachels, ovstats);
|
|
3203
|
|
3204 return total;
|
|
3205 }
|
|
3206
|
|
3207 #endif /* MEMORY_USAGE_STATS */
|
|
3208
|
|
3209
|
|
3210 /*****************************************************************************
|
|
3211 * display tables *
|
|
3212 *****************************************************************************/
|
|
3213
|
361
|
3214 /* Get the display tables for use currently on window W with face
|
|
3215 FACE. #### This will have to be redone. */
|
|
3216
|
|
3217 void
|
|
3218 get_display_tables (struct window *w, face_index findex,
|
|
3219 Lisp_Object *face_table, Lisp_Object *window_table)
|
0
|
3220 {
|
272
|
3221 Lisp_Object tem;
|
0
|
3222 tem = WINDOW_FACE_CACHEL_DISPLAY_TABLE (w, findex);
|
361
|
3223 if (UNBOUNDP (tem))
|
|
3224 tem = Qnil;
|
|
3225 if (!LISTP (tem))
|
|
3226 tem = noseeum_cons (tem, Qnil);
|
|
3227 *face_table = tem;
|
0
|
3228 tem = w->display_table;
|
361
|
3229 if (UNBOUNDP (tem))
|
|
3230 tem = Qnil;
|
|
3231 if (!LISTP (tem))
|
|
3232 tem = noseeum_cons (tem, Qnil);
|
|
3233 *window_table = tem;
|
|
3234 }
|
|
3235
|
|
3236 Lisp_Object
|
|
3237 display_table_entry (Emchar ch, Lisp_Object face_table,
|
|
3238 Lisp_Object window_table)
|
|
3239 {
|
|
3240 Lisp_Object tail;
|
|
3241
|
|
3242 /* Loop over FACE_TABLE, and then over WINDOW_TABLE. */
|
|
3243 for (tail = face_table; 1; tail = XCDR (tail))
|
|
3244 {
|
|
3245 Lisp_Object table;
|
|
3246 if (NILP (tail))
|
|
3247 {
|
|
3248 if (!NILP (window_table))
|
|
3249 {
|
|
3250 tail = window_table;
|
|
3251 window_table = Qnil;
|
|
3252 }
|
|
3253 else
|
|
3254 return Qnil;
|
|
3255 }
|
|
3256 table = XCAR (tail);
|
|
3257
|
|
3258 if (VECTORP (table))
|
|
3259 {
|
|
3260 if (ch < XVECTOR_LENGTH (table) && !NILP (XVECTOR_DATA (table)[ch]))
|
|
3261 return XVECTOR_DATA (table)[ch];
|
|
3262 else
|
|
3263 continue;
|
|
3264 }
|
|
3265 else if (CHAR_TABLEP (table)
|
|
3266 && XCHAR_TABLE_TYPE (table) == CHAR_TABLE_TYPE_CHAR)
|
|
3267 {
|
|
3268 return get_char_table (ch, XCHAR_TABLE (table));
|
|
3269 }
|
|
3270 else if (CHAR_TABLEP (table)
|
|
3271 && XCHAR_TABLE_TYPE (table) == CHAR_TABLE_TYPE_GENERIC)
|
|
3272 {
|
|
3273 Lisp_Object gotit = get_char_table (ch, XCHAR_TABLE (table));
|
|
3274 if (!NILP (gotit))
|
|
3275 return gotit;
|
|
3276 else
|
|
3277 continue;
|
|
3278 }
|
|
3279 else if (RANGE_TABLEP (table))
|
|
3280 {
|
|
3281 Lisp_Object gotit = Fget_range_table (make_char (ch), table, Qnil);
|
|
3282 if (!NILP (gotit))
|
|
3283 return gotit;
|
|
3284 else
|
|
3285 continue;
|
|
3286 }
|
|
3287 else
|
|
3288 abort ();
|
|
3289 }
|
0
|
3290 }
|
|
3291
|
|
3292
|
|
3293 /*****************************************************************************
|
|
3294 * initialization *
|
|
3295 *****************************************************************************/
|
|
3296
|
|
3297 void
|
|
3298 syms_of_glyphs (void)
|
|
3299 {
|
|
3300 /* image instantiators */
|
|
3301
|
20
|
3302 DEFSUBR (Fimage_instantiator_format_list);
|
|
3303 DEFSUBR (Fvalid_image_instantiator_format_p);
|
|
3304 DEFSUBR (Fset_console_type_image_conversion_list);
|
|
3305 DEFSUBR (Fconsole_type_image_conversion_list);
|
0
|
3306
|
|
3307 defkeyword (&Q_file, ":file");
|
|
3308 defkeyword (&Q_data, ":data");
|
|
3309 defkeyword (&Q_face, ":face");
|
|
3310
|
276
|
3311 #ifdef HAVE_XPM
|
|
3312 defkeyword (&Q_color_symbols, ":color-symbols");
|
|
3313 #endif
|
288
|
3314 #ifdef HAVE_WINDOW_SYSTEM
|
|
3315 defkeyword (&Q_mask_file, ":mask-file");
|
|
3316 defkeyword (&Q_mask_data, ":mask-data");
|
|
3317 defkeyword (&Q_hotspot_x, ":hotspot-x");
|
|
3318 defkeyword (&Q_hotspot_y, ":hotspot-y");
|
|
3319 defkeyword (&Q_foreground, ":foreground");
|
|
3320 defkeyword (&Q_background, ":background");
|
|
3321 #endif
|
0
|
3322 /* image specifiers */
|
|
3323
|
20
|
3324 DEFSUBR (Fimage_specifier_p);
|
0
|
3325 /* Qimage in general.c */
|
|
3326
|
|
3327 /* image instances */
|
|
3328
|
|
3329 defsymbol (&Qimage_instancep, "image-instance-p");
|
|
3330
|
|
3331 defsymbol (&Qnothing_image_instance_p, "nothing-image-instance-p");
|
|
3332 defsymbol (&Qtext_image_instance_p, "text-image-instance-p");
|
|
3333 defsymbol (&Qmono_pixmap_image_instance_p, "mono-pixmap-image-instance-p");
|
|
3334 defsymbol (&Qcolor_pixmap_image_instance_p, "color-pixmap-image-instance-p");
|
|
3335 defsymbol (&Qpointer_image_instance_p, "pointer-image-instance-p");
|
|
3336 defsymbol (&Qsubwindow_image_instance_p, "subwindow-image-instance-p");
|
|
3337
|
20
|
3338 DEFSUBR (Fmake_image_instance);
|
|
3339 DEFSUBR (Fimage_instance_p);
|
|
3340 DEFSUBR (Fimage_instance_type);
|
|
3341 DEFSUBR (Fvalid_image_instance_type_p);
|
|
3342 DEFSUBR (Fimage_instance_type_list);
|
|
3343 DEFSUBR (Fimage_instance_name);
|
|
3344 DEFSUBR (Fimage_instance_string);
|
|
3345 DEFSUBR (Fimage_instance_file_name);
|
|
3346 DEFSUBR (Fimage_instance_mask_file_name);
|
|
3347 DEFSUBR (Fimage_instance_depth);
|
|
3348 DEFSUBR (Fimage_instance_height);
|
|
3349 DEFSUBR (Fimage_instance_width);
|
|
3350 DEFSUBR (Fimage_instance_hotspot_x);
|
|
3351 DEFSUBR (Fimage_instance_hotspot_y);
|
|
3352 DEFSUBR (Fimage_instance_foreground);
|
|
3353 DEFSUBR (Fimage_instance_background);
|
|
3354 DEFSUBR (Fcolorize_image_instance);
|
0
|
3355
|
|
3356 /* Qnothing defined as part of the "nothing" image-instantiator
|
|
3357 type. */
|
|
3358 /* Qtext defined in general.c */
|
|
3359 defsymbol (&Qmono_pixmap, "mono-pixmap");
|
|
3360 defsymbol (&Qcolor_pixmap, "color-pixmap");
|
|
3361 /* Qpointer defined in general.c */
|
|
3362 defsymbol (&Qsubwindow, "subwindow");
|
|
3363
|
|
3364 /* glyphs */
|
|
3365
|
|
3366 defsymbol (&Qglyphp, "glyphp");
|
|
3367 defsymbol (&Qcontrib_p, "contrib-p");
|
|
3368 defsymbol (&Qbaseline, "baseline");
|
|
3369
|
|
3370 defsymbol (&Qbuffer_glyph_p, "buffer-glyph-p");
|
|
3371 defsymbol (&Qpointer_glyph_p, "pointer-glyph-p");
|
|
3372 defsymbol (&Qicon_glyph_p, "icon-glyph-p");
|
|
3373
|
|
3374 defsymbol (&Qconst_glyph_variable, "const-glyph-variable");
|
|
3375
|
20
|
3376 DEFSUBR (Fglyph_type);
|
|
3377 DEFSUBR (Fvalid_glyph_type_p);
|
|
3378 DEFSUBR (Fglyph_type_list);
|
|
3379 DEFSUBR (Fglyphp);
|
|
3380 DEFSUBR (Fmake_glyph_internal);
|
|
3381 DEFSUBR (Fglyph_width);
|
|
3382 DEFSUBR (Fglyph_ascent);
|
|
3383 DEFSUBR (Fglyph_descent);
|
|
3384 DEFSUBR (Fglyph_height);
|
0
|
3385
|
|
3386 /* Qbuffer defined in general.c. */
|
|
3387 /* Qpointer defined above */
|
269
|
3388
|
|
3389 /* Errors */
|
|
3390 deferror (&Qimage_conversion_error,
|
|
3391 "image-conversion-error",
|
|
3392 "image-conversion error", Qio_error);
|
|
3393
|
0
|
3394 }
|
|
3395
|
|
3396 void
|
|
3397 specifier_type_create_image (void)
|
|
3398 {
|
|
3399 /* image specifiers */
|
|
3400
|
|
3401 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (image, "image", "imagep");
|
|
3402
|
|
3403 SPECIFIER_HAS_METHOD (image, create);
|
|
3404 SPECIFIER_HAS_METHOD (image, mark);
|
|
3405 SPECIFIER_HAS_METHOD (image, instantiate);
|
|
3406 SPECIFIER_HAS_METHOD (image, validate);
|
|
3407 SPECIFIER_HAS_METHOD (image, after_change);
|
|
3408 SPECIFIER_HAS_METHOD (image, going_to_add);
|
|
3409 }
|
|
3410
|
|
3411 void
|
|
3412 image_instantiator_format_create (void)
|
|
3413 {
|
|
3414 /* image instantiators */
|
|
3415
|
|
3416 the_image_instantiator_format_entry_dynarr =
|
185
|
3417 Dynarr_new (image_instantiator_format_entry);
|
0
|
3418
|
|
3419 Vimage_instantiator_format_list = Qnil;
|
|
3420 staticpro (&Vimage_instantiator_format_list);
|
|
3421
|
|
3422 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (nothing, "nothing");
|
|
3423
|
|
3424 IIFORMAT_HAS_METHOD (nothing, possible_dest_types);
|
|
3425 IIFORMAT_HAS_METHOD (nothing, instantiate);
|
|
3426
|
|
3427 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (inherit, "inherit");
|
|
3428
|
|
3429 IIFORMAT_HAS_METHOD (inherit, validate);
|
|
3430 IIFORMAT_HAS_METHOD (inherit, normalize);
|
|
3431 IIFORMAT_HAS_METHOD (inherit, possible_dest_types);
|
|
3432 IIFORMAT_HAS_METHOD (inherit, instantiate);
|
|
3433
|
|
3434 IIFORMAT_VALID_KEYWORD (inherit, Q_face, check_valid_face);
|
|
3435
|
|
3436 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (string, "string");
|
|
3437
|
|
3438 IIFORMAT_HAS_METHOD (string, validate);
|
|
3439 IIFORMAT_HAS_METHOD (string, possible_dest_types);
|
|
3440 IIFORMAT_HAS_METHOD (string, instantiate);
|
|
3441
|
|
3442 IIFORMAT_VALID_KEYWORD (string, Q_data, check_valid_string);
|
|
3443
|
|
3444 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (formatted_string, "formatted-string");
|
|
3445
|
|
3446 IIFORMAT_HAS_METHOD (formatted_string, validate);
|
|
3447 IIFORMAT_HAS_METHOD (formatted_string, possible_dest_types);
|
|
3448 IIFORMAT_HAS_METHOD (formatted_string, instantiate);
|
|
3449
|
|
3450 IIFORMAT_VALID_KEYWORD (formatted_string, Q_data, check_valid_string);
|
276
|
3451
|
288
|
3452 #ifdef HAVE_WINDOW_SYSTEM
|
|
3453 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (xbm, "xbm");
|
|
3454
|
|
3455 IIFORMAT_HAS_METHOD (xbm, validate);
|
|
3456 IIFORMAT_HAS_METHOD (xbm, normalize);
|
|
3457 IIFORMAT_HAS_METHOD (xbm, possible_dest_types);
|
|
3458 IIFORMAT_HAS_METHOD (xbm, instantiate);
|
|
3459
|
|
3460 IIFORMAT_VALID_KEYWORD (xbm, Q_data, check_valid_xbm_inline);
|
|
3461 IIFORMAT_VALID_KEYWORD (xbm, Q_file, check_valid_string);
|
|
3462 IIFORMAT_VALID_KEYWORD (xbm, Q_mask_data, check_valid_xbm_inline);
|
|
3463 IIFORMAT_VALID_KEYWORD (xbm, Q_mask_file, check_valid_string);
|
|
3464 IIFORMAT_VALID_KEYWORD (xbm, Q_hotspot_x, check_valid_int);
|
|
3465 IIFORMAT_VALID_KEYWORD (xbm, Q_hotspot_y, check_valid_int);
|
|
3466 IIFORMAT_VALID_KEYWORD (xbm, Q_foreground, check_valid_string);
|
|
3467 IIFORMAT_VALID_KEYWORD (xbm, Q_background, check_valid_string);
|
|
3468 #endif /* HAVE_WINDOW_SYSTEM */
|
|
3469
|
276
|
3470 #ifdef HAVE_XPM
|
|
3471 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (xpm, "xpm");
|
|
3472
|
|
3473 IIFORMAT_HAS_METHOD (xpm, validate);
|
|
3474 IIFORMAT_HAS_METHOD (xpm, normalize);
|
|
3475 IIFORMAT_HAS_METHOD (xpm, possible_dest_types);
|
|
3476 IIFORMAT_HAS_METHOD (xpm, instantiate);
|
|
3477
|
|
3478 IIFORMAT_VALID_KEYWORD (xpm, Q_data, check_valid_string);
|
|
3479 IIFORMAT_VALID_KEYWORD (xpm, Q_file, check_valid_string);
|
|
3480 IIFORMAT_VALID_KEYWORD (xpm, Q_color_symbols, check_valid_xpm_color_symbols);
|
284
|
3481 #endif /* HAVE_XPM */
|
0
|
3482 }
|
|
3483
|
|
3484 void
|
|
3485 vars_of_glyphs (void)
|
|
3486 {
|
|
3487 Vthe_nothing_vector = vector1 (Qnothing);
|
|
3488 staticpro (&Vthe_nothing_vector);
|
|
3489
|
|
3490 /* image instances */
|
|
3491
|
|
3492 Vimage_instance_type_list = list6 (Qnothing, Qtext, Qmono_pixmap,
|
|
3493 Qcolor_pixmap, Qpointer, Qsubwindow);
|
|
3494 staticpro (&Vimage_instance_type_list);
|
|
3495
|
|
3496 /* glyphs */
|
|
3497
|
|
3498 Vglyph_type_list = list3 (Qbuffer, Qpointer, Qicon);
|
|
3499 staticpro (&Vglyph_type_list);
|
|
3500
|
|
3501 /* The octal-escape glyph, control-arrow-glyph and
|
|
3502 invisible-text-glyph are completely initialized in glyphs.el */
|
|
3503
|
|
3504 DEFVAR_LISP ("octal-escape-glyph", &Voctal_escape_glyph /*
|
|
3505 What to prefix character codes displayed in octal with.
|
|
3506 */);
|
|
3507 Voctal_escape_glyph = allocate_glyph (GLYPH_BUFFER, redisplay_glyph_changed);
|
|
3508
|
|
3509 DEFVAR_LISP ("control-arrow-glyph", &Vcontrol_arrow_glyph /*
|
|
3510 What to use as an arrow for control characters.
|
|
3511 */);
|
|
3512 Vcontrol_arrow_glyph = allocate_glyph (GLYPH_BUFFER,
|
|
3513 redisplay_glyph_changed);
|
|
3514
|
|
3515 DEFVAR_LISP ("invisible-text-glyph", &Vinvisible_text_glyph /*
|
|
3516 What to use to indicate the presence of invisible text.
|
|
3517 This is the glyph that is displayed when an ellipsis is called for
|
|
3518 \(see `selective-display-ellipses' and `buffer-invisibility-spec').
|
185
|
3519 Normally this is three dots ("...").
|
0
|
3520 */);
|
|
3521 Vinvisible_text_glyph = allocate_glyph (GLYPH_BUFFER,
|
|
3522 redisplay_glyph_changed);
|
|
3523
|
|
3524 /* Partially initialized in glyphs.el */
|
|
3525 DEFVAR_LISP ("hscroll-glyph", &Vhscroll_glyph /*
|
|
3526 What to display at the beginning of horizontally scrolled lines.
|
|
3527 */);
|
|
3528 Vhscroll_glyph = allocate_glyph (GLYPH_BUFFER, redisplay_glyph_changed);
|
276
|
3529
|
|
3530 #ifdef HAVE_XPM
|
|
3531 Fprovide (Qxpm);
|
|
3532
|
|
3533 DEFVAR_LISP ("xpm-color-symbols", &Vxpm_color_symbols /*
|
|
3534 Definitions of logical color-names used when reading XPM files.
|
|
3535 Elements of this list should be of the form (COLOR-NAME FORM-TO-EVALUATE).
|
|
3536 The COLOR-NAME should be a string, which is the name of the color to define;
|
|
3537 the FORM should evaluate to a `color' specifier object, or a string to be
|
|
3538 passed to `make-color-instance'. If a loaded XPM file references a symbolic
|
|
3539 color called COLOR-NAME, it will display as the computed color instead.
|
|
3540
|
|
3541 The default value of this variable defines the logical color names
|
|
3542 \"foreground\" and \"background\" to be the colors of the `default' face.
|
|
3543 */ );
|
|
3544 Vxpm_color_symbols = Qnil; /* initialized in x-faces.el */
|
284
|
3545 #endif /* HAVE_XPM */
|
0
|
3546 }
|
|
3547
|
|
3548 void
|
|
3549 specifier_vars_of_glyphs (void)
|
|
3550 {
|
249
|
3551 /* #### Can we GC here? The set_specifier_* calls definitely need */
|
|
3552 /* protection. */
|
0
|
3553 /* display tables */
|
|
3554
|
|
3555 DEFVAR_SPECIFIER ("current-display-table", &Vcurrent_display_table /*
|
|
3556 *The display table currently in use.
|
|
3557 This is a specifier; use `set-specifier' to change it.
|
|
3558 The display table is a vector created with `make-display-table'.
|
|
3559 The 256 elements control how to display each possible text character.
|
|
3560 Each value should be a string, a glyph, a vector or nil.
|
|
3561 If a value is a vector it must be composed only of strings and glyphs.
|
|
3562 nil means display the character in the default fashion.
|
|
3563 Faces can have their own, overriding display table.
|
|
3564 */ );
|
116
|
3565 Vcurrent_display_table = Fmake_specifier (Qdisplay_table);
|
0
|
3566 set_specifier_fallback (Vcurrent_display_table,
|
|
3567 list1 (Fcons (Qnil, Qnil)));
|
|
3568 set_specifier_caching (Vcurrent_display_table,
|
|
3569 slot_offset (struct window,
|
|
3570 display_table),
|
|
3571 some_window_value_changed,
|
|
3572 0, 0);
|
|
3573 }
|
|
3574
|
|
3575 void
|
|
3576 complex_vars_of_glyphs (void)
|
|
3577 {
|
|
3578 /* Partially initialized in glyphs-x.c, glyphs.el */
|
|
3579 DEFVAR_LISP ("truncation-glyph", &Vtruncation_glyph /*
|
|
3580 What to display at the end of truncated lines.
|
|
3581 */ );
|
|
3582 Vtruncation_glyph = allocate_glyph (GLYPH_BUFFER, redisplay_glyph_changed);
|
|
3583
|
|
3584 /* Partially initialized in glyphs-x.c, glyphs.el */
|
|
3585 DEFVAR_LISP ("continuation-glyph", &Vcontinuation_glyph /*
|
|
3586 What to display at the end of wrapped lines.
|
|
3587 */ );
|
|
3588 Vcontinuation_glyph = allocate_glyph (GLYPH_BUFFER, redisplay_glyph_changed);
|
|
3589
|
|
3590 /* Partially initialized in glyphs-x.c, glyphs.el */
|
|
3591 DEFVAR_LISP ("xemacs-logo", &Vxemacs_logo /*
|
|
3592 The glyph used to display the XEmacs logo at startup.
|
|
3593 */ );
|
|
3594 Vxemacs_logo = allocate_glyph (GLYPH_BUFFER, 0);
|
|
3595 }
|