anchor.diff:  (defun xterm-esc-dispatch (terminal char)
     (push char (slot-value terminal 'intermediate-characters))
     (let ((intermediates (reverse (slot-value terminal 'intermediate-characters))))
  -    (cond ((equal intermediates '(#\7))
  +    (cond ((equal intermediates '(#\D)) ; Index (IND).
  +           (xterm-execute terminal #\Lf))
  +          ((equal intermediates '(#\E)) ; Next Line (NEL).
  +           (xterm-execute terminal #\Lf)
  +           (xterm-execute terminal #\Cr))
  +          ((equal intermediates '(#\M)) ; Reverse Index (RI).
  +           (cond ((eql (y-pos terminal)
  +                       (or (scroll-start terminal)
  +                           0))
  +                  (scroll-terminal terminal
  +                                   (scroll-start terminal)
  +                                   (or (scroll-end terminal)
  +                                       (terminal-height terminal))
  +                                   -1))
  +                 (t (decf (y-pos terminal)))))
  +          ((equal intermediates '(#\7)) ; Save Cursor (DECSC).
              (save-cursor terminal))
  -          ((equal intermediates '(#\8))
  +          ((equal intermediates '(#\8)) ; Restore Cursor (DECRC).
              (restore-cursor terminal))
             ((equal intermediates '(#\( #\B))
              ;; Set G0 character set.
  
positive.code:              (t (report-unknown-escape terminal))))
            ((equal intermediates '(#\?))
             (case char
               (#\h (dolist (p params)
                      (adjust-dec-private-mode terminal p t)))
               (#\l (dolist (p params)
                      (adjust-dec-private-mode terminal p nil)))
               (t (report-unknown-escape terminal))))
            (t (report-unknown-escape terminal)))))
  
  
negative.code:         (intermediates (reverse (slot-value terminal 'intermediate-characters))))
      (cond ((endp intermediates)
             (case char
               (#\c ; Device Attributes (DA).
                (cond ((or (null params)
                           (eql (first params) 0))
                       ;; FIXME: Respond with something.
                       ;; \e[?1;2c  "I am a VT100 terminal with AVO."
                       )
                      (t (report-unknown-escape terminal))))
               (#\d ; Line Position Absolute (VPA).
                (setf (y-pos terminal) (1- (or (first params) 1))))
               (#\h ; Set Mode (SM).
                (dolist (p params)
                  (adjust-ansi-mode terminal p t)))
               (#\l ; Reset Mode (RM).
                (dolist (p params)
                  (adjust-ansi-mode terminal p nil)))
               (#\m ; Select Graphics Rendition (SGR).
                (set-character-attributes terminal params))
               (#\r ; Set Top and Bottom Margins (DECSTBM).
                (setf (scroll-start terminal) (1- (or (first params) 1))
                      (scroll-end terminal) (when (second params)
                                              (1- (second params))))
                (format t "Scroll region: ~D ~D~%" (scroll-start terminal) (scroll-end terminal)))
               (#\A ; Cursor Up (CUU).
                (setf (y-pos terminal) (max 0
                                            (- (y-pos terminal)
                                               (max (or (first params) 1) 1)))))
               (#\B ; Cursor Down (CUD).
                (setf (y-pos terminal) (min (1- (terminal-height terminal))
                                            (+ (y-pos terminal)
                                               (max (or (first params) 1) 1)))))
               (#\C ; Cursor Forwards (CUF).
                (setf (x-pos terminal) (min (1- (terminal-width terminal))
                                            (+ (x-pos terminal)
                                               (max (or (first params) 1) 1)))))
               (#\D ; Cursor Backwards (CUB).
                (setf (x-pos terminal) (max 0
                                            (- (x-pos terminal)
                                               (max (or (first params) 1) 1)))))
               ((#\f #\H) ; Horizontal and Vertical Position (HVP) and Cursor Position (CUP).
                (let* ((row (max (or (first params) 1) 1))
                       (column (max (or (second params) 1) 1)))
                  (setf (y-pos terminal) (1- row)
                        (x-pos terminal) (1- column))))
               (#\G ; Cursor Character Absolute (CHA).
                (setf (x-pos terminal) (1- (or (first params) 1))))
               (#\J ; Erase In Display (ED).
                (case (first params)
                  ((0 nil)
                   ;; clear below
                   (erase terminal (x-pos terminal) (terminal-width terminal))
                   (clear terminal (1+ (y-pos terminal)) (terminal-height terminal)))
                  (1 (clear terminal 0 (y-pos terminal))) ; clear above
                  (2 (clear terminal 0 (terminal-height terminal))) ; clear screen
                  (t (report-unknown-escape terminal))))
               (#\K ; Erase In Line (EL).
                (case (first params)
                  ((0 nil) (erase terminal (x-pos terminal) (terminal-width terminal))) ; erase to right
                  (1 (erase terminal 0 (x-pos terminal))) ; erase to left
                  (2 (erase terminal 0 (terminal-width terminal))) ; erase line
                  (t (report-unknown-escape terminal))))
               (#\L ; Insert Line (IL).
                ;; Insert Pn lines, starting at the cursor. Lines move down.
                (when (<= (scroll-start terminal)
                          (y-pos terminal)
  