anchor.diff:                  (1 (erase terminal 0 (x-pos terminal))) ; erase to left
                   (2 (erase terminal 0 (terminal-width terminal))) ; erase all
                   (t (report-unknown-escape terminal))))
  +             (#\L
  +              ;; Insert Pn lines, starting at the cursor. Lines move down.
  +              (when (<= (scroll-start terminal)
  +                        (y-pos terminal)
  +                        (1- (or (scroll-end terminal)
  +                                (terminal-height terminal))))
  +                (scroll-terminal terminal
  +                                 (y-pos terminal)
  +                                 (or (scroll-end terminal)
  +                                     (terminal-height terminal))
  +                                 (- (or (first (slot-value terminal 'parameters)) 1)))))
  +             (#\M
  +              ;; Delete Pn lines, starting at the cursor. Lines move up.
  +              (when (<= (scroll-start terminal)
  +                        (y-pos terminal)
  +                        (1- (or (scroll-end terminal)
  +                                (terminal-height terminal))))
  +                  (scroll-terminal terminal
  +                                   (y-pos terminal)
  +                                   (or (scroll-end terminal)
  +                                       (terminal-height terminal))
  +                                   (or (first (slot-value terminal 'parameters)) 1))))
                (#\d
                 (setf (y-pos terminal) (1- (or (first (slot-value terminal 'parameters)) 1))))
                (#\m (set-character-attributes terminal (nreverse (slot-value terminal 'parameters))))
  -             (#\r) ; set scroll region. **
  -             (#\h) ; set mode **
  -             (#\l) ; clear mode **
  +             (#\r ; set scroll region.
  +              (let ((params (nreverse (slot-value terminal 'parameters))))
  +                (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))))
  +             #+nil(#\h) ; set mode **
  +             #+nil(#\l) ; clear mode **
  +             (#\!
  +              (if (or (slot-value terminal 'parameters)
  +                      (slot-value terminal 'current-number))
  +                  (report-unknown-escape terminal)
  +                  (return-from xterm-saw-bracket 'xterm-saw-bracket-exclaim)))
                (#\?
                 (if (or (slot-value terminal 'parameters)
                         (slot-value terminal 'current-number))
  
positive.code:    (underline :initarg :underline :accessor underline)
     (character-set :initarg :charset :accessor charset)
     (saved-x :initform 0 :accessor saved-x)
     (saved-y :initform 0 :accessor saved-y))
    (:default-initargs
     :interrupt-character nil
     :queued-bytes '()
  
negative.code:    :bold nil
     :inverse nil
     :underline nil
     :charset :us-ascii
     :scroll-start 0
     :scroll-end nil
     :x 0 :y 0))
  
  (defun soft-reset (terminal)
    "Reset the terminal to the default state."
    (setf (autowrap terminal) nil))
  
  (defmethod sys.gray:stream-element-type ((stream xterm-terminal))
    '(unsigned-byte 8))
  