annotate src/objects.c @ 872:79c6ff3eef26

[xemacs-hg @ 2002-06-20 21:18:01 by ben] font changes etc.; some 21.4 changes mule/mule-msw-init-late.el: Specify charset->windows-registry conversion. mule/mule-x-init.el: Delete extra mule font additions here. Put them in faces.c. cl-macs.el: Document better. font-lock.el: Move Lisp function regexp to lisp-mode.el. lisp-mode.el: Various indentation fixes: Handle flet functions better. Handle argument lists in defuns and flets. Handle quoted lists, e.g. property lists -- don't indent like function calls. Distinguish between lambdas and other lists. lisp-mode.el: Handle this form. faces.el, font-menu.el, font.el, gtk-faces.el, msw-faces.el, msw-font-menu.el, x-faces.el, x-init.el: Major overhaul of face-handling code: -- Fix lots of bogus code in msw-faces.el, msw-font-menu.el, font-menu.el that was "truenaming" font specs -- i.e. in the process of frobbing a particular field in a general user-specified font spec with wildcarded fields, sticking in particular values for all the remaining wildcarded fields. This bug was rampant everywhere except in x-faces.el (the oldest and only correctly written code). This also means that we need to work with font names at all times and not font instances, because a font instance is essentially a truenamed font. -- Total rewrite of extremely junky code in msw-faces.el. Work with names as well as font instances, and return names; stop truenaming when canonicalizing and frobbing; fix handling of the combined style field, i.e. weight/slant (also fixed in font.el). -- Totally rewrite the frobbing functions in faces.el. This time, we frob all the instantiators rather than just computing a single instance value and working backwards. That way, e.g., `bold' will work for all charsets that have bold available, rather than only for whatever charset was part of the computed font instance (another example of the truename virus). Also fix up code to look at the fallbacks (all of them) when no global value present, so we don't need to put something in the global value. Intelligently handle a request to frob a buffer locale, rather than signalling an error. When frobbing instantiators, try hard to figure out what device type is associated with them, and frob each according to its own proper device type. Correctly handle inheritance vectors given as instantiators. Preserve existing tags when putting back frobbed instantiators. Extract out general specifier-frobbing code into specifier.el. Document everything cleanly. Do lots of other things better, etc. -- Don't duplicatively set a global specification for the default font -- it's already in the fallback and we no longer need a default global specification present. Delete various code in x-faces.el and msw-faces.el that duplicated the lists of fonts in faces.c. -- init-global-faces was not being called at all under MS Windows! Major bogosity. That caused device-specific values to get stuck into all the fonts, making it very hard to change them -- setting global specs caused nothing to happen. -- Correct weight names in font.el. -- Lots more font fixups in objects*.c. Printer.el: Warning fix. specifier.el: Add more args to map-specifier. Add various "heuristic" specifier functions to aid in creation of specifier-munging code such as in faces.el. subr.el: New functions. lwlib.c: Fix warning. config.inc.samp: Clean up, add args to control fastcall (not yet supported! the changes needed are in another ws of mine), profile support, vc6 support, union-type. xemacs.dsp, xemacs.mak: Semi-major overhaul. Fix bug where dump-id was always getting recomputed, forcing a redump even when nothing changed. Add support for fastcall. Support edit-and-continue (on by default) with vc6. Use incremental linking when doing a debug compilation. Add support for profiling. Consolidate the various debug flags. Partial support for "batch-compiling" -- compiling many files on a single invocation of the compiler. Doesn't seem to help that much for me, so it's not finished or enabled by default. Remove HAVE_MSW_C_DIRED, we always do. Correct some sloppy use of directories. s/cygwin32.h: Allow pdump to work under Cygwin (mmap is broken, so need to undefine HAVE_MMAP). s/win32-common.h, s/windowsnt.h: Support for fastcall. Add WIN32_ANY for identifying all Win32 variants (Cygwin, native, MinGW). Both of these are properly used in another ws. alloc.c, balloon-x.c, buffer.c, bytecode.c, callint.c, cm.c, cmdloop.c, cmds.c, console-gtk.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-stream.h, console-tty.c, console-tty.h, console-x.c, console-x.h, console.c, console.h, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, device.h, devslots.h, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, editfns.c, emacs.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.c, extents.c, extents.h, faces.c, fileio.c, fns.c, frame-gtk.c, frame-msw.c, frame-tty.c, frame-x.c, frame.c, frame.h, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gui-gtk.c, gui-msw.c, gui-x.c, gui.c, gutter.c, input-method-xlib.c, intl-encap-win32.c, intl-win32.c, keymap.c, lisp.h, macros.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, menubar.h, minibuf.c, mule-charset.c, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-msw.h, objects-tty.c, objects-tty.h, objects-x.c, objects-x.h, objects.c, objects.h, postgresql.c, print.c, process.h, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, select-gtk.c, select-msw.c, select-x.c, select.c, signal.c, sound.c, specifier.c, symbols.c, syntax.c, sysdep.c, syssignal.h, syswindows.h, toolbar-common.c, toolbar-gtk.c, toolbar-msw.c, toolbar-x.c, toolbar.c, unicode.c, window.c, window.h: The following are the major changes made: (1) Separation of various header files into an external and an internal version, similar to the existing separation of process.h and procimpl.h. Eventually this should be done for all Lisp objects. The external version has the same name as currently; the internal adds -impl. The external file has XFOO() macros for objects, but the structure is opaque and defined only in the internal file. It's now reasonable to move all prototypes in lisp.h into the appropriate external file, and this should be done. Currently, separation has been done on extents.h, objects*.h, console.h, device.h, frame.h, and window.h. For c/d/f/w, the most basic properties are available in the external header file, with the macros resolving to functions. In the internal header file, the macros are redefined to directly access the structure. Also, the global MARK_FOO_CHANGED macros have been made into functions so that they can be accessed without needing to include lots of -impl headers -- they are used in almost exclusively in non-time-critical functions, and take up enough time that the function overhead will be negligible. Similarly, the function overhead from making the basic properties mentioned above into functions is negligible, and code that does heavy accessing of c/d/f/w structures inevitably ends up needing the internal header files, anyway. (2) More face changes. -- Major rewrite of objects-msw.c. Now handles wildcard specs properly, rather than "truenaming" (or even worse, signalling an error, which previously happened with some of the fallbacks if you tried to use them in make-font-instance!). -- Split charset matching of fonts into two stages -- one to find a font specifically designed for a particular charset (by examining its registry), the second to find a Unicode font that can support the charset. This needs to proceed as two complete, separate instantiations in order to work properly (otherwise many of the fonts in the HELLO page look wrong). This should also make it easy to support iso10646 (Unicode) fonts under X. -- All default values for fonts are now completely specified in the fallbacks. Stuff from mule-x-init.el has all been moved here, merged with the existing specs, and totally rethought so you get sensible results. (HELLO now looks much better!). -- Generalize the "default X/GTK device" stuff into a per-device-type "default device". -- Add mswindows-{set-}charset-registry. In time, charset<->code-page conversion functions will be removed. -- Wrap protective code around calls to compute device specifier tags, and do this computation before calling the face initialization code because the latter may need these tags to be correctly updated. (3) Other changes. EmacsFrame.c, glyphs-msw.c, eval.c, gui-x.c, intl-encap-win32.c, search.c, signal.c, toolbar-msw.c, unicode.c: Warning fixes. config.h.in: #undefs meant to be frobbed by configure *MUST* go inside of #ifndef WIN32_NO_CONFIGURE, and everything else *MUST* go outside! eval.c: Let detailed backtraces be detailed. specifier.c: Don't override user's print-string-length/print-length settings. glyphs.c: New function image-instance-instantiator. config.h.in, sysdep.c: Changes for fastcall. sysdep.c, nt.c: Fix up a previous botched patch that tried to add support for both EEXIST and EACCES. IF THE BOTCHED PATCH WENT INTO 21.4, THIS FIXUP NEEDS TO GO IN, TOO. search.c: Fix *evil* crash due to incorrect synching of syntax-cache code with 21.1. THIS SHOULD GO INTO 21.4.
author ben
date Thu, 20 Jun 2002 21:19:10 +0000
parents 804517e16990
children d4ba25667ff4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Generic Objects and Functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
4 Copyright (C) 1995, 1996, 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
28 #include "buffer.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
29 #include "device-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "elhash.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "faces.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "frame.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
33 #include "glyphs.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
34 #include "objects-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "specifier.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 /* Objects that are substituted when an instantiation fails.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 If we leave in the Qunbound value, we will probably get crashes. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 /* Authors: Ben Wing, Chuck Thompson */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 finalose (void *ptr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
47 Lisp_Object obj = wrap_pointer_1 (ptr);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
48
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
50 invalid_operation
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 ("Can't dump an emacs containing window system objects", obj);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 /****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 * Color-Instance Object *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 Lisp_Object Qcolor_instancep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 mark_color_instance (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
64 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 mark_object (c->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 if (!NILP (c->device)) /* Vthe_null_color_instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 MAYBE_DEVMETH (XDEVICE (c->device), mark_color_instance, (c));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 return c->device;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 print_color_instance (Lisp_Object obj, Lisp_Object printcharfun,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
76 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 if (print_readably)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
78 printing_unreadable_object ("#<color-instance 0x%x>",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 c->header.uid);
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
80 write_fmt_string_lisp (printcharfun, "#<color-instance %s", 1, c->name);
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
81 write_fmt_string_lisp (printcharfun, " on %s", 1, c->device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 if (!NILP (c->device)) /* Vthe_null_color_instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 (c, printcharfun, escapeflag));
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
85 write_fmt_string (printcharfun, " 0x%x>", c->header.uid);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 finalize_color_instance (void *header, int for_disksave)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
91 Lisp_Color_Instance *c = (Lisp_Color_Instance *) header;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 if (!NILP (c->device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 if (for_disksave) finalose (c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 MAYBE_DEVMETH (XDEVICE (c->device), finalize_color_instance, (c));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 color_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
103 Lisp_Color_Instance *c1 = XCOLOR_INSTANCE (obj1);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
104 Lisp_Color_Instance *c2 = XCOLOR_INSTANCE (obj2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 return (c1 == c2) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 (EQ (c1->device, c2->device) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 DEVICEP (c1->device) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 HAS_DEVMETH_P (XDEVICE (c1->device), color_instance_equal) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 DEVMETH (XDEVICE (c1->device), color_instance_equal, (c1, c2, depth)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 static unsigned long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 color_instance_hash (Lisp_Object obj, int depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
116 Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 struct device *d = DEVICEP (c->device) ? XDEVICE (c->device) : 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 return HASH2 ((unsigned long) d,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 !d ? LISP_HASH (obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 LISP_HASH (obj)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 mark_color_instance, print_color_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 finalize_color_instance, color_instance_equal,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 color_instance_hash, 0,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
129 Lisp_Color_Instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 Return a new `color-instance' object named NAME (a string).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 Optional argument DEVICE specifies the device this object applies to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 and defaults to the selected device.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 An error is signaled if the color is unknown or cannot be allocated;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
138 however, if optional argument NOERROR is non-nil, nil is simply
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
139 returned in this case. (And if NOERROR is other than t, a warning may
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 be issued.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 The returned object is a normal, first-class lisp object. The way you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 `deallocate' the color is the way you deallocate any other lisp object:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 you drop all pointers to it and allow it to be garbage collected. When
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 these objects are GCed, the underlying window-system data (e.g. X object)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 is deallocated as well.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
148 (name, device, noerror))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
150 Lisp_Color_Instance *c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 int retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 CHECK_STRING (name);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
154 device = wrap_device (decode_device (device));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
156 c = alloc_lcrecord_type (Lisp_Color_Instance, &lrecord_color_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 c->name = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 c->device = device;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 c->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (c, name, device,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
163 decode_error_behavior_flag (noerror)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 if (!retval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
167 return wrap_color_instance (c);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 DEFUN ("color-instance-p", Fcolor_instance_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 Return non-nil if OBJECT is a color instance.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 return COLOR_INSTANCEP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 DEFUN ("color-instance-name", Fcolor_instance_name, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 Return the name used to allocate COLOR-INSTANCE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (color_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 CHECK_COLOR_INSTANCE (color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 return XCOLOR_INSTANCE (color_instance)->name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 DEFUN ("color-instance-rgb-components", Fcolor_instance_rgb_components, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 Return a three element list containing the red, green, and blue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 color components of COLOR-INSTANCE, or nil if unknown.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 Component values range from 0 to 65535.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (color_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
194 Lisp_Color_Instance *c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 CHECK_COLOR_INSTANCE (color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 c = XCOLOR_INSTANCE (color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 if (NILP (c->device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 return MAYBE_LISP_DEVMETH (XDEVICE (c->device),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 color_instance_rgb_components,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (c));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 DEFUN ("valid-color-name-p", Fvalid_color_name_p, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 Return true if COLOR names a valid color for the current device.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 Valid color names for X are listed in the file /usr/lib/X11/rgb.txt, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 whatever the equivalent is on your system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 Valid color names for TTY are those which have an ISO 6429 (ANSI) sequence.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 In addition to being a color this may be one of a number of attributes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 such as `blink'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 (color, device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 struct device *d = decode_device (device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 CHECK_STRING (color);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 return MAYBE_INT_DEVMETH (d, valid_color_name_p, (d, color)) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 /***************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 * Font-Instance Object *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 ***************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 Lisp_Object Qfont_instancep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 static Lisp_Object font_instance_truename_internal (Lisp_Object xfont,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
233 Error_Behavior errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 mark_font_instance (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
238 Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 mark_object (f->name);
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
241 mark_object (f->truename);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 if (!NILP (f->device)) /* Vthe_null_font_instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 MAYBE_DEVMETH (XDEVICE (f->device), mark_font_instance, (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 return f->device;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 print_font_instance (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
251 Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 if (print_readably)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
253 printing_unreadable_object ("#<font-instance 0x%x>", f->header.uid);
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
254 write_fmt_string_lisp (printcharfun, "#<font-instance %S", 1, f->name);
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
255 write_fmt_string_lisp (printcharfun, " on %s", 1, f->device);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 if (!NILP (f->device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 MAYBE_DEVMETH (XDEVICE (f->device), print_font_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 (f, printcharfun, escapeflag));
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
259 write_fmt_string (printcharfun, " 0x%x>", f->header.uid);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 finalize_font_instance (void *header, int for_disksave)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
265 Lisp_Font_Instance *f = (Lisp_Font_Instance *) header;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 if (!NILP (f->device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 if (for_disksave) finalose (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 MAYBE_DEVMETH (XDEVICE (f->device), finalize_font_instance, (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 /* Fonts are equal if they resolve to the same name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 Since we call `font-truename' to do this, and since font-truename is lazy,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 this means the `equal' could cause XListFonts to be run the first time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 font_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 /* #### should this be moved into a device method? */
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
282 return internal_equal (font_instance_truename_internal
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
283 (obj1, ERROR_ME_DEBUG_WARN),
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
284 font_instance_truename_internal
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
285 (obj2, ERROR_ME_DEBUG_WARN),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 depth + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 static unsigned long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 font_instance_hash (Lisp_Object obj, int depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
292 return internal_hash (font_instance_truename_internal
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
293 (obj, ERROR_ME_DEBUG_WARN),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 depth + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 DEFINE_LRECORD_IMPLEMENTATION ("font-instance", font_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 mark_font_instance, print_font_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 finalize_font_instance, font_instance_equal,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
300 font_instance_hash, 0, Lisp_Font_Instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 DEFUN ("make-font-instance", Fmake_font_instance, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 Return a new `font-instance' object named NAME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 DEVICE specifies the device this object applies to and defaults to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 selected device. An error is signalled if the font is unknown or cannot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 be allocated; however, if NOERROR is non-nil, nil is simply returned in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 this case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 The returned object is a normal, first-class lisp object. The way you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 `deallocate' the font is the way you deallocate any other lisp object:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 you drop all pointers to it and allow it to be garbage collected. When
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 these objects are GCed, the underlying X data is deallocated as well.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
314 (name, device, noerror))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
316 Lisp_Font_Instance *f;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 int retval = 0;
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
318 Error_Behavior errb = decode_error_behavior_flag (noerror);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 if (ERRB_EQ (errb, ERROR_ME))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 CHECK_STRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 else if (!STRINGP (name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
325 device = wrap_device (decode_device (device));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
327 f = alloc_lcrecord_type (Lisp_Font_Instance, &lrecord_font_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 f->name = name;
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
329 f->truename = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 f->device = device;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 f->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 /* Stick some default values here ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 f->ascent = f->height = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 f->descent = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 f->width = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 f->proportional_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_font_instance,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (f, name, device, errb));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 if (!retval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
346 return wrap_font_instance (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 DEFUN ("font-instance-p", Ffont_instance_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 Return non-nil if OBJECT is a font instance.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 return FONT_INSTANCEP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 DEFUN ("font-instance-name", Ffont_instance_name, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 Return the name used to allocate FONT-INSTANCE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 CHECK_FONT_INSTANCE (font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 return XFONT_INSTANCE (font_instance)->name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 DEFUN ("font-instance-ascent", Ffont_instance_ascent, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 Return the ascent in pixels of FONT-INSTANCE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 The returned value is the maximum ascent for all characters in the font,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 where a character's ascent is the number of pixels above (and including)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 the baseline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 CHECK_FONT_INSTANCE (font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 return make_int (XFONT_INSTANCE (font_instance)->ascent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 DEFUN ("font-instance-descent", Ffont_instance_descent, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 Return the descent in pixels of FONT-INSTANCE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 The returned value is the maximum descent for all characters in the font,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 where a character's descent is the number of pixels below the baseline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 \(Many characters to do not have any descent. Typical characters with a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 descent are lowercase p and lowercase g.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 (font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 CHECK_FONT_INSTANCE (font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 return make_int (XFONT_INSTANCE (font_instance)->descent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 DEFUN ("font-instance-width", Ffont_instance_width, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 Return the width in pixels of FONT-INSTANCE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 The returned value is the average width for all characters in the font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 CHECK_FONT_INSTANCE (font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 return make_int (XFONT_INSTANCE (font_instance)->width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 DEFUN ("font-instance-proportional-p", Ffont_instance_proportional_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 Return whether FONT-INSTANCE is proportional.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 This means that different characters in the font have different widths.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 CHECK_FONT_INSTANCE (font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 return XFONT_INSTANCE (font_instance)->proportional_p ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 font_instance_truename_internal (Lisp_Object font_instance,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
413 Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
415 Lisp_Font_Instance *f = XFONT_INSTANCE (font_instance);
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
416
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 if (NILP (f->device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
419 maybe_signal_error (Qgui_error, "Couldn't determine font truename",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
420 font_instance, Qfont, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
423
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 return DEVMETH_OR_GIVEN (XDEVICE (f->device),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 font_instance_truename, (f, errb), f->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 DEFUN ("font-instance-truename", Ffont_instance_truename, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 Return the canonical name of FONT-INSTANCE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 Font names are patterns which may match any number of fonts, of which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 the first found is used. This returns an unambiguous name for that font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 \(but not necessarily its only unambiguous name).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 CHECK_FONT_INSTANCE (font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 return font_instance_truename_internal (font_instance, ERROR_ME);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 DEFUN ("font-instance-properties", Ffont_instance_properties, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 Return the properties (an alist or nil) of FONT-INSTANCE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (font_instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
445 Lisp_Font_Instance *f;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 CHECK_FONT_INSTANCE (font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 f = XFONT_INSTANCE (font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 if (NILP (f->device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 return MAYBE_LISP_DEVMETH (XDEVICE (f->device),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 font_instance_properties, (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 DEFUN ("list-fonts", Flist_fonts, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 Return a list of font names matching the given pattern.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 DEVICE specifies which device to search for names, and defaults to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 currently selected device.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (pattern, device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 CHECK_STRING (pattern);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
465 device = wrap_device (decode_device (device));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 return MAYBE_LISP_DEVMETH (XDEVICE (device), list_fonts, (pattern, device));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 /****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 Color Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 ***************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 DEFINE_SPECIFIER_TYPE (color);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 /* Qcolor defined in general.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 color_create (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
480 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 COLOR_SPECIFIER_FACE (color) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 COLOR_SPECIFIER_FACE_PROPERTY (color) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 color_mark (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
489 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 mark_object (COLOR_SPECIFIER_FACE (color));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 mark_object (COLOR_SPECIFIER_FACE_PROPERTY (color));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 /* No equal or hash methods; ignore the face the color is based off
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 of for `equal' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 color_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 Lisp_Object domain, Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 Lisp_Object depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 /* When called, we're inside of call_with_suspended_errors(),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 so we can freely error. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
505 Lisp_Object device = DOMAIN_DEVICE (domain);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 struct device *d = XDEVICE (device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 if (COLOR_INSTANCEP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 /* If we are on the same device then we're done. Otherwise change
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 the instantiator to the name used to generate the pixel and let the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 STRINGP case deal with it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 if (NILP (device) /* Vthe_null_color_instance */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 || EQ (device, XCOLOR_INSTANCE (instantiator)->device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 return instantiator;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 instantiator = Fcolor_instance_name (instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 if (STRINGP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 /* First, look to see if we can retrieve a cached value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 Lisp_Object instance =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 Fgethash (instantiator, d->color_instance_cache, Qunbound);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 /* Otherwise, make a new one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 if (UNBOUNDP (instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 /* make sure we cache the failures, too. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 instance = Fmake_color_instance (instantiator, device, Qt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 Fputhash (instantiator, instance, d->color_instance_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 return NILP (instance) ? Qunbound : instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 else if (VECTORP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 switch (XVECTOR_LENGTH (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 if (DEVICE_TTY_P (d))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 return Vthe_null_color_instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
543 gui_error ("Color instantiator [] only valid on TTY's",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier))))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
548 gui_error ("Color specifier not attached to a face",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 return (FACE_PROPERTY_INSTANCE_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 (Fget_face (XVECTOR_DATA (instantiator)[0]),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 domain, ERROR_ME, 0, depth));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 case 2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 return (FACE_PROPERTY_INSTANCE_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 (Fget_face (XVECTOR_DATA (instantiator)[0]),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 XVECTOR_DATA (instantiator)[1], domain, ERROR_ME, 0, depth));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 else if (NILP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 if (DEVICE_TTY_P (d))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 return Vthe_null_color_instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
569 gui_error ("Color instantiator [] only valid on TTY's",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 abort (); /* The spec validation routines are screwed up. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 color_validate (Lisp_Object instantiator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 if (COLOR_INSTANCEP (instantiator) || STRINGP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 if (VECTORP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 if (XVECTOR_LENGTH (instantiator) > 2)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
586 sferror ("Inheritance vector must be of size 0 - 2",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 else if (XVECTOR_LENGTH (instantiator) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 Fget_face (face);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 if (XVECTOR_LENGTH (instantiator) == 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 Lisp_Object field = XVECTOR_DATA (instantiator)[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 if (!EQ (field, Qforeground) && !EQ (field, Qbackground))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
597 invalid_constant
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 ("Inheritance field must be `foreground' or `background'",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 field);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
604 invalid_argument ("Invalid color instantiator", instantiator);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 color_after_change (Lisp_Object specifier, Lisp_Object locale)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 Lisp_Object face = COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 Lisp_Object property =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 if (!NILP (face))
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
614 {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
615 face_property_was_changed (face, property, locale);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
616 if (BUFFERP (locale))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
617 XBUFFER (locale)->buffer_local_face_property = 1;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
618 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 set_color_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
624 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 COLOR_SPECIFIER_FACE (color) = face;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 COLOR_SPECIFIER_FACE_PROPERTY (color) = property;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 DEFUN ("color-specifier-p", Fcolor_specifier_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 Return t if OBJECT is a color specifier.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 See `make-color-specifier' for a description of possible color instantiators.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 return COLOR_SPECIFIERP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 /****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 Font Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 ***************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 DEFINE_SPECIFIER_TYPE (font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 /* Qfont defined in general.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 font_create (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
650 Lisp_Specifier *font = XFONT_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 FONT_SPECIFIER_FACE (font) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 FONT_SPECIFIER_FACE_PROPERTY (font) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 font_mark (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
659 Lisp_Specifier *font = XFONT_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 mark_object (FONT_SPECIFIER_FACE (font));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 mark_object (FONT_SPECIFIER_FACE_PROPERTY (font));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 /* No equal or hash methods; ignore the face the font is based off
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 of for `equal' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
670 /* Given a truename font spec (i.e. the font spec should have its registry
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
671 field filled in), does it support displaying characters from CHARSET? */
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
672
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
673 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 font_spec_matches_charset (struct device *d, Lisp_Object charset,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
675 const Ibyte *nonreloc, Lisp_Object reloc,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
676 Bytecount offset, Bytecount length,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
677 int stage)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 return DEVMETH_OR_GIVEN (d, font_spec_matches_charset,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
680 (d, charset, nonreloc, reloc, offset, length,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
681 stage),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 font_validate_matchspec (Lisp_Object matchspec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
688 CHECK_CONS (matchspec);
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
689 Fget_charset (XCAR (matchspec));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
694 void
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
695 initialize_charset_font_caches (struct device *d)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
696 {
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
697 /* Note that the following tables are bi-level. */
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
698 d->charset_font_cache_stage_1 =
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
699 make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
700 d->charset_font_cache_stage_2 =
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
701 make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
702 }
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
703
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
704 void
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
705 invalidate_charset_font_caches (Lisp_Object charset)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
706 {
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
707 /* Invalidate font cache entries for charset on all devices. */
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
708 Lisp_Object devcons, concons, hash_table;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
709 DEVICE_LOOP_NO_BREAK (devcons, concons)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
710 {
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
711 struct device *d = XDEVICE (XCAR (devcons));
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
712 hash_table = Fgethash (charset, d->charset_font_cache_stage_1,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
713 Qunbound);
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
714 if (!UNBOUNDP (hash_table))
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
715 Fclrhash (hash_table);
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
716 hash_table = Fgethash (charset, d->charset_font_cache_stage_2,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
717 Qunbound);
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
718 if (!UNBOUNDP (hash_table))
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
719 Fclrhash (hash_table);
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
720 }
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
721 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 font_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 Lisp_Object domain, Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 Lisp_Object depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 /* When called, we're inside of call_with_suspended_errors(),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 so we can freely error. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
730 Lisp_Object device = DOMAIN_DEVICE (domain);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 struct device *d = XDEVICE (device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 Lisp_Object instance;
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
733 Lisp_Object charset = Qnil;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
734 int stage = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 if (!UNBOUNDP (matchspec))
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
738 {
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
739 charset = Fget_charset (XCAR (matchspec));
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
740 stage = NILP (XCDR (matchspec)) ? 0 : 1;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
741 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 if (FONT_INSTANCEP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 if (NILP (device)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 || EQ (device, XFONT_INSTANCE (instantiator)->device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 #ifdef MULE
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
750 if (font_spec_matches_charset (d, charset, 0,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 Ffont_instance_truename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 (instantiator),
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
753 0, -1, stage))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 return instantiator;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 return instantiator;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 instantiator = Ffont_instance_name (instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 if (STRINGP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
764 Lisp_Object cache = stage ? d->charset_font_cache_stage_2 :
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
765 d->charset_font_cache_stage_1;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
766
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 #ifdef MULE
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
768 if (!NILP (charset))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 /* The instantiator is a font spec that could match many
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 different fonts. We need to find one of those fonts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 whose registry matches the registry of the charset in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 MATCHSPEC. This is potentially a very slow operation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 as it involves doing an XListFonts() or equivalent to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 iterate over all possible fonts, and a regexp match
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 on each one. So we cache the results. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 Lisp_Object matching_font = Qunbound;
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
778 Lisp_Object hash_table = Fgethash (charset, cache, Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 if (UNBOUNDP (hash_table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 /* need to make a sub hash table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 hash_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 HASH_TABLE_EQUAL);
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
784 Fputhash (charset, hash_table, cache);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 matching_font = Fgethash (instantiator, hash_table, Qunbound);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 if (UNBOUNDP (matching_font))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 /* make sure we cache the failures, too. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 matching_font =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 DEVMETH_OR_GIVEN (d, find_charset_font,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
794 (device, instantiator, charset, stage),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 Fputhash (instantiator, matching_font, hash_table);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 if (NILP (matching_font))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 instantiator = matching_font;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 /* First, look to see if we can retrieve a cached value. */
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
805 instance = Fgethash (instantiator, cache, Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 /* Otherwise, make a new one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 if (UNBOUNDP (instance))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 /* make sure we cache the failures, too. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 instance = Fmake_font_instance (instantiator, device, Qt);
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
811 Fputhash (instantiator, instance, cache);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 return NILP (instance) ? Qunbound : instance;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 else if (VECTORP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 assert (XVECTOR_LENGTH (instantiator) == 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 return (face_property_matching_instance
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
821 charset, domain, ERROR_ME, 0, depth));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 else if (NILP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 abort (); /* Eh? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 font_validate (Lisp_Object instantiator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 if (FONT_INSTANCEP (instantiator) || STRINGP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 if (VECTORP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 if (XVECTOR_LENGTH (instantiator) != 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
840 sferror
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 ("Vector length must be one for font inheritance", instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 Fget_face (XVECTOR_DATA (instantiator)[0]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
846 invalid_argument ("Must be string, vector, or font-instance",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 font_after_change (Lisp_Object specifier, Lisp_Object locale)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 Lisp_Object face = FONT_SPECIFIER_FACE (XFONT_SPECIFIER (specifier));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 Lisp_Object property =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 FONT_SPECIFIER_FACE_PROPERTY (XFONT_SPECIFIER (specifier));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 if (!NILP (face))
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
857 {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
858 face_property_was_changed (face, property, locale);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
859 if (BUFFERP (locale))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
860 XBUFFER (locale)->buffer_local_face_property = 1;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
861 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 set_font_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
867 Lisp_Specifier *font = XFONT_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 FONT_SPECIFIER_FACE (font) = face;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 FONT_SPECIFIER_FACE_PROPERTY (font) = property;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 DEFUN ("font-specifier-p", Ffont_specifier_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 Return non-nil if OBJECT is a font specifier.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
876 See `make-font-specifier' for a description of possible font instantiators.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 return FONT_SPECIFIERP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 Face Boolean Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 ****************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 DEFINE_SPECIFIER_TYPE (face_boolean);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 Lisp_Object Qface_boolean;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 face_boolean_create (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
893 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 face_boolean_mark (Lisp_Object obj)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
902 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 mark_object (FACE_BOOLEAN_SPECIFIER_FACE (face_boolean));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 mark_object (FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 /* No equal or hash methods; ignore the face the face-boolean is based off
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 of for `equal' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 face_boolean_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 Lisp_Object domain, Lisp_Object instantiator,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 Lisp_Object depth)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 /* When called, we're inside of call_with_suspended_errors(),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 so we can freely error. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 if (NILP (instantiator) || EQ (instantiator, Qt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 return instantiator;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 else if (VECTORP (instantiator))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 Lisp_Object retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 Lisp_Object prop;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 int instantiator_len = XVECTOR_LENGTH (instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 assert (instantiator_len >= 1 && instantiator_len <= 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 if (instantiator_len > 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 prop = XVECTOR_DATA (instantiator)[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 if (NILP (FACE_BOOLEAN_SPECIFIER_FACE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 (XFACE_BOOLEAN_SPECIFIER (specifier))))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
933 gui_error
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 ("Face-boolean specifier not attached to a face", instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 prop = FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 (XFACE_BOOLEAN_SPECIFIER (specifier));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 retval = (FACE_PROPERTY_INSTANCE_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 (Fget_face (XVECTOR_DATA (instantiator)[0]),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 prop, domain, ERROR_ME, 0, depth));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 retval = NILP (retval) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 abort (); /* Eh? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 return Qunbound;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 face_boolean_validate (Lisp_Object instantiator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 if (NILP (instantiator) || EQ (instantiator, Qt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 else if (VECTORP (instantiator) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 (XVECTOR_LENGTH (instantiator) >= 1 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 XVECTOR_LENGTH (instantiator) <= 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 Fget_face (face);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 if (XVECTOR_LENGTH (instantiator) > 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 Lisp_Object field = XVECTOR_DATA (instantiator)[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 if (!EQ (field, Qunderline)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 && !EQ (field, Qstrikethru)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 && !EQ (field, Qhighlight)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 && !EQ (field, Qdim)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 && !EQ (field, Qblinking)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 && !EQ (field, Qreverse))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
976 invalid_constant ("Invalid face-boolean inheritance field",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 field);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 else if (VECTORP (instantiator))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
981 sferror ("Wrong length for face-boolean inheritance spec",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
984 invalid_argument ("Face-boolean instantiator must be nil, t, or vector",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 instantiator);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 face_boolean_after_change (Lisp_Object specifier, Lisp_Object locale)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 Lisp_Object face =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 FACE_BOOLEAN_SPECIFIER_FACE (XFACE_BOOLEAN_SPECIFIER (specifier));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 Lisp_Object property =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (XFACE_BOOLEAN_SPECIFIER (specifier));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 if (!NILP (face))
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
996 {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
997 face_property_was_changed (face, property, locale);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
998 if (BUFFERP (locale))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
999 XBUFFER (locale)->buffer_local_face_property = 1;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 444
diff changeset
1000 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 Lisp_Object property)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1007 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = face;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = property;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 DEFUN ("face-boolean-specifier-p", Fface_boolean_specifier_p, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 Return non-nil if OBJECT is a face-boolean specifier.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1016 See `make-face-boolean-specifier' for a description of possible
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1017 face-boolean instantiators.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 (object))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 syms_of_objects (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1032 INIT_LRECORD_IMPLEMENTATION (color_instance);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1033 INIT_LRECORD_IMPLEMENTATION (font_instance);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1034
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 DEFSUBR (Fcolor_specifier_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 DEFSUBR (Ffont_specifier_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 DEFSUBR (Fface_boolean_specifier_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
1039 DEFSYMBOL_MULTIWORD_PREDICATE (Qcolor_instancep);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 DEFSUBR (Fmake_color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 DEFSUBR (Fcolor_instance_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 DEFSUBR (Fcolor_instance_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 DEFSUBR (Fcolor_instance_rgb_components);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 DEFSUBR (Fvalid_color_name_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
1046 DEFSYMBOL_MULTIWORD_PREDICATE (Qfont_instancep);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 DEFSUBR (Fmake_font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 DEFSUBR (Ffont_instance_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 DEFSUBR (Ffont_instance_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 DEFSUBR (Ffont_instance_ascent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 DEFSUBR (Ffont_instance_descent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 DEFSUBR (Ffont_instance_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 DEFSUBR (Ffont_instance_proportional_p);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 DEFSUBR (Ffont_instance_truename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 DEFSUBR (Ffont_instance_properties);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 DEFSUBR (Flist_fonts);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 /* Qcolor, Qfont defined in general.c */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 448
diff changeset
1059 DEFSYMBOL (Qface_boolean);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 static const struct lrecord_description color_specifier_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1063 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct color_specifier, face) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1064 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct color_specifier, face_property) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 static const struct lrecord_description font_specifier_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1069 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct font_specifier, face) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1070 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct font_specifier, face_property) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 static const struct lrecord_description face_boolean_specifier_description[] = {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1075 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct face_boolean_specifier, face) },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1076 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct face_boolean_specifier, face_property) },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 { XD_END }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 specifier_type_create_objects (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 "face-boolean-specifier-p");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 SPECIFIER_HAS_METHOD (color, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 SPECIFIER_HAS_METHOD (font, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 SPECIFIER_HAS_METHOD (face_boolean, instantiate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 SPECIFIER_HAS_METHOD (color, validate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 SPECIFIER_HAS_METHOD (font, validate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 SPECIFIER_HAS_METHOD (face_boolean, validate);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 SPECIFIER_HAS_METHOD (color, create);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 SPECIFIER_HAS_METHOD (font, create);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 SPECIFIER_HAS_METHOD (face_boolean, create);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 SPECIFIER_HAS_METHOD (color, mark);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 SPECIFIER_HAS_METHOD (font, mark);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 SPECIFIER_HAS_METHOD (face_boolean, mark);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 SPECIFIER_HAS_METHOD (color, after_change);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 SPECIFIER_HAS_METHOD (font, after_change);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 SPECIFIER_HAS_METHOD (face_boolean, after_change);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 SPECIFIER_HAS_METHOD (font, validate_matchspec);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 reinit_specifier_type_create_objects (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 REINITIALIZE_SPECIFIER_TYPE (color);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 REINITIALIZE_SPECIFIER_TYPE (font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 REINITIALIZE_SPECIFIER_TYPE (face_boolean);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 reinit_vars_of_objects (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 staticpro_nodump (&Vthe_null_color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1126 Lisp_Color_Instance *c =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1127 alloc_lcrecord_type (Lisp_Color_Instance, &lrecord_color_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 c->name = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 c->device = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 c->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1132 Vthe_null_color_instance = wrap_color_instance (c);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 staticpro_nodump (&Vthe_null_font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1137 Lisp_Font_Instance *f =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1138 alloc_lcrecord_type (Lisp_Font_Instance, &lrecord_font_instance);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 f->name = Qnil;
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1140 f->truename = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 f->device = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 f->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 f->ascent = f->height = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 f->descent = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 f->width = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 f->proportional_p = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1149 Vthe_null_font_instance = wrap_font_instance (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 vars_of_objects (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 reinit_vars_of_objects ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 }