(Qsquare): New variable.
[chise/xemacs-chise.git-] / src / glyphs.c
index d92508e..b03fe24 100644 (file)
@@ -174,21 +174,38 @@ decode_image_instantiator_format (Lisp_Object format, Error_behavior errb)
 }
 
 static int
-valid_image_instantiator_format_p (Lisp_Object format)
+valid_image_instantiator_format_p (Lisp_Object format, Lisp_Object locale)
 {
-  return (decode_image_instantiator_format (format, ERROR_ME_NOT) != 0);
+  int i;
+  struct image_instantiator_methods* meths =
+    decode_image_instantiator_format (format, ERROR_ME_NOT);
+  struct console* console = decode_console (locale);
+  Lisp_Object contype = console ? CONSOLE_TYPE (console) : locale;
+  /* nothing is valid in all locales */
+  if (EQ (format, Qnothing))
+    return 1;
+  /* reject unknown formats */
+  else if (!console || !meths)
+    return 0;
+
+  for (i = 0; i < Dynarr_length (meths->consoles); i++)
+    if (EQ (contype, Dynarr_at (meths->consoles, i).symbol))
+      return 1;
+  return 0;
 }
 
 DEFUN ("valid-image-instantiator-format-p", Fvalid_image_instantiator_format_p,
-       1, 1, 0, /*
+       1, 2, 0, /*
 Given an IMAGE-INSTANTIATOR-FORMAT, return non-nil if it is valid.
+If LOCALE is non-nil then the format is checked in that domain.
+If LOCALE is nil the current console is used.
 Valid formats are some subset of 'nothing, 'string, 'formatted-string,
 'xpm, 'xbm, 'xface, 'gif, 'jpeg, 'png, 'tiff, 'cursor-font, 'font,
 'autodetect, 'widget and 'subwindow, depending on how XEmacs was compiled.
 */
-       (image_instantiator_format))
+       (image_instantiator_format, locale))
 {
-  return valid_image_instantiator_format_p (image_instantiator_format) ?
+  return valid_image_instantiator_format_p (image_instantiator_format, locale) ?
     Qt : Qnil;
 }
 
@@ -547,6 +564,11 @@ instantiate_image_instantiator (Lisp_Object device, Lisp_Object domain,
   int  methp = 0;
 
   GCPRO1 (ii);
+  if (!valid_image_instantiator_format_p (XVECTOR_DATA (instantiator)[0], device))
+    signal_simple_error
+      ("Image instantiator format is invalid in this locale.",
+       instantiator);
+
   meths = decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0],
                                            ERROR_ME);
   methp = (int)HAS_IIFORMAT_METH_P (meths, instantiate);
@@ -600,7 +622,7 @@ mark_image_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
       markobj (IMAGE_INSTANCE_WIDGET_TYPE (i));
       markobj (IMAGE_INSTANCE_WIDGET_PROPS (i));
       markobj (IMAGE_INSTANCE_WIDGET_FACE (i));
-      mark_gui_item (&IMAGE_INSTANCE_WIDGET_ITEM (i), markobj);
+      markobj (IMAGE_INSTANCE_WIDGET_ITEM (i));
     case IMAGE_SUBWINDOW:
       markobj (IMAGE_INSTANCE_SUBWINDOW_FRAME (i));
       break;
@@ -707,11 +729,13 @@ print_image_instance (Lisp_Object obj, Lisp_Object printcharfun,
       break;
 
     case IMAGE_WIDGET:
+      /*
       if (!NILP (IMAGE_INSTANCE_WIDGET_CALLBACK (ii)))
        {
          print_internal (IMAGE_INSTANCE_WIDGET_CALLBACK (ii), printcharfun, 0);
          write_c_string (", ", printcharfun);
        }
+      */
       if (!NILP (IMAGE_INSTANCE_WIDGET_FACE (ii)))
        {
          write_c_string (" (", printcharfun);
@@ -834,15 +858,14 @@ image_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
 
     case IMAGE_WIDGET:
       if (!(EQ (IMAGE_INSTANCE_WIDGET_TYPE (i1),
-               IMAGE_INSTANCE_WIDGET_TYPE (i2)) &&
-           EQ (IMAGE_INSTANCE_WIDGET_CALLBACK (i1),
-               IMAGE_INSTANCE_WIDGET_CALLBACK (i2))
+               IMAGE_INSTANCE_WIDGET_TYPE (i2))
+           && internal_equal (IMAGE_INSTANCE_WIDGET_ITEM (i1),
+                              IMAGE_INSTANCE_WIDGET_ITEM (i2),
+                              depth + 1)
            && internal_equal (IMAGE_INSTANCE_WIDGET_PROPS (i1),
                               IMAGE_INSTANCE_WIDGET_PROPS (i2),
                               depth + 1)
-           && internal_equal (IMAGE_INSTANCE_WIDGET_TEXT (i1),
-                              IMAGE_INSTANCE_WIDGET_TEXT (i2),
-                              depth + 1)))
+           ))
        return 0;
     case IMAGE_SUBWINDOW:
       if (!(IMAGE_INSTANCE_SUBWINDOW_WIDTH (i1) ==
@@ -892,7 +915,7 @@ image_instance_hash (Lisp_Object obj, int depth)
       hash = HASH4 (hash, 
                    internal_hash (IMAGE_INSTANCE_WIDGET_TYPE (i), depth + 1),
                    internal_hash (IMAGE_INSTANCE_WIDGET_PROPS (i), depth + 1),
-                   internal_hash (IMAGE_INSTANCE_WIDGET_CALLBACK (i), depth + 1));
+                   internal_hash (IMAGE_INSTANCE_WIDGET_ITEM (i), depth + 1));
     case IMAGE_SUBWINDOW:
       hash = HASH4 (hash, IMAGE_INSTANCE_SUBWINDOW_WIDTH (i),
                    IMAGE_INSTANCE_SUBWINDOW_HEIGHT (i),
@@ -910,7 +933,7 @@ image_instance_hash (Lisp_Object obj, int depth)
 DEFINE_LRECORD_IMPLEMENTATION ("image-instance", image_instance,
                               mark_image_instance, print_image_instance,
                               finalize_image_instance, image_instance_equal,
-                              image_instance_hash,
+                              image_instance_hash, 0,
                               struct Lisp_Image_Instance);
 
 static Lisp_Object
@@ -2925,9 +2948,14 @@ glyph_plist (Lisp_Object obj)
   return result;
 }
 
+static const struct lrecord_description glyph_description[] = {
+  { XD_LISP_OBJECT, offsetof(struct Lisp_Glyph, image), 5 },
+  { XD_END }
+};
+
 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("glyph", glyph,
                                          mark_glyph, print_glyph, 0,
-                                         glyph_equal, glyph_hash,
+                                         glyph_equal, glyph_hash, glyph_description,
                                          glyph_getprop, glyph_putprop,
                                          glyph_remprop, glyph_plist,
                                          struct Lisp_Glyph);
@@ -3206,7 +3234,7 @@ glyph_height_internal (Lisp_Object glyph, Lisp_Object frame_face,
       {
        struct font_metric_info fm;
        Lisp_Object string = XIMAGE_INSTANCE_TEXT_STRING (instance);
-       unsigned char charsets[NUM_LEADING_BYTES];
+       Charset_ID charsets[NUM_LEADING_BYTES];
        struct face_cachel frame_cachel;
        struct face_cachel *cachel;
 
@@ -4101,7 +4129,6 @@ image_instantiator_format_create (void)
   IIFORMAT_HAS_METHOD (formatted_string, validate);
   IIFORMAT_HAS_METHOD (formatted_string, possible_dest_types);
   IIFORMAT_HAS_METHOD (formatted_string, instantiate);
-
   IIFORMAT_VALID_KEYWORD (formatted_string, Q_data, check_valid_string);
 
   /* subwindows */