CLIM mail archive

[Prev][Next][Index][Thread]

Question about defining presentation types with parameters and options



Hi there,

Consider the following small example:

;;; -*- Mode: Common-Lisp; Package: CLIM-USER; -*-

(define-presentation-type sentence
    (language)
  :options (direction)
  :inherit-from 'string)


(define-presentation-method accept
    ((type sentence) stream (view textual-view) &key)
  (with-input-editing (stream) (read-line stream)))

(define-presentation-method present
    (object (type sentence) stream (view textual-view) &key)
  (format stream "~a" object))

(define-presentation-method presentation-typep
    (object (type sentence))
  (and (typep object 'standard-presentation)
       (let ((ptype (presentation-type object)))
	 (and (listp ptype)
	      (equal ptype (list 'sentence language)))))
  )

(define-presentation-method presentation-subtypep
    ((type sentence) putative-supertype)
  (let (language1)
    (with-presentation-type-parameters (sentence type)
      (setf language1 language))
    (with-presentation-type-parameters (sentence putative-supertype)
      (if (eq language1 language)
	  (values t t)
	(values nil t)))))

(defun test ()
  (present "Das Haus brennt" '((sentence german) :direction :source))
  (terpri)
  (present "The house burns." '((sentence english) :direction :target))
  (terpri)
  (accept '((sentence german) :direction :source)))

Here is my question:
Call the function test inside an application frame's interactor pane.
The inner call to ACCEPT accepts both the german and the english
sentence.
How could I change my code, so that only german sentences are
accepted?

Thomas


Follow-Ups:

Main Index | Thread Index