X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/6de8d30004efc9337b8c40d2ff2d0a76651d23eb..b1c8f43be32503f3911e60696dba8c9194f28ca5:/src/display.lisp diff --git a/src/display.lisp b/src/display.lisp index 28957a9..a0be611 100644 --- a/src/display.lisp +++ b/src/display.lisp @@ -1,45 +1,45 @@ (in-package :lisp-on-lines) -(defvar *description*) -(defvar *display*) -(defvar *object* nil) +(defvar *display*) -(deflayer display-layer) (define-layered-function display-using-description (description display object &rest args) (:documentation "Displays OBJECT via description using/in/with/on display")) -(defun display (display object &rest args &key attributes ) - (let ((*display-attributes* attributes)) - (apply #'display-using-description (description-of object) display object args))) + + +(defun modify-layer-context (context &key activate deactivate) + (dolist (d deactivate) + (setf context (remove-layer (find-description d) + context))) + (dolist (d activate context) + (setf context (adjoin-layer (find-description d) + context)))) + + + + +(defun display (display object &rest args &key deactivate activate &allow-other-keys) + (funcall-with-layer-context + (modify-layer-context (current-layer-context) + :activate activate + :deactivate deactivate) + (lambda () + (apply #'display-using-description (description-of object) display object args)))) (define-layered-method display-using-description :around (description display object &rest args) (declare (ignorable args)) - (let ((*description* description) - (*display* display) - (*object* object)) - (contextl::funcall-with-special-initargs - (loop - :for (key val) :on args :by #'cddr - :collect (list (find key (description-attributes description) - :key #'attribute-keyword) - :value val)) - (lambda () - (contextl::funcall-with-special-initargs - (let ((attribute (find-attribute description 'active-attributes))) - (when attribute - (loop for spec in (attribute-value object attribute) - if (listp spec) - collect (cons (or - (find-attribute description (car spec)) - (error "No attribute matching ~A" (car spec))) - (cdr spec))))) + (let ((*display* display)) + (apply #'funcall-with-described-object (lambda () - (call-next-method))))))) - + (call-next-method)) + object description args))) + + + (defun display/d (&rest args) @@ -62,7 +62,7 @@ OMGWTF! If you didn't do this, it's a bug!" description display object args)) (return (destructuring-bind (description-spec &optional (display-spec (gensym)) (object-spec (gensym))) (car tail) - `(define-layered-method + `(define-layered-method display-using-description :in-layer ,(if (eq t description) t