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
))))
48 (define-layered-function display-attribute-value
(attribute)
49 (:method-combination arnesi
:wrapping-standard
)
51 (flet ((disp (val &rest args
)
52 (apply #'display
*display
* val
53 :activate
(attribute-active-descriptions attribute
)
54 :deactivate
(attribute-inactive-descriptions attribute
)
58 (let ((val (attribute-value attribute
)))
59 #+nil
(break "display Attribute value: ~A with object ~A ~% Description ~A att-d ~A ~% VALUE ~A display on ~A"
61 (attribute-object attribute
)
63 (attribute-description attribute
)
67 (if (and (not (slot-boundp attribute
'active-attributes
))
68 (equal val
(attribute-object attribute
)))
69 (progn (generic-format *display
* "~A"(funcall (attribute-value-formatter attribute
) val
))
70 #+nil
(break "using generic format because val is object and there is no active attributes."))
72 (with-active-descriptions (inline)
73 (cond ((slot-value attribute
'value-formatter
)
74 (generic-format *display
* "~A"(funcall (attribute-value-formatter attribute
) val
)))
75 ((slot-boundp attribute
'active-attributes
)
76 (disp val
:attributes
(slot-value attribute
'active-attributes
)))
80 (define-layered-method display-using-description
81 ((attribute standard-attribute
) display object
&rest args
)
82 (declare (ignore args
))
83 (when (attribute-label attribute
)
84 (display-attribute-label attribute
))
85 (display-attribute-value attribute
))
87 (define-layered-method display-attribute
:around
88 ((attribute standard-attribute
))
89 (funcall-with-layer-context
90 (modify-layer-context (current-layer-context)
91 :activate
(attribute-active-descriptions attribute
)
92 :deactivate
(attribute-inactive-descriptions attribute
))
96 (define-layered-method display-attribute
:before
97 ((attribute standard-attribute
))
98 #+nil
(break "Attribute : ~A with object ~A ~% Description ~A att-d ~A"
100 (attribute-object attribute
)
102 (attribute-description attribute
)
105 (define-display ((description t
))
106 (let ((attributes (attributes description
)))
107 (when (first attributes
)(display-attribute (first attributes
)))
108 (dolist (attribute (rest attributes
) (values))
109 (generic-format *display
*
111 (find-attribute description
'attribute-delimiter
)))
112 (display-attribute attribute
))))
115 (define-display :around
((description t
) (display null
) object
)
116 (with-output-to-string (*standard-output
*)
117 (call-next-layered-method description t object
))