comparison src/glyphs.c @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 56c54cf7c5b6
children 54cc21c15cbb
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
384 /* utility function useful in retrieving data from a file. */ 384 /* utility function useful in retrieving data from a file. */
385 385
386 Lisp_Object 386 Lisp_Object
387 make_string_from_file (Lisp_Object file) 387 make_string_from_file (Lisp_Object file)
388 { 388 {
389 /* This function can call lisp */
390 int count = specpdl_depth (); 389 int count = specpdl_depth ();
391 Lisp_Object temp_buffer; 390 Lisp_Object temp_buffer;
392 struct gcpro gcpro1; 391 struct gcpro gcpro1;
393 Lisp_Object data; 392 Lisp_Object data;
394 393
396 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 395 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
397 temp_buffer = Fget_buffer_create (build_string (" *pixmap conversion*")); 396 temp_buffer = Fget_buffer_create (build_string (" *pixmap conversion*"));
398 GCPRO1 (temp_buffer); 397 GCPRO1 (temp_buffer);
399 set_buffer_internal (XBUFFER (temp_buffer)); 398 set_buffer_internal (XBUFFER (temp_buffer));
400 Ferase_buffer (Fcurrent_buffer ()); 399 Ferase_buffer (Fcurrent_buffer ());
401 Finsert_file_contents_internal (file, Qnil, Qnil, Qnil, Qnil); 400 Finsert_file_contents_internal (file, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil);
402 data = Fbuffer_substring (Qnil, Qnil, Fcurrent_buffer ()); 401 data = Fbuffer_substring (Qnil, Qnil, Fcurrent_buffer ());
403 unbind_to (count, Qnil); 402 unbind_to (count, Qnil);
404 UNGCPRO; 403 UNGCPRO;
405 return data; 404 return data;
406 } 405 }
477 476
478 return instantiator; 477 return instantiator;
479 } 478 }
480 479
481 static Lisp_Object 480 static Lisp_Object
482 instantiate_image_instantiator (Lisp_Object device, Lisp_Object domain, 481 instantiate_image_instantiator (Lisp_Object device, Lisp_Object instantiator,
483 Lisp_Object instantiator,
484 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 482 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
485 int dest_mask) 483 int dest_mask)
486 { 484 {
487 Lisp_Object ii; 485 Lisp_Object ii;
488 struct gcpro gcpro1; 486 struct gcpro gcpro1;
498 if (!HAS_IIFORMAT_METH_P (meths, instantiate)) 496 if (!HAS_IIFORMAT_METH_P (meths, instantiate))
499 signal_simple_error 497 signal_simple_error
500 ("Don't know how to instantiate this image instantiator?", 498 ("Don't know how to instantiate this image instantiator?",
501 instantiator); 499 instantiator);
502 IIFORMAT_METH (meths, instantiate, (ii, instantiator, pointer_fg, 500 IIFORMAT_METH (meths, instantiate, (ii, instantiator, pointer_fg,
503 pointer_bg, dest_mask, domain)); 501 pointer_bg, dest_mask));
504 } 502 }
505 UNGCPRO; 503 UNGCPRO;
506 504
507 return ii; 505 return ii;
508 } 506 }
981 make_int (dest_mask)); 979 make_int (dest_mask));
982 GCPRO1 (data); 980 GCPRO1 (data);
983 if (VECTORP (data) 981 if (VECTORP (data)
984 && EQ (vector_data (XVECTOR (data))[0], Qinherit)) 982 && EQ (vector_data (XVECTOR (data))[0], Qinherit))
985 signal_simple_error ("inheritance not allowed here", data); 983 signal_simple_error ("inheritance not allowed here", data);
986 ii = instantiate_image_instantiator (device, device, data, 984 ii = instantiate_image_instantiator (device, data, Qnil, Qnil, dest_mask);
987 Qnil, Qnil, dest_mask);
988 RETURN_UNGCPRO (ii); 985 RETURN_UNGCPRO (ii);
989 } 986 }
990 987
991 DEFUN ("make-image-instance", Fmake_image_instance, 1, 4, 0, /* 988 DEFUN ("make-image-instance", Fmake_image_instance, 1, 4, 0, /*
992 Create a new `image-instance' object. 989 Create a new `image-instance' object.
1049 */ 1046 */
1050 (data, device, dest_types, no_error)) 1047 (data, device, dest_types, no_error))
1051 { 1048 {
1052 Error_behavior errb = decode_error_behavior_flag (no_error); 1049 Error_behavior errb = decode_error_behavior_flag (no_error);
1053 1050
1054 return call_with_suspended_errors ((lisp_fn_t) make_image_instance_1, 1051 return call_with_suspended_errors (make_image_instance_1,
1055 Qnil, Qimage, errb, 1052 Qnil, Qimage, errb,
1056 3, data, device, dest_types); 1053 3, data, device, dest_types);
1057 } 1054 }
1058 1055
1059 DEFUN ("image-instance-p", Fimage_instance_p, 1, 1, 0, /* 1056 DEFUN ("image-instance-p", Fimage_instance_p, 1, 1, 0, /*
1319 /**************************************************************************** 1316 /****************************************************************************
1320 * nothing * 1317 * nothing *
1321 ****************************************************************************/ 1318 ****************************************************************************/
1322 1319
1323 static int 1320 static int
1324 nothing_possible_dest_types (void) 1321 nothing_possible_dest_types ()
1325 { 1322 {
1326 return IMAGE_NOTHING_MASK; 1323 return IMAGE_NOTHING_MASK;
1327 } 1324 }
1328 1325
1329 static void 1326 static void
1330 nothing_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1327 nothing_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1331 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1328 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1332 int dest_mask, Lisp_Object domain) 1329 int dest_mask)
1333 { 1330 {
1334 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1331 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1335 1332
1336 if (dest_mask & IMAGE_NOTHING_MASK) 1333 if (dest_mask & IMAGE_NOTHING_MASK)
1337 IMAGE_INSTANCE_TYPE (ii) = IMAGE_NOTHING; 1334 IMAGE_INSTANCE_TYPE (ii) = IMAGE_NOTHING;
1361 inst = vector3 (Qinherit, Q_face, Fget_face (face)); 1358 inst = vector3 (Qinherit, Q_face, Fget_face (face));
1362 return inst; 1359 return inst;
1363 } 1360 }
1364 1361
1365 static int 1362 static int
1366 inherit_possible_dest_types (void) 1363 inherit_possible_dest_types ()
1367 { 1364 {
1368 return IMAGE_MONO_PIXMAP_MASK; 1365 return IMAGE_MONO_PIXMAP_MASK;
1369 } 1366 }
1370 1367
1371 static void 1368 static void
1372 inherit_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1369 inherit_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1373 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1370 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1374 int dest_mask, Lisp_Object domain) 1371 int dest_mask)
1375 { 1372 {
1376 /* handled specially in image_instantiate */ 1373 /* handled specially in image_instantiate */
1377 abort (); 1374 abort ();
1378 } 1375 }
1379 1376
1387 { 1384 {
1388 data_must_be_present (instantiator); 1385 data_must_be_present (instantiator);
1389 } 1386 }
1390 1387
1391 static int 1388 static int
1392 string_possible_dest_types (void) 1389 string_possible_dest_types ()
1393 { 1390 {
1394 return IMAGE_TEXT_MASK; 1391 return IMAGE_TEXT_MASK;
1395 } 1392 }
1396 1393
1397 /* called from autodetect_instantiate() */ 1394 /* called from autodetect_instantiate() */
1398 void 1395 void
1399 string_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1396 string_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1400 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1397 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1401 int dest_mask, Lisp_Object domain) 1398 int dest_mask)
1402 { 1399 {
1403 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1400 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1404 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1401 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1405 1402
1406 assert (!NILP (data)); 1403 assert (!NILP (data));
1423 { 1420 {
1424 data_must_be_present (instantiator); 1421 data_must_be_present (instantiator);
1425 } 1422 }
1426 1423
1427 static int 1424 static int
1428 formatted_string_possible_dest_types (void) 1425 formatted_string_possible_dest_types ()
1429 { 1426 {
1430 return IMAGE_TEXT_MASK; 1427 return IMAGE_TEXT_MASK;
1431 } 1428 }
1432 1429
1433 static void 1430 static void
1434 formatted_string_instantiate (Lisp_Object image_instance, 1431 formatted_string_instantiate (Lisp_Object image_instance,
1435 Lisp_Object instantiator, 1432 Lisp_Object instantiator,
1436 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1433 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1437 int dest_mask, Lisp_Object domain) 1434 int dest_mask)
1438 { 1435 {
1439 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1436 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1440 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1437 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1441 1438
1442 assert (!NILP (data)); 1439 assert (!NILP (data));
1596 car of the locative to the resulting instance, 1593 car of the locative to the resulting instance,
1597 which gets recorded instead. */ 1594 which gets recorded instead. */
1598 record_unwind_protect (image_instantiate_cache_result, 1595 record_unwind_protect (image_instantiate_cache_result,
1599 locative); 1596 locative);
1600 instance = instantiate_image_instantiator (device, 1597 instance = instantiate_image_instantiator (device,
1601 domain,
1602 instantiator, 1598 instantiator,
1603 pointer_fg, pointer_bg, 1599 pointer_fg, pointer_bg,
1604 dest_mask); 1600 dest_mask);
1605 Fsetcar (locative, instance); 1601 Fsetcar (locative, instance);
1606 unbind_to (speccount, Qnil); 1602 unbind_to (speccount, Qnil);
1732 LIST_LOOP (rest, possible_console_types) 1728 LIST_LOOP (rest, possible_console_types)
1733 { 1729 {
1734 Lisp_Object newinst; 1730 Lisp_Object newinst;
1735 Lisp_Object contype = XCAR (rest); 1731 Lisp_Object contype = XCAR (rest);
1736 1732
1737 newinst = call_with_suspended_errors 1733 newinst = call_with_suspended_errors (normalize_image_instantiator,
1738 ((lisp_fn_t) normalize_image_instantiator, 1734 Qnil, Qimage, ERROR_ME_NOT,
1739 Qnil, Qimage, ERROR_ME_NOT, 3, instantiator, contype, 1735 3, instantiator, contype,
1740 make_int (XIMAGE_SPECIFIER_ALLOWED (specifier))); 1736 make_int
1741 1737 (XIMAGE_SPECIFIER_ALLOWED
1738 (specifier)));
1742 if (!NILP (newinst)) 1739 if (!NILP (newinst))
1743 { 1740 {
1744 Lisp_Object newtag; 1741 Lisp_Object newtag;
1745 if (NILP (memq_no_quit (contype, tag_set))) 1742 if (NILP (memq_no_quit (contype, tag_set)))
1746 newtag = Fcons (contype, tag_set); 1743 newtag = Fcons (contype, tag_set);
2381 unsigned char charsets[NUM_LEADING_BYTES]; 2378 unsigned char charsets[NUM_LEADING_BYTES];
2382 struct face_cachel frame_cachel; 2379 struct face_cachel frame_cachel;
2383 struct face_cachel *cachel; 2380 struct face_cachel *cachel;
2384 2381
2385 find_charsets_in_bufbyte_string (charsets, 2382 find_charsets_in_bufbyte_string (charsets,
2386 XSTRING_DATA (string), 2383 XSTRING_DATA (string),
2387 XSTRING_LENGTH (string)); 2384 XSTRING_LENGTH (string));
2388 2385
2389 if (!NILP (frame_face)) 2386 if (!NILP (frame_face))
2390 { 2387 {
2391 reset_face_cachel (&frame_cachel); 2388 reset_face_cachel (&frame_cachel);