anchor.diff:    (when (and (<= 0 (y-pos term) (1- (terminal-height term)))
                (< left right))
       (sys.graphics::bitset 16 (* (- right left) 8)
  -                          #xFF000000 (terminal-framebuffer term)
  +                          (logior #xFF000000 (background-colour term)) (terminal-framebuffer term)
                             (+ (* (y-pos term) 16) (y-offset term)) (+ (* left 8) (x-offset term)))))
  +
  +(defparameter *xterm-colours*
  +  #(#x000000 ; 0 Black
  +    #x800000 ; 1 Red
  +    #x008000 ; 2 Green
  +    #x808000 ; 3 Yellow
  +    #x000080 ; 4 Blue
  +    #x800080 ; 5 Magenta
  +    #x008080 ; 6 Cyan
  +    #xC0C0C0 ; 7 "White"
  +    #x808080 ; 0 Bright Black
  +    #xFF0000 ; 1 Bright Red
  +    #x00FF00 ; 2 Bright Green
  +    #xFFFF00 ; 3 Bright Yellow
  +    #x0000FF ; 4 Bright Blue
  +    #xFF00FF ; 5 Bright Magenta
  +    #x00FFFF ; 6 Bright Cyan
  +    #xFFFFFF ; 7 Bright White
  +    ))
  +
  +(defun set-character-attributes (terminal attributes)
  +  (when (endp attributes) (setf attributes '(0)))
  +  (dolist (attr attributes)
  +    (case attr
  +      (0 ;; Normal (reset to defaults).
  +       (setf (bold terminal) nil
  +             (foreground-colour terminal) #xC0C0C0
  +             (background-colour terminal) #x000000))
  +      (1 ;; Bold.
  +       (setf (bold terminal) t))
  +      (4 ;; Underlined
  +       )
  +      (5 ;; Blink.
  +       (setf (bold terminal) t))
  +      (7 ;; Inverse.
  +       )
  +      (8 ;; Invisible.
  +       )
  +      (22 ;; Not bold.
  +       (setf (bold terminal) nil))
  +      (24 ;; Not underlined.
  +       )
  +      (25 ;; Not blink.
  +       )
  +      (27 ;; Not inverse.
  +       )
  +      (28 ;; Not invisible.
  +       )
  +      (39 ;; Set foreground to default
  +       (setf (foreground-colour terminal) #xC0C0C0))
  +      (49 ;; Set background to default
  +       (setf (background-colour terminal) #x000000))
  +      (t (cond
  +           ((<= 30 attr 37)
  +            (setf (foreground-colour terminal) (elt *xterm-colours* (- attr 30))))
  +           ((<= 40 attr 47)
  +            (setf (background-colour terminal) (elt *xterm-colours* (- attr 40))))
  +           ((<= 90 attr 97)
  +            (setf (foreground-colour terminal) (elt *xterm-colours* (+ 8 (- attr 90)))))
  +           ((<= 100 attr 107)
  +            (setf (background-colour terminal) (elt *xterm-colours* (+ 8 (- attr 100)))))
  +           (t (report-unknown-escape terminal)))))))
   
   (defun xterm-initial (terminal byte)
     "Initial state."
  
positive.code:            (data (read-subnegotiation connection)))
         (case option
           (#.+option-terminal-type+
            (write-sequence (vector +command-iac+ +command-sb+ +option-terminal-type+ +subnegotiation-is+
                                    (char-code #\x) (char-code #\t) (char-code #\e) (char-code #\r) (char-code #\m)
                                    +command-iac+ +command-se+)
                            connection))
           (t (write-sequence (vector +command-iac+ +command-sb+ option +subnegotiation-is+
                                      +command-iac+ +command-se+)
  
negative.code:    (width :reader terminal-width)
     (height :reader terminal-height)
     (x-pos :initform 0 :accessor x-pos)
     (y-pos :initform 0 :accessor y-pos)
     (foreground :initarg :foreground :accessor foreground-colour)
     (background :initarg :background :accessor background-colour)
     (bold :initarg :bold :accessor bold))
    (:default-initargs
     :interrupt-character nil
     :queued-bytes '()
     :foreground #xC0C0C0
     :background #x000000
     :bold nil
     :x 0 :y 0))
  
  (defmethod initialize-instance :after ((term xterm-terminal) &key width height)
  