annotate src/xfaces.c @ 2821:95010b414003

* xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it knows something has changed.
author Jim Blandy <jimb@redhat.com>
date Sun, 16 May 1993 01:32:11 +0000
parents d1cfc6cbdbf7
children 5f6a2d52d2ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
1 /* "Face" primitives.
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
2 Copyright (C) 1992, 1993 Free Software Foundation.
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
3
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
2438
b513de4de386 * xfaces.c: Doc fixes.
Jim Blandy <jimb@redhat.com>
parents: 2391
diff changeset
20 /* This is derived from work by Lucid (some parts very loosely so). */
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
21
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 #include <sys/types.h>
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 #include <sys/stat.h>
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 #include "config.h"
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #include "lisp.h"
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
28 #ifdef HAVE_X_WINDOWS
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
29
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 #include "xterm.h"
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 #include "buffer.h"
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
32 #include "dispextern.h"
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
33 #include "frame.h"
2438
b513de4de386 * xfaces.c: Doc fixes.
Jim Blandy <jimb@redhat.com>
parents: 2391
diff changeset
34 #include "blockinput.h"
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
35 #include "window.h"
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 /* Display Context for the icons */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #include <X11/Intrinsic.h>
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 #include <X11/StringDefs.h>
2538
78420d74d47f Don't include Xmu/Drawing.h.
Richard M. Stallman <rms@gnu.org>
parents: 2513
diff changeset
40 /* #include <X11/Xmu/Drawing.h> */ /* Appears not to be used */
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 #include <X11/Xos.h>
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
43
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
44 /* 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
45
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
46 /* ========================= Face Data Structures =========================
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
47
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
48 All lisp code uses symbols as face names.
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
49
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
50 Each frame has a face_alist member (with the frame-face-alist and
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
51 set-frame-face-alist accessors), associating the face names with
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
52 vectors of the form
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
53 [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
54 where
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
55 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
56 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
57 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
58 the face,
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
59 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
60 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
61 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
62 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
63 UNDERLINE-P is non-nil if the face should be underlined.
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
64 (lisp/faces.el maintains these association lists.)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
65
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
66 The frames' private alists hold the frame-local definitions for the
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
67 faces. The lisp variable global-face-data contains the global
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
68 defaults for faces. (See lisp/faces.el for this too.)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
69
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
70 In the C code, we also have a `struct face' with the elements
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
71 `foreground', `background', `font', and `underline',
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
72 which specify its visual appearance, and elements
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
73 `gc' and `cached_index';
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
74 `gc' may be an X GC which has been built for the given display
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
75 parameters. Faces with GC's are called `display faces'. Whether
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
76 or not a face has a GC depends on what data structure the face is
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
77 in; we explain these more below. (See src/dispextern.h.)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
78
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
79 Each frame also has members called `faces' and `n_faces' (with the
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
80 accessors FRAME_FACES and FRAME_N_FACES), which define an array of
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
81 struct face pointers, indexed by face ID (element 2 of the
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
82 vector). These are called "frame faces".
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
83 Element 0 is the default face --- the one used for normal text.
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
84 Element 1 is the modeline face.
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
85 These faces have their GC's set; the rest do not. (See src/xterm.h.)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
86
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
87 The global variables `face_vector' and `nfaces' define another
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
88 array of struct face pointers, with their GC's set. This array
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
89 acts as a cache of GC's to be used by all frames. The function
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
90 `intern_face', passed a struct face *, searches face_vector for a
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
91 struct face with the same parameters, adds a new one with a GC if
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
92 it doesn't find one, and returns it. If you have a `struct face',
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
93 and you want a GC for it, call intern_face on that struct, and it
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
94 will return a `struct face *' with its GC set. The faces in
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
95 face_vector are called `cached faces.' (See src/xfaces.c.)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
96
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
97 The `GLYPH' data type is an unsigned integer type; the bottom byte
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
98 is a character code, and the byte above that is a face id. The
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
99 `struct frame_glyphs' structure, used to describe frames' current
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
100 or desired contents, is essentially a matrix of GLYPHs; the face
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
101 ID's in a struct frame_glyphs are indices into FRAME_FACES. (See
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
102 src/dispextern.h.)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
103
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
104 Some subtleties:
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
105
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 purge.
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
114
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
115 We're often applying intern_face to faces in frames' local arrays -
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
116 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
117 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
118 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
119 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
120 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
121 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
122
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
123
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
124 /* Definitions and declarations. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
125
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 /* A table of display faces. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 struct face **face_vector;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 /* The length in use of the table. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 int nfaces;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 /* The allocated length of the table. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 int nfaces_allocated;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 /* The number of face-id's in use (same for all frames). */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 int next_face_id;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
136 /* 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
137 int region_face;
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
138
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
139 #define FACE_DEFAULT (~0)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
140
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
141 Lisp_Object Qface, Qwindow, Qpriority;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
142
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 static void build_face ();
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
144 static Lisp_Object face_name_id_number ();
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
145
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
146 struct face *intern_face ();
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
147 static void ensure_face_ready ();
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
149 /* 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
150
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
151 /* 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
152 static struct face *
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
153 allocate_face ()
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
154 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
155 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
156 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
157 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
158 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
159 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
160 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
161 return result;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
162 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
163
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 /* Make a new face that's a copy of an existing one. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 static struct face *
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 copy_face (face)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 struct face *face;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 struct face *result = allocate_face ();
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 result->font = face->font;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 result->foreground = face->foreground;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 result->background = face->background;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
174 result->stipple = face->stipple;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 result->underline = face->underline;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 return result;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 static int
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 face_eql (face1, face2)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 struct face *face1, *face2;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 {
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
184 return ( face1->font == face2->font
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 && face1->foreground == face2->foreground
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 && 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
187 && 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
188 && face1->underline == face2->underline);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 }
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
190
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
191 /* Interning faces in the `face_vector' cache, and clearing that cache. */
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 /* Return the unique display face corresponding to the user-level face FACE.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 If there isn't one, make one, and find a slot in the face_vector to
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 put it in. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 static struct face *
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
197 get_cached_face (f, face)
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 struct frame *f;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 struct face *face;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 int i, empty = -1;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
202 struct face *result;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
204 /* 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
205 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
206 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
207 && 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
208 && 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
209 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
210
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 /* Look for an existing display face that does the job.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 Also find an empty slot if any. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 for (i = 0; i < nfaces; i++)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 if (face_eql (face_vector[i], face))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 return face_vector[i];
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 if (face_vector[i] == 0)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 empty = i;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 /* If no empty slots, make one. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 if (empty < 0 && nfaces == nfaces_allocated)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 int newsize = nfaces + 20;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 face_vector
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 = (struct face **) xrealloc (face_vector,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 newsize * sizeof (struct face *));
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 nfaces_allocated = newsize;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 if (empty < 0)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 empty = nfaces++;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 /* Put a new display face in the empty slot. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 result = copy_face (face);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 face_vector[empty] = result;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 /* Make a graphics context for it. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 build_face (f, result);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 return result;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
244 /* Given a frame face, return an equivalent display face
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
245 (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
246
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
247 struct face *
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
248 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
249 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
250 struct face *face;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
251 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
252 /* 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
253 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
254 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
255 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
256 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
257 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
258 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
259
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
260 /* 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
261 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
262 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
263 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
264 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
265 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
266 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
267
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
268 /* 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
269 if (face->gc)
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
270 abort ();
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
271
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
272 /* 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
273 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
274 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
275
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 /* Clear out face_vector and start anew.
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 This should be done from time to time just to avoid
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 keeping too many graphics contexts in face_vector
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 that are no longer needed. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 void
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 clear_face_vector ()
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 Lisp_Object rest;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 Display *dpy = x_current_display;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
286 int i;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 BLOCK_INPUT;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 /* Free the display faces in the face_vector. */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 for (i = 0; i < nfaces; i++)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 struct face *face = face_vector[i];
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
293 if (face->gc)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
294 XFreeGC (dpy, face->gc);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 xfree (face);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 nfaces = 0;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 UNBLOCK_INPUT;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
302 /* 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
303
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
304 /* Make a graphics context for face FACE, which is on frame F,
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
305 if that can be done. */
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 static void
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 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
308 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
309 struct face *face;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 GC gc;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 XGCValues xgcv;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 unsigned long mask;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
315 if (face->foreground != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
316 xgcv.foreground = face->foreground;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
317 else
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
318 xgcv. foreground = f->display.x->foreground_pixel;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
319 if (face->background != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
320 xgcv.background = face->background;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
321 else
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
322 xgcv. background = f->display.x->background_pixel;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
323 if (face->font && (int) face->font != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
324 xgcv.font = face->font->fid;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
325 else
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
326 xgcv.font = f->display.x->font->fid;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 xgcv.graphics_exposures = 0;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 gc = XCreateGC (x_current_display, FRAME_X_WINDOW (f),
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 mask, &xgcv);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 #if 0
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
332 if (face->stipple && face->stipple != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
333 XSetStipple (x_current_display, gc, face->stipple);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 #endif
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
335 face->gc = gc;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 }
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
337
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
338 /* 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
339
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
340 static XFontStruct *
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
341 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
342 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
343 Lisp_Object name;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
344 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
345 XFontStruct *font;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
346
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
347 if (NILP (name))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
348 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
349
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
350 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
351 BLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
352 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
353 UNBLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
354
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
355 if (! font)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
356 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
357 Fcons (name, Qnil)));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
358 return font;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
359 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
360
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
361 static void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
362 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
363 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
364 XFontStruct *font;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
365 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
366 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
367 return;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
368 XFreeFont (x_current_display, font);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
369 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
370
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
371 static unsigned long
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
372 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
373 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
374 Lisp_Object name;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
375 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
376 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
377 Colormap cmap;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
378 XColor color;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
379 int result;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
380
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
381 if (NILP (name))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
382 return FACE_DEFAULT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
383
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
384 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
385
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
386 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
387 BLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
388 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
389 UNBLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
390 if (! result)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
391 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
392 Fcons (name, Qnil)));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
393 BLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
394 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
395 UNBLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
396 if (! result)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
397 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
398 Fcons (name, Qnil)));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
399 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
400 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
401
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
402 static void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
403 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
404 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
405 Pixel pixel;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
406 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
407 Colormap cmap;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
408 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
409 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
410 || 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
411 || 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
412 return;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
413 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
414 BLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
415 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
416 UNBLOCK_INPUT;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
417 }
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
419 /* Initializing face arrays for frames. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
420
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
421 /* Set up faces 0 and 1 based on the normal text and modeline GC's. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
422 void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
423 init_frame_faces (f)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
424 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
425 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
426 ensure_face_ready (f, 0);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
427 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
428 XGCValues gcv;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
429 struct face *face = FRAME_FACES (f) [0];
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
430
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
431 XGetGCValues (x_current_display, f->display.x->normal_gc,
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
432 GCForeground | GCBackground | GCFont, &gcv);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
433 face->gc = f->display.x->normal_gc;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
434 face->foreground = gcv.foreground;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
435 face->background = gcv.background;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
436 face->font = XQueryFont (x_current_display, gcv.font);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
437 face->stipple = 0;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
438 face->underline = 0;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
439 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
440
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
441 ensure_face_ready (f, 1);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
442 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
443 XGCValues gcv;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
444 struct face *face = FRAME_FACES (f) [1];
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
445
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
446 XGetGCValues (x_current_display, f->display.x->reverse_gc,
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
447 GCForeground | GCBackground | GCFont, &gcv);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
448 face->gc = f->display.x->reverse_gc;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
449 face->foreground = gcv.foreground;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
450 face->background = gcv.background;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
451 face->font = XQueryFont (x_current_display, gcv.font);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
452 face->stipple = 0;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
453 face->underline = 0;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
454 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
455 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
456
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
457 #if 0
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
458 void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
459 init_frame_faces (f)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
460 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
461 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
462 struct frame *other_frame = 0;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
463 Lisp_Object rest;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
464
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
465 for (rest = Vframe_list; !NILP (rest); rest = Fcdr (rest))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
466 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
467 struct frame *f2 = XFRAME (Fcar (rest));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
468 if (f2 != f && FRAME_X_P (f2))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
469 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
470 other_frame = f2;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
471 break;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
472 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
473 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
474
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
475 if (other_frame)
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 /* Make sure this frame's face vector is as big as the others. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
478 FRAME_N_FACES (f) = FRAME_N_FACES (other_frame);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
479 FRAME_FACES (f)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
480 = (struct face **) xmalloc (FRAME_N_FACES (f) * sizeof (struct face *));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
481
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
482 /* Make sure the frame has the two basic faces. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
483 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
484 = copy_face (FRAME_DEFAULT_FACE (other_frame));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
485 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
486 = copy_face (FRAME_MODE_LINE_FACE (other_frame));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
487 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
488 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
489 #endif
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
490
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
491
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
492 /* 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
493 void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
494 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
495 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
496 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
497 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
498 int i;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
499
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
500 for (i = 0; i < FRAME_N_FACES (f); i++)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
501 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
502 struct face *face = FRAME_FACES (f) [i];
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
503 if (! face)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
504 continue;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
505 if (face->gc)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
506 XFreeGC (dpy, face->gc);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
507 unload_font (f, face->font);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
508 unload_color (f, face->foreground);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
509 unload_color (f, face->background);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
510 #if 0
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
511 unload_pixmap (f, face->stipple);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
512 #endif
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
513 xfree (face);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
514 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
515 xfree (FRAME_FACES (f));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
516 FRAME_FACES (f) = 0;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
517 FRAME_N_FACES (f) = 0;
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
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
520 /* 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
521
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
522 /* Find a match for NEW_FACE in a FRAME's face array, and add it if we don't
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
523 find one. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
524 int
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
525 intern_frame_face (frame, new_face)
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
526 struct frame *frame;
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
527 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
528 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
529 int len = FRAME_N_FACES (frame);
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
530 int i;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
531
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
532 /* Search for a face already on FRAME equivalent to FACE. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
533 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
534 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
535 struct face *frame_face = FRAME_FACES (frame)[i];
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
536
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
537 if (frame_face && face_eql (new_face, frame_face))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
538 return i;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
539 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
540
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
541 /* We didn't find one; add a new one. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
542 i = next_face_id++;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
543
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
544 ensure_face_ready (frame, i);
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
545 bcopy (new_face, FRAME_FACES (frame)[i], sizeof (*new_face));
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
546
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
547 return i;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
548 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
549
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
550 /* Make face id ID valid on frame F. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
551
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
552 static void
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
553 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
554 struct frame *f;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
555 int id;
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 if (FRAME_N_FACES (f) <= id)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
558 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
559 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
560 int i;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
561 if (!FRAME_N_FACES (f))
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
562 FRAME_FACES (f)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
563 = (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
564 else
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
565 FRAME_FACES (f)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
566 = (struct face **) xrealloc (FRAME_FACES (f),
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
567 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
568
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
569 bzero (FRAME_FACES (f) + FRAME_N_FACES (f),
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
570 (n - FRAME_N_FACES (f)) * sizeof (struct face *));
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
571 FRAME_N_FACES (f) = n;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
572 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
573
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
574 if (FRAME_FACES (f) [id] == 0)
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
575 FRAME_FACES (f) [id] = allocate_face ();
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
576 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
577
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
578 /* 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
579
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
580 /* Modify face TO by copying from FROM all properties which have
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
581 nondefault settings. */
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
582 static void
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
583 merge_faces (from, to)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
584 struct face *from, *to;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
585 {
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
586 if (from->font != (XFontStruct *)FACE_DEFAULT)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
587 {
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
588 to->font = from->font;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
589 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
590 if (from->foreground != FACE_DEFAULT)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
591 to->foreground = from->foreground;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
592 if (from->background != FACE_DEFAULT)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
593 to->background = from->background;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
594 if (from->stipple != FACE_DEFAULT)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
595 to->stipple = from->stipple;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
596 if (from->underline)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
597 to->underline = from->underline;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
598 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
599
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
600 struct sortvec
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
601 {
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
602 Lisp_Object overlay;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
603 int beg, end;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
604 int priority;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
605 };
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
606
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
607 static int
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
608 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
609 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
610 {
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
611 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
612 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
613 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
614 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
615 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
616 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
617 return 0;
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
618 }
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
619
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
620 /* Return the face ID associated with a buffer position POS.
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
621 Store into *ENDPTR the position at which a different face is needed.
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
622 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
623 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
624 the current buffer.
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
625
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
626 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
627
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
628 int
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
629 compute_char_face (f, w, pos, region_beg, region_end, endptr)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
630 struct frame *f;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
631 struct window *w;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
632 int pos;
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
633 int region_beg, region_end;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
634 int *endptr;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
635 {
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
636 struct face face;
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
637 Lisp_Object prop, position;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
638 int i, j, noverlays;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
639 int facecode;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
640 Lisp_Object *overlay_vec;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
641 int len;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
642 struct sortvec *sortvec;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
643 Lisp_Object frame;
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
644 int endpos;
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
645
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
646 /* 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
647 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
648 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
649 abort ();
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
650
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
651 XSET (frame, Lisp_Frame, f);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
652
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
653 endpos = ZV;
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
654 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
655 endpos = region_beg;
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
656
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
657 XFASTINT (position) = pos;
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
658 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
659 {
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
660 Lisp_Object end;
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
661
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
662 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
663 if (INTEGERP (end))
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
664 endpos = XINT (end);
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
665 }
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
666
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
667 {
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
668 int next_overlay;
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
669
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
670 len = 10;
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
671 overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
672 noverlays = overlays_at (pos, &overlay_vec, &len, &next_overlay);
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
673 if (next_overlay < endpos)
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
674 endpos = next_overlay;
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
675 }
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
676
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
677 *endptr = endpos;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
678
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
679 /* 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
680 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
681 && !(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
682 return 0;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
683
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
684 bcopy (FRAME_DEFAULT_FACE (f), &face, sizeof (struct face));
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
685 face.gc = 0;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
686
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
687 if (!NILP (prop))
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
688 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
689 facecode = face_name_id_number (frame, prop);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
690 if (facecode >= 0 && facecode < FRAME_N_FACES (f)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
691 && FRAME_FACES (f) [facecode] != 0)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
692 merge_faces (FRAME_FACES (f) [facecode], &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
693 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
694
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
695 /* Put the valid and relevant overlays into sortvec. */
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
696 sortvec = (struct sortvec *) alloca (noverlays * sizeof (struct sortvec));
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
697
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
698 for (i = 0, j = 0; i < noverlays; i++)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
699 {
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
700 Lisp_Object overlay = overlay_vec[i];
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
701
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
702 if (OVERLAY_VALID (overlay)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
703 && OVERLAY_POSITION (OVERLAY_START (overlay)) > 0
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
704 && OVERLAY_POSITION (OVERLAY_END (overlay)) > 0)
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
705 {
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
706 Lisp_Object window;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
707 window = Foverlay_get (overlay, Qwindow);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
708
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
709 /* Also ignore overlays limited to one window
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
710 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
711 if (XTYPE (window) != Lisp_Window
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
712 || XWINDOW (window) == w)
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
713 {
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
714 Lisp_Object tem;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
715
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
716 /* This overlay is good and counts:
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
717 put it in sortvec. */
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
718 sortvec[j].overlay = overlay;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
719 sortvec[j].beg = OVERLAY_POSITION (OVERLAY_START (overlay));
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
720 sortvec[j].end = OVERLAY_POSITION (OVERLAY_END (overlay));
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
721 tem = Foverlay_get (overlay, Qpriority);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
722 if (INTEGERP (tem))
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
723 sortvec[j].priority = XINT (tem);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
724 else
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
725 sortvec[j].priority = 0;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
726 j++;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
727 }
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
728 }
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
729 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
730 noverlays = j;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
731
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
732 /* Sort the overlays into the proper order: increasing priority. */
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
733
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
734 if (noverlays > 1)
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
735 qsort (sortvec, noverlays, sizeof (struct sortvec), sort_overlays);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
736
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
737 /* Now merge the overlay data in that order. */
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
738 for (i = 0; i < noverlays; i++)
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
739 {
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
740 prop = Foverlay_get (sortvec[i].overlay, Qface);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
741 if (!NILP (prop))
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
742 {
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
743 Lisp_Object oend;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
744 int oendpos;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
745
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
746 facecode = face_name_id_number (frame, prop);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
747 if (facecode >= 0 && facecode < FRAME_N_FACES (f)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
748 && FRAME_FACES (f) [facecode] != 0)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
749 merge_faces (FRAME_FACES (f) [facecode], &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
750
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
751 oend = OVERLAY_END (sortvec[i].overlay);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
752 oendpos = OVERLAY_POSITION (oend);
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
753 if (oendpos < endpos)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
754 endpos = oendpos;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
755 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
756 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
757
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
758 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
759 {
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
760 if (region_end < endpos)
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
761 endpos = region_end;
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
762 if (region_face >= 0 && region_face < next_face_id)
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
763 merge_faces (FRAME_FACES (f) [region_face], &face);
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
764 }
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
765
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
766 xfree (overlay_vec);
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
767
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
768 *endptr = endpos;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
769
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
770 return intern_frame_face (f, &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
771 }
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
772
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
773 /* 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
774 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
775 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
776 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
777 compute_glyph_face (f, face_code)
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
778 struct frame *f;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
779 int face_code;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
780 {
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
781 struct face face;
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
782
2743
ddc49d5eee56 * xdisp.c (display_text_line): We can't use the FRAME_DEFAULT_FACE
Jim Blandy <jimb@redhat.com>
parents: 2730
diff changeset
783 bcopy (FRAME_DEFAULT_FACE (f), &face, sizeof (face));
2784
f8c6796b7777 * xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents: 2767
diff changeset
784 face.gc = 0;
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
785
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
786 if (face_code >= 0 && face_code < FRAME_N_FACES (f)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
787 && FRAME_FACES (f) [face_code] != 0)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
788 merge_faces (FRAME_FACES (f) [face_code], &face);
2342
f881f2936eec *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2336
diff changeset
789
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
790 return intern_frame_face (f, &face);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
791 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
793 /* Lisp interface. */
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist, 1, 1, 0,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
796 "")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
797 (frame)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
798 Lisp_Object frame;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
799 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
800 CHECK_FRAME (frame, 0);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
801 return XFRAME (frame)->face_alist;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
803
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804 DEFUN ("set-frame-face-alist", Fset_frame_face_alist, Sset_frame_face_alist,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805 2, 2, 0, "")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
806 (frame, value)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807 Lisp_Object frame, value;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809 CHECK_FRAME (frame, 0);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 XFRAME (frame)->face_alist = value;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 return value;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 DEFUN ("make-face-internal", Fmake_face_internal, Smake_face_internal, 1, 1, 0,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 "Create face number FACE-ID on all frames.")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 (face_id)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818 Lisp_Object face_id;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
819 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 Lisp_Object rest;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821 int id = XINT (face_id);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
823 CHECK_NUMBER (face_id, 0);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
824 if (id < 0 || id >= next_face_id)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
825 error ("Face id out of range");
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 for (rest = Vframe_list; !NILP (rest); rest = XCONS (rest)->cdr)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829 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
830 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
831 ensure_face_ready (f, id);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
833 return Qnil;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
834 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837 DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
838 Sset_face_attribute_internal, 4, 4, 0, "")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
839 (face_id, attr_name, attr_value, frame)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
840 Lisp_Object face_id, attr_name, attr_value, frame;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
841 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
842 struct face *face;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
843 struct frame *f;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
844 int magic_p;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845 int id;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 CHECK_FRAME (frame, 0);
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
848 CHECK_NUMBER (face_id, 0);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849 CHECK_SYMBOL (attr_name, 0);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
851 f = XFRAME (frame);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
852 id = XINT (face_id);
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
853 if (id < 0 || id >= next_face_id)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
854 error ("Face id out of range");
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
856 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
857 return;
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
858
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859 ensure_face_ready (f, id);
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
860 face = FRAME_FACES (f) [XFASTINT (face_id)];
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862 if (EQ (attr_name, intern ("font")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
863 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
864 XFontStruct *font = load_font (f, attr_value);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865 unload_font (f, face->font);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866 face->font = font;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
867 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868 else if (EQ (attr_name, intern ("foreground")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
869 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
870 unsigned long new_color = load_color (f, attr_value);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
871 unload_color (f, face->foreground);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872 face->foreground = new_color;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
874 else if (EQ (attr_name, intern ("background")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
875 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
876 unsigned long new_color = load_color (f, attr_value);
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877 unload_color (f, face->background);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
878 face->background = new_color;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
879 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
880 #if 0
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
881 else if (EQ (attr_name, intern ("background-pixmap")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
882 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 unsigned int w, h, d;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
884 unsigned long new_pixmap = load_pixmap (f, attr_value, &w, &h, &d, 0);
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
885 unload_pixmap (f, face->stipple);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
886 if (NILP (attr_value))
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
887 new_pixmap = 0;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
888 face->stipple = new_pixmap;
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889 face->pixmap_w = w;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890 face->pixmap_h = h;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 /* face->pixmap_depth = d; */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 #endif /* 0 */
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894 else if (EQ (attr_name, intern ("underline")))
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896 int new = !NILP (attr_value);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897 face->underline = new;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
898 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 else
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 error ("unknown face attribute");
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 if (id == 0)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904 BLOCK_INPUT;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
905 if (FRAME_DEFAULT_FACE (f)->gc != 0)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
906 XFreeGC (x_current_display, FRAME_DEFAULT_FACE (f)->gc);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
907 build_face (f, FRAME_DEFAULT_FACE (f));
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908 UNBLOCK_INPUT;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 if (id == 1)
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
912 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
913 BLOCK_INPUT;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
914 if (FRAME_MODE_LINE_FACE (f)->gc != 0)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
915 XFreeGC (x_current_display, FRAME_MODE_LINE_FACE (f)->gc);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
916 build_face (f, FRAME_MODE_LINE_FACE (f));
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 UNBLOCK_INPUT;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919
2821
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
920 /* 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
921 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
922 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
923 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
924 kick. */
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
925 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
926 SET_FRAME_GARBAGED (f);
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
927 else
95010b414003 * xfaces.c (Fset_face_attribute_internal): Jolt redisplay, so it
Jim Blandy <jimb@redhat.com>
parents: 2818
diff changeset
928 /* 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
929 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
930
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 return Qnil;
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 }
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 DEFUN ("internal-next-face-id", Finternal_next_face_id, Sinternal_next_face_id,
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 0, 0, 0, "")
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 ()
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937 {
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 return make_number (next_face_id++);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 }
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
940
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
941 /* Return the face id for name NAME on frame FRAME.
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
942 (It should be the same for all frames,
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
943 but it's as easy to use the "right" frame to look it up
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
944 as to use any other one.) */
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
945
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
946 static Lisp_Object
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
947 face_name_id_number (frame, name)
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
948 Lisp_Object frame, name;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
949 {
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
950 Lisp_Object tem;
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
951
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
952 CHECK_FRAME (frame, 0);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
953 tem = Fcdr (Fassq (name, XFRAME (frame)->face_alist));
2767
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
954 if (NILP (tem))
482fa0725db6 * xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents: 2743
diff changeset
955 return 0;
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
956 CHECK_VECTOR (tem, 0);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
957 tem = XVECTOR (tem)->contents[2];
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
958 CHECK_NUMBER (tem, 0);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
959 return XINT (tem);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
960 }
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
962 /* Emacs initialization. */
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
963
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
964 void
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
965 syms_of_xfaces ()
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
966 {
2391
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
967 Qwindow = intern ("window");
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
968 staticpro (&Qwindow);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
969 Qface = intern ("face");
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
970 staticpro (&Qface);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
971 Qpriority = intern ("priority");
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
972 staticpro (&Qpriority);
226dcdb8ab67 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 2342
diff changeset
973
2795
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
974 DEFVAR_INT ("region-face", &region_face,
e97e96fb0cb8 (compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents: 2784
diff changeset
975 "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
976 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
977 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
978
2336
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
979 defsubr (&Sframe_face_alist);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 defsubr (&Sset_frame_face_alist);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 defsubr (&Smake_face_internal);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 defsubr (&Sset_face_attribute_internal);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983 defsubr (&Sinternal_next_face_id);
7aaafd275bec Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984 }
2730
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
985
139740855fa6 * xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents: 2538
diff changeset
986 #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
987