anchor.diff:        (values (- right left) (- bottom top)))) 
   
   (defmacro sheet-inside-size (stream)
  -  #FEATURE-CASE
  -  ((:CLIM
  -     `(stream-viewport-size ,stream))
  -   ((NOT :CLIM)
  -    `(values (send ,stream :inside-size))))
  -  )
  +  `(stream-viewport-size ,stream))
   
   (defun stream-height (stream)
     "Height of the viewport."
  
positive.code: 
  (in-package :dwim)
  
  (defun typep* (OBJECT SIMPLE-TYPE)
    ;; NLC21MAY92
    ;; We need the following because the Lucid compiler seems to lose sometimes  
    ;; when compiling certain forms.  E.g. when doing a compile-file on:
    ;;       (TYPEP STREAM 'CLIM::CLX-WINDOW)
    ;; We get the following error:
    ;; >>Error: MAKE-LOAD-FORM is too complicated.
    ;;         (MAKE-LOAD-FORM #<Standard-Class CLIM::CLX-WINDOW>) =>
    ;;                               #<Standard-Class CLIM::CLX-WINDOW> NIL
    (typep OBJECT SIMPLE-TYPE))
  
  
  ;;;
  ;;; Operations associated with tv windows (mostly).
  ;;;
  
  (defun window-under-mouse ()
    #FEATURE-CASE
    ((:mcclim (clim:pointer-sheet (clim:port-pointer
  				 (clim:port clim:*application-frame*))))
     (:clim-2 (clim-internals::find-appropriate-window *standard-input*))
     (:clim-1.0 (clim::find-appropriate-window *standard-input*))
     (:clim-0.9 (ci::find-appropriate-window *standard-input*))
     ((not :clim) (tv:window-under-mouse))))
  
  (defun window-clear (window)
    #FEATURE-CASE
    (((not :clim) (send window :clear-history))
     (:clim-0.9 (ci::window-clear window))
     ((or :clim-1.0 :clim-2) (clim:window-clear window))))
  
  ;;; This doesn't appear to be used at all with CLIM.
  #-mcclim
  (defun change-size (window new-width new-height)
    #FEATURE-CASE
    (((not :clim) (send window :set-size new-width new-height))
     (:clim-0.9 (ci::change-size window new-width new-height))
     ((or :clim-1.0 :clim-2)
      (clim::window-set-inside-size window new-width new-height))))
  
  (defun pane-frame (pane)
    #FEATURE-CASE
    (((not :clim) (scl:send pane :superior))
     ((or :clim-0.9 :clim-2) (clim:pane-frame pane))
     (:clim-1.0
      (let ((p pane) f)
        (loop (or p (return))
  	(when (setq f (clim::window-stream-to-frame p))
  	  (return f))
  	(setq p (clim:window-parent p)))))))
  
  (defun redisplay-frame-pane (pane &optional (force-p t))
    #FEATURE-CASE
    ((:clim-0.9 (clim:redisplay-frame-pane pane))
     ((or :clim-1.0 :clim-2)
      ;; force-p is probably wrong for redisplayable panes:
      (clim:redisplay-frame-pane (pane-frame pane) pane :force-p force-p))
     ((not :clim)
      (let ((frame (scl:send pane :superior)))
        (scl:send frame :redisplay-pane pane force-p)))))
  
  (defun sheet-parent (sheet)
    #FEATURE-CASE
    (((not :clim) (send sheet :superior))
     (:clim-0.9 (clim:sheet-parent sheet))
     ((or :clim-1.0 (and :clim-2 (not :mcclim))) (clim:window-parent sheet))
     (:mcclim (clim:sheet-parent sheet))))
  
  (defmethod (setf sheet-parent) (new sheet)
    #FEATURE-CASE
    (((not :clim) (send sheet :set-superior new))
     (:clim-0.9 (setf (clim:sheet-parent sheet) new))
     ((or :clim-1.0 (and :clim-2 (not :mcclim)))
      (setf (clim:window-parent sheet) new))
     (:mcclim (sheet-adopt-child sheet new))))
  
  (defun stream-current-text-style (STREAM)
    #FEATURE-CASE
    ((:clim-0.9
      (clim:stream-current-text-style 
       (if (typep stream 'ci::encapsulating-stream-mixin)
  	 (slot-value stream 'ci::stream)
         stream)))
     (:CLIM-1.0
      ;; Functions such as stream-line-height and stream-string-width
      ;; need a fully merged text style.  This makes sure all text styles
      ;; are fully merged.
      (slot-value stream 'clim::merged-text-style))
     (:CLIM-2
      (clim:medium-text-style stream))))
  
  (defun stream-merged-text-style (STREAM)
    #FEATURE-CASE
    ((:CLIM-1.0
       (slot-value stream 'clim::merged-text-style))
     (:CLIM-2
       (clim:medium-merged-text-style stream))))
  
  (defun parse-text-style (LIST)
    #FEATURE-CASE
    ((:CLIM
       (clim:parse-text-style LIST))
     ))
  
  (defun stream-line-height (stream &optional TEXT-STYLE)
    #FEATURE-CASE
    (((NOT :CLIM)
      TEXT-STYLE				; wrong - but what's right? (MT)
      (or (scl:send-if-handles stream :line-height) 12))
     (:CLIM-0.9
      (if TEXT-STYLE
  	(clim:stream-line-height stream TEXT-STYLE)
  	(clim:stream-line-height stream (stream-current-text-style stream))))
     ((or :CLIM-1.0 :clim-2)
      (if TEXT-STYLE
  	(truncate (clim:stream-line-height stream
  					   :text-style TEXT-STYLE))
          (truncate (clim:stream-line-height stream))))))
  
  (defun stream-character-width (stream &optional (char #\m))
    ;; "m" is the usual character (the term "ems" is often used in typesetting
    ;; to indicate units of width).
    #FEATURE-CASE
    (((not :clim) (or (scl:send-if-handles stream :character-width char) 8))
     (:clim-0.9 (clim:stream-character-width STREAM char))
     (:clim-1.0 (if (clim:extended-output-stream-p stream)
  		  (clim:stream-character-width STREAM char)
  		8))
     (:clim-2 (if (clim:extended-output-stream-p stream)
  		  (clim:stream-character-width STREAM char)
  		8))))
  
  (defun stream-string-width (STREAM string &key (start 0) end text-style)
    #FEATURE-CASE
    ((:CLIM-1.0
      (when (eq text-style clim:*null-text-style*)
        (setq text-style (stream-current-text-style stream)))
      (clim:stream-string-width STREAM string :start START :end END
  			      :text-style TEXT-STYLE))
     (:CLIM
      (clim:stream-string-width STREAM string :start START :end END
  			      :text-style TEXT-STYLE))
     ))
  
  (defmethod stream-cursor-position* (stream)
    #FEATURE-CASE
    (((not :clim) (send stream :read-cursorpos))
     (:clim-0.9 (clim:stream-cursor-position* stream))
     (:clim-1.0 (cond ((clim:extended-output-stream-p stream)
  		     (clim:stream-cursor-position* stream))
  		    ((typep* stream 'clim::encapsulating-stream-mixin)
  		     (stream-cursor-position* (slot-value stream 'clim::stream)))
  		    (t (values 0 0))))
     (:clim-2 (if (clim:extended-output-stream-p stream)
  		  (multiple-value-bind (x y)
  		      (clim:stream-cursor-position stream)
  		    ;; Its nice to assume that cursor positions are fixnums,
  		    ;; even though postscript streams meaningfully use floats.
  		    (values (truncate x) (truncate y)))
  		  (values 0 0)))))
  
  (defmethod stream-set-cursor-position* (stream x y)
    #FEATURE-CASE
    (((not :clim) (send stream :set-cursorpos x y))
     ((or :clim-0.9 :clim-1.0) (clim:stream-set-cursor-position* stream x y))
     ((and :clim-2 (not :mcclim)) (clim:stream-set-cursor-position stream x y))
     (:mcclim (setf (clim:stream-cursor-position stream) (values x y)))))
  
  (defmethod stream-increment-cursor-position* (stream x y)
    #FEATURE-CASE
    (((not :clim) (send stream :increment-cursorpos x y))
     (:clim-0.9 (clim:stream-increment-cursor-position* stream x y))
     (:clim-1.0 (if (typep* stream 'clim::output-protocol-mixin)
  		  (clim:stream-increment-cursor-position* stream x y)))
     (:clim-2 (clim:stream-increment-cursor-position stream x y))))
  
  (defmethod stream-viewport (stream)
    ;;(declare (values left top right bottom))
    #FEATURE-CASE
    (((not :clim) (send stream :visible-cursorpos-limits))
     (:clim-0.9
      (clim:bounding-rectangle*
       (clim:sheet-region (clim:pane-viewport stream))))
     (:clim-1.0
      (if (typep stream 'clim::postscript-stream)
  	(values 0 0 700 700)		; anything will do...
        (multiple-value-bind (left top right bottom)
  	  (clim:rectangle-edges* (clim:window-viewport stream))
  	(multiple-value-bind (xoff yoff)
  	    (if (typep* stream 'clim::avv-stream)
  		(values 0 0)
  	      (clim:window-margins stream))
  	  (values left top (- right xoff) (- bottom yoff))))))
     (:clim-2
      (cond ((not (clim:extended-output-stream-p stream)))
  	  ((and (type-specifier-p 'clim-postscript::postscript-stream)
  		(typep stream 'clim-postscript::postscript-stream))
  	   ;; width  = inches x 72
  	   ;; height = inches x 72
  	   (values 0 0 #.(* 72 7) #.(* 72 10)))
  	  (t
  	   (let ((v (and (not (typep (clim:medium-sheet
                                        (clim:sheet-medium stream))
                                       'climi::pixmap))
  			 (clim:window-viewport stream))))
  	     (if v (clim:rectangle-edges* v)
  	       (values 0 0
  		       (clim:bounding-rectangle-width stream)
  		       (clim:bounding-rectangle-height stream)))))))))
  
  (defmethod stream-viewport-size (stream)
    ;;(declare (values width height))
  
negative.code: 
  (defmethod reset-frame (frame &key title)
    "Prepare a frame for reuse."
    (setf (clim:frame-pretty-name frame) title)
  	      (clim:reset-frame frame))
  
  ;;; You pay a price for this, so set it to nil if resources are scarce.
  (defvar *enable-backing-store* :when-mapped
  