comparison lisp/faces.el @ 2744:f4fc0c4c76f9

Re-arranged stuff to put defsubst accessors at the top
author Jim Blandy <jimb@redhat.com>
date Tue, 11 May 1993 19:14:34 +0000
parents 9caee9338229
children 17c322204ce3
comparison
equal deleted inserted replaced
2743:ddc49d5eee56 2744:f4fc0c4c76f9
22 22
23 ;; Mostly derived from Lucid. 23 ;; Mostly derived from Lucid.
24 24
25 ;;; Code: 25 ;;; Code:
26 26
27
28 ;;;; Functions for manipulating face vectors.
29
30 ;;; A face vector is a vector of the form:
31 ;;; [face ID FONT FOREGROUND BACKGROUND BACKGROUND-PIXMAP UNDERLINE]
32
33 ;;; Type checkers.
27 (defsubst internal-facep (x) 34 (defsubst internal-facep (x)
28 (and (vectorp x) (= (length x) 8) (eq (aref x 0) 'face))) 35 (and (vectorp x) (= (length x) 8) (eq (aref x 0) 'face)))
29 36
30 (defmacro internal-check-face (face) 37 (defmacro internal-check-face (face)
31 (` (while (not (internal-facep (, face))) 38 (` (while (not (internal-facep (, face)))
32 (setq (, face) (signal 'wrong-type-argument (list 'internal-facep (, face))))))) 39 (setq (, face) (signal 'wrong-type-argument (list 'internal-facep (, face)))))))
33 40
41 ;;; Accessors.
42 (defsubst face-name (face)
43 "Return the name of face FACE."
44 (aref (internal-get-face face) 1))
45
46 (defsubst face-id (face)
47 "Return the internal ID number of face FACE."
48 (aref (internal-get-face face) 2))
49
50 (defsubst face-font (face &optional frame)
51 "Return the font name of face FACE, or nil if it is unspecified.
52 If the optional argument FRAME is given, report on face FACE in that frame.
53 Otherwise report on the defaults for face FACE (for new frames)."
54 (aref (internal-get-face face frame) 3))
55
56 (defsubst face-foreground (face &optional frame)
57 "Return the foreground color name of face FACE, or nil if unspecified.
58 If the optional argument FRAME is given, report on face FACE in that frame.
59 Otherwise report on the defaults for face FACE (for new frames)."
60 (aref (internal-get-face face frame) 4))
61
62 (defsubst face-background (face &optional frame)
63 "Return the background color name of face FACE, or nil if unspecified.
64 If the optional argument FRAME is given, report on face FACE in that frame.
65 Otherwise report on the defaults for face FACE (for new frames)."
66 (aref (internal-get-face face frame) 5))
67
68 (defsubst face-background-pixmap (face &optional frame)
69 "Return the background pixmap name of face FACE, or nil if unspecified.
70 If the optional argument FRAME is given, report on face FACE in that frame.
71 Otherwise report on the defaults for face FACE (for new frames)."
72 (aref (internal-get-face face frame) 6))
73
74 (defsubst face-underline-p (face &optional frame)
75 "Return t if face FACE is underlined.
76 If the optional argument FRAME is given, report on face FACE in that frame.
77 Otherwise report on the defaults for face FACE (for new frames)."
78 (aref (internal-get-face face frame) 7))
79
80
81 ;;; Mutators.
82
83 (defsubst set-face-font (face font &optional frame)
84 "Change the font of face FACE to FONT (a string).
85 If the optional FRAME argument is provided, change only
86 in that frame; otherwise change each frame."
87 (interactive (internal-face-interactive "font"))
88 (internal-set-face-1 face 'font font 3 frame))
89
90 (defsubst set-face-foreground (face color &optional frame)
91 "Change the foreground color of face FACE to COLOR (a string).
92 If the optional FRAME argument is provided, change only
93 in that frame; otherwise change each frame."
94 (interactive (internal-face-interactive "foreground"))
95 (internal-set-face-1 face 'foreground color 4 frame))
96
97 (defsubst set-face-background (face color &optional frame)
98 "Change the background color of face FACE to COLOR (a string).
99 If the optional FRAME argument is provided, change only
100 in that frame; otherwise change each frame."
101 (interactive (internal-face-interactive "background"))
102 (internal-set-face-1 face 'background color 5 frame))
103
104 (defsubst set-face-background-pixmap (face name &optional frame)
105 "Change the background pixmap of face FACE to PIXMAP.
106 PIXMAP should be a string, the name of a file of pixmap data.
107 The directories listed in the `x-bitmap-file-path' variable are searched.
108
109 Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA)
110 where WIDTH and HEIGHT are the size in pixels,
111 and DATA is a string, containing the raw bits of the bitmap.
112
113 If the optional FRAME argument is provided, change only
114 in that frame; otherwise change each frame."
115 (interactive (internal-face-interactive "background-pixmap"))
116 (internal-set-face-1 face 'background-pixmap name 6 frame))
117
118 (defsubst set-face-underline-p (face underline-p &optional frame)
119 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.)
120 If the optional FRAME argument is provided, change only
121 in that frame; otherwise change each frame."
122 (interactive (internal-face-interactive "underline-p" "underlined"))
123 (internal-set-face-1 face 'underline underline-p 7 frame))
124
125
126 ;;;; Associating face names (symbols) with their face vectors.
34 127
35 (defvar global-face-data nil "do not use this") 128 (defvar global-face-data nil "do not use this")
36 129
37 (defun face-list () 130 (defun face-list ()
38 "Returns a list of all defined face names." 131 "Returns a list of all defined face names."
61 If FRAME is the symbol t, then the global, non-frame face is returned. 154 If FRAME is the symbol t, then the global, non-frame face is returned.
62 If NAME is already a face, it is simply returned." 155 If NAME is already a face, it is simply returned."
63 (or (internal-find-face name frame) 156 (or (internal-find-face name frame)
64 (internal-check-face name))) 157 (internal-check-face name)))
65 158
66 (defsubst face-name (face)
67 "Return the name of face FACE."
68 (aref (internal-get-face face) 1))
69
70 (defsubst face-id (face)
71 "Return the internal ID number of face FACE."
72 (aref (internal-get-face face) 2))
73
74 (defsubst face-font (face &optional frame)
75 "Return the font name of face FACE, or nil if it is unspecified.
76 If the optional argument FRAME is given, report on face FACE in that frame.
77 Otherwise report on the defaults for face FACE (for new frames)."
78 (aref (internal-get-face face frame) 3))
79
80 (defsubst face-foreground (face &optional frame)
81 "Return the foreground color name of face FACE, or nil if unspecified.
82 If the optional argument FRAME is given, report on face FACE in that frame.
83 Otherwise report on the defaults for face FACE (for new frames)."
84 (aref (internal-get-face face frame) 4))
85
86 (defsubst face-background (face &optional frame)
87 "Return the background color name of face FACE, or nil if unspecified.
88 If the optional argument FRAME is given, report on face FACE in that frame.
89 Otherwise report on the defaults for face FACE (for new frames)."
90 (aref (internal-get-face face frame) 5))
91
92 (defsubst face-background-pixmap (face &optional frame)
93 "Return the background pixmap name of face FACE, or nil if unspecified.
94 If the optional argument FRAME is given, report on face FACE in that frame.
95 Otherwise report on the defaults for face FACE (for new frames)."
96 (aref (internal-get-face face frame) 6))
97
98 (defsubst face-underline-p (face &optional frame)
99 "Return t if face FACE is underlined.
100 If the optional argument FRAME is given, report on face FACE in that frame.
101 Otherwise report on the defaults for face FACE (for new frames)."
102 (aref (internal-get-face face frame) 7))
103
104 159
105 (defun internal-set-face-1 (face name value index frame) 160 (defun internal-set-face-1 (face name value index frame)
106 (let ((inhibit-quit t)) 161 (let ((inhibit-quit t))
107 (if (null frame) 162 (if (null frame)
108 (let ((frames (frame-list))) 163 (let ((frames (frame-list)))
138 " be " bool "? ")) 193 " be " bool "? "))
139 (read-string (concat prompt " " (symbol-name face) " to: ") 194 (read-string (concat prompt " " (symbol-name face) " to: ")
140 default)))) 195 default))))
141 (list face (if (equal value "") nil value)))) 196 (list face (if (equal value "") nil value))))
142 197
143
144 (defsubst set-face-font (face font &optional frame)
145 "Change the font of face FACE to FONT (a string).
146 If the optional FRAME argument is provided, change only
147 in that frame; otherwise change each frame."
148 (interactive (internal-face-interactive "font"))
149 (internal-set-face-1 face 'font font 3 frame))
150
151 (defsubst set-face-foreground (face color &optional frame)
152 "Change the foreground color of face FACE to COLOR (a string).
153 If the optional FRAME argument is provided, change only
154 in that frame; otherwise change each frame."
155 (interactive (internal-face-interactive "foreground"))
156 (internal-set-face-1 face 'foreground color 4 frame))
157
158 (defsubst set-face-background (face color &optional frame)
159 "Change the background color of face FACE to COLOR (a string).
160 If the optional FRAME argument is provided, change only
161 in that frame; otherwise change each frame."
162 (interactive (internal-face-interactive "background"))
163 (internal-set-face-1 face 'background color 5 frame))
164
165 (defsubst set-face-background-pixmap (face name &optional frame)
166 "Change the background pixmap of face FACE to PIXMAP.
167 PIXMAP should be a string, the name of a file of pixmap data.
168 The directories listed in the `x-bitmap-file-path' variable are searched.
169
170 Alternatively, PIXMAP may be a list of the form (WIDTH HEIGHT DATA)
171 where WIDTH and HEIGHT are the size in pixels,
172 and DATA is a string, containing the raw bits of the bitmap.
173
174 If the optional FRAME argument is provided, change only
175 in that frame; otherwise change each frame."
176 (interactive (internal-face-interactive "background-pixmap"))
177 (internal-set-face-1 face 'background-pixmap name 6 frame))
178
179 (defsubst set-face-underline-p (face underline-p &optional frame)
180 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.)
181 If the optional FRAME argument is provided, change only
182 in that frame; otherwise change each frame."
183 (interactive (internal-face-interactive "underline-p" "underlined"))
184 (internal-set-face-1 face 'underline underline-p 7 frame))
185 198
186 199
187 (defun make-face (name) 200 (defun make-face (name)
188 "Define a new FACE on all frames. 201 "Define a new FACE on all frames.
189 You can modify the font, color, etc of this face with the set-face- functions. 202 You can modify the font, color, etc of this face with the set-face- functions.