minor updates to work with released ucw-core
[clinton/lisp-on-lines.git] / src / display.lisp
CommitLineData
e7c5f95a 1(in-package :lisp-on-lines)
2
b1c8f43b 3
e7c5f95a 4(defvar *display*)
b1c8f43b 5
6de8d300 6
e7c5f95a 7(define-layered-function display-using-description (description display object &rest args)
8 (:documentation
9 "Displays OBJECT via description using/in/with/on display"))
10
b7657b86 11
12
13(defun modify-layer-context (context &key activate deactivate)
14 (dolist (d deactivate)
15 (setf context (remove-layer (find-description d)
16 context)))
17 (dolist (d activate context)
18 (setf context (adjoin-layer (find-description d)
19 context))))
20
21
22
23
24(defun display (display object &rest args &key deactivate activate &allow-other-keys)
46440824 25
b7657b86 26 (funcall-with-layer-context
27 (modify-layer-context (current-layer-context)
28 :activate activate
29 :deactivate deactivate)
30 (lambda ()
31 (apply #'display-using-description (description-of object) display object args))))
e7c5f95a 32
33(define-layered-method display-using-description
34 :around (description display object &rest args)
4358148e 35 (declare (ignorable args))
46440824 36#+nil (break "Entering DISPLAY for ~A on ~A using ~A" object display description)
b1c8f43b 37 (let ((*display* display))
38 (apply #'funcall-with-described-object
39 (lambda ()
40 (call-next-method))
41 object description args)))
b7657b86 42
43
44
6de8d300 45
e7c5f95a 46
4271ab0b 47(defun display/d (&rest args)
48 (apply #'display-using-description args))
49
e7c5f95a 50(define-layered-method display-using-description (description display object &rest args)
51 (error "No DISPLAY-USING-DESCRIPTION methods are specified for: ~% DESCRIPTION: ~A ~% DISPLAY: ~A ~% OBJECT: ~A ~% ARGS: ~S
52
53OMGWTF! If you didn't do this, it's a bug!" description display object args))
54
e7c5f95a 55(defmacro define-display (&body body)
4358148e 56 (loop with in-descriptionp = (eq (car body) :in-description)
57 with description = (if in-descriptionp (cadr body) 't)
58 for tail on (if in-descriptionp (cddr body) body)
e7c5f95a 59 until (listp (car tail))
60 collect (car tail) into qualifiers
61 finally
4358148e 62 (when (member :in-description qualifiers)
63 (error "Incorrect occurrence of :in-description in defdisplay. Must occur before qualifiers."))
e7c5f95a 64 (return
65 (destructuring-bind (description-spec &optional (display-spec (gensym)) (object-spec (gensym)))
66 (car tail)
b1c8f43b 67 `(define-layered-method
e7c5f95a 68 display-using-description
4358148e 69 :in-layer ,(if (eq t description)
70 t
71 (defining-description description))
e7c5f95a 72 ,@qualifiers
73 (,(if (listp description-spec)
74 (list (first description-spec)
75 (if (eq 'description (second description-spec))
76 'description
77 (defining-description (second description-spec)))))
78 ,display-spec
79 ,object-spec &rest args)
80 (declare (ignorable args))
81 ,@(cdr tail))))))
82
83
84
85