comparison src/xfaces.c @ 25799:1c370ec939da

(load_pixmap): Call add_to_log without frame parameter. (load_face_font_or_fontset, load_color, merge_face_vector_with_property): Ditto. (add_to_log): Move to xdisp.c.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 23 Sep 1999 22:17:44 +0000
parents 1878f7ae0df5
children 2955c353186a
comparison
equal deleted inserted replaced
25798:775d0eca0cc3 25799:1c370ec939da
410 static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int)); 410 static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int));
411 static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); 411 static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *));
412 static char *xstrdup P_ ((char *)); 412 static char *xstrdup P_ ((char *));
413 static unsigned char *xstrlwr P_ ((unsigned char *)); 413 static unsigned char *xstrlwr P_ ((unsigned char *));
414 static void signal_error P_ ((char *, Lisp_Object)); 414 static void signal_error P_ ((char *, Lisp_Object));
415 static void add_to_log P_ ((struct frame *, char *, Lisp_Object, Lisp_Object));
416 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); 415 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int));
417 static void load_face_font_or_fontset P_ ((struct frame *, struct face *, char *, int)); 416 static void load_face_font_or_fontset P_ ((struct frame *, struct face *, char *, int));
418 static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); 417 static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *));
419 static void free_face_colors P_ ((struct frame *, struct face *)); 418 static void free_face_colors P_ ((struct frame *, struct face *));
420 static int face_color_gray_p P_ ((struct frame *, char *)); 419 static int face_color_gray_p P_ ((struct frame *, char *));
591 { 590 {
592 Fsignal (Qerror, Fcons (build_string (s), Fcons (arg, Qnil))); 591 Fsignal (Qerror, Fcons (build_string (s), Fcons (arg, Qnil)));
593 } 592 }
594 593
595 594
596 /* Display a message with format string FORMAT and arguments ARG1 and
597 ARG2 on frame F. Used to display errors if fonts, bitmaps, colors
598 etc. for a realized face on frame F cannot be loaded. (If we would
599 signal an error in these cases, we would end up in an infinite
600 recursion because this would stop realization, and the redisplay
601 triggered by the signal would try to realize that same face again.)
602
603 If basic faces of F are not realized, just add the message to the
604 messages buffer "*Messages*". Because Fmessage calls
605 echo_area_display which tries to realize basic faces again, we would
606 otherwise also end in an infinite recursion. */
607
608 static void
609 add_to_log (f, format, arg1, arg2)
610 struct frame *f;
611 char *format;
612 Lisp_Object arg1, arg2;
613 {
614 Lisp_Object args[3];
615 Lisp_Object nargs;
616 Lisp_Object msg;
617 char *buffer;
618 extern int waiting_for_input;
619
620 /* Function note_mouse_highlight calls face_at_buffer_position which
621 may realize a face. If some attribute of that face is invalid,
622 say an invalid color, don't display an error to avoid calling
623 Lisp from XTread_socket. */
624 if (waiting_for_input)
625 return;
626
627 nargs = make_number (DIM (args));
628 args[0] = build_string (format);
629 args[1] = arg1;
630 args[2] = arg2;
631 msg = Fformat (nargs, args);
632
633 /* Log the error, but don't display it in the echo area. This
634 proves to be annoying in many cases. */
635 buffer = LSTRDUPA (msg);
636 message_dolog (buffer, strlen (buffer), 1, 0);
637 }
638
639
640 /* If FRAME is nil, return a pointer to the selected frame. 595 /* If FRAME is nil, return a pointer to the selected frame.
641 Otherwise, check that FRAME is a live frame, and return a pointer 596 Otherwise, check that FRAME is a live frame, and return a pointer
642 to it. NPARAM is the parameter number of FRAME, for 597 to it. NPARAM is the parameter number of FRAME, for
643 CHECK_LIVE_FRAME. This is here because it's a frequent pattern in 598 CHECK_LIVE_FRAME. This is here because it's a frequent pattern in
644 Lisp function definitions. */ 599 Lisp function definitions. */
952 } 907 }
953 UNBLOCK_INPUT; 908 UNBLOCK_INPUT;
954 909
955 if (bitmap_id < 0) 910 if (bitmap_id < 0)
956 { 911 {
957 add_to_log (f, "Invalid or undefined bitmap %s", name, Qnil); 912 add_to_log ("Invalid or undefined bitmap %s", name, Qnil);
958 bitmap_id = 0; 913 bitmap_id = 0;
959 914
960 if (w_ptr) 915 if (w_ptr)
961 *w_ptr = 0; 916 *w_ptr = 0;
962 if (h_ptr) 917 if (h_ptr)
1070 else 1025 else
1071 face->registry = build_string (s + 1); 1026 face->registry = build_string (s + 1);
1072 } 1027 }
1073 } 1028 }
1074 else if (fontset >= 0) 1029 else if (fontset >= 0)
1075 add_to_log (f, "Unable to load ASCII font of fontset %d", 1030 add_to_log ("Unable to load ASCII font of fontset %d",
1076 make_number (fontset), Qnil); 1031 make_number (fontset), Qnil);
1077 else if (font_name) 1032 else if (font_name)
1078 add_to_log (f, "Unable to load font %s", 1033 add_to_log ("Unable to load font %s",
1079 build_string (font_name), Qnil); 1034 build_string (font_name), Qnil);
1080 } 1035 }
1081 1036
1082 #endif /* HAVE_X_WINDOWS */ 1037 #endif /* HAVE_X_WINDOWS */
1083 1038
1195 1150
1196 /* if the color map is full, defined_color will return a best match 1151 /* if the color map is full, defined_color will return a best match
1197 to the values in an existing cell. */ 1152 to the values in an existing cell. */
1198 if (!defined_color (f, XSTRING (name)->data, &color, 1)) 1153 if (!defined_color (f, XSTRING (name)->data, &color, 1))
1199 { 1154 {
1200 add_to_log (f, "Unable to load color %s", name, Qnil); 1155 add_to_log ("Unable to load color %s", name, Qnil);
1201 1156
1202 switch (target_index) 1157 switch (target_index)
1203 { 1158 {
1204 case LFACE_FOREGROUND_INDEX: 1159 case LFACE_FOREGROUND_INDEX:
1205 face->foreground_defaulted_p = 1; 1160 face->foreground_defaulted_p = 1;
1416 color = call1 (Qmsdos_color_translate, name); 1371 color = call1 (Qmsdos_color_translate, name);
1417 1372
1418 if (INTEGERP (color)) 1373 if (INTEGERP (color))
1419 return (unsigned long)XINT (color); 1374 return (unsigned long)XINT (color);
1420 1375
1421 add_to_log (f, "Unable to load color %s", name, Qnil); 1376 add_to_log ("Unable to load color %s", name, Qnil);
1422 1377
1423 switch (target_index) 1378 switch (target_index)
1424 { 1379 {
1425 case LFACE_FOREGROUND_INDEX: 1380 case LFACE_FOREGROUND_INDEX:
1426 face->foreground_defaulted_p = 1; 1381 face->foreground_defaulted_p = 1;
2850 to[LFACE_FOREGROUND_INDEX] = color_name; 2805 to[LFACE_FOREGROUND_INDEX] = color_name;
2851 else 2806 else
2852 to[LFACE_BACKGROUND_INDEX] = color_name; 2807 to[LFACE_BACKGROUND_INDEX] = color_name;
2853 } 2808 }
2854 else 2809 else
2855 add_to_log (f, "Invalid face color", color_name, Qnil); 2810 add_to_log ("Invalid face color", color_name, Qnil);
2856 } 2811 }
2857 else if (SYMBOLP (first) 2812 else if (SYMBOLP (first)
2858 && *XSYMBOL (first)->name->data == ':') 2813 && *XSYMBOL (first)->name->data == ':')
2859 { 2814 {
2860 /* Assume this is the property list form. */ 2815 /* Assume this is the property list form. */
2866 if (EQ (keyword, QCfamily)) 2821 if (EQ (keyword, QCfamily))
2867 { 2822 {
2868 if (STRINGP (value)) 2823 if (STRINGP (value))
2869 to[LFACE_FAMILY_INDEX] = value; 2824 to[LFACE_FAMILY_INDEX] = value;
2870 else 2825 else
2871 add_to_log (f, "Illegal face font family", value, Qnil); 2826 add_to_log ("Illegal face font family", value, Qnil);
2872 } 2827 }
2873 else if (EQ (keyword, QCheight)) 2828 else if (EQ (keyword, QCheight))
2874 { 2829 {
2875 if (INTEGERP (value)) 2830 if (INTEGERP (value))
2876 to[LFACE_HEIGHT_INDEX] = value; 2831 to[LFACE_HEIGHT_INDEX] = value;
2877 else 2832 else
2878 add_to_log (f, "Illegal face font height", value, Qnil); 2833 add_to_log ("Illegal face font height", value, Qnil);
2879 } 2834 }
2880 else if (EQ (keyword, QCweight)) 2835 else if (EQ (keyword, QCweight))
2881 { 2836 {
2882 if (SYMBOLP (value) 2837 if (SYMBOLP (value)
2883 && face_numeric_weight (value) >= 0) 2838 && face_numeric_weight (value) >= 0)
2884 to[LFACE_WEIGHT_INDEX] = value; 2839 to[LFACE_WEIGHT_INDEX] = value;
2885 else 2840 else
2886 add_to_log (f, "Illegal face weight", value, Qnil); 2841 add_to_log ("Illegal face weight", value, Qnil);
2887 } 2842 }
2888 else if (EQ (keyword, QCslant)) 2843 else if (EQ (keyword, QCslant))
2889 { 2844 {
2890 if (SYMBOLP (value) 2845 if (SYMBOLP (value)
2891 && face_numeric_slant (value) >= 0) 2846 && face_numeric_slant (value) >= 0)
2892 to[LFACE_SLANT_INDEX] = value; 2847 to[LFACE_SLANT_INDEX] = value;
2893 else 2848 else
2894 add_to_log (f, "Illegal face slant", value, Qnil); 2849 add_to_log ("Illegal face slant", value, Qnil);
2895 } 2850 }
2896 else if (EQ (keyword, QCunderline)) 2851 else if (EQ (keyword, QCunderline))
2897 { 2852 {
2898 if (EQ (value, Qt) 2853 if (EQ (value, Qt)
2899 || NILP (value) 2854 || NILP (value)
2900 || STRINGP (value)) 2855 || STRINGP (value))
2901 to[LFACE_UNDERLINE_INDEX] = value; 2856 to[LFACE_UNDERLINE_INDEX] = value;
2902 else 2857 else
2903 add_to_log (f, "Illegal face underline", value, Qnil); 2858 add_to_log ("Illegal face underline", value, Qnil);
2904 } 2859 }
2905 else if (EQ (keyword, QCoverline)) 2860 else if (EQ (keyword, QCoverline))
2906 { 2861 {
2907 if (EQ (value, Qt) 2862 if (EQ (value, Qt)
2908 || NILP (value) 2863 || NILP (value)
2909 || STRINGP (value)) 2864 || STRINGP (value))
2910 to[LFACE_OVERLINE_INDEX] = value; 2865 to[LFACE_OVERLINE_INDEX] = value;
2911 else 2866 else
2912 add_to_log (f, "Illegal face overline", value, Qnil); 2867 add_to_log ("Illegal face overline", value, Qnil);
2913 } 2868 }
2914 else if (EQ (keyword, QCstrike_through)) 2869 else if (EQ (keyword, QCstrike_through))
2915 { 2870 {
2916 if (EQ (value, Qt) 2871 if (EQ (value, Qt)
2917 || NILP (value) 2872 || NILP (value)
2918 || STRINGP (value)) 2873 || STRINGP (value))
2919 to[LFACE_STRIKE_THROUGH_INDEX] = value; 2874 to[LFACE_STRIKE_THROUGH_INDEX] = value;
2920 else 2875 else
2921 add_to_log (f, "Illegal face strike-through", value, Qnil); 2876 add_to_log ("Illegal face strike-through", value, Qnil);
2922 } 2877 }
2923 else if (EQ (keyword, QCbox)) 2878 else if (EQ (keyword, QCbox))
2924 { 2879 {
2925 if (EQ (value, Qt)) 2880 if (EQ (value, Qt))
2926 value = make_number (1); 2881 value = make_number (1);
2928 || STRINGP (value) 2883 || STRINGP (value)
2929 || CONSP (value) 2884 || CONSP (value)
2930 || NILP (value)) 2885 || NILP (value))
2931 to[LFACE_BOX_INDEX] = value; 2886 to[LFACE_BOX_INDEX] = value;
2932 else 2887 else
2933 add_to_log (f, "Illegal face box", value, Qnil); 2888 add_to_log ("Illegal face box", value, Qnil);
2934 } 2889 }
2935 else if (EQ (keyword, QCinverse_video) 2890 else if (EQ (keyword, QCinverse_video)
2936 || EQ (keyword, QCreverse_video)) 2891 || EQ (keyword, QCreverse_video))
2937 { 2892 {
2938 if (EQ (value, Qt) || NILP (value)) 2893 if (EQ (value, Qt) || NILP (value))
2939 to[LFACE_INVERSE_INDEX] = value; 2894 to[LFACE_INVERSE_INDEX] = value;
2940 else 2895 else
2941 add_to_log (f, "Illegal face inverse-video", value, Qnil); 2896 add_to_log ("Illegal face inverse-video", value, Qnil);
2942 } 2897 }
2943 else if (EQ (keyword, QCforeground)) 2898 else if (EQ (keyword, QCforeground))
2944 { 2899 {
2945 if (STRINGP (value)) 2900 if (STRINGP (value))
2946 to[LFACE_FOREGROUND_INDEX] = value; 2901 to[LFACE_FOREGROUND_INDEX] = value;
2947 else 2902 else
2948 add_to_log (f, "Illegal face foreground", value, Qnil); 2903 add_to_log ("Illegal face foreground", value, Qnil);
2949 } 2904 }
2950 else if (EQ (keyword, QCbackground)) 2905 else if (EQ (keyword, QCbackground))
2951 { 2906 {
2952 if (STRINGP (value)) 2907 if (STRINGP (value))
2953 to[LFACE_BACKGROUND_INDEX] = value; 2908 to[LFACE_BACKGROUND_INDEX] = value;
2954 else 2909 else
2955 add_to_log (f, "Illegal face background", value, Qnil); 2910 add_to_log ("Illegal face background", value, Qnil);
2956 } 2911 }
2957 else if (EQ (keyword, QCstipple)) 2912 else if (EQ (keyword, QCstipple))
2958 { 2913 {
2959 #ifdef HAVE_X_WINDOWS 2914 #ifdef HAVE_X_WINDOWS
2960 Lisp_Object pixmap_p = Fpixmap_spec_p (value); 2915 Lisp_Object pixmap_p = Fpixmap_spec_p (value);
2961 if (!NILP (pixmap_p)) 2916 if (!NILP (pixmap_p))
2962 to[LFACE_STIPPLE_INDEX] = value; 2917 to[LFACE_STIPPLE_INDEX] = value;
2963 else 2918 else
2964 add_to_log (f, "Illegal face stipple", value, Qnil); 2919 add_to_log ("Illegal face stipple", value, Qnil);
2965 #endif 2920 #endif
2966 } 2921 }
2967 else if (EQ (keyword, QCwidth)) 2922 else if (EQ (keyword, QCwidth))
2968 { 2923 {
2969 if (SYMBOLP (value) 2924 if (SYMBOLP (value)
2970 && face_numeric_swidth (value) >= 0) 2925 && face_numeric_swidth (value) >= 0)
2971 to[LFACE_SWIDTH_INDEX] = value; 2926 to[LFACE_SWIDTH_INDEX] = value;
2972 else 2927 else
2973 add_to_log (f, "Illegal face width", value, Qnil); 2928 add_to_log ("Illegal face width", value, Qnil);
2974 } 2929 }
2975 else 2930 else
2976 add_to_log (f, "Invalid attribute %s in face property", 2931 add_to_log ("Invalid attribute %s in face property",
2977 keyword, Qnil); 2932 keyword, Qnil);
2978 2933
2979 prop = XCDR (XCDR (prop)); 2934 prop = XCDR (XCDR (prop));
2980 } 2935 }
2981 } 2936 }
2994 else 2949 else
2995 { 2950 {
2996 /* PROP ought to be a face name. */ 2951 /* PROP ought to be a face name. */
2997 Lisp_Object lface = lface_from_face_name (f, prop, 0); 2952 Lisp_Object lface = lface_from_face_name (f, prop, 0);
2998 if (NILP (lface)) 2953 if (NILP (lface))
2999 add_to_log (f, "Invalid face text property value: %s", prop, Qnil); 2954 add_to_log ("Invalid face text property value: %s", prop, Qnil);
3000 else 2955 else
3001 merge_face_vectors (XVECTOR (lface)->contents, to); 2956 merge_face_vectors (XVECTOR (lface)->contents, to);
3002 } 2957 }
3003 } 2958 }
3004 2959