Mercurial > hg > xemacs-beta
comparison src/glyphs.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | 8eaf7971accc |
children | 2c611d1463a6 |
comparison
equal
deleted
inserted
replaced
184:bcd2674570bf | 185:3d6bfa290dbd |
---|---|
74 DEFINE_IMAGE_INSTANTIATOR_FORMAT (formatted_string); | 74 DEFINE_IMAGE_INSTANTIATOR_FORMAT (formatted_string); |
75 Lisp_Object Qformatted_string; | 75 Lisp_Object Qformatted_string; |
76 | 76 |
77 MAC_DEFINE (struct image_instantiator_methods *, MTiiformat_meth_or_given) | 77 MAC_DEFINE (struct image_instantiator_methods *, MTiiformat_meth_or_given) |
78 | 78 |
79 typedef struct image_instantiator_format_entry image_instantiator_format_entry; | |
79 struct image_instantiator_format_entry | 80 struct image_instantiator_format_entry |
80 { | 81 { |
81 Lisp_Object symbol; | 82 Lisp_Object symbol; |
82 struct image_instantiator_methods *meths; | 83 struct image_instantiator_methods *meths; |
83 }; | 84 }; |
84 | 85 |
85 typedef struct image_instantiator_format_entry_dynarr_type | 86 typedef struct |
86 { | 87 { |
87 Dynarr_declare (struct image_instantiator_format_entry); | 88 Dynarr_declare (struct image_instantiator_format_entry); |
88 } image_instantiator_format_entry_dynarr; | 89 } image_instantiator_format_entry_dynarr; |
89 | 90 |
90 image_instantiator_format_entry_dynarr * | 91 image_instantiator_format_entry_dynarr * |
265 (console_type)) | 266 (console_type)) |
266 { | 267 { |
267 return Fcopy_tree (*get_image_conversion_list (console_type), Qt); | 268 return Fcopy_tree (*get_image_conversion_list (console_type), Qt); |
268 } | 269 } |
269 | 270 |
270 /* Process an string instantiator according to the image-conversion-list for | 271 /* Process a string instantiator according to the image-conversion-list for |
271 CONSOLE_TYPE. Returns a vector. */ | 272 CONSOLE_TYPE. Returns a vector. */ |
272 | 273 |
273 static Lisp_Object | 274 static Lisp_Object |
274 process_image_string_instantiator (Lisp_Object data, | 275 process_image_string_instantiator (Lisp_Object data, |
275 Lisp_Object console_type, | 276 Lisp_Object console_type, |
435 | 436 |
436 Lisp_Object | 437 Lisp_Object |
437 alist_to_tagged_vector (Lisp_Object tag, Lisp_Object alist) | 438 alist_to_tagged_vector (Lisp_Object tag, Lisp_Object alist) |
438 { | 439 { |
439 int len = 1 + 2 * XINT (Flength (alist)); | 440 int len = 1 + 2 * XINT (Flength (alist)); |
440 Lisp_Object *elt = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); | 441 Lisp_Object *elt = alloca_array (Lisp_Object, len); |
441 int i; | 442 int i; |
442 Lisp_Object rest; | 443 Lisp_Object rest; |
443 | 444 |
444 i = 0; | 445 i = 0; |
445 elt[i++] = tag; | 446 elt[i++] = tag; |
613 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))) | 614 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))) |
614 { | 615 { |
615 write_c_string (" @", printcharfun); | 616 write_c_string (" @", printcharfun); |
616 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii))) | 617 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii))) |
617 { | 618 { |
618 sprintf (buf, "%ld", | 619 sprintf (buf, "%ld", |
619 (long) XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii))); | 620 (long) XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii))); |
620 write_c_string (buf, printcharfun); | 621 write_c_string (buf, printcharfun); |
621 } | 622 } |
622 else | 623 else |
623 write_c_string ("??", printcharfun); | 624 write_c_string ("??", printcharfun); |
624 write_c_string (",", printcharfun); | 625 write_c_string (",", printcharfun); |
625 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))) | 626 if (!NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))) |
626 { | 627 { |
627 sprintf (buf, "%ld", | 628 sprintf (buf, "%ld", |
628 (long) XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))); | 629 (long) XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii))); |
629 write_c_string (buf, printcharfun); | 630 write_c_string (buf, printcharfun); |
630 } | 631 } |
631 else | 632 else |
632 write_c_string ("??", printcharfun); | 633 write_c_string ("??", printcharfun); |
781 | 782 |
782 static Lisp_Object | 783 static Lisp_Object |
783 allocate_image_instance (Lisp_Object device) | 784 allocate_image_instance (Lisp_Object device) |
784 { | 785 { |
785 struct Lisp_Image_Instance *lp = | 786 struct Lisp_Image_Instance *lp = |
786 alloc_lcrecord (sizeof (struct Lisp_Image_Instance), | 787 alloc_lcrecord_type (struct Lisp_Image_Instance, lrecord_image_instance); |
787 lrecord_image_instance); | |
788 Lisp_Object val = Qnil; | 788 Lisp_Object val = Qnil; |
789 | 789 |
790 zero_lcrecord (lp); | 790 zero_lcrecord (lp); |
791 lp->device = device; | 791 lp->device = device; |
792 lp->type = IMAGE_NOTHING; | 792 lp->type = IMAGE_NOTHING; |
799 decode_image_instance_type (Lisp_Object type, Error_behavior errb) | 799 decode_image_instance_type (Lisp_Object type, Error_behavior errb) |
800 { | 800 { |
801 if (ERRB_EQ (errb, ERROR_ME)) | 801 if (ERRB_EQ (errb, ERROR_ME)) |
802 CHECK_SYMBOL (type); | 802 CHECK_SYMBOL (type); |
803 | 803 |
804 if (EQ (type, Qnothing)) | 804 if (EQ (type, Qnothing)) return IMAGE_NOTHING; |
805 return IMAGE_NOTHING; | 805 if (EQ (type, Qtext)) return IMAGE_TEXT; |
806 if (EQ (type, Qtext)) | 806 if (EQ (type, Qmono_pixmap)) return IMAGE_MONO_PIXMAP; |
807 return IMAGE_TEXT; | 807 if (EQ (type, Qcolor_pixmap)) return IMAGE_COLOR_PIXMAP; |
808 if (EQ (type, Qmono_pixmap)) | 808 if (EQ (type, Qpointer)) return IMAGE_POINTER; |
809 return IMAGE_MONO_PIXMAP; | 809 if (EQ (type, Qsubwindow)) return IMAGE_SUBWINDOW; |
810 if (EQ (type, Qcolor_pixmap)) | |
811 return IMAGE_COLOR_PIXMAP; | |
812 if (EQ (type, Qpointer)) | |
813 return IMAGE_POINTER; | |
814 if (EQ (type, Qsubwindow)) | |
815 return IMAGE_SUBWINDOW; | |
816 | 810 |
817 maybe_signal_simple_error ("Invalid image-instance type", type, | 811 maybe_signal_simple_error ("Invalid image-instance type", type, |
818 Qimage, errb); | 812 Qimage, errb); |
819 return IMAGE_UNKNOWN; | 813 |
814 return IMAGE_UNKNOWN; /* not reached */ | |
820 } | 815 } |
821 | 816 |
822 static Lisp_Object | 817 static Lisp_Object |
823 encode_image_instance_type (enum image_instance_type type) | 818 encode_image_instance_type (enum image_instance_type type) |
824 { | 819 { |
825 switch (type) | 820 switch (type) |
826 { | 821 { |
827 case IMAGE_NOTHING: | 822 case IMAGE_NOTHING: return Qnothing; |
828 return Qnothing; | 823 case IMAGE_TEXT: return Qtext; |
829 case IMAGE_TEXT: | 824 case IMAGE_MONO_PIXMAP: return Qmono_pixmap; |
830 return Qtext; | 825 case IMAGE_COLOR_PIXMAP: return Qcolor_pixmap; |
831 case IMAGE_MONO_PIXMAP: | 826 case IMAGE_POINTER: return Qpointer; |
832 return Qmono_pixmap; | 827 case IMAGE_SUBWINDOW: return Qsubwindow; |
833 case IMAGE_COLOR_PIXMAP: | |
834 return Qcolor_pixmap; | |
835 case IMAGE_POINTER: | |
836 return Qpointer; | |
837 case IMAGE_SUBWINDOW: | |
838 return Qsubwindow; | |
839 default: | 828 default: |
840 abort (); | 829 abort (); |
841 } | 830 } |
842 | 831 |
843 return Qnil; /* not reached */ | 832 return Qnil; /* not reached */ |
914 } | 903 } |
915 | 904 |
916 static int | 905 static int |
917 valid_image_instance_type_p (Lisp_Object type) | 906 valid_image_instance_type_p (Lisp_Object type) |
918 { | 907 { |
919 if (!NILP (memq_no_quit (type, Vimage_instance_type_list))) | 908 return !NILP (memq_no_quit (type, Vimage_instance_type_list)); |
920 return 1; | |
921 return 0; | |
922 } | 909 } |
923 | 910 |
924 DEFUN ("valid-image-instance-type-p", Fvalid_image_instance_type_p, 1, 1, 0, /* | 911 DEFUN ("valid-image-instance-type-p", Fvalid_image_instance_type_p, 1, 1, 0, /* |
925 Given an IMAGE-INSTANCE-TYPE, return non-nil if it is valid. | 912 Given an IMAGE-INSTANCE-TYPE, return non-nil if it is valid. |
926 Valid types are some subset of 'nothing, 'text, 'mono-pixmap, 'color-pixmap, | 913 Valid types are some subset of 'nothing, 'text, 'mono-pixmap, 'color-pixmap, |
927 'pointer, and 'subwindow, depending on how XEmacs was compiled. | 914 'pointer, and 'subwindow, depending on how XEmacs was compiled. |
928 */ | 915 */ |
929 (image_instance_type)) | 916 (image_instance_type)) |
930 { | 917 { |
931 if (valid_image_instance_type_p (image_instance_type)) | 918 return valid_image_instance_type_p (image_instance_type) ? Qt : Qnil; |
932 return Qt; | |
933 else | |
934 return Qnil; | |
935 } | 919 } |
936 | 920 |
937 DEFUN ("image-instance-type-list", Fimage_instance_type_list, 0, 0, 0, /* | 921 DEFUN ("image-instance-type-list", Fimage_instance_type_list, 0, 0, 0, /* |
938 Return a list of valid image-instance types. | 922 Return a list of valid image-instance types. |
939 */ | 923 */ |
943 } | 927 } |
944 | 928 |
945 Error_behavior | 929 Error_behavior |
946 decode_error_behavior_flag (Lisp_Object no_error) | 930 decode_error_behavior_flag (Lisp_Object no_error) |
947 { | 931 { |
948 if (NILP (no_error)) | 932 if (NILP (no_error)) return ERROR_ME; |
949 return ERROR_ME; | 933 else if (EQ (no_error, Qt)) return ERROR_ME_NOT; |
950 else if (EQ (no_error, Qt)) | 934 else return ERROR_ME_WARN; |
951 return ERROR_ME_NOT; | |
952 else | |
953 return ERROR_ME_WARN; | |
954 } | 935 } |
955 | 936 |
956 Lisp_Object | 937 Lisp_Object |
957 encode_error_behavior_flag (Error_behavior errb) | 938 encode_error_behavior_flag (Error_behavior errb) |
958 { | 939 { |
1028 A child window that is treated as an image. This allows (e.g.) | 1009 A child window that is treated as an image. This allows (e.g.) |
1029 another program to be responsible for drawing into the window. | 1010 another program to be responsible for drawing into the window. |
1030 Not currently implemented. | 1011 Not currently implemented. |
1031 | 1012 |
1032 The DEST-TYPES list is unordered. If multiple destination types | 1013 The DEST-TYPES list is unordered. If multiple destination types |
1033 are possible for a given instantiator, the \"most natural\" type | 1014 are possible for a given instantiator, the "most natural" type |
1034 for the instantiator's format is chosen. (For XBM, the most natural | 1015 for the instantiator's format is chosen. (For XBM, the most natural |
1035 types are `mono-pixmap', followed by `color-pixmap', followed by | 1016 types are `mono-pixmap', followed by `color-pixmap', followed by |
1036 `pointer'. For the other normal image formats, the most natural | 1017 `pointer'. For the other normal image formats, the most natural |
1037 types are `color-pixmap', followed by `mono-pixmap', followed by | 1018 types are `color-pixmap', followed by `mono-pixmap', followed by |
1038 `pointer'. For the string and formatted-string formats, the most | 1019 `pointer'. For the string and formatted-string formats, the most |
1770 etc. This describes the format of the data describing the image. The | 1751 etc. This describes the format of the data describing the image. The |
1771 resulting image instances also come in many types -- `mono-pixmap', | 1752 resulting image instances also come in many types -- `mono-pixmap', |
1772 `color-pixmap', `text', `pointer', etc. This refers to the behavior of | 1753 `color-pixmap', `text', `pointer', etc. This refers to the behavior of |
1773 the image and the sorts of places it can appear. (For example, a | 1754 the image and the sorts of places it can appear. (For example, a |
1774 color-pixmap image has fixed colors specified for it, while a | 1755 color-pixmap image has fixed colors specified for it, while a |
1775 mono-pixmap image comes in two unspecified shades \"foreground\" and | 1756 mono-pixmap image comes in two unspecified shades "foreground" and |
1776 \"background\" that are determined from the face of the glyph or | 1757 "background" that are determined from the face of the glyph or |
1777 surrounding text; a text image appears as a string of text and has an | 1758 surrounding text; a text image appears as a string of text and has an |
1778 unspecified foreground, background, and font; a pointer image behaves | 1759 unspecified foreground, background, and font; a pointer image behaves |
1779 like a mono-pixmap image but can only be used as a mouse pointer | 1760 like a mono-pixmap image but can only be used as a mouse pointer |
1780 \[mono-pixmap images cannot be used as mouse pointers]; etc.) It is | 1761 \[mono-pixmap images cannot be used as mouse pointers]; etc.) It is |
1781 important to keep the distinction between image instantiator format and | 1762 important to keep the distinction between image instantiator format and |
1827 (A PNG/GIF24 image; only if PNG support was compiled into this XEmacs. | 1808 (A PNG/GIF24 image; only if PNG support was compiled into this XEmacs. |
1828 Can be instanced as `color-pixmap'.) | 1809 Can be instanced as `color-pixmap'.) |
1829 'tiff | 1810 'tiff |
1830 (A TIFF image; not currently implemented.) | 1811 (A TIFF image; not currently implemented.) |
1831 'cursor-font | 1812 'cursor-font |
1832 (One of the standard cursor-font names, such as \"watch\" or | 1813 (One of the standard cursor-font names, such as "watch" or |
1833 \"right_ptr\" under X. Under X, this is, more specifically, any | 1814 "right_ptr" under X. Under X, this is, more specifically, any |
1834 of the standard cursor names from appendix B of the Xlib manual | 1815 of the standard cursor names from appendix B of the Xlib manual |
1835 [also known as the file <X11/cursorfont.h>] minus the XC_ prefix. | 1816 [also known as the file <X11/cursorfont.h>] minus the XC_ prefix. |
1836 On other window systems, the valid names will be specific to the | 1817 On other window systems, the valid names will be specific to the |
1837 type of window system. Can only be instanced as `pointer'.) | 1818 type of window system. Can only be instanced as `pointer'.) |
1838 'font | 1819 'font |
1839 (A glyph from a font; i.e. the name of a font, and glyph index into it | 1820 (A glyph from a font; i.e. the name of a font, and glyph index into it |
1840 of the form \"FONT fontname index [[mask-font] mask-index]\". | 1821 of the form "FONT fontname index [[mask-font] mask-index]". |
1841 Currently can only be instanced as `pointer', although this should | 1822 Currently can only be instanced as `pointer', although this should |
1842 probably be fixed.) | 1823 probably be fixed.) |
1843 'subwindow | 1824 'subwindow |
1844 (An embedded X window; not currently implemented.) | 1825 (An embedded X window; not currently implemented.) |
1845 'autodetect | 1826 'autodetect |
1884 :data.) | 1865 :data.) |
1885 :mask-file | 1866 :mask-file |
1886 (For `xbm' and `xface'. This specifies a file containing the mask data. | 1867 (For `xbm' and `xface'. This specifies a file containing the mask data. |
1887 If neither a mask file nor inline mask data is given for an XBM image, | 1868 If neither a mask file nor inline mask data is given for an XBM image, |
1888 and the XBM image comes from a file, XEmacs will look for a mask file | 1869 and the XBM image comes from a file, XEmacs will look for a mask file |
1889 with the same name as the image file but with \"Mask\" or \"msk\" | 1870 with the same name as the image file but with "Mask" or "msk" |
1890 appended. For example, if you specify the XBM file \"left_ptr\" | 1871 appended. For example, if you specify the XBM file "left_ptr" |
1891 [usually located in \"/usr/include/X11/bitmaps\"], the associated | 1872 [usually located in "/usr/include/X11/bitmaps"], the associated |
1892 mask file \"left_ptrmsk\" will automatically be picked up.) | 1873 mask file "left_ptrmsk" will automatically be picked up.) |
1893 :hotspot-x | 1874 :hotspot-x |
1894 :hotspot-y | 1875 :hotspot-y |
1895 (For `xbm' and `xface'. These keywords specify a hotspot if the image | 1876 (For `xbm' and `xface'. These keywords specify a hotspot if the image |
1896 is instantiated as a `pointer'. Note that if the XBM image file | 1877 is instantiated as a `pointer'. Note that if the XBM image file |
1897 specifies a hotspot, it will automatically be picked up if no | 1878 specifies a hotspot, it will automatically be picked up if no |
1988 struct Lisp_Glyph *g1 = XGLYPH (o1); | 1969 struct Lisp_Glyph *g1 = XGLYPH (o1); |
1989 struct Lisp_Glyph *g2 = XGLYPH (o2); | 1970 struct Lisp_Glyph *g2 = XGLYPH (o2); |
1990 | 1971 |
1991 depth++; | 1972 depth++; |
1992 | 1973 |
1993 if (!internal_equal (g1->image, g2->image, depth) || | 1974 return (internal_equal (g1->image, g2->image, depth) && |
1994 !internal_equal (g1->contrib_p, g2->contrib_p, depth) || | 1975 internal_equal (g1->contrib_p, g2->contrib_p, depth) && |
1995 !internal_equal (g1->baseline, g2->baseline, depth) || | 1976 internal_equal (g1->baseline, g2->baseline, depth) && |
1996 !internal_equal (g1->face, g2->face, depth) || | 1977 internal_equal (g1->face, g2->face, depth) && |
1997 plists_differ (g1->plist, g2->plist, 0, 0, depth + 1)) | 1978 !plists_differ (g1->plist, g2->plist, 0, 0, depth + 1)); |
1998 return 0; | |
1999 | |
2000 return 1; | |
2001 } | 1979 } |
2002 | 1980 |
2003 static unsigned long | 1981 static unsigned long |
2004 glyph_hash (Lisp_Object obj, int depth) | 1982 glyph_hash (Lisp_Object obj, int depth) |
2005 { | 1983 { |
2006 struct Lisp_Glyph *g = XGLYPH (obj); | |
2007 | |
2008 depth++; | 1984 depth++; |
2009 | 1985 |
2010 /* No need to hash all of the elements; that would take too long. | 1986 /* No need to hash all of the elements; that would take too long. |
2011 Just hash the most common ones. */ | 1987 Just hash the most common ones. */ |
2012 return HASH2 (internal_hash (g->image, depth), | 1988 return HASH2 (internal_hash (XGLYPH (obj)->image, depth), |
2013 internal_hash (g->face, depth)); | 1989 internal_hash (XGLYPH (obj)->face, depth)); |
2014 } | 1990 } |
2015 | 1991 |
2016 static Lisp_Object | 1992 static Lisp_Object |
2017 glyph_getprop (Lisp_Object obj, Lisp_Object prop) | 1993 glyph_getprop (Lisp_Object obj, Lisp_Object prop) |
2018 { | 1994 { |
2019 struct Lisp_Glyph *g = XGLYPH (obj); | 1995 struct Lisp_Glyph *g = XGLYPH (obj); |
2020 | 1996 |
2021 #define FROB(propprop) \ | 1997 if (EQ (prop, Qimage)) return g->image; |
2022 do { \ | 1998 if (EQ (prop, Qcontrib_p)) return g->contrib_p; |
2023 if (EQ (prop, Q##propprop)) \ | 1999 if (EQ (prop, Qbaseline)) return g->baseline; |
2024 { \ | 2000 if (EQ (prop, Qface)) return g->face; |
2025 return g->propprop; \ | |
2026 } \ | |
2027 } while (0) | |
2028 | |
2029 FROB (image); | |
2030 FROB (contrib_p); | |
2031 FROB (baseline); | |
2032 FROB (face); | |
2033 | |
2034 #undef FROB | |
2035 | 2001 |
2036 return external_plist_get (&g->plist, prop, 0, ERROR_ME); | 2002 return external_plist_get (&g->plist, prop, 0, ERROR_ME); |
2037 } | 2003 } |
2038 | 2004 |
2039 static int | 2005 static int |
2040 glyph_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value) | 2006 glyph_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value) |
2041 { | 2007 { |
2042 struct Lisp_Glyph *g = XGLYPH (obj); | 2008 if ((EQ (prop, Qimage)) || |
2043 | 2009 (EQ (prop, Qcontrib_p)) || |
2044 #define FROB(propprop) \ | 2010 (EQ (prop, Qbaseline))) |
2045 do { \ | 2011 return 0; |
2046 if (EQ (prop, Q##propprop)) \ | |
2047 return 0; \ | |
2048 } while (0) | |
2049 | |
2050 FROB (image); | |
2051 FROB (contrib_p); | |
2052 FROB (baseline); | |
2053 | |
2054 #undef FROB | |
2055 | 2012 |
2056 if (EQ (prop, Qface)) | 2013 if (EQ (prop, Qface)) |
2057 { | 2014 { |
2058 value = Fget_face (value); | 2015 XGLYPH (obj)->face = Fget_face (value); |
2059 g->face = value; | |
2060 return 1; | 2016 return 1; |
2061 } | 2017 } |
2062 | 2018 |
2063 external_plist_put (&g->plist, prop, value, 0, ERROR_ME); | 2019 external_plist_put (&XGLYPH (obj)->plist, prop, value, 0, ERROR_ME); |
2064 return 1; | 2020 return 1; |
2065 } | 2021 } |
2066 | 2022 |
2067 static int | 2023 static int |
2068 glyph_remprop (Lisp_Object obj, Lisp_Object prop) | 2024 glyph_remprop (Lisp_Object obj, Lisp_Object prop) |
2069 { | 2025 { |
2070 struct Lisp_Glyph *g = XGLYPH (obj); | 2026 if ((EQ (prop, Qimage)) || |
2071 | 2027 (EQ (prop, Qcontrib_p)) || |
2072 #define FROB(propprop) \ | 2028 (EQ (prop, Qbaseline))) |
2073 do { \ | 2029 return -1; |
2074 if (EQ (prop, Q##propprop)) \ | |
2075 return -1; \ | |
2076 } while (0) | |
2077 | |
2078 FROB (image); | |
2079 FROB (contrib_p); | |
2080 FROB (baseline); | |
2081 | 2030 |
2082 if (EQ (prop, Qface)) | 2031 if (EQ (prop, Qface)) |
2083 { | 2032 { |
2084 g->face = Qnil; | 2033 XGLYPH (obj)->face = Qnil; |
2085 return 1; | 2034 return 1; |
2086 } | 2035 } |
2087 | 2036 |
2088 #undef FROB | 2037 return external_remprop (&XGLYPH (obj)->plist, prop, 0, ERROR_ME); |
2089 return external_remprop (&g->plist, prop, 0, ERROR_ME); | |
2090 } | 2038 } |
2091 | 2039 |
2092 static Lisp_Object | 2040 static Lisp_Object |
2093 glyph_plist (Lisp_Object obj) | 2041 glyph_plist (Lisp_Object obj) |
2094 { | 2042 { |
2095 struct Lisp_Glyph *g = XGLYPH (obj); | 2043 struct Lisp_Glyph *g = XGLYPH (obj); |
2096 Lisp_Object result = Qnil; | 2044 Lisp_Object result = Qnil; |
2097 | 2045 |
2098 #define FROB(propprop) \ | 2046 /* backwards order; we reverse it below */ |
2099 do { \ | 2047 result = Fcons (g->image, Fcons (Qimage, result)); |
2100 /* backwards order; we reverse it below */ \ | 2048 result = Fcons (g->contrib_p, Fcons (Qcontrib_p, result)); |
2101 result = Fcons (g->propprop, Fcons (Q##propprop, result)); \ | 2049 result = Fcons (g->baseline, Fcons (Qbaseline, result)); |
2102 } while (0) | 2050 result = Fcons (g->face, Fcons (Qface, result)); |
2103 | 2051 |
2104 FROB (image); | |
2105 FROB (contrib_p); | |
2106 FROB (baseline); | |
2107 FROB (face); | |
2108 | |
2109 #undef FROB | |
2110 return nconc2 (Fnreverse (result), g->plist); | 2052 return nconc2 (Fnreverse (result), g->plist); |
2111 } | 2053 } |
2112 | 2054 |
2113 Lisp_Object | 2055 Lisp_Object |
2114 allocate_glyph (enum glyph_type type, | 2056 allocate_glyph (enum glyph_type type, |
2115 void (*after_change) (Lisp_Object glyph, Lisp_Object property, | 2057 void (*after_change) (Lisp_Object glyph, Lisp_Object property, |
2116 Lisp_Object locale)) | 2058 Lisp_Object locale)) |
2117 { | 2059 { |
2118 Lisp_Object obj = Qnil; | 2060 Lisp_Object obj = Qnil; |
2119 struct Lisp_Glyph *g = | 2061 struct Lisp_Glyph *g = |
2120 alloc_lcrecord (sizeof (struct Lisp_Glyph), lrecord_glyph); | 2062 alloc_lcrecord_type (struct Lisp_Glyph, lrecord_glyph); |
2121 | 2063 |
2122 g->type = type; | 2064 g->type = type; |
2123 g->image = Fmake_specifier (Qimage); | 2065 g->image = Fmake_specifier (Qimage); |
2124 switch (g->type) | 2066 switch (g->type) |
2125 { | 2067 { |
2163 return GLYPH_BUFFER; | 2105 return GLYPH_BUFFER; |
2164 | 2106 |
2165 if (ERRB_EQ (errb, ERROR_ME)) | 2107 if (ERRB_EQ (errb, ERROR_ME)) |
2166 CHECK_SYMBOL (type); | 2108 CHECK_SYMBOL (type); |
2167 | 2109 |
2168 if (EQ (type, Qbuffer)) | 2110 if (EQ (type, Qbuffer)) return GLYPH_BUFFER; |
2169 return GLYPH_BUFFER; | 2111 if (EQ (type, Qpointer)) return GLYPH_POINTER; |
2170 if (EQ (type, Qpointer)) | 2112 if (EQ (type, Qicon)) return GLYPH_ICON; |
2171 return GLYPH_POINTER; | |
2172 if (EQ (type, Qicon)) | |
2173 return GLYPH_ICON; | |
2174 | 2113 |
2175 maybe_signal_simple_error ("Invalid glyph type", type, Qimage, errb); | 2114 maybe_signal_simple_error ("Invalid glyph type", type, Qimage, errb); |
2115 | |
2176 return GLYPH_UNKNOWN; | 2116 return GLYPH_UNKNOWN; |
2177 } | 2117 } |
2178 | 2118 |
2179 static int | 2119 static int |
2180 valid_glyph_type_p (Lisp_Object type) | 2120 valid_glyph_type_p (Lisp_Object type) |
2181 { | 2121 { |
2182 if (!NILP (memq_no_quit (type, Vglyph_type_list))) | 2122 return !NILP (memq_no_quit (type, Vglyph_type_list)); |
2183 return 1; | |
2184 return 0; | |
2185 } | 2123 } |
2186 | 2124 |
2187 DEFUN ("valid-glyph-type-p", Fvalid_glyph_type_p, 1, 1, 0, /* | 2125 DEFUN ("valid-glyph-type-p", Fvalid_glyph_type_p, 1, 1, 0, /* |
2188 Given a GLYPH-TYPE, return non-nil if it is valid. | 2126 Given a GLYPH-TYPE, return non-nil if it is valid. |
2189 Valid types are `buffer', `pointer', and `icon'. | 2127 Valid types are `buffer', `pointer', and `icon'. |
2190 */ | 2128 */ |
2191 (glyph_type)) | 2129 (glyph_type)) |
2192 { | 2130 { |
2193 if (valid_glyph_type_p (glyph_type)) | 2131 return valid_glyph_type_p (glyph_type) ? Qt : Qnil; |
2194 return Qt; | |
2195 else | |
2196 return Qnil; | |
2197 } | 2132 } |
2198 | 2133 |
2199 DEFUN ("glyph-type-list", Fglyph_type_list, 0, 0, 0, /* | 2134 DEFUN ("glyph-type-list", Fglyph_type_list, 0, 0, 0, /* |
2200 Return a list of valid glyph types. | 2135 Return a list of valid glyph types. |
2201 */ | 2136 */ |
2252 (glyph)) | 2187 (glyph)) |
2253 { | 2188 { |
2254 CHECK_GLYPH (glyph); | 2189 CHECK_GLYPH (glyph); |
2255 switch (XGLYPH_TYPE (glyph)) | 2190 switch (XGLYPH_TYPE (glyph)) |
2256 { | 2191 { |
2257 case GLYPH_BUFFER: | 2192 case GLYPH_BUFFER: return Qbuffer; |
2258 return Qbuffer; | 2193 case GLYPH_POINTER: return Qpointer; |
2259 case GLYPH_POINTER: | 2194 case GLYPH_ICON: return Qicon; |
2260 return Qpointer; | |
2261 case GLYPH_ICON: | |
2262 return Qicon; | |
2263 default: | 2195 default: |
2264 abort (); | 2196 abort (); |
2265 } | 2197 return Qnil; /* not reached */ |
2266 | 2198 } |
2267 return Qnil; /* not reached */ | |
2268 } | 2199 } |
2269 | 2200 |
2270 /***************************************************************************** | 2201 /***************************************************************************** |
2271 glyph_width | 2202 glyph_width |
2272 | 2203 |
2400 cachel = WINDOW_FACE_CACHEL (XWINDOW (window), window_findex); | 2331 cachel = WINDOW_FACE_CACHEL (XWINDOW (window), window_findex); |
2401 ensure_face_cachel_complete (cachel, window, charsets); | 2332 ensure_face_cachel_complete (cachel, window, charsets); |
2402 | 2333 |
2403 face_cachel_charset_font_metric_info (cachel, charsets, &fm); | 2334 face_cachel_charset_font_metric_info (cachel, charsets, &fm); |
2404 | 2335 |
2405 if (function == RETURN_ASCENT) | 2336 switch (function) |
2406 return fm.ascent; | 2337 { |
2407 else if (function == RETURN_DESCENT) | 2338 case RETURN_ASCENT: return fm.ascent; |
2408 return fm.descent; | 2339 case RETURN_DESCENT: return fm.descent; |
2409 else if (function == RETURN_HEIGHT) | 2340 case RETURN_HEIGHT: return fm.ascent + fm.descent; |
2410 return fm.ascent + fm.descent; | 2341 default: |
2411 else | 2342 abort (); |
2412 abort (); | 2343 return 0; /* not reached */ |
2413 return 0; | 2344 } |
2414 } | 2345 } |
2415 | 2346 |
2416 case IMAGE_MONO_PIXMAP: | 2347 case IMAGE_MONO_PIXMAP: |
2417 case IMAGE_COLOR_PIXMAP: | 2348 case IMAGE_COLOR_PIXMAP: |
2418 case IMAGE_POINTER: | 2349 case IMAGE_POINTER: |
2533 | 2464 |
2534 Lisp_Object | 2465 Lisp_Object |
2535 glyph_face (Lisp_Object glyph, Lisp_Object domain) | 2466 glyph_face (Lisp_Object glyph, Lisp_Object domain) |
2536 { | 2467 { |
2537 /* #### Domain parameter not currently used but it will be */ | 2468 /* #### Domain parameter not currently used but it will be */ |
2538 if (!GLYPHP (glyph)) | 2469 return GLYPHP (glyph) ? GLYPH_FACE (XGLYPH (glyph)) : Qnil; |
2539 return Qnil; | |
2540 else | |
2541 return GLYPH_FACE (XGLYPH (glyph)); | |
2542 } | 2470 } |
2543 | 2471 |
2544 int | 2472 int |
2545 glyph_contrib_p (Lisp_Object glyph, Lisp_Object domain) | 2473 glyph_contrib_p (Lisp_Object glyph, Lisp_Object domain) |
2546 { | 2474 { |
2596 if (NILP (cachel->glyph) || !EQ (cachel->glyph, glyph)) | 2524 if (NILP (cachel->glyph) || !EQ (cachel->glyph, glyph)) |
2597 { | 2525 { |
2598 Lisp_Object window = Qnil; | 2526 Lisp_Object window = Qnil; |
2599 | 2527 |
2600 XSETWINDOW (window, w); | 2528 XSETWINDOW (window, w); |
2601 cachel->glyph = glyph; | |
2602 | |
2603 #define FROB(field) \ | |
2604 do { \ | |
2605 unsigned short new_val = glyph_##field (glyph, Qnil, DEFAULT_INDEX, \ | |
2606 window); \ | |
2607 if (cachel->field != new_val) \ | |
2608 cachel->field = new_val; \ | |
2609 } while (0) | |
2610 | 2529 |
2611 /* #### This could be sped up if we redid things to grab the glyph | 2530 /* #### This could be sped up if we redid things to grab the glyph |
2612 instantiation and passed it to the size functions. */ | 2531 instantiation and passed it to the size functions. */ |
2613 FROB (width); | 2532 cachel->glyph = glyph; |
2614 FROB (ascent); | 2533 cachel->width = glyph_width (glyph, Qnil, DEFAULT_INDEX, window); |
2615 FROB (descent); | 2534 cachel->ascent = glyph_ascent (glyph, Qnil, DEFAULT_INDEX, window); |
2616 #undef FROB | 2535 cachel->descent = glyph_descent (glyph, Qnil, DEFAULT_INDEX, window); |
2617 | |
2618 } | 2536 } |
2619 | 2537 |
2620 cachel->updated = 1; | 2538 cachel->updated = 1; |
2621 } | 2539 } |
2622 | 2540 |
2847 image_instantiator_format_create (void) | 2765 image_instantiator_format_create (void) |
2848 { | 2766 { |
2849 /* image instantiators */ | 2767 /* image instantiators */ |
2850 | 2768 |
2851 the_image_instantiator_format_entry_dynarr = | 2769 the_image_instantiator_format_entry_dynarr = |
2852 Dynarr_new (struct image_instantiator_format_entry); | 2770 Dynarr_new (image_instantiator_format_entry); |
2853 | 2771 |
2854 Vimage_instantiator_format_list = Qnil; | 2772 Vimage_instantiator_format_list = Qnil; |
2855 staticpro (&Vimage_instantiator_format_list); | 2773 staticpro (&Vimage_instantiator_format_list); |
2856 | 2774 |
2857 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (nothing, "nothing"); | 2775 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (nothing, "nothing"); |
2918 | 2836 |
2919 DEFVAR_LISP ("invisible-text-glyph", &Vinvisible_text_glyph /* | 2837 DEFVAR_LISP ("invisible-text-glyph", &Vinvisible_text_glyph /* |
2920 What to use to indicate the presence of invisible text. | 2838 What to use to indicate the presence of invisible text. |
2921 This is the glyph that is displayed when an ellipsis is called for | 2839 This is the glyph that is displayed when an ellipsis is called for |
2922 \(see `selective-display-ellipses' and `buffer-invisibility-spec'). | 2840 \(see `selective-display-ellipses' and `buffer-invisibility-spec'). |
2923 Normally this is three dots (\"...\"). | 2841 Normally this is three dots ("..."). |
2924 */); | 2842 */); |
2925 Vinvisible_text_glyph = allocate_glyph (GLYPH_BUFFER, | 2843 Vinvisible_text_glyph = allocate_glyph (GLYPH_BUFFER, |
2926 redisplay_glyph_changed); | 2844 redisplay_glyph_changed); |
2927 | 2845 |
2928 /* Partially initialized in glyphs.el */ | 2846 /* Partially initialized in glyphs.el */ |