1 (in-package :lisp-on-lines
)
3 (define-description T
()
5 :function
(lambda (object)
7 (substitute #\Space
#\-
11 (identity :label nil
:function
#'identity
)
12 (type :label
"Type" :function
#'type-of
)
13 (class :label
"Class" :function
#'class-of
)
14 (active-attributes :label
"Attributes"
18 (attribute-delimiter :label
"Attribute Delimiter"
22 (active-descriptions :label
"Active Descriptions"
26 (inactive-descriptions :label
"Inactive Descriptions"
30 (label-formatter :value
(lambda (label)
31 (generic-format *display
* "~A:" label
))
33 (value-formatter :value
(curry #'format nil
"~A")
36 (define-layered-method description-of
(any-lisp-object)
37 (find-description 't
))
39 (define-layered-function display-attribute
(attribute)
41 (display-using-description attribute
*display
* (attribute-object attribute
))))
44 (define-layered-function display-attribute-label
(attribute)
46 (funcall (attribute-label-formatter attribute
) (attribute-label attribute
))))
51 (define-layered-function display-attribute-value
(attribute)
53 (flet ((disp (val &rest args
)
54 (apply #'display
*display
* val
55 :activate
(attribute-active-descriptions attribute
)
56 :deactivate
(attribute-inactive-descriptions attribute
)
59 (let ((val (attribute-value attribute
)))
60 (if (and (not (slot-boundp attribute
'active-attributes
))
61 (eql val
(attribute-object attribute
)))
62 (generic-format *display
* (funcall (attribute-value-formatter attribute
) val
))
63 (with-active-descriptions (inline)
64 (cond ((slot-value attribute
'value-formatter
)
65 (generic-format *display
* (funcall (attribute-value-formatter attribute
) val
)))
66 ((slot-boundp attribute
'active-attributes
)
67 (disp val
:attributes
(slot-value attribute
'active-attributes
)))
71 (define-layered-method display-using-description
72 ((attribute standard-attribute
) display object
&rest args
)
73 (declare (ignore args
))
74 (when (attribute-label attribute
)
75 (display-attribute-label attribute
))
76 (display-attribute-value attribute
))
78 (define-layered-method display-attribute
:around
79 ((attribute standard-attribute
))
80 (funcall-with-layer-context
81 (modify-layer-context (current-layer-context)
82 :activate
(attribute-active-descriptions attribute
)
83 :deactivate
(attribute-inactive-descriptions attribute
))
87 (define-layered-method display-attribute
:before
88 ((attribute standard-attribute
))
91 (define-display ((description t
))
92 (let ((attributes (attributes description
)))
93 (display-attribute (first attributes
))
94 (dolist (attribute (rest attributes
) (values))
95 (generic-format *display
*
97 (find-attribute description
'attribute-delimiter
)))
98 (display-attribute attribute
))))
101 (define-display :around
((description t
) (display null
) object
)
102 (with-output-to-string (*standard-output
*)
103 (call-next-layered-method description t object
))