anchor.diff:      (move win (car pos) (+ (cadr pos) inptr))
       (refresh win)))
   
  -;; is this better than a form-specific method?
  +;; TODO: delete, replaced by (draw win form)
   (defun draw-form (win form)
     "Draw the form by drawing the fields, then moving the cursor to the current field."
     ;; TODO: "current" field or "active" field??
  
positive.code: 
  ;; here we do not pass the window to the function, but we associate the window with the form in the window slot
  ;; see t16f
  (defun edit (form)
    "Let the user edit the form fields, then return the form object."
    ;; declaring the field special lets the object keep its contents after the edit functions returns
    ;; we need this only when we want to edit the field values in place instead of returning the form object
    ;;(declare (special form))
    (draw (.window form) form)
    (with-accessors ((current-field .current-field) (win .window)) form
      ;; TODO: we need better event handling than a event-case.
      ;; a user needs to be able to pass his own keybindings (alist or hash table)
      (event-case (win event)
        ;; Use C-a ^A #\soh 1 to exit the edit loop.
        ;; TODO: what to return, a form or the buffers?
        ;; TODO: we need a function and throw-catch so the user can bind his own key to accept the form.
        ;; TODO: trim left and right spaces before returning
        (#\soh (return-from event-case nil))
  
        ;; TODO: the parameter form doesnt fit to the (handler win event) form used in run-event-loop.
        ;; this means that the used cant simply bind these functions to the events
        ;; how do we reconcile this?
        ;; maybe accept no arguments and only a rest parameter and every handler has to pick arguments by itself?
              
        ;; TAB, C-i, S-TAB (= :btab)
        ((:btab :up)   (select-prev-field form))
        ((#\tab :down) (select-next-field form))
        (:left         (move-prev-char form))
        (:right        (move-next-char form))
        (:backspace    (delete-prev-char form))
        (:dc           (delete-next-char form))
  
        ;; for debugging, return prints the content of the buffer and then deletes the buffer
        ;; PROBLEM: how is the user supposed to add bindings to the event loop?
        ;; everything we have done here is hard-coding all the keys.
        ;; TODO: we dont want to define handlers here, the user should define them in his keybindings.
        (#\newline     (debug-print-field-buffer form event))
  
        ;; toggle insert/overwrite mode
        (:ic (setf (.insert-enabled win) (not (.insert-enabled win))))
  
        ;; TODO: try to print only graphic chars.
        (otherwise (form-add-char form event)) )))
  
negative.code:               ;; if we're in the middle of the field, either insert or replace
                (if (.insert-enabled win)
                    (setf inbuf (insert-nth  (- len inptr)      char inbuf))
                    (setf inbuf (replace-nth (- len (1+ inptr)) char inbuf))))
            ;; both replacing and inserting advance the cursor
            (incf inptr))))
      ;; after were done with editing, redraw the field.
      ;; TODO: redraw the entire field or echo one single char?
      (draw win current-field))
    (refresh win))
  
  (defun field-buffer-to-string (field)
    "Return the value of the field buffer (list of chars) as a string."
    (coerce (reverse (.buffer field)) 'string))
  
  (defun debug-print-field-buffer (win event form)
    (declare (ignore event))
    (with-accessors ((current-field .current-field)) form
      (with-accessors ((inbuf .buffer) (inptr .fill-pointer)) current-field
        (when (> (length inbuf) 0)
          (clear win)
  