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