anchor.diff:    (with-simple-restart (continue "Ignore this character.")
       (let ((new-state (funcall (terminal-state stream) stream char)))
         (cond (new-state
  +             (when (eql new-state 'xterm-ground)
  +               (setf (slot-value stream 'escape-sequence) '()))
                (setf (terminal-state stream) new-state))
  -            (t (setf (terminal-state stream) 'xterm-initial
  -                     (slot-value stream 'current-number) nil
  -                     (slot-value stream 'parameters) '()
  -                     (slot-value stream 'escape-sequence) '()))))))
  +            (t (setf (terminal-state stream) 'xterm-ground))))))
   
   (defvar *xterm-translations*
     (list (list (name-char "Up-Arrow")    '(#\Esc #\[ #\A))
  
positive.code:             (restore-cursor terminal))))
      (t (format t "Unsupported DEC private mode ~D.~%" mode))))
  
  (defun xterm-saw-bracket-exclaim (terminal char)
    "Saw '<Esc>[!'"
    (case char
      (#\p ; DECSTR.
       (soft-reset terminal))
      (t (report-unknown-escape terminal)))
    nil)
  
  (defun xterm-saw-bracket-question (terminal char)
    "Saw '<Esc>[?'"
    (cond ((eql char #\;)
           (cond ((slot-value terminal 'current-number)
                  (push (slot-value terminal 'current-number) (slot-value terminal 'parameters))
                  (setf (slot-value terminal 'current-number) nil))
                 (t (push 0 (slot-value terminal 'parameters))))
           'xterm-saw-bracket-question)
          ((digit-char-p char)
           (unless (slot-value terminal 'current-number)
             (setf (slot-value terminal 'current-number) 0))
           (setf (slot-value terminal 'current-number) (+ (* (slot-value terminal 'current-number) 10)
                                                        (- (char-code char) (char-code #\0))))
           'xterm-saw-bracket-question)
          (t (when (slot-value terminal 'current-number)
               (push (slot-value terminal 'current-number) (slot-value terminal 'parameters))
               (setf (slot-value terminal 'current-number) nil))
             (case char
               (#\h
                (dolist (p (nreverse (slot-value terminal 'parameters)))
                  (adjust-dec-private-mode terminal p t)))
               (#\l
                (dolist (p (nreverse (slot-value terminal 'parameters)))
                  (adjust-dec-private-mode terminal p nil)))
               (t (report-unknown-escape terminal)))
             nil)))
  
  (defun xterm-saw-close-bracket (terminal char)
    "Saw '<Esc>]'/OSC and maybe some digits and semicolons."
    (cond ((eql char #\;)
           (cond ((slot-value terminal 'current-number)
                  (push (slot-value terminal 'current-number) (slot-value terminal 'parameters))
                  (setf (slot-value terminal 'current-number) nil))
                 (t (push 0 (slot-value terminal 'parameters))))
           (return-from xterm-saw-close-bracket 'xterm-saw-close-bracket))
          ((digit-char-p char)
           (unless (slot-value terminal 'current-number)
             (setf (slot-value terminal 'current-number) 0))
           (setf (slot-value terminal 'current-number) (+ (* (slot-value terminal 'current-number) 10)
                                                          (- (char-code char) (char-code #\0))))
           (return-from xterm-saw-close-bracket 'xterm-saw-close-bracket))
          (t (report-unknown-escape terminal)))
    nil)
  
  (defun xterm-saw-paren (terminal char)
    "Saw '<Esc>(', expecting a character set identifier."
    ;; Set G0 character set.
    (case char
      (#\B (setf (charset terminal) :us-ascii))
      (#\0 (setf (charset terminal) :dec))
      (t (setf (charset terminal) :us-ascii)
         (report-unknown-escape terminal)))
    nil)
  
  (defun xterm-saw-close-paren (terminal char)
    "Saw '<Esc>)', expecting a character set identifier."
    ;; Set G1 character set.
    (case char
      (#\B #+nil(setf (charset terminal) :us-ascii))
      (#\0 #+nil(setf (charset terminal) :dec))
      (t #+nil(setf (charset terminal) :us-ascii)
         (report-unknown-escape terminal)))
    nil)
  
  (defun utf-8-code-point-length (code-point)
    "Return the number of bytes required to encode CODE-POINT or NIL if it can't be encoded."
  
negative.code:                      (setf (background-colour terminal) (+ 8 (- attr 100))))
                      (t (report-unknown-escape terminal)))))))))
  
  (defun save-cursor (terminal)
    (setf (saved-x terminal) (x-pos terminal)
          (saved-y terminal) (y-pos terminal)))
  