comparison lisp/faces.el @ 19479:3c201ec148a4

(modify-face): New arg INVERSE-P. Clear the inverse-video flag before installing new colors. (face-spec-set): Pass INVERSE-P arg, and use (nil) for colors when calling modify-face.
author Richard M. Stallman <rms@gnu.org>
date Sat, 23 Aug 1997 02:01:34 +0000
parents 11d21b4613cd
children 8430323b838e
comparison
equal deleted inserted replaced
19478:b2544c0eada8 19479:3c201ec148a4
44 (put 'set-face-underline-p 'byte-optimizer nil)) 44 (put 'set-face-underline-p 'byte-optimizer nil))
45 45
46 ;;;; Functions for manipulating face vectors. 46 ;;;; Functions for manipulating face vectors.
47 47
48 ;;; A face vector is a vector of the form: 48 ;;; A face vector is a vector of the form:
49 ;;; [face NAME ID FONT FOREGROUND BACKGROUND STIPPLE UNDERLINE INVERSE] 49 ;;; [face NAME ID FONT FOREGROUND BACKGROUND STIPPLE
50 ;;; UNDERLINE-P INVERSE-VIDEO-P FONT-EXPLICIT-P BOLD-P ITALIC-P]
50 51
51 ;;; Type checkers. 52 ;;; Type checkers.
52 (defsubst internal-facep (x) 53 (defsubst internal-facep (x)
53 (and (vectorp x) (= (length x) 12) (eq (aref x 0) 'face))) 54 (and (vectorp x) (= (length x) 12) (eq (aref x 0) 'face)))
54 55
286 ((equal value "") 287 ((equal value "")
287 default) 288 default)
288 (t value)))) 289 (t value))))
289 290
290 (defun modify-face (face foreground background stipple 291 (defun modify-face (face foreground background stipple
291 bold-p italic-p underline-p &optional frame) 292 bold-p italic-p underline-p &optional inverse-p frame)
292 "Change the display attributes for face FACE. 293 "Change the display attributes for face FACE.
293 If the optional FRAME argument is provided, change only 294 If the optional FRAME argument is provided, change only
294 in that frame; otherwise change each frame. 295 in that frame; otherwise change each frame.
295 296
296 FOREGROUND and BACKGROUND should be a colour name string (or list of strings to 297 FOREGROUND and BACKGROUND should be a colour name string (or list of strings to
297 try) or nil. STIPPLE should be a stipple pattern name string or nil. 298 try) or nil. STIPPLE should be a stipple pattern name string or nil.
298 If nil, means do not change the display attribute corresponding to that arg. 299 If nil, means do not change the display attribute corresponding to that arg.
299 300
300 BOLD-P, ITALIC-P, and UNDERLINE-P specify whether the face should be set bold, 301 BOLD-P, ITALIC-P, UNDERLINE-P, and INVERSE-P specify whether
301 in italic, and underlined, respectively. If neither nil or t, means do not 302 the face should be set bold, italic, underlined or in inverse-video,
302 change the display attribute corresponding to that arg. 303 respectively. If one of these arguments is neither nil or t, it means do not
304 change the display attribute corresponding to that argument.
303 305
304 If called interactively, prompts for a face name and face attributes." 306 If called interactively, prompts for a face name and face attributes."
305 (interactive 307 (interactive
306 (let* ((completion-ignore-case t) 308 (let* ((completion-ignore-case t)
307 (face (symbol-name (read-face-name "Modify face: "))) 309 (face (symbol-name (read-face-name "Modify face: ")))
336 (read new-stipple-string) 338 (read new-stipple-string)
337 new-stipple-string))) 339 new-stipple-string)))
338 (bold-p (y-or-n-p (concat "Should face " face " be bold "))) 340 (bold-p (y-or-n-p (concat "Should face " face " be bold ")))
339 (italic-p (y-or-n-p (concat "Should face " face " be italic "))) 341 (italic-p (y-or-n-p (concat "Should face " face " be italic ")))
340 (underline-p (y-or-n-p (concat "Should face " face " be underlined "))) 342 (underline-p (y-or-n-p (concat "Should face " face " be underlined ")))
343 (inverse-p (y-or-n-p (concat "Should face " face " be inverse-video ")))
341 (all-frames-p (y-or-n-p (concat "Modify face " face " in all frames ")))) 344 (all-frames-p (y-or-n-p (concat "Modify face " face " in all frames "))))
342 (message "Face %s: %s" face 345 (message "Face %s: %s" face
343 (mapconcat 'identity 346 (mapconcat 'identity
344 (delq nil 347 (delq nil
345 (list (and foreground (concat (downcase foreground) " foreground")) 348 (list (and foreground (concat (downcase foreground) " foreground"))
346 (and background (concat (downcase background) " background")) 349 (and background (concat (downcase background) " background"))
347 (and stipple (concat (downcase new-stipple-string) " stipple")) 350 (and stipple (concat (downcase new-stipple-string) " stipple"))
348 (and bold-p "bold") (and italic-p "italic") 351 (and bold-p "bold") (and italic-p "italic")
352 (and inverse-p "inverse")
349 (and underline-p "underline"))) ", ")) 353 (and underline-p "underline"))) ", "))
350 (list (intern face) foreground background stipple 354 (list (intern face) foreground background stipple
351 bold-p italic-p underline-p 355 bold-p italic-p underline-p inverse-p
352 (if all-frames-p nil (selected-frame))))) 356 (if all-frames-p nil (selected-frame)))))
357 ;; Clear this before we install the new foreground and background;
358 ;; otherwise, clearing it after would swap them!
359 (when (and (or foreground background) (face-inverse-video-p face))
360 (set-face-inverse-video-p face frame nil)
361 ;; Arrange to restore it after, if we are not setting it now.
362 (or (memq inverse-p '(t nil))
363 (setq inverse-p t)))
353 (condition-case nil 364 (condition-case nil
354 (face-try-color-list 'set-face-foreground face foreground frame) 365 (face-try-color-list 'set-face-foreground face foreground frame)
355 (error nil)) 366 (error nil))
356 (condition-case nil 367 (condition-case nil
357 (face-try-color-list 'set-face-background face background frame) 368 (face-try-color-list 'set-face-background face background frame)
358 (error nil)) 369 (error nil))
359 (condition-case nil 370 (condition-case nil
360 (set-face-stipple face stipple frame) 371 (set-face-stipple face stipple frame)
361 (error nil)) 372 (error nil))
373 ;; Now that we have the new colors,
374 (if (memq inverse-p '(nil t))
375 (set-face-inverse-video-p face inverse-p frame))
362 (cond ((eq bold-p nil) 376 (cond ((eq bold-p nil)
363 (if (face-font face frame) 377 (if (face-font face frame)
364 (make-face-unbold face frame t))) 378 (make-face-unbold face frame t)))
365 ((eq bold-p t) 379 ((eq bold-p t)
366 (make-face-bold face frame t))) 380 (make-face-bold face frame t)))
1257 (when attrs 1271 (when attrs
1258 ;; If the font was set automatically, clear it out 1272 ;; If the font was set automatically, clear it out
1259 ;; to allow it to be set it again. 1273 ;; to allow it to be set it again.
1260 (unless (face-font-explicit face frame) 1274 (unless (face-font-explicit face frame)
1261 (set-face-font face nil frame)) 1275 (set-face-font face nil frame))
1262 (modify-face face nil nil nil nil nil nil frame) 1276 (modify-face face '(nil) '(nil) nil nil nil nil nil frame)
1263 (face-spec-set-1 face frame attrs ':foreground 'set-face-foreground) 1277 (face-spec-set-1 face frame attrs ':foreground 'set-face-foreground)
1264 (face-spec-set-1 face frame attrs ':background 'set-face-background) 1278 (face-spec-set-1 face frame attrs ':background 'set-face-background)
1265 (face-spec-set-1 face frame attrs ':stipple 'set-face-stipple) 1279 (face-spec-set-1 face frame attrs ':stipple 'set-face-stipple)
1266 (face-spec-set-1 face frame attrs ':bold 'set-face-bold-p) 1280 (face-spec-set-1 face frame attrs ':bold 'set-face-bold-p)
1267 (face-spec-set-1 face frame attrs ':italic 'set-face-italic-p) 1281 (face-spec-set-1 face frame attrs ':italic 'set-face-italic-p)