anchor.diff:             (values (second known) (third known)))
             (t (error "Unknown server ~S~%" name)))))
   
  -(defclass irc-client (sys.graphics::text-window)
  +(defclass irc-client (sys.graphics::character-input-mixin
  +                      sys.graphics::window-with-chrome
  +                      sys.int::edit-stream
  +                      sys.int::stream-object)
     ((command-process :reader irc-command-process)
      (receive-process :reader irc-receive-process)
      (connection :initform nil :accessor irc-connection)
  -   (display :accessor irc-display*)))
  +   (input :reader irc-input)
  +   (display :reader irc-display)))
  +
  +;;; This is just so the graphics manager knows the display needs an update.
  +(defclass irc-display (sys.graphics::text-widget) ())
  +(defmethod sys.int::stream-write-char :after (character (stream irc-display))
  +  (setf sys.graphics::*refresh-required* t))
   
   (defmethod initialize-instance :after ((instance irc-client))
  +  (multiple-value-bind (left right top bottom)
  +      (sys.graphics::compute-window-margins instance)
  +    (setf (slot-value instance 'display) (make-instance 'irc-display
  +                                                        :framebuffer (sys.graphics::window-backbuffer instance)
  +                                                        :x left
  +                                                        :y top
  +                                                        :width (- (array-dimension (sys.graphics::window-backbuffer instance) 1)
  +                                                                  left right)
  +                                                        :height (- (array-dimension (sys.graphics::window-backbuffer instance) 0)
  +                                                                   top bottom 1 16)))
  +    (setf (slot-value instance 'input) (make-instance 'sys.graphics::text-widget
  +                                                      :framebuffer (sys.graphics::window-backbuffer instance)
  +                                                      :x left
  +                                                      :y (+ top
  +                                                            (- (array-dimension (sys.graphics::window-backbuffer instance) 0)
  +                                                               top bottom 1 16)
  +                                                            1)
  +                                                      :width (- (array-dimension (sys.graphics::window-backbuffer instance) 1)
  +                                                                left right)
  +                                                      :height 16)))
     (let ((cmd (sys.int::make-process "IRC command"))
           (rcv (sys.int::make-process "IRC receive")))
       (setf (slot-value instance 'command-process) cmd)
  
positive.code: 
  (defun create-irc-client ()
    "Open an IRC window."
    (sys.graphics::window-set-visibility (sys.graphics::make-window "Unconnected IRC" 640 400 'irc-client) t))
  
  (setf (gethash (name-char "F2") sys.graphics::*global-keybindings*) 'create-irc-client)
  
negative.code: 
  (define-command me (:text text :connection connection :channel channel :nick nick)
    (when (and connection channel)
      (format t "[~A]* ~A ~A~%" channel nick text)
      (send connection "PRIVMSG ~A :~AACTION ~A~A~%"
            channel (code-char 1) text (code-char 1))))
  
  (defmethod sys.graphics::window-redraw ((window irc-client))
    (multiple-value-bind (left right top bottom)
        (sys.graphics::compute-window-margins window)
      (sys.graphics::bitset (sys.graphics::window-height window) (sys.graphics::window-width window)
                            (sys.graphics::window-background-colour (irc-display window))
                            (sys.graphics::window-backbuffer window) top left)
      (sys.graphics::bitset 1 (sys.graphics::window-width window)
                            (sys.graphics::make-colour :gray)
                            (sys.graphics::window-backbuffer window)
                            (+ top
                               (- (array-dimension (sys.graphics::window-backbuffer window) 0)
                                  top bottom 1 16))
                            left)))
  
  (defun irc-top-level (irc)
    (let ((*standard-input* irc)
          (*standard-output* (irc-display irc))
          (*error-output* (irc-display irc))
          (*query-io* (make-two-way-stream irc (irc-display irc)))
          (*debug-io* (make-two-way-stream irc (irc-display irc))))
      (unwind-protect
           (handler-case
               (let ((current-channel nil)
                     (joined-channels '())
                     (connection nil)
                     (nick nil))
                 (loop (format irc "~A] " (or current-channel "")) ; write prompt to the input line. (ugh!)
                    (let ((line (read-line)))
                      (sys.int::stream-move-to irc 0 0)
                      (cond ((and (>= (length line) 1)
                                  (eql (char line 0) #\/)
                                  (not (and (>= (length line) 2)
                                            (eql (char line 1) #\/))))
                             (multiple-value-bind (command rest)
                                 (parse-command line)
                               (cond ((string-equal command "nick")
                                      (setf nick rest)
                                      (when connection
                                        (send connection "NICK ~A~%" nick)))
                                     ((string-equal command "connect")
                                      (cond ((not nick)
                                             (format t "Use /nick to set a nickname before connecting.~%"))
                                            ((irc-connection irc)
                                             (format t "Already connected.~%"))
                                            (t (multiple-value-bind (address port)
                                                   (resolve-server-name rest)
                                                 (setf connection (sys.net::tcp-stream-connect address port)
                                                       (irc-connection irc) connection)
                                                 (send (irc-connection irc) "USER ~A hostname servername :~A~%" nick nick)
                                                 (send (irc-connection irc) "NICK ~A~%" nick)))))
                                     ((string-equal command "join")
                                      (when connection
                                        (send connection "JOIN ~A~%" rest)
                                        (push rest joined-channels)
                                        (unless current-channel
                                          (setf current-channel rest))))
                                     ((string-equal command "chan")
                                      (when connection
                                        (setf current-channel rest)))
                                     ((string-equal command "part")
                                      (when (and connection current-channel)
                                        (send connection "PART ~A :~A~%" current-channel rest)
                                        (setf current-channel nil)))
                                     (t (let ((fn (gethash (string-upcase command) *top-level-commands*)))
                                          (if fn
                                              (with-simple-restart (abort "Abort evaulation and return to IRC.")
                                                (funcall fn rest connection current-channel nick))
                                              (format t "Unknown command ~S.~%" command)))))))
                            (current-channel
                             (format t "[~A]<~A> ~A~%" current-channel nick line)
                             (send connection "PRIVMSG ~A :~A~%" current-channel line))))))
             (quit-irc ()))
        (sys.int::process-disable (irc-receive-process irc))
        (when (irc-connection irc)
  