annotate src/xfaces.c @ 6757:770fe370479b

(show_mouse_face): Change the mouse cursor accordingly.
author Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
date Fri, 08 Apr 1994 15:57:24 +0000
parents 96ddf85642d1
children 0b61d2b74e64
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
1 /* "Face" primitives.
2961
e94a593c3952 Updated copyright years.
Jim Blandy <jimb@redhat.com>
parents: 2918
diff changeset
2 Copyright (C) 1993 Free Software Foundation.
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
3
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
2438
b513de4de386 * xfaces.c: Doc fixes.
Jim Blandy <jimb@redhat.com>
parents: 2391
diff changeset
20 /* This is derived from work by Lucid (some parts very loosely so). */
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
21
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 #include <sys/types.h>
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 #include <sys/stat.h>
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4258
diff changeset
25 #include <config.h>
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #include "lisp.h"
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
28 #ifdef HAVE_X_WINDOWS
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
29
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 #include "xterm.h"
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 #include "buffer.h"
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
32 #include "dispextern.h"
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
33 #include "frame.h"
2438
b513de4de386 * xfaces.c: Doc fixes.
Jim Blandy <jimb@redhat.com>
parents: 2391
diff changeset
34 #include "blockinput.h"
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
35 #include "window.h"
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
3997
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
37 /* Compensate for bug in Xos.h on some systems, on which it requires
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
38 time.h. On some such systems, Xos.h tries to redefine struct
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
39 timeval and struct timezone if USG is #defined while it is
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
40 #included. */
3436
291f28da7ea1 Test XOS_NEEDS_TIME_H, not HPUX, for including time.hj.
Richard M. Stallman <rms@gnu.org>
parents: 3401
diff changeset
41 #ifdef XOS_NEEDS_TIME_H
3277
564f748751ea [HPUX]: Include time.h and define __TIMEVAL__.
Richard M. Stallman <rms@gnu.org>
parents: 3074
diff changeset
42
3997
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
43 #include <time.h>
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
44 #undef USG
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
45 #include <X11/Xos.h>
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
46 #define USG
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
47 #define __TIMEVAL__
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
48
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
49 #else
3316
9857db8aa4cd * xfaces.c (unload_color): Don't #include <X11/Intrinsic.h>,
Jim Blandy <jimb@redhat.com>
parents: 3302
diff changeset
50
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 #include <X11/Xos.h>
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
3997
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
53 #endif
d968bcba16af * xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents: 3882
diff changeset
54
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
55
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
56 /* An explanation of the face data structures. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
57
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
58 /* ========================= Face Data Structures =========================
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
59
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
60 Let FACE-NAME be a symbol naming a face.
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
61
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
62 Let FACE-VECTOR be (assq FACE-NAME (frame-face-alist FRAME))
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
63 FACE-VECTOR is either nil, or a vector of the form
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
64 [face NAME ID FONT FOREGROUND BACKGROUND BACKGROUND-PIXMAP UNDERLINE-P]
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
65 where
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
66 face is the symbol `face',
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
67 NAME is the symbol with which this vector is associated (a backpointer),
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
68 ID is the face ID, an integer used internally by the C code to identify
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
69 the face,
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
70 FONT, FOREGROUND, and BACKGROUND are strings naming the fonts and colors
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
71 to use with the face,
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
72 BACKGROUND-PIXMAP is the name of an x bitmap filename, which we don't
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
73 use right now, and
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
74 UNDERLINE-P is non-nil if the face should be underlined.
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
75 If any of these elements are nil, that parameter is considered
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
76 unspecified; parameters from faces specified by lower-priority
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
77 overlays or text properties, or the parameters of the frame itself,
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
78 can show through. (lisp/faces.el maintains these lists.)
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
79
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
80 (assq FACE-NAME global-face-data) returns a vector describing the
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
81 global parameters for that face.
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
82
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
83 Let PARAM-FACE be FRAME->display.x->param_faces[Faref (FACE-VECTOR, 2)].
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
84 PARAM_FACE is a struct face whose members are the Xlib analogues of
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
85 the parameters in FACE-VECTOR. If an element of FACE-VECTOR is
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
86 nil, then the corresponding member of PARAM_FACE is FACE_DEFAULT.
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
87 These faces are called "parameter faces", because they're the ones
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
88 lisp manipulates to control what gets displayed. Elements 0 and 1
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
89 of FRAME->display.x->param_faces are special - they describe the
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
90 default and mode line faces. None of the faces in param_faces have
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
91 GC's. (See src/dispextern.h for the definiton of struct face.
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
92 lisp/faces.el maintains the isomorphism between face_alist and
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
93 param_faces.)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
94
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
95 The functions compute_char_face and compute_glyph_face find and
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
96 combine the parameter faces associated with overlays and text
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
97 properties. The resulting faces are called "computed faces"; none
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
98 of their members are FACE_DEFAULT; they are completely specified.
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
99 They then call intern_compute_face to search
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
100 FRAME->display.x->computed_faces for a matching face, add one if
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
101 none is found, and return the index into
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
102 FRAME->display.x->computed_faces. FRAME's glyph matrices use these
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
103 indices to record the faces of the matrix characters, and the X
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
104 display hooks consult compute_faces to decide how to display these
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
105 characters. Elements 0 and 1 of computed_faces always describe the
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
106 default and mode-line faces.
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
107
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
108 Elements 0 and 1 of computed_faces have GC's; all the other faces
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
109 in computed_faces do not. The global array face_vector contains
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
110 faces with their GC's set. Given a computed_face, the function
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
111 intern_face finds (or adds) an element of face_vector with
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
112 equivalent parameters, and returns a pointer to that face, whose GC
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
113 can then be used for display.
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
114
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
115 Constraints:
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
116
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
117 Symbols naming faces must have associations on all frames; for any
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
118 FRAME, for all FACE-NAME, if (assq FACE-NAME (frame-face-alist
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
119 FRAME)) is non-nil, it must be non-nil for all frames.
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
120
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
121 Analogously, indices into param_faces must be valid on all frames;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
122 if param_faces[i] is a non-zero face pointer on one frame, then it
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
123 must be filled in on all frames. Code assumes that face ID's can
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
124 be used on any frame.
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
125
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
126 Some subtleties:
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
127
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
128 Why do we keep param_faces and computed_faces separate?
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
129 computed_faces contains an element for every combination of facial
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
130 parameters we have ever displayed. indices into param_faces have
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
131 to be valid on all frames. If they were the same array, then that
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
132 array would grow very large on all frames, because any facial
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
133 combination displayed on any frame would need to be a valid entry
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
134 on all frames.
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
135
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
136 Since face_vector is just a cache --- there are no pointers into it
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
137 from the rest of the code, and everyone accesses it through
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
138 intern_face --- we could just free its GC's and throw the whole
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
139 thing away without breaking anything. This gives us a simple way
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
140 to garbage-collect old GC's nobody's using any more - we can just
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
141 purge face_vector, and then let subsequent calls to intern_face
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
142 refill it as needed. The function clear_face_vector performs this
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
143 purge.
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
144
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
145 We're often applying intern_face to faces in computed_faces -
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
146 for example, we do this while sending GLYPHs from a struct
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
147 frame_glyphs to X during redisplay. It would be nice to avoid
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
148 searching all of face_vector every time we intern a frame's face.
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
149 So, when intern_face finds a match for FACE in face_vector, it
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
150 stores the index of the match in FACE's cached_index member, and
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
151 checks there first next time. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
152
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
153
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
154 /* Definitions and declarations. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
155
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 /* A table of display faces. */
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
157 static struct face **face_vector;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 /* The length in use of the table. */
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
159 static int nfaces;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 /* The allocated length of the table. */
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
161 static int nfaces_allocated;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 /* The number of face-id's in use (same for all frames). */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 int next_face_id;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
166 /* The number of the face to use to indicate the region. */
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
167 int region_face;
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
168
2838
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
169 /* This is what appears in a slot in a face to signify that the face
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
170 does not specify that display aspect. */
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
171 #define FACE_DEFAULT (~0)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
172
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
173 Lisp_Object Qface, Qmouse_face;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
174
3830
205d69567177 * xfaces.c: Add forward declaration for recompute_basic_faces.
Jim Blandy <jimb@redhat.com>
parents: 3811
diff changeset
175 static void build_face ( /* FRAME_PTR, struct face * */ );
205d69567177 * xfaces.c: Add forward declaration for recompute_basic_faces.
Jim Blandy <jimb@redhat.com>
parents: 3811
diff changeset
176 int face_name_id_number ( /* FRAME_PTR, Lisp_Object name */ );
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
177
3830
205d69567177 * xfaces.c: Add forward declaration for recompute_basic_faces.
Jim Blandy <jimb@redhat.com>
parents: 3811
diff changeset
178 struct face *intern_face ( /* FRAME_PTR, struct face * */ );
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
179 static int new_computed_face ( /* FRAME_PTR, struct face * */ );
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
180 static int intern_computed_face ( /* FRAME_PTR, struct face * */ );
3830
205d69567177 * xfaces.c: Add forward declaration for recompute_basic_faces.
Jim Blandy <jimb@redhat.com>
parents: 3811
diff changeset
181 static void ensure_face_ready ( /* FRAME_PTR, int id */ );
3843
18892e151d53 * xfaces.c (recompute_basic_faces): This shouldn't be declared static.
Jim Blandy <jimb@redhat.com>
parents: 3830
diff changeset
182 void recompute_basic_faces ( /* FRAME_PTR f */ );
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
184 /* Allocating, copying, and comparing struct faces. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
185
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
186 /* Allocate a new face */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
187 static struct face *
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
188 allocate_face ()
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
189 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
190 struct face *result = (struct face *) xmalloc (sizeof (struct face));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
191 bzero (result, sizeof (struct face));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
192 result->font = (XFontStruct *) FACE_DEFAULT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
193 result->foreground = FACE_DEFAULT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
194 result->background = FACE_DEFAULT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
195 result->stipple = FACE_DEFAULT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
196 return result;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
197 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
198
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 /* Make a new face that's a copy of an existing one. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 static struct face *
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 copy_face (face)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 struct face *face;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 struct face *result = allocate_face ();
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 result->font = face->font;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 result->foreground = face->foreground;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 result->background = face->background;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
209 result->stipple = face->stipple;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 result->underline = face->underline;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 return result;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 static int
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 face_eql (face1, face2)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 struct face *face1, *face2;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 {
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
219 return ( face1->font == face2->font
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 && face1->foreground == face2->foreground
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 && face1->background == face2->background
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
222 && face1->stipple == face2->stipple
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
223 && face1->underline == face2->underline);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 }
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
225
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
226 /* Interning faces in the `face_vector' cache, and clearing that cache. */
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 /* Return the unique display face corresponding to the user-level face FACE.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 If there isn't one, make one, and find a slot in the face_vector to
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 put it in. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 static struct face *
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
232 get_cached_face (f, face)
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 struct frame *f;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 struct face *face;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 int i, empty = -1;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
237 struct face *result;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
239 /* Perhaps FACE->cached_index is valid; this could happen if FACE is
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
240 in a frame's face list. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
241 if (face->cached_index >= 0
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
242 && face->cached_index < nfaces
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
243 && face_eql (face_vector[face->cached_index], face))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
244 return face_vector[face->cached_index];
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
245
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 /* Look for an existing display face that does the job.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 Also find an empty slot if any. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 for (i = 0; i < nfaces; i++)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 if (face_eql (face_vector[i], face))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 return face_vector[i];
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 if (face_vector[i] == 0)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 empty = i;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 /* If no empty slots, make one. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 if (empty < 0 && nfaces == nfaces_allocated)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 int newsize = nfaces + 20;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 face_vector
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 = (struct face **) xrealloc (face_vector,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 newsize * sizeof (struct face *));
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 nfaces_allocated = newsize;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 if (empty < 0)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 empty = nfaces++;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 /* Put a new display face in the empty slot. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 result = copy_face (face);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 face_vector[empty] = result;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 /* Make a graphics context for it. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 build_face (f, result);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 return result;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
279 /* Given a computed face, return an equivalent display face
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
280 (one which has a graphics context). */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
281
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
282 struct face *
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
283 intern_face (f, face)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
284 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
285 struct face *face;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
286 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
287 /* If it's equivalent to the default face, use that. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
288 if (face_eql (face, FRAME_DEFAULT_FACE (f)))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
289 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
290 if (!FRAME_DEFAULT_FACE (f)->gc)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
291 build_face (f, FRAME_DEFAULT_FACE (f));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
292 return FRAME_DEFAULT_FACE (f);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
293 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
294
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
295 /* If it's equivalent to the mode line face, use that. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
296 if (face_eql (face, FRAME_MODE_LINE_FACE (f)))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
297 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
298 if (!FRAME_MODE_LINE_FACE (f)->gc)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
299 build_face (f, FRAME_MODE_LINE_FACE (f));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
300 return FRAME_MODE_LINE_FACE (f);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
301 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
302
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
303 /* If it's not one of the frame's default faces, it shouldn't have a GC. */
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
304 if (face->gc)
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
305 abort ();
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
306
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
307 /* Get a specialized display face. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
308 return get_cached_face (f, face);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
309 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
310
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 /* Clear out face_vector and start anew.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 This should be done from time to time just to avoid
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 keeping too many graphics contexts in face_vector
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 that are no longer needed. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 void
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 clear_face_vector ()
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 Lisp_Object rest;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 Display *dpy = x_current_display;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
321 int i;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 BLOCK_INPUT;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 /* Free the display faces in the face_vector. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 for (i = 0; i < nfaces; i++)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 struct face *face = face_vector[i];
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
328 if (face->gc)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
329 XFreeGC (dpy, face->gc);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 xfree (face);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 nfaces = 0;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 UNBLOCK_INPUT;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
337 /* Allocating and freeing X resources for display faces. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
338
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
339 /* Make a graphics context for face FACE, which is on frame F,
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
340 if that can be done. */
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 static void
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 build_face (f, face)
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
343 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
344 struct face *face;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 GC gc;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 XGCValues xgcv;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 unsigned long mask;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
350 BLOCK_INPUT;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
351
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
352 if (face->foreground != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
353 xgcv.foreground = face->foreground;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
354 else
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
355 xgcv.foreground = f->display.x->foreground_pixel;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
356
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
357 if (face->background != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
358 xgcv.background = face->background;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
359 else
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
360 xgcv.background = f->display.x->background_pixel;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
361
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
362 if (face->font && (int) face->font != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
363 xgcv.font = face->font->fid;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
364 else
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
365 xgcv.font = f->display.x->font->fid;
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
366
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 xgcv.graphics_exposures = 0;
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
368
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f),
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 mask, &xgcv);
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
372
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 #if 0
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
374 if (face->stipple && face->stipple != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
375 XSetStipple (x_current_display, gc, face->stipple);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 #endif
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
377
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
378 face->gc = gc;
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
379
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
380 UNBLOCK_INPUT;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 }
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
382
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
383 /* Allocating, freeing, and duplicating fonts, colors, and pixmaps. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
384
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
385 static XFontStruct *
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
386 load_font (f, name)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
387 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
388 Lisp_Object name;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
389 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
390 XFontStruct *font;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
391
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
392 if (NILP (name))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
393 return (XFontStruct *) FACE_DEFAULT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
394
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
395 CHECK_STRING (name, 0);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
396 BLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
397 font = XLoadQueryFont (x_current_display, (char *) XSTRING (name)->data);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
398 UNBLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
399
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
400 if (! font)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
401 Fsignal (Qerror, Fcons (build_string ("undefined font"),
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
402 Fcons (name, Qnil)));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
403 return font;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
404 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
405
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
406 static void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
407 unload_font (f, font)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
408 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
409 XFontStruct *font;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
410 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
411 if (!font || font == ((XFontStruct *) FACE_DEFAULT))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
412 return;
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
413
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
414 BLOCK_INPUT;
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
415 XFreeFont (x_current_display, font);
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
416 UNBLOCK_INPUT;
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
417 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
418
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
419 static unsigned long
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
420 load_color (f, name)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
421 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
422 Lisp_Object name;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
423 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
424 Display *dpy = x_current_display;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
425 Colormap cmap;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
426 XColor color;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
427 int result;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
428
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
429 if (NILP (name))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
430 return FACE_DEFAULT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
431
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
432 cmap = DefaultColormapOfScreen (DefaultScreenOfDisplay (x_current_display));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
433
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
434 CHECK_STRING (name, 0);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
435 BLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
436 result = XParseColor (dpy, cmap, (char *) XSTRING (name)->data, &color);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
437 UNBLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
438 if (! result)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
439 Fsignal (Qerror, Fcons (build_string ("undefined color"),
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
440 Fcons (name, Qnil)));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
441 BLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
442 result = XAllocColor (dpy, cmap, &color);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
443 UNBLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
444 if (! result)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
445 Fsignal (Qerror, Fcons (build_string ("X server cannot allocate color"),
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
446 Fcons (name, Qnil)));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
447 return (unsigned long) color.pixel;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
448 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
449
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
450 static void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
451 unload_color (f, pixel)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
452 struct frame *f;
3316
9857db8aa4cd * xfaces.c (unload_color): Don't #include <X11/Intrinsic.h>,
Jim Blandy <jimb@redhat.com>
parents: 3302
diff changeset
453 unsigned long pixel;
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
454 {
3065
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
455 /* Since faces get built by copying parameters from other faces, the
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
456 allocation counts for the colors get all screwed up. I don't see
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
457 any solution that will take less than 10 minutes, and it's better
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
458 to have a color leak than a crash, so I'm just dyking this out.
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
459 This isn't really a color leak, anyway - if we ask for it again,
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
460 we'll get the same pixel. */
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
461 #if 0
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
462 Colormap cmap;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
463 Display *dpy = x_current_display;
2818
d1cfc6cbdbf7 * xfaces.c (unload_color): Don't try to unload the standard black
Jim Blandy <jimb@redhat.com>
parents: 2795
diff changeset
464 if (pixel == FACE_DEFAULT
d1cfc6cbdbf7 * xfaces.c (unload_color): Don't try to unload the standard black
Jim Blandy <jimb@redhat.com>
parents: 2795
diff changeset
465 || pixel == BLACK_PIX_DEFAULT
d1cfc6cbdbf7 * xfaces.c (unload_color): Don't try to unload the standard black
Jim Blandy <jimb@redhat.com>
parents: 2795
diff changeset
466 || pixel == WHITE_PIX_DEFAULT)
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
467 return;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
468 cmap = DefaultColormapOfScreen (DefaultScreenOfDisplay (x_current_display));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
469 BLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
470 XFreeColors (dpy, cmap, &pixel, 1, 0);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
471 UNBLOCK_INPUT;
3065
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
472 #endif
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
473 }
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
475 /* Managing parameter face arrays for frames. */
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
476
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
477 void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
478 init_frame_faces (f)
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
479 FRAME_PTR f;
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
480 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
481 ensure_face_ready (f, 0);
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
482 ensure_face_ready (f, 1);
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
483
5801
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
484 FRAME_N_COMPUTED_FACES (f) = 0;
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
485 FRAME_SIZE_COMPUTED_FACES (f) = 0;
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
486
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
487 new_computed_face (f, FRAME_PARAM_FACES (f)[0]);
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
488 new_computed_face (f, FRAME_PARAM_FACES (f)[1]);
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
489 recompute_basic_faces (f);
3299
6fab7c7bb1f1 * xfaces.c (init_frame_faces): We have to make sure that face ID's
Jim Blandy <jimb@redhat.com>
parents: 3277
diff changeset
490
3583
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
491 /* Find another X frame. */
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
492 {
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
493 Lisp_Object tail, frame, result;
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
494
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
495 result = Qnil;
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
496 FOR_EACH_FRAME (tail, frame)
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
497 if (FRAME_X_P (XFRAME (frame))
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
498 && XFRAME (frame) != f)
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
499 {
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
500 result = frame;
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
501 break;
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
502 }
3299
6fab7c7bb1f1 * xfaces.c (init_frame_faces): We have to make sure that face ID's
Jim Blandy <jimb@redhat.com>
parents: 3277
diff changeset
503
3583
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
504 /* If we didn't find any X frames other than f, then we don't need
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
505 any faces other than 0 and 1, so we're okay. Otherwise, make
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
506 sure that all faces valid on the selected frame are also valid
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
507 on this new frame. */
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
508 if (FRAMEP (result))
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
509 {
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
510 int i;
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
511 int n_faces = FRAME_N_PARAM_FACES (XFRAME (result));
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
512 struct face **faces = FRAME_PARAM_FACES (XFRAME (result));
3299
6fab7c7bb1f1 * xfaces.c (init_frame_faces): We have to make sure that face ID's
Jim Blandy <jimb@redhat.com>
parents: 3277
diff changeset
513
3583
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
514 for (i = 2; i < n_faces; i++)
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
515 if (faces[i])
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
516 ensure_face_ready (f, i);
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
517 }
0bc9838eb0bb * xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents: 3528
diff changeset
518 }
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
519 }
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
520
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
521
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
522 /* Called from Fdelete_frame. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
523 void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
524 free_frame_faces (f)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
525 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
526 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
527 Display *dpy = x_current_display;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
528 int i;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
529
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
530 BLOCK_INPUT;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
531
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
532 for (i = 0; i < FRAME_N_PARAM_FACES (f); i++)
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
533 {
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
534 struct face *face = FRAME_PARAM_FACES (f) [i];
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
535 if (face)
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
536 {
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
537 if (face->gc)
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
538 XFreeGC (dpy, face->gc);
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
539 unload_font (f, face->font);
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
540 unload_color (f, face->foreground);
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
541 unload_color (f, face->background);
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
542 #if 0
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
543 unload_pixmap (f, face->stipple);
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
544 #endif
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
545 xfree (face);
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
546 }
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
547 }
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
548 xfree (FRAME_PARAM_FACES (f));
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
549 FRAME_PARAM_FACES (f) = 0;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
550 FRAME_N_PARAM_FACES (f) = 0;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
551
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
552 /* All faces in FRAME_COMPUTED_FACES use resources copied from
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
553 FRAME_PARAM_FACES; we can free them without fuss. */
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
554 xfree (FRAME_COMPUTED_FACES (f));
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
555 FRAME_COMPUTED_FACES (f) = 0;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
556 FRAME_N_COMPUTED_FACES (f) = 0;
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
557
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
558 UNBLOCK_INPUT;
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
559 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
560
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
561 /* Interning faces in a frame's face array. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
562
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
563 static int
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
564 new_computed_face (f, new_face)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
565 struct frame *f;
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
566 struct face *new_face;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
567 {
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
568 int i = FRAME_N_COMPUTED_FACES (f);
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
569
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
570 if (i >= FRAME_SIZE_COMPUTED_FACES (f))
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
571 {
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
572 int new_size = i + 32;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
573
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
574 FRAME_COMPUTED_FACES (f)
5801
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
575 = (struct face **) (FRAME_SIZE_COMPUTED_FACES (f) == 0
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
576 ? xmalloc (new_size * sizeof (struct face *))
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
577 : xrealloc (FRAME_COMPUTED_FACES (f),
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
578 new_size * sizeof (struct face *)));
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
579 FRAME_SIZE_COMPUTED_FACES (f) = new_size;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
580 }
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
581
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
582 i = FRAME_N_COMPUTED_FACES (f)++;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
583 FRAME_COMPUTED_FACES (f)[i] = copy_face (new_face);
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
584 return i;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
585 }
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
586
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
587
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
588 /* Find a match for NEW_FACE in a FRAME's computed face array, and add
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
589 it if we don't find one. */
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
590 static int
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
591 intern_computed_face (f, new_face)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
592 struct frame *f;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
593 struct face *new_face;
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
594 {
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
595 int len = FRAME_N_COMPUTED_FACES (f);
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
596 int i;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
597
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
598 /* Search for a computed face already on F equivalent to FACE. */
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
599 for (i = 0; i < len; i++)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
600 {
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
601 if (! FRAME_COMPUTED_FACES (f)[i])
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
602 abort ();
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
603 if (face_eql (new_face, FRAME_COMPUTED_FACES (f)[i]))
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
604 return i;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
605 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
606
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
607 /* We didn't find one; add a new one. */
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
608 return new_computed_face (f, new_face);
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
609 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
610
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
611 /* Make parameter face id ID valid on frame F. */
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
612
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
613 static void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
614 ensure_face_ready (f, id)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
615 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
616 int id;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
617 {
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
618 if (FRAME_N_PARAM_FACES (f) <= id)
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
619 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
620 int n = id + 10;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
621 int i;
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
622 if (!FRAME_N_PARAM_FACES (f))
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
623 FRAME_PARAM_FACES (f)
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
624 = (struct face **) xmalloc (sizeof (struct face *) * n);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
625 else
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
626 FRAME_PARAM_FACES (f)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
627 = (struct face **) xrealloc (FRAME_PARAM_FACES (f),
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
628 sizeof (struct face *) * n);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
629
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
630 bzero (FRAME_PARAM_FACES (f) + FRAME_N_PARAM_FACES (f),
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
631 (n - FRAME_N_PARAM_FACES (f)) * sizeof (struct face *));
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
632 FRAME_N_PARAM_FACES (f) = n;
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
633 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
634
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
635 if (FRAME_PARAM_FACES (f) [id] == 0)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
636 FRAME_PARAM_FACES (f) [id] = allocate_face ();
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
637 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
638
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
639 /* Computing faces appropriate for a given piece of text in a buffer. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
640
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
641 /* Return non-zero if FONT1 and FONT2 have the same size bounding box.
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
642 We assume that they're both character-cell fonts. */
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
643 int
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
644 same_size_fonts (font1, font2)
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
645 XFontStruct *font1, *font2;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
646 {
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
647 XCharStruct *bounds1 = &font1->min_bounds;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
648 XCharStruct *bounds2 = &font2->min_bounds;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
649
3528
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
650 return (bounds1->width == bounds2->width);
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
651 /* Checking the following caused bad results in some cases
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
652 when fonts that should be the same size
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
653 actually have very slightly different size.
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
654 It is possible that this reintroduces the bug whereby line positions
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
655 were not right. However, the right way to fix that is to change xterm.c
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
656 so that the vertical positions of lines
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
657 depend only on the height of the frame's font.
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
658 && bounds1->ascent == bounds2->ascent
3528
aad9fd004281 (same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents: 3436
diff changeset
659 && bounds1->descent == bounds2->descent); */
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
660 }
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
661
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
662 /* Modify face TO by copying from FROM all properties which have
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
663 nondefault settings. */
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
664 static void
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
665 merge_faces (from, to)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
666 struct face *from, *to;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
667 {
2883
b8a3b11892dc Make sure that all the display faces use fonts of the
Jim Blandy <jimb@redhat.com>
parents: 2875
diff changeset
668 /* Only merge the font if it's the same size as the base font. */
b8a3b11892dc Make sure that all the display faces use fonts of the
Jim Blandy <jimb@redhat.com>
parents: 2875
diff changeset
669 if (from->font != (XFontStruct *) FACE_DEFAULT
b8a3b11892dc Make sure that all the display faces use fonts of the
Jim Blandy <jimb@redhat.com>
parents: 2875
diff changeset
670 && same_size_fonts (from->font, to->font))
b8a3b11892dc Make sure that all the display faces use fonts of the
Jim Blandy <jimb@redhat.com>
parents: 2875
diff changeset
671 to->font = from->font;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
672 if (from->foreground != FACE_DEFAULT)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
673 to->foreground = from->foreground;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
674 if (from->background != FACE_DEFAULT)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
675 to->background = from->background;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
676 if (from->stipple != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
677 to->stipple = from->stipple;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
678 if (from->underline)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
679 to->underline = from->underline;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
680 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
681
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
682 /* Set up the basic set of facial parameters, based on the frame's
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
683 data; all faces are deltas applied to this. */
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
684 static void
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
685 compute_base_face (f, face)
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
686 FRAME_PTR f;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
687 struct face *face;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
688 {
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
689 struct x_display *d = f->display.x;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
690
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
691 face->gc = 0;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
692 face->foreground = d->foreground_pixel;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
693 face->background = d->background_pixel;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
694 face->font = d->font;
3811
48b1ef149180 * xfaces.c (compute_base_face): Initialize the face's stipple.
Jim Blandy <jimb@redhat.com>
parents: 3583
diff changeset
695 face->stipple = 0;
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
696 face->underline = 0;
3811
48b1ef149180 * xfaces.c (compute_base_face): Initialize the face's stipple.
Jim Blandy <jimb@redhat.com>
parents: 3583
diff changeset
697
48b1ef149180 * xfaces.c (compute_base_face): Initialize the face's stipple.
Jim Blandy <jimb@redhat.com>
parents: 3583
diff changeset
698 /* Avoid a face comparison by making this invalid. */
48b1ef149180 * xfaces.c (compute_base_face): Initialize the face's stipple.
Jim Blandy <jimb@redhat.com>
parents: 3583
diff changeset
699 face->cached_index = -1;
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
700 }
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
701
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
702
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
703 /* Return the face ID associated with a buffer position POS.
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
704 Store into *ENDPTR the position at which a different face is needed.
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
705 This does not take account of glyphs that specify their own face codes.
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
706 F is the frame in use for display, and W is a window displaying
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
707 the current buffer.
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
708
5084
863e092a5891 (compute_char_face): Accept new arg LIMIT.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
709 REGION_BEG, REGION_END delimit the region, so it can be highlighted.
863e092a5891 (compute_char_face): Accept new arg LIMIT.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
710
863e092a5891 (compute_char_face): Accept new arg LIMIT.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
711 LIMIT is a position not to scan beyond. That is to limit
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
712 the time this function can take.
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
713
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
714 If MOUSE is nonzero, use the character's mouse-face, not its face. */
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
715
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
716 int
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
717 compute_char_face (f, w, pos, region_beg, region_end, endptr, limit, mouse)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
718 struct frame *f;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
719 struct window *w;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
720 int pos;
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
721 int region_beg, region_end;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
722 int *endptr;
5084
863e092a5891 (compute_char_face): Accept new arg LIMIT.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
723 int limit;
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
724 int mouse;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
725 {
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
726 struct face face;
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
727 Lisp_Object prop, position;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
728 int i, j, noverlays;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
729 int facecode;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
730 Lisp_Object *overlay_vec;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
731 Lisp_Object frame;
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
732 int endpos;
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
733 Lisp_Object propname;
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
734
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
735 /* W must display the current buffer. We could write this function
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
736 to use the frame and buffer of W, but right now it doesn't. */
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
737 if (XBUFFER (w->buffer) != current_buffer)
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
738 abort ();
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
739
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
740 XSET (frame, Lisp_Frame, f);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
741
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
742 endpos = ZV;
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
743 if (pos < region_beg && region_beg < endpos)
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
744 endpos = region_beg;
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
745
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
746 XFASTINT (position) = pos;
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
747
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
748 if (mouse)
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
749 propname = Qmouse_face;
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
750 else
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
751 propname = Qface;
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
752
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
753 prop = Fget_text_property (position, propname, w->buffer);
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
754
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
755 {
5084
863e092a5891 (compute_char_face): Accept new arg LIMIT.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
756 Lisp_Object limit1, end;
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
757
5084
863e092a5891 (compute_char_face): Accept new arg LIMIT.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
758 XFASTINT (limit1) = (limit < endpos ? limit : endpos);
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
759 end = Fnext_single_property_change (position, propname, w->buffer, limit1);
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
760 if (INTEGERP (end))
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
761 endpos = XINT (end);
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
762 }
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
763
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
764 {
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
765 int next_overlay;
2838
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
766 int len;
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
767
2838
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
768 /* First try with room for 40 overlays. */
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
769 len = 40;
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
770 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
771
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
772 noverlays = overlays_at (pos, 0, &overlay_vec, &len, &next_overlay);
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
773
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
774 /* If there are more than 40,
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
775 make enough space for all, and try again. */
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
776 if (noverlays > len)
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
777 {
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
778 len = noverlays;
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
779 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
780 noverlays = overlays_at (pos, 0, &overlay_vec, &len, &next_overlay);
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
781 }
5f6a2d52d2ef (compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 2821
diff changeset
782
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
783 if (next_overlay < endpos)
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
784 endpos = next_overlay;
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
785 }
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
786
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
787 *endptr = endpos;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
788
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
789 /* Optimize the default case. */
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
790 if (noverlays == 0 && NILP (prop)
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
791 && !(pos >= region_beg && pos < region_end))
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
792 return 0;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
793
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
794 compute_base_face (f, &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
795
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
796 if (!NILP (prop))
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
797 {
3065
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
798 facecode = face_name_id_number (f, prop);
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
799 if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
800 && FRAME_PARAM_FACES (f) [facecode] != 0)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
801 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
802 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
803
5858
021e58905963 (compute_char_face): Extract overlay-sorting code as a separate function,
Karl Heuer <kwzh@gnu.org>
parents: 5801
diff changeset
804 noverlays = sort_overlays (overlay_vec, noverlays, w);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
805
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
806 /* Now merge the overlay data in that order. */
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
807 for (i = 0; i < noverlays; i++)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
808 {
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
809 prop = Foverlay_get (overlay_vec[i], propname);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
810 if (!NILP (prop))
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
811 {
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
812 Lisp_Object oend;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
813 int oendpos;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
814
3065
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
815 facecode = face_name_id_number (f, prop);
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
816 if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
817 && FRAME_PARAM_FACES (f) [facecode] != 0)
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
818 merge_faces (FRAME_PARAM_FACES (f)[facecode], &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
819
5858
021e58905963 (compute_char_face): Extract overlay-sorting code as a separate function,
Karl Heuer <kwzh@gnu.org>
parents: 5801
diff changeset
820 oend = OVERLAY_END (overlay_vec[i]);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
821 oendpos = OVERLAY_POSITION (oend);
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
822 if (oendpos < endpos)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
823 endpos = oendpos;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
824 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
825 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
826
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
827 if (pos >= region_beg && pos < region_end)
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
828 {
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
829 if (region_end < endpos)
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
830 endpos = region_end;
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
831 if (region_face >= 0 && region_face < next_face_id)
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
832 merge_faces (FRAME_PARAM_FACES (f)[region_face], &face);
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
833 }
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
834
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
835 *endptr = endpos;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
836
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
837 return intern_computed_face (f, &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
838 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
839
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
840 /* Return the face ID to use to display a special glyph which selects
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
841 FACE_CODE as the face ID, assuming that ordinarily the face would
5801
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
842 be CURRENT_FACE. F is the frame. */
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
843
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
844 int
5801
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
845 compute_glyph_face (f, face_code, current_face)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
846 struct frame *f;
5801
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
847 int face_code, current_face;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
848 {
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
849 struct face face;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
850
5801
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
851 face = *FRAME_COMPUTED_FACES (f)[current_face];
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
852
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
853 if (face_code >= 0 && face_code < FRAME_N_PARAM_FACES (f)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
854 && FRAME_PARAM_FACES (f) [face_code] != 0)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
855 merge_faces (FRAME_PARAM_FACES (f) [face_code], &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
856
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
857 return intern_computed_face (f, &face);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
858 }
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
859
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
860
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
861 /* Recompute the GC's for the default and modeline faces.
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
862 We call this after changing frame parameters on which those GC's
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
863 depend. */
5801
af397aaa8e6b (init_frame_faces): Clear FRAME_N_COMPUTED_FACES
Richard M. Stallman <rms@gnu.org>
parents: 5084
diff changeset
864
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
865 void
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
866 recompute_basic_faces (f)
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
867 FRAME_PTR f;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
868 {
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
869 /* If the frame's faces haven't been initialized yet, don't worry about
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
870 this stuff. */
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
871 if (FRAME_N_PARAM_FACES (f) < 2)
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
872 return;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
873
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
874 BLOCK_INPUT;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
875
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
876 if (FRAME_DEFAULT_FACE (f)->gc)
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
877 XFreeGC (x_current_display, FRAME_DEFAULT_FACE (f)->gc);
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
878 if (FRAME_MODE_LINE_FACE (f)->gc)
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
879 XFreeGC (x_current_display, FRAME_MODE_LINE_FACE (f)->gc);
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
880
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
881 compute_base_face (f, FRAME_DEFAULT_FACE (f));
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
882 compute_base_face (f, FRAME_MODE_LINE_FACE (f));
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
883
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
884 merge_faces (FRAME_DEFAULT_PARAM_FACE (f), FRAME_DEFAULT_FACE (f));
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
885 merge_faces (FRAME_MODE_LINE_PARAM_FACE (f), FRAME_MODE_LINE_FACE (f));
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
886
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
887 build_face (f, FRAME_DEFAULT_FACE (f));
3074
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
888 build_face (f, FRAME_MODE_LINE_FACE (f));
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
889
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
890 UNBLOCK_INPUT;
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
891 }
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
892
96b4623fdeb3 * xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents: 3065
diff changeset
893
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
895 /* Lisp interface. */
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897 DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist, 1, 1, 0,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
898 "")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 (frame)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 Lisp_Object frame;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 CHECK_FRAME (frame, 0);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 return XFRAME (frame)->face_alist;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
906 DEFUN ("set-frame-face-alist", Fset_frame_face_alist, Sset_frame_face_alist,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
907 2, 2, 0, "")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908 (frame, value)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 Lisp_Object frame, value;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 CHECK_FRAME (frame, 0);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
912 XFRAME (frame)->face_alist = value;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
913 return value;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 DEFUN ("make-face-internal", Fmake_face_internal, Smake_face_internal, 1, 1, 0,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 "Create face number FACE-ID on all frames.")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919 (face_id)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 Lisp_Object face_id;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
922 Lisp_Object rest;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923 int id = XINT (face_id);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
924
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
925 CHECK_NUMBER (face_id, 0);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
926 if (id < 0 || id >= next_face_id)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
927 error ("Face id out of range");
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929 for (rest = Vframe_list; !NILP (rest); rest = XCONS (rest)->cdr)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
930 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 struct frame *f = XFRAME (XCONS (rest)->car);
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
932 if (FRAME_X_P (f))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
933 ensure_face_ready (f, id);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 return Qnil;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940 Sset_face_attribute_internal, 4, 4, 0, "")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
941 (face_id, attr_name, attr_value, frame)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942 Lisp_Object face_id, attr_name, attr_value, frame;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 struct face *face;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945 struct frame *f;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
946 int magic_p;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
947 int id;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949 CHECK_FRAME (frame, 0);
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
950 CHECK_NUMBER (face_id, 0);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
951 CHECK_SYMBOL (attr_name, 0);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953 f = XFRAME (frame);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
954 id = XINT (face_id);
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
955 if (id < 0 || id >= next_face_id)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
956 error ("Face id out of range");
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
957
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
958 if (! FRAME_X_P (f))
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
959 return;
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
960
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 ensure_face_ready (f, id);
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
962 face = FRAME_PARAM_FACES (f) [XFASTINT (face_id)];
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
964 if (EQ (attr_name, intern ("font")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
965 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
966 XFontStruct *font = load_font (f, attr_value);
2998
885e08ef0577 (Fset_face_attribute_internal): Don't call unload_font
Richard M. Stallman <rms@gnu.org>
parents: 2981
diff changeset
967 if (face->font != f->display.x->font)
885e08ef0577 (Fset_face_attribute_internal): Don't call unload_font
Richard M. Stallman <rms@gnu.org>
parents: 2981
diff changeset
968 unload_font (f, face->font);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
969 face->font = font;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 else if (EQ (attr_name, intern ("foreground")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
972 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
973 unsigned long new_color = load_color (f, attr_value);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 unload_color (f, face->foreground);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
975 face->foreground = new_color;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
976 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
977 else if (EQ (attr_name, intern ("background")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
978 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
979 unsigned long new_color = load_color (f, attr_value);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 unload_color (f, face->background);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 face->background = new_color;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983 #if 0
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984 else if (EQ (attr_name, intern ("background-pixmap")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
985 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
986 unsigned int w, h, d;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
987 unsigned long new_pixmap = load_pixmap (f, attr_value, &w, &h, &d, 0);
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
988 unload_pixmap (f, face->stipple);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
989 if (NILP (attr_value))
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
990 new_pixmap = 0;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
991 face->stipple = new_pixmap;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
992 face->pixmap_w = w;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
993 face->pixmap_h = h;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
994 /* face->pixmap_depth = d; */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
995 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
996 #endif /* 0 */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
997 else if (EQ (attr_name, intern ("underline")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
998 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
999 int new = !NILP (attr_value);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1000 face->underline = new;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1001 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1002 else
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1003 error ("unknown face attribute");
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004
3882
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
1005 if (id == 0 || id == 1)
a0b9347a3973 Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents: 3843
diff changeset
1006 recompute_basic_faces (f);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1007
2821
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1008 /* If we're modifying either of the frame's display faces, that
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1009 means that we're changing the parameters of a fixed face code;
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1010 since the color/font/whatever is changed but the face ID hasn't,
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1011 redisplay won't know to redraw the affected sections. Give it a
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1012 kick. */
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1013 if (id == 0 || id == 1)
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1014 SET_FRAME_GARBAGED (f);
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1015 else
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1016 /* Otherwise, it's enough to tell it to redisplay the text. */
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1017 windows_or_buffers_changed = 1;
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
1018
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1019 return Qnil;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1020 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1021
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1022 DEFUN ("internal-next-face-id", Finternal_next_face_id, Sinternal_next_face_id,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1023 0, 0, 0, "")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1024 ()
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1025 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1026 return make_number (next_face_id++);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1027 }
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1028
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1029 /* Return the face id for name NAME on frame FRAME.
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1030 (It should be the same for all frames,
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1031 but it's as easy to use the "right" frame to look it up
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1032 as to use any other one.) */
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1033
3065
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
1034 int
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
1035 face_name_id_number (f, name)
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
1036 FRAME_PTR f;
fff06093b756 * xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents: 2998
diff changeset
1037 Lisp_Object name;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1038 {
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1039 Lisp_Object tem;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1040
4258
8f02e992e4dc (face_name_id_number): Use assq_no_quit, not Fassq.
Richard M. Stallman <rms@gnu.org>
parents: 3997
diff changeset
1041 tem = Fcdr (assq_no_quit (name, f->face_alist));
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
1042 if (NILP (tem))
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
1043 return 0;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1044 CHECK_VECTOR (tem, 0);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1045 tem = XVECTOR (tem)->contents[2];
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1046 CHECK_NUMBER (tem, 0);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1047 return XINT (tem);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1048 }
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1049
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
1050 /* Emacs initialization. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
1051
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1052 void
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1053 syms_of_xfaces ()
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1054 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1055 Qface = intern ("face");
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1056 staticpro (&Qface);
6615
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
1057 Qmouse_face = intern ("mouse-face");
96ddf85642d1 (compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents: 5858
diff changeset
1058 staticpro (&Qmouse_face);
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
1059
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
1060 DEFVAR_INT ("region-face", &region_face,
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
1061 "Face number to use to highlight the region\n\
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
1062 The region is highlighted with this face\n\
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
1063 when Transient Mark mode is enabled and the mark is active.");
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
1064
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065 defsubr (&Sframe_face_alist);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1066 defsubr (&Sset_frame_face_alist);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1067 defsubr (&Smake_face_internal);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068 defsubr (&Sset_face_attribute_internal);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1069 defsubr (&Sinternal_next_face_id);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1070 }
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
1071
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
1072 #endif /* HAVE_X_WINDOWS */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
1073