Mercurial > emacs
annotate src/xfaces.c @ 4165:328187f39c3a
(SYSTEM_MALLOC): Add #undef.
(GNU_MALLOC, REL_ALLOC): Defined.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 19 Jul 1993 21:16:07 +0000 |
parents | d968bcba16af |
children | 8f02e992e4dc |
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 | 2 Copyright (C) 1993 Free Software Foundation. |
2342 | 3 |
2336 | 4 This file is part of GNU Emacs. |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
2342 | 8 the Free Software Foundation; either version 2, or (at your option) |
2336 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
2438 | 20 /* This is derived from work by Lucid (some parts very loosely so). */ |
2342 | 21 |
2336 | 22 #include <sys/types.h> |
23 #include <sys/stat.h> | |
24 | |
25 #include "config.h" | |
26 #include "lisp.h" | |
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 | 30 #include "xterm.h" |
31 #include "buffer.h" | |
2391 | 32 #include "dispextern.h" |
2342 | 33 #include "frame.h" |
2438 | 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 | 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 | 51 #include <X11/Xos.h> |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 162 |
163 /* The number of face-id's in use (same for all frames). */ | |
164 int next_face_id; | |
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 | 171 #define FACE_DEFAULT (~0) |
172 | |
2391 | 173 Lisp_Object Qface, Qwindow, Qpriority; |
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 | 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 | 199 /* Make a new face that's a copy of an existing one. */ |
200 static struct face * | |
201 copy_face (face) | |
202 struct face *face; | |
203 { | |
204 struct face *result = allocate_face (); | |
205 | |
206 result->font = face->font; | |
207 result->foreground = face->foreground; | |
208 result->background = face->background; | |
2391 | 209 result->stipple = face->stipple; |
2336 | 210 result->underline = face->underline; |
211 | |
212 return result; | |
213 } | |
214 | |
215 static int | |
216 face_eql (face1, face2) | |
217 struct face *face1, *face2; | |
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 | 220 && face1->foreground == face2->foreground |
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 | 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 | 227 |
228 /* Return the unique display face corresponding to the user-level face FACE. | |
229 If there isn't one, make one, and find a slot in the face_vector to | |
230 put it in. */ | |
231 static struct face * | |
2342 | 232 get_cached_face (f, face) |
2336 | 233 struct frame *f; |
234 struct face *face; | |
235 { | |
236 int i, empty = -1; | |
2391 | 237 struct face *result; |
2336 | 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 | 246 /* Look for an existing display face that does the job. |
247 Also find an empty slot if any. */ | |
248 for (i = 0; i < nfaces; i++) | |
249 { | |
250 if (face_eql (face_vector[i], face)) | |
251 return face_vector[i]; | |
252 if (face_vector[i] == 0) | |
253 empty = i; | |
254 } | |
255 | |
256 /* If no empty slots, make one. */ | |
257 if (empty < 0 && nfaces == nfaces_allocated) | |
258 { | |
259 int newsize = nfaces + 20; | |
260 face_vector | |
261 = (struct face **) xrealloc (face_vector, | |
262 newsize * sizeof (struct face *)); | |
263 nfaces_allocated = newsize; | |
264 } | |
265 | |
266 if (empty < 0) | |
267 empty = nfaces++; | |
268 | |
269 /* Put a new display face in the empty slot. */ | |
270 result = copy_face (face); | |
271 face_vector[empty] = result; | |
272 | |
273 /* Make a graphics context for it. */ | |
274 build_face (f, result); | |
275 | |
276 return result; | |
277 } | |
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 | 311 /* Clear out face_vector and start anew. |
312 This should be done from time to time just to avoid | |
313 keeping too many graphics contexts in face_vector | |
314 that are no longer needed. */ | |
315 | |
316 void | |
317 clear_face_vector () | |
318 { | |
319 Lisp_Object rest; | |
320 Display *dpy = x_current_display; | |
2391 | 321 int i; |
2336 | 322 |
323 BLOCK_INPUT; | |
324 /* Free the display faces in the face_vector. */ | |
325 for (i = 0; i < nfaces; i++) | |
326 { | |
327 struct face *face = face_vector[i]; | |
2391 | 328 if (face->gc) |
329 XFreeGC (dpy, face->gc); | |
2336 | 330 xfree (face); |
331 } | |
332 nfaces = 0; | |
333 | |
334 UNBLOCK_INPUT; | |
335 } | |
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 | 339 /* Make a graphics context for face FACE, which is on frame F, |
340 if that can be done. */ | |
2336 | 341 static void |
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 | 345 { |
346 GC gc; | |
347 XGCValues xgcv; | |
348 unsigned long mask; | |
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 | 352 if (face->foreground != FACE_DEFAULT) |
353 xgcv.foreground = face->foreground; | |
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 | 357 if (face->background != FACE_DEFAULT) |
358 xgcv.background = face->background; | |
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 | 362 if (face->font && (int) face->font != FACE_DEFAULT) |
363 xgcv.font = face->font->fid; | |
364 else | |
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 | 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 | 369 mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; |
370 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f), | |
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 | 373 #if 0 |
2391 | 374 if (face->stipple && face->stipple != FACE_DEFAULT) |
375 XSetStipple (x_current_display, gc, face->stipple); | |
2336 | 376 #endif |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
377 |
2391 | 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 | 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 | 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 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
484 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
|
485 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
|
486 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
|
487 |
3583
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
488 /* Find another X frame. */ |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
489 { |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
490 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
|
491 |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
492 result = Qnil; |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
493 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
|
494 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
|
495 && XFRAME (frame) != f) |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
496 { |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
497 result = frame; |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
498 break; |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
499 } |
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
|
500 |
3583
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
501 /* 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
|
502 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
|
503 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
|
504 on this new frame. */ |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
505 if (FRAMEP (result)) |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
506 { |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
507 int i; |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
508 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
|
509 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
|
510 |
3583
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
511 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
|
512 if (faces[i]) |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
513 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
|
514 } |
0bc9838eb0bb
* xfaces.c (init_frame_faces): Remove assumption that the selected
Jim Blandy <jimb@redhat.com>
parents:
3528
diff
changeset
|
515 } |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
516 } |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
517 |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
518 |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
519 /* 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
|
520 void |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
521 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
|
522 struct frame *f; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
523 { |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
524 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
|
525 int i; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
526 |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
527 BLOCK_INPUT; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
528 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
529 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
|
530 { |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
531 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
|
532 if (face) |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
533 { |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
534 if (face->gc) |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
535 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
|
536 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
|
537 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
|
538 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
|
539 #if 0 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
540 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
|
541 #endif |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
542 xfree (face); |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
543 } |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
544 } |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
545 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
|
546 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
|
547 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
|
548 |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
549 /* 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
555 UNBLOCK_INPUT; |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
556 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
557 |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
558 /* 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
|
559 |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
560 static int |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
561 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
|
562 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
|
563 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
|
564 { |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
565 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
|
566 |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
567 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
|
568 { |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
569 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
|
570 |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
571 FRAME_COMPUTED_FACES (f) |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
572 = (struct face **) |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
573 (FRAME_SIZE_COMPUTED_FACES (f) == 0 |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
574 ? xmalloc (new_size * sizeof (struct face *)) |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
575 : xrealloc (FRAME_COMPUTED_FACES (f), |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
576 new_size * sizeof (struct face *))); |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
577 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
|
578 } |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
579 |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
580 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
|
581 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
|
582 return i; |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
583 } |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
584 |
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 /* 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
|
587 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
|
588 static int |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
589 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
|
590 struct frame *f; |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
591 struct face *new_face; |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
592 { |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
593 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
|
594 int i; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
595 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
596 /* 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
|
597 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
|
598 { |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
599 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
|
600 abort (); |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
601 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
|
602 return i; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
603 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
604 |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
605 /* 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
|
606 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
|
607 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
608 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
609 /* 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
|
610 |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
611 static void |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
612 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
|
613 struct frame *f; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
614 int id; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
615 { |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
616 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
|
617 { |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
618 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
|
619 int i; |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
620 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
|
621 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
|
622 = (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
|
623 else |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
624 FRAME_PARAM_FACES (f) |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
625 = (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
|
626 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
|
627 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
628 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
|
629 (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
|
630 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
|
631 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
632 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
633 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
|
634 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
|
635 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
636 |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
637 /* 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
|
638 |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
639 /* 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
|
640 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
|
641 int |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
642 same_size_fonts (font1, font2) |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
643 XFontStruct *font1, *font2; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
644 { |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
645 XCharStruct *bounds1 = &font1->min_bounds; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
646 XCharStruct *bounds2 = &font2->min_bounds; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
647 |
3528
aad9fd004281
(same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents:
3436
diff
changeset
|
648 return (bounds1->width == bounds2->width); |
aad9fd004281
(same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents:
3436
diff
changeset
|
649 /* 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
|
650 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
|
651 actually have very slightly different size. |
aad9fd004281
(same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents:
3436
diff
changeset
|
652 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
|
653 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
|
654 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
|
655 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
|
656 && bounds1->ascent == bounds2->ascent |
3528
aad9fd004281
(same_size_fonts): Compare only the width.
Richard M. Stallman <rms@gnu.org>
parents:
3436
diff
changeset
|
657 && bounds1->descent == bounds2->descent); */ |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
658 } |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
659 |
2342 | 660 /* Modify face TO by copying from FROM all properties which have |
661 nondefault settings. */ | |
662 static void | |
663 merge_faces (from, to) | |
664 struct face *from, *to; | |
665 { | |
2883
b8a3b11892dc
Make sure that all the display faces use fonts of the
Jim Blandy <jimb@redhat.com>
parents:
2875
diff
changeset
|
666 /* 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
|
667 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
|
668 && 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
|
669 to->font = from->font; |
2342 | 670 if (from->foreground != FACE_DEFAULT) |
671 to->foreground = from->foreground; | |
672 if (from->background != FACE_DEFAULT) | |
673 to->background = from->background; | |
2391 | 674 if (from->stipple != FACE_DEFAULT) |
675 to->stipple = from->stipple; | |
2342 | 676 if (from->underline) |
677 to->underline = from->underline; | |
678 } | |
679 | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
680 /* 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
|
681 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
|
682 static void |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
683 compute_base_face (f, face) |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
684 FRAME_PTR f; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
685 struct face *face; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
686 { |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
687 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
|
688 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
689 face->gc = 0; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
690 face->foreground = d->foreground_pixel; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
691 face->background = d->background_pixel; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
692 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
|
693 face->stipple = 0; |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
694 face->underline = 0; |
3811
48b1ef149180
* xfaces.c (compute_base_face): Initialize the face's stipple.
Jim Blandy <jimb@redhat.com>
parents:
3583
diff
changeset
|
695 |
48b1ef149180
* xfaces.c (compute_base_face): Initialize the face's stipple.
Jim Blandy <jimb@redhat.com>
parents:
3583
diff
changeset
|
696 /* 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
|
697 face->cached_index = -1; |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
698 } |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
699 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
700 |
2391 | 701 struct sortvec |
702 { | |
703 Lisp_Object overlay; | |
704 int beg, end; | |
705 int priority; | |
706 }; | |
707 | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
708 static int |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
709 sort_overlays (s1, s2) |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
710 struct sortvec *s1, *s2; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
711 { |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
712 if (s1->priority != s2->priority) |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
713 return s1->priority - s2->priority; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
714 if (s1->beg != s2->beg) |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
715 return s1->beg - s2->beg; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
716 if (s1->end != s2->end) |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
717 return s2->end - s1->end; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
718 return 0; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
719 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
720 |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
721 /* Return the face ID associated with a buffer position POS. |
2342 | 722 Store into *ENDPTR the position at which a different face is needed. |
723 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
|
724 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
|
725 the current buffer. |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
726 |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
727 REGION_BEG, REGION_END delimit the region, so it can be highlighted. */ |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
728 |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
729 int |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
730 compute_char_face (f, w, pos, region_beg, region_end, endptr) |
2342 | 731 struct frame *f; |
2391 | 732 struct window *w; |
2342 | 733 int pos; |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
734 int region_beg, region_end; |
2342 | 735 int *endptr; |
736 { | |
737 struct face face; | |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
738 Lisp_Object prop, position; |
2342 | 739 int i, j, noverlays; |
740 int facecode; | |
741 Lisp_Object *overlay_vec; | |
2391 | 742 struct sortvec *sortvec; |
743 Lisp_Object frame; | |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
744 int endpos; |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
745 |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
746 /* 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
|
747 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
|
748 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
|
749 abort (); |
2391 | 750 |
751 XSET (frame, Lisp_Frame, f); | |
2342 | 752 |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
753 endpos = ZV; |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
754 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
|
755 endpos = region_beg; |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
756 |
2342 | 757 XFASTINT (position) = pos; |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
758 prop = Fget_text_property (position, Qface, w->buffer); |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
759 { |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
760 Lisp_Object end; |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
761 |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
762 end = Fnext_single_property_change (position, Qface, w->buffer); |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
763 if (INTEGERP (end)) |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
764 endpos = XINT (end); |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
765 } |
2342 | 766 |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
767 { |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
768 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
|
769 int len; |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
770 |
2838
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
771 /* 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
|
772 len = 40; |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
773 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
|
774 |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
775 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
|
776 |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
777 /* 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
|
778 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
|
779 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
|
780 { |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
781 len = noverlays; |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
782 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
|
783 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
|
784 } |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
785 |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
786 if (next_overlay < endpos) |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
787 endpos = next_overlay; |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
788 } |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
789 |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
790 *endptr = endpos; |
2342 | 791 |
792 /* 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
|
793 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
|
794 && !(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
|
795 return 0; |
2342 | 796 |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
797 compute_base_face (f, &face); |
2342 | 798 |
799 if (!NILP (prop)) | |
800 { | |
3065
fff06093b756
* xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents:
2998
diff
changeset
|
801 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
|
802 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
|
803 && 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
|
804 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); |
2342 | 805 } |
806 | |
2391 | 807 /* Put the valid and relevant overlays into sortvec. */ |
808 sortvec = (struct sortvec *) alloca (noverlays * sizeof (struct sortvec)); | |
809 | |
2342 | 810 for (i = 0, j = 0; i < noverlays; i++) |
811 { | |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
812 Lisp_Object overlay = overlay_vec[i]; |
2342 | 813 |
814 if (OVERLAY_VALID (overlay) | |
815 && OVERLAY_POSITION (OVERLAY_START (overlay)) > 0 | |
816 && OVERLAY_POSITION (OVERLAY_END (overlay)) > 0) | |
2391 | 817 { |
818 Lisp_Object window; | |
819 window = Foverlay_get (overlay, Qwindow); | |
820 | |
821 /* Also ignore overlays limited to one window | |
822 if it's not the window we are using. */ | |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
823 if (XTYPE (window) != Lisp_Window |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
824 || XWINDOW (window) == w) |
2391 | 825 { |
826 Lisp_Object tem; | |
827 | |
828 /* This overlay is good and counts: | |
829 put it in sortvec. */ | |
830 sortvec[j].overlay = overlay; | |
831 sortvec[j].beg = OVERLAY_POSITION (OVERLAY_START (overlay)); | |
832 sortvec[j].end = OVERLAY_POSITION (OVERLAY_END (overlay)); | |
833 tem = Foverlay_get (overlay, Qpriority); | |
834 if (INTEGERP (tem)) | |
835 sortvec[j].priority = XINT (tem); | |
836 else | |
837 sortvec[j].priority = 0; | |
838 j++; | |
839 } | |
840 } | |
2342 | 841 } |
842 noverlays = j; | |
843 | |
2391 | 844 /* Sort the overlays into the proper order: increasing priority. */ |
845 | |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
846 if (noverlays > 1) |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
847 qsort (sortvec, noverlays, sizeof (struct sortvec), sort_overlays); |
2342 | 848 |
849 /* Now merge the overlay data in that order. */ | |
850 for (i = 0; i < noverlays; i++) | |
851 { | |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
852 prop = Foverlay_get (sortvec[i].overlay, Qface); |
2342 | 853 if (!NILP (prop)) |
854 { | |
855 Lisp_Object oend; | |
856 int oendpos; | |
857 | |
3065
fff06093b756
* xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents:
2998
diff
changeset
|
858 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
|
859 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
|
860 && 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
|
861 merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); |
2342 | 862 |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
863 oend = OVERLAY_END (sortvec[i].overlay); |
2342 | 864 oendpos = OVERLAY_POSITION (oend); |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
865 if (oendpos < endpos) |
2342 | 866 endpos = oendpos; |
867 } | |
868 } | |
869 | |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
870 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
|
871 { |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
872 if (region_end < endpos) |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
873 endpos = region_end; |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
874 if (region_face >= 0 && region_face < next_face_id) |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
875 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
|
876 } |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
877 |
2342 | 878 *endptr = endpos; |
879 | |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
880 return intern_computed_face (f, &face); |
2342 | 881 } |
882 | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
883 /* 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
|
884 FACE_CODE as the face ID, assuming that ordinarily the face would |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
885 be BASIC_FACE. F is the frame. */ |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
886 int |
2743
ddc49d5eee56
* xdisp.c (display_text_line): We can't use the FRAME_DEFAULT_FACE
Jim Blandy <jimb@redhat.com>
parents:
2730
diff
changeset
|
887 compute_glyph_face (f, face_code) |
2342 | 888 struct frame *f; |
889 int face_code; | |
890 { | |
891 struct face face; | |
892 | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
893 compute_base_face (f, &face); |
2342 | 894 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
895 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
|
896 && 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
|
897 merge_faces (FRAME_PARAM_FACES (f) [face_code], &face); |
2342 | 898 |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
899 return intern_computed_face (f, &face); |
2336 | 900 } |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
901 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
902 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
903 /* 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
|
904 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
|
905 depend. */ |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
906 void |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
907 recompute_basic_faces (f) |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
908 FRAME_PTR f; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
909 { |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
910 /* 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
|
911 this stuff. */ |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
912 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
|
913 return; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
914 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
915 BLOCK_INPUT; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
916 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
917 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
|
918 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
|
919 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
|
920 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
|
921 |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
922 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
|
923 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
|
924 |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
925 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
|
926 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
|
927 |
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
928 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
|
929 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
|
930 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
931 UNBLOCK_INPUT; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
932 } |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
933 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
934 |
2336 | 935 |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
936 /* Lisp interface. */ |
2336 | 937 |
938 DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist, 1, 1, 0, | |
939 "") | |
940 (frame) | |
941 Lisp_Object frame; | |
942 { | |
943 CHECK_FRAME (frame, 0); | |
944 return XFRAME (frame)->face_alist; | |
945 } | |
946 | |
947 DEFUN ("set-frame-face-alist", Fset_frame_face_alist, Sset_frame_face_alist, | |
948 2, 2, 0, "") | |
949 (frame, value) | |
950 Lisp_Object frame, value; | |
951 { | |
952 CHECK_FRAME (frame, 0); | |
953 XFRAME (frame)->face_alist = value; | |
954 return value; | |
955 } | |
956 | |
957 | |
958 DEFUN ("make-face-internal", Fmake_face_internal, Smake_face_internal, 1, 1, 0, | |
959 "Create face number FACE-ID on all frames.") | |
960 (face_id) | |
961 Lisp_Object face_id; | |
962 { | |
963 Lisp_Object rest; | |
964 int id = XINT (face_id); | |
965 | |
2391 | 966 CHECK_NUMBER (face_id, 0); |
967 if (id < 0 || id >= next_face_id) | |
968 error ("Face id out of range"); | |
2336 | 969 |
970 for (rest = Vframe_list; !NILP (rest); rest = XCONS (rest)->cdr) | |
971 { | |
972 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
|
973 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
|
974 ensure_face_ready (f, id); |
2336 | 975 } |
976 return Qnil; | |
977 } | |
978 | |
979 | |
980 DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal, | |
981 Sset_face_attribute_internal, 4, 4, 0, "") | |
982 (face_id, attr_name, attr_value, frame) | |
983 Lisp_Object face_id, attr_name, attr_value, frame; | |
984 { | |
985 struct face *face; | |
986 struct frame *f; | |
987 int magic_p; | |
988 int id; | |
989 | |
990 CHECK_FRAME (frame, 0); | |
2391 | 991 CHECK_NUMBER (face_id, 0); |
2336 | 992 CHECK_SYMBOL (attr_name, 0); |
993 | |
994 f = XFRAME (frame); | |
995 id = XINT (face_id); | |
2391 | 996 if (id < 0 || id >= next_face_id) |
997 error ("Face id out of range"); | |
2336 | 998 |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
999 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
|
1000 return; |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
1001 |
2336 | 1002 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
|
1003 face = FRAME_PARAM_FACES (f) [XFASTINT (face_id)]; |
2336 | 1004 |
1005 if (EQ (attr_name, intern ("font"))) | |
1006 { | |
2391 | 1007 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
|
1008 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
|
1009 unload_font (f, face->font); |
2336 | 1010 face->font = font; |
1011 } | |
1012 else if (EQ (attr_name, intern ("foreground"))) | |
1013 { | |
2391 | 1014 unsigned long new_color = load_color (f, attr_value); |
2336 | 1015 unload_color (f, face->foreground); |
1016 face->foreground = new_color; | |
1017 } | |
1018 else if (EQ (attr_name, intern ("background"))) | |
1019 { | |
2391 | 1020 unsigned long new_color = load_color (f, attr_value); |
2336 | 1021 unload_color (f, face->background); |
1022 face->background = new_color; | |
1023 } | |
1024 #if 0 | |
1025 else if (EQ (attr_name, intern ("background-pixmap"))) | |
1026 { | |
1027 unsigned int w, h, d; | |
1028 unsigned long new_pixmap = load_pixmap (f, attr_value, &w, &h, &d, 0); | |
2391 | 1029 unload_pixmap (f, face->stipple); |
1030 if (NILP (attr_value)) | |
1031 new_pixmap = 0; | |
1032 face->stipple = new_pixmap; | |
2336 | 1033 face->pixmap_w = w; |
1034 face->pixmap_h = h; | |
1035 /* face->pixmap_depth = d; */ | |
1036 } | |
1037 #endif /* 0 */ | |
1038 else if (EQ (attr_name, intern ("underline"))) | |
1039 { | |
1040 int new = !NILP (attr_value); | |
1041 face->underline = new; | |
1042 } | |
1043 else | |
1044 error ("unknown face attribute"); | |
1045 | |
3882
a0b9347a3973
Separate parameter faces (those created and modified by the user)
Jim Blandy <jimb@redhat.com>
parents:
3843
diff
changeset
|
1046 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
|
1047 recompute_basic_faces (f); |
2336 | 1048 |
2821
95010b414003
* xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents:
2818
diff
changeset
|
1049 /* 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
|
1050 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
|
1051 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
|
1052 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
|
1053 kick. */ |
95010b414003
* xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents:
2818
diff
changeset
|
1054 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
|
1055 SET_FRAME_GARBAGED (f); |
95010b414003
* xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents:
2818
diff
changeset
|
1056 else |
95010b414003
* xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents:
2818
diff
changeset
|
1057 /* 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
|
1058 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
|
1059 |
2336 | 1060 return Qnil; |
1061 } | |
1062 | |
1063 DEFUN ("internal-next-face-id", Finternal_next_face_id, Sinternal_next_face_id, | |
1064 0, 0, 0, "") | |
1065 () | |
1066 { | |
1067 return make_number (next_face_id++); | |
1068 } | |
2391 | 1069 |
1070 /* Return the face id for name NAME on frame FRAME. | |
1071 (It should be the same for all frames, | |
1072 but it's as easy to use the "right" frame to look it up | |
1073 as to use any other one.) */ | |
1074 | |
3065
fff06093b756
* xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents:
2998
diff
changeset
|
1075 int |
fff06093b756
* xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents:
2998
diff
changeset
|
1076 face_name_id_number (f, name) |
fff06093b756
* xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents:
2998
diff
changeset
|
1077 FRAME_PTR f; |
fff06093b756
* xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents:
2998
diff
changeset
|
1078 Lisp_Object name; |
2391 | 1079 { |
1080 Lisp_Object tem; | |
1081 | |
3065
fff06093b756
* xfns.c (Fx_list_fonts): New function.
Jim Blandy <jimb@redhat.com>
parents:
2998
diff
changeset
|
1082 tem = Fcdr (Fassq (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
|
1083 if (NILP (tem)) |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
1084 return 0; |
2391 | 1085 CHECK_VECTOR (tem, 0); |
1086 tem = XVECTOR (tem)->contents[2]; | |
1087 CHECK_NUMBER (tem, 0); | |
1088 return XINT (tem); | |
1089 } | |
2336 | 1090 |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
1091 /* Emacs initialization. */ |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
1092 |
2336 | 1093 void |
2391 | 1094 syms_of_xfaces () |
2336 | 1095 { |
2391 | 1096 Qwindow = intern ("window"); |
1097 staticpro (&Qwindow); | |
1098 Qface = intern ("face"); | |
1099 staticpro (&Qface); | |
1100 Qpriority = intern ("priority"); | |
1101 staticpro (&Qpriority); | |
1102 | |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
1103 DEFVAR_INT ("region-face", ®ion_face, |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
1104 "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
|
1105 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
|
1106 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
|
1107 |
2336 | 1108 defsubr (&Sframe_face_alist); |
1109 defsubr (&Sset_frame_face_alist); | |
1110 defsubr (&Smake_face_internal); | |
1111 defsubr (&Sset_face_attribute_internal); | |
1112 defsubr (&Sinternal_next_face_id); | |
1113 } | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
1114 |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
1115 #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
|
1116 |