anchor.diff:  ;;; -*- Mode: Lisp; Package: CLIM-DEMO -*-
  -
   ;;;  (c) copyright 2001 by
   ;;;           Arnaud Rouanet (rouanet@emi.u-bordeaux.fr)
   ;;;           Lionel Salabartan (salabart@emi.u-bordeaux.fr)
  
positive.code: (define-application-frame clim-fig ()
    ((drawing-mode :initform :line :accessor clim-fig-drawing-mode)
     (output-record :accessor clim-fig-output-record)
     (redo-list :initform nil :accessor clim-fig-redo-list)
     (current-color :initform +black+ :accessor clim-fig-current-color)
     (line-style :initform (make-line-style) :accessor clim-fig-line-style)
  
negative.code:   (frame-exit *application-frame*))
  
  (define-clim-fig-command com-undo ()
    "Undo the previous command, which might have been either 'draw a new object',
     or the CLEAR command. In the former case, remove the record and add it to the
     redo list; in the latter case, replay the output-history."
    (let ((latest-undo-entry (pop (clim-fig-undo-list *application-frame*))))
      (cond
        ((not latest-undo-entry) (beep))
        ((listp latest-undo-entry)
         (loop for record in latest-undo-entry do
              (stream-add-output-record *standard-output* record)
              (replay record *standard-output* (bounding-rectangle record))))
        (T
         (erase-output-record latest-undo-entry *standard-output*)
         (push latest-undo-entry (clim-fig-redo-list *application-frame*))))))
  
  (define-clim-fig-command com-redo ()
    (alexandria:if-let ((record (pop (clim-fig-redo-list *application-frame*))))
      (progn
        (push record (clim-fig-undo-list *application-frame*))
        (stream-add-output-record *standard-output* record)
        (replay record *standard-output* (bounding-rectangle record)))
      (beep)))
  
  (define-clim-fig-command com-clear ()
    (push (coerce (output-record-children (clim-fig-output-record
  					 *application-frame*))
  		'list)
          (clim-fig-undo-list *application-frame*))
    (setf (clim-fig-redo-list *application-frame*) (list))
    (window-clear *standard-output*))
  
  (define-clim-fig-command (com-add-figure :name nil) ((x real) (y real))
  