Commits

Anonymous committed 2f13c99

Corrected names of some console colour functions which had changed in libtcod.

Comments (0)

Files changed (2)

 ;;;; loaded into the running lisp image first)
 ;;;;
 ;;;; (cldoc:extract-documentation 'cldoc:html
-;;;;       "/home/paul/lisp/wormwood/src/tcod-gui/html" 
+;;;;       "/home/paul/lisp/wormwood/src/tcod-gui/html"
 ;;;;       (asdf:find-system :dormouse)
 ;;;;       :table-of-contents-title
 ;;;;       "Dormouse, a graphical user interface using the Doryen library"
 ;;;      (dormouse:start-gui :title \"Testing\")
 ;;;      (setf msgwin
 ;;;        (make-instance '<Log-Window> :tlx 30 :tly 10 :width 20 :height 6
-;;;			 :title \"log\" :foreground :cornsilk
-;;;			 :background :dark-blue))
+;;;                      :title \"log\" :foreground :cornsilk
+;;;                      :background :dark-blue))
 ;;;      (add-message msgwin \"Press control-F1 or control-Esc to quit\")
 ;;;      (main-gui-loop)))
 - Save it in a file, load it, and run (mypkg:my-test) at the lisp prompt
   to try it.
 ")
   (:export #:start-gui
-	   #:main-gui-loop
+           #:main-gui-loop
            #:resume-gui
-	   #:*shift*
-	   #:*ctrl*
-	   #:*alt*
-	   #:*exit-gui?*
+           #:*shift*
+           #:*ctrl*
+           #:*alt*
+           #:*exit-gui?*
            #:+OPAQUE+
            #:+INVISIBLE+
            #:+DIMMED+
-	   #:screen-width
-	   #:screen-height
+           #:screen-width
+           #:screen-height
            #:legal-window-coordinates?
-	   #:colour
-	   #:destroy-window
-	   #:destroy-all-windows
-	   #:copy-windows-to-console
-	   #:prepare-window
-	   #:process-window
-	   #:redraw-window
-	   #:redraw-window-area
-	   #:redraw-all-windows
-	   #:prepare-windows-by-type
-	   #:do-for-windows-by-type
-	   #:hide-window
-	   #:raise-window
-	   #:move-window
+           #:colour
+           #:destroy-window
+           #:destroy-all-windows
+           #:copy-windows-to-console
+           #:prepare-window
+           #:process-window
+           #:redraw-window
+           #:redraw-window-area
+           #:redraw-all-windows
+           #:prepare-windows-by-type
+           #:do-for-windows-by-type
+           #:hide-window
+           #:raise-window
+           #:move-window
            #:resize-window
-	   #:*window-stack*
-	   #:all-windows
-	   #:*mouse-x*
-	   #:*mouse-y*
-	   #:send-to-window
-	   #:send-key-to-window
-	   #:mouse-drag
-	   #:key->string
-	   #:<Window>
-	   #:<Modal-Window>
-	   #:<Ghost-Window>
-	   #:<Background-Window>
-	   #:<List-Window>
-	   #:<Menu-Window>
-	   #:<Alert-Window>
-	   #:<Yes/No-Window>
-	   #:<Tooltip-Window>
-	   #:<Filtered-Window>
-	   #:filter-string
+           #:*window-stack*
+           #:all-windows
+           #:*mouse-x*
+           #:*mouse-y*
+           #:send-to-window
+           #:send-key-to-window
+           #:mouse-drag
+           #:key->string
+           #:<Window>
+           #:<Modal-Window>
+           #:<Ghost-Window>
+           #:<Background-Window>
+           #:<List-Window>
+           #:<Menu-Window>
+           #:<Alert-Window>
+           #:<Yes/No-Window>
+           #:<Tooltip-Window>
+           #:<Filtered-Window>
+           #:filter-string
            #:clear-filter
-	   #:binding->key
-	   #:character->vk
-	   #:character->shift
-	   #:<Window-With-Context-Menu>
-	   #:get-menu-items-for-context
-	   #:command-from-context-menu
-	   #:tooltip-text
-	   #:calculate-floating-window-width
-	   #:<Dialog-Window>
-	   #:window-cursor
-	   #:move-cursor-to
-	   #:cursor-moved-to-item
-	   #:window-offset
-	   #:wrap-coloured-text
-	   #:coloured-string-length
-	   #:draw-string-at
-	   #:add-item
-	   #:window-items
-	   #:window-items-lines
-	   #:clear-items
-	   #:list-item
-	   #:list-item-item
-	   #:list-item-hotkey
-	   #:list-item-p
-	   #:move-cursor-to-end
-	   #:window-show-tail-by-default?
+           #:binding->key
+           #:character->vk
+           #:character->shift
+           #:<Window-With-Context-Menu>
+           #:get-menu-items-for-context
+           #:command-from-context-menu
+           #:tooltip-text
+           #:calculate-floating-window-width
+           #:<Dialog-Window>
+           #:window-cursor
+           #:move-cursor-to
+           #:cursor-moved-to-item
+           #:window-offset
+           #:wrap-coloured-text
+           #:coloured-string-length
+           #:draw-string-at
+           #:add-item
+           #:window-items
+           #:window-items-lines
+           #:clear-items
+           #:list-item
+           #:list-item-item
+           #:list-item-hotkey
+           #:list-item-p
+           #:move-cursor-to-end
+           #:window-show-tail-by-default?
            #:window-fades-when-unfocussed?
            #:window-can-close?
            #:window-can-drag?
            #:window-can-resize?
-	   #:window-item-at-cursor
-	   ;; Log window
-	   #:<Log-Window>
-	   #:clear-messages
-	   #:add-message
+           #:window-item-at-cursor
+           ;; Log window
+           #:<Log-Window>
+           #:clear-messages
+           #:add-message
            #:add-message-and-redraw
-	   #:bottom-message
+           #:bottom-message
            ;; Terminal window
            #:<Terminal-Window>
-	   ;; Viewports
-	   #:<Viewport>
-	   #:clear-map
-	   #:share-map
-	   #:unshare-map
-	   #:map-xdim
-	   #:map-ydim
-	   #:map-draw-char-at
+           ;; Viewports
+           #:<Viewport>
+           #:clear-map
+           #:share-map
+           #:unshare-map
+           #:map-xdim
+           #:map-ydim
+           #:map-draw-char-at
            #:map-char-at
-	   #:in-view?
-	   #:centre-viewport-on
-	   #:window-foreground
-	   #:window-background
-	   #:window-width
-	   #:window-height
-	   #:window-tlx
-	   #:window-tly
-	   #:window-brx
-	   #:window-bry
+           #:map-set-background-at
+           #:in-view?
+           #:centre-viewport-on
+           #:window-foreground
+           #:window-background
+           #:window-width
+           #:window-height
+           #:window-tlx
+           #:window-tly
+           #:window-brx
+           #:window-bry
            #:window-framed?
-	   #:window-children
-	   #:window-raise-children-with-parent?
-	   #:window-hidden?
-	   #:window-changed?
-	   #:window-auto-redraw?
-	   #:view-tlx
-	   #:view-tly
-	   #:view-brx
-	   #:view-bry
-	   #:viewport-width
-	   #:viewport-height
-	   #:in-view?
-	   #:in-viewport-map?
-	   #:winx->mapx
-	   #:winy->mapy
-	   #:winx->rootx
-	   #:winy->rooty
-	   #:bar-chart
-	   ))
+           #:window-children
+           #:window-raise-children-with-parent?
+           #:window-hidden?
+           #:window-changed?
+           #:window-auto-redraw?
+           #:view-tlx
+           #:view-tly
+           #:view-brx
+           #:view-bry
+           #:viewport-width
+           #:viewport-height
+           #:in-view?
+           #:in-viewport-map?
+           #:winx->mapx
+           #:winy->mapy
+           #:winx->rootx
+           #:winy->rooty
+           #:bar-chart
+           ))
 
 (in-package :dormouse)
 
   (:documentation "TODO document."))
 (defgeneric mouse-drag-window (win rodent)
   (:documentation
-   "* Arguments: 
+   "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 - RODENT: a mouse object.
 * Returns: None.
 when the user uses the mouse to move a window across the screen."))
 (defgeneric mouse-resize-window (win rodent)
   (:documentation
-   "* Arguments: 
+   "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 - RODENT: a mouse object.
 * Returns: None.
 when the user uses the mouse to resize a window."))
 (defgeneric raise-window (win &key redraw &allow-other-keys)
   (:documentation
-   "* Arguments: 
+   "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 - REDRAW: boolean value indicating whether the area of the screen occupied
 by the window should be redrawn.
 * Returns: None.
 * Description: Put the window WIN at the top of the window stack, so that
 it is displayed as overlying any other overlapping windows.
-* Examples: 
+* Examples:
 * See Also: "))
 (defgeneric hide-window (win &key redraw &allow-other-keys)
   (:documentation
-   "* Arguments: 
+   "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 - REDRAW: boolean value indicating whether the area of the screen occupied
 by the window should be redrawn.
 * See Also: "))
 (defgeneric send-to-window (win data parm winx winy)
   (:documentation
-   "* Arguments: 
+   "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 - DATA: A value of type {deftype dormouse:=window-event-type=}, to be passed
-to WIN as an event. 
+to WIN as an event.
 - PARM: Some additional value to passed to WIN to provide further information
 about the event. For key structs it is the value of the KEY-VK slot, or the
 KEY-C slot if KEY-VK is :CHAR.
 not handled."))
 (defgeneric on-border? (win x y)
   (:documentation
-   "* Arguments: 
+   "* Arguments:
 - WIN:
 - X, Y: Coordinates.
-* Returns: 
-* Description: 
-* Examples: 
+* Returns:
+* Description:
+* Examples:
 * See Also: "))
 (defgeneric on-lower-window-border? (win x y)
   (:documentation "TODO document."))
 (defgeneric on-upper-window-border? (win x y)
   (:documentation "TODO document."))
 (defgeneric window-draw-char-at (win cg winx winy
-				&key background-flag fg bg redraw
-				&allow-other-keys)
+                                &key background-flag fg bg redraw
+                                &allow-other-keys)
   (:documentation "TODO document."))
 (defgeneric console-draw-char-at (con ch winx winy
-			     &key background-flag fg bg &allow-other-keys)
+                             &key background-flag fg bg &allow-other-keys)
   (:documentation "TODO document."))
 (defgeneric draw-string-at (win str x y
-			   &key fg bg redraw &allow-other-keys)
+                           &key fg bg redraw &allow-other-keys)
   (:documentation
-   "* Arguments: 
+   "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 - STR: A string, which may contain formatting directives (see below).
 - X, Y: coordinates where the string should be printed, relative to
 the top left corner of WIN.
 - FG, BG: foreground and background colours for the string.
-- REDRAW: Boolean. 
+- REDRAW: Boolean.
 * Returns: None.
 * Description: Draw the string STR on the window object WIN at
 position X,Y. The string STR can contain colour-changing directives - see the
 (defgeneric unshare-map (receiver giver)
   (:documentation "TODO document."))
 (defgeneric map-draw-char-at (win ch x y
-				&key background-flag fg bg redraw
-			     &allow-other-keys)
+                                &key background-flag fg bg redraw
+                             &allow-other-keys)
   (:documentation   "Draw character with ASCII code CH at position MAPX, MAPY
 on the map console of WIN."))
 (defgeneric map-char-at (win mapx mapy)
   `(progn
      (assert (and (integerp ,x) (integerp ,y)))
      (if (< ,x 0)
-	 (incf ,x (screen-width)))
+         (incf ,x (screen-width)))
      (if (< ,y 0)
-	 (incf ,y (screen-height)))))
+         (incf ,y (screen-height)))))
 
 
 (defmacro do-for-windows-by-type ((winvar wtype &key (include-hidden? nil))
-				  &body body)
+                                  &body body)
   "* Usage
 : (do-for-windows-by-type (WIN WTYPE &key INCLUDE-HIDDEN?)
 :     ...body...)
 in BAG occur within it. The resulting substrings will not contain the
 characters in BAG. Returns the resulting list of substrings."
   (let ((tokens nil)
-	(found-pos nil))
+        (found-pos nil))
     (check-type str string)
     (setf str (string-trim bag str))
     (iterate
 
 
 (defun word-wrap (text &key (width 80) respect-newlines respect-hyphens
-		  exclude-start-char exclude-end-char)
+                  exclude-start-char exclude-end-char)
   "* Usage
 : (word-wrap TEXT &key WIDTH RESPECT-NEWLINES RESPECT-HYPHENS
 :    EXCLUDE-START-CHAR EXCLUDE-END-CHAR)
     (when (not skipping)
       (incf counted)
       (if (or (eql c #\space) (eql c #\tab)
-	      (and (eql c #\Newline) (not respect-newlines))
-	      (and (eql c #\-) (not respect-hyphens)))
-	  (setf breakpoint actual))
+              (and (eql c #\Newline) (not respect-newlines))
+              (and (eql c #\-) (not respect-hyphens)))
+          (setf breakpoint actual))
       (when (and (eql c #\Newline) respect-newlines)
-	(setf breakpoint actual)
-	(setf counted (1+ width))))
+        (setf breakpoint actual)
+        (setf counted (1+ width))))
     (when (>= counted width)
       (return (cons (substitute-if #\space
-				   #'(lambda (ch)
-				       (or (eql ch #\tab)
-					   (eql ch #\newline)))
-				   (subseq text 0
-					   (or breakpoint actual)))
-		    (word-wrap (subseq text (if breakpoint
-						(1+ breakpoint)
-						actual))
-			       :width width
-			       :respect-newlines respect-newlines
-			       :respect-hyphens respect-hyphens
-			       :exclude-start-char exclude-start-char
-			       :exclude-end-char exclude-end-char))))
+                                   #'(lambda (ch)
+                                       (or (eql ch #\tab)
+                                           (eql ch #\newline)))
+                                   (subseq text 0
+                                           (or breakpoint actual)))
+                    (word-wrap (subseq text (if breakpoint
+                                                (1+ breakpoint)
+                                                actual))
+                               :width width
+                               :respect-newlines respect-newlines
+                               :respect-hyphens respect-hyphens
+                               :exclude-start-char exclude-start-char
+                               :exclude-end-char exclude-end-char))))
     (finally (return (list text)))))
 
 
   "Given a character CH, return the value of the 'SHIFT' field that is expected
 when the key for that character is pressed by the user."
   (if (or (upper-case-p ch)
-	  (find ch '(#\~ #\! #\@ #\# #\$ #\% #\^ #\& #\*
-		     #\( #\) #\_ #\+ #\{ #\} #\| #\: #\"
-		     #\< #\> #\?)))
- 
+          (find ch '(#\~ #\! #\@ #\# #\$ #\% #\^ #\& #\*
+                     #\( #\) #\_ #\+ #\{ #\} #\| #\: #\"
+                     #\< #\> #\?)))
+
       t nil))
 
 
   (destructuring-bind (keycode &key ctrl shift alt) binding
       (tcod:make-key
        :vk (if (characterp keycode)
-	       (character->vk keycode)
-	       keycode)
+               (character->vk keycode)
+               keycode)
        :c (if (characterp keycode)
-	      keycode
-	      #\null)
+              keycode
+              #\null)
        :pressed t
        :shift (if (not (characterp keycode))
-		  shift
-		  (character->shift keycode ))
+                  shift
+                  (character->shift keycode ))
        :lctrl ctrl :rctrl ctrl :lalt alt :ralt alt)))
 
 
 ;;;   \"G{'i}mli, son of Glo{'i}n\"
 "
   (let ((pos@ nil)
-	(pos@@ 0))
+        (pos@@ 0))
     (setf pos@ (position *text-format-start-char* str))
     (cond
       ((null pos@)
        str)
       ((and (> (length str) 1)
-	    (member (char str 0) (list *text-format-start-char*
+            (member (char str 0) (list *text-format-start-char*
                                        *text-format-end-char*))
-	    (eql (char str 0) (char str 1)))
+            (eql (char str 0) (char str 1)))
        (format nil "~C~A" (char str 0)
-	       (make-coloured-string (subseq str 2)
+               (make-coloured-string (subseq str 2)
                                      :dialog? dialog? :win win)))
       ((> pos@ 0)
        (concatenate 'string (subseq str 0 pos@)
                     (make-coloured-string (subseq str pos@)
                                           :dialog? dialog? :win win)))
       ((null (setf pos@@ (position *text-format-end-char*
-				   (subseq str 1))))
+                                   (subseq str 1))))
        (warn "Missing format-end character `~C' in string ~s"
-	     *text-format-end-char* str)
+             *text-format-end-char* str)
        str)
       (t
        (incf pos@@)
                          (subseq str (+ 1 pos@@)) :dialog? dialog?
                          :win win)))))))
 
-		       
+
 (defmethod colour->control-string ((col integer) background?)
   (multiple-value-bind (r g b) (decompose-colour col)
     (format nil "~C~C~C~C"
 (defmethod colour->control-string ((col string) background?)
   (colour->control-string (string->colournum col) background?))
 
-  
+
 (defun string->tcod-colour-codes (str &optional win)
   "Given the contents of a formatting directive STR (a string), return the TCOD
 control codes that are needed to use the colours specified in the string.
        ;;                                  (colour (window-background win))))
        ;; (format s "~C" (colctrl->char :COLCTRL-STOP)))
       ((and (= 2 (length str))
-	    (member (char str 0) '(#\^ #\: #\' #\`))
-	    (member (char str 1) '(#\A #\E #\I #\O #\U #\a #\e #\i #\o #\u)))
+            (member (char str 0) '(#\^ #\: #\' #\`))
+            (member (char str 1) '(#\A #\E #\I #\O #\U #\a #\e #\i #\o #\u)))
        (format s "~C" (compose-accented-char (char str 1) (char str 0))))
       (t
        (let* ((props (string->properties str :foreground))
                               (getf props :fg)))
               (background (or (getf props :background)
                               (getf props :bg))))
-	 (when foreground
+         (when foreground
            (format s (colour->control-string foreground nil)))
-	   ;; (multiple-value-bind
+           ;; (multiple-value-bind
            ;;       (fr fg fb) (decompose-colour (string->colournum foreground))
-	   ;;   (format s "~C~C~C~C"
-	   ;;           (colctrl->char :COLCTRL-FORE-RGB)
-	   ;;           (code-char (max fr 1))
-	   ;;           (code-char (max fg 1))
-	   ;;           (code-char (max fb 1)))))
-	 (when background
+           ;;   (format s "~C~C~C~C"
+           ;;           (colctrl->char :COLCTRL-FORE-RGB)
+           ;;           (code-char (max fr 1))
+           ;;           (code-char (max fg 1))
+           ;;           (code-char (max fb 1)))))
+         (when background
            (format s (colour->control-string background t))))))))
-	   ;; (multiple-value-bind
+           ;; (multiple-value-bind
            ;;       (br bg bb) (decompose-colour (string->colournum background))
-	   ;;   (format s "~C~C~C~C"
-	   ;;           (colctrl->char :COLCTRL-BACK-RGB)
-	   ;;           (code-char (max br 1))
-	   ;;           (code-char (max bg 1))
-	   ;;           (code-char (max bb 1))))))))))
+           ;;   (format s "~C~C~C~C"
+           ;;           (colctrl->char :COLCTRL-BACK-RGB)
+           ;;           (code-char (max br 1))
+           ;;           (code-char (max bg 1))
+           ;;           (code-char (max bb 1))))))))))
 
 
 (defun compose-accented-char (ch accent)
               (click-label (or (getf props :button)
                                (getf props :btn)
                                (getf props :click))))
-	 (when click-label
-	   (multiple-value-bind
+         (when click-label
+           (multiple-value-bind
                  (fr fg fb) (decompose-colour
                              (string->dialog-colour click-label))
-	     (format s "~C~C~C~C"
-		     (colctrl->char :COLCTRL-FORE-RGB)
-		     (code-char (max fr 1))
-		     (code-char (max fg 1))
-		     (code-char (max fb 1))))))))))
+             (format s "~C~C~C~C"
+                     (colctrl->char :COLCTRL-FORE-RGB)
+                     (code-char (max fr 1))
+                     (code-char (max fg 1))
+                     (code-char (max fb 1))))))))))
 
 
 (defun string->properties (str &optional (default-label :unlabelled))
   (let ((properties nil))
     (dolist (term (string-tokenise '(#\,) str))
       (cond
-	((and (position #\: term)
-	      (> (position #\: term) 0))
-	 (setf (getf properties
-		     (make-keyword (subseq term 0 (position #\: term))))
-	       (subseq term (1+ (position #\: term)))))
-	(t				; default - no label given
-	 (setf (getf properties default-label) term))))
+        ((and (position #\: term)
+              (> (position #\: term) 0))
+         (setf (getf properties
+                     (make-keyword (subseq term 0 (position #\: term))))
+               (subseq term (1+ (position #\: term)))))
+        (t                              ; default - no label given
+         (setf (getf properties default-label) term))))
     properties))
 
 
-  
+
 (defun string->colournum (str)
   "Given a string STR, return the colournum that is associated with the
 corresponding keyword."
     (cond
       (counting
        (if (eql c *text-format-start-char*)
-	   (setf counting nil)
-	   ;; else
-	   (incf cnt)))
+           (setf counting nil)
+           ;; else
+           (incf cnt)))
       ((eql c *text-format-end-char*)
        (setf counting t))
       (t nil))
        str)
       (t
        (iterate
-	 (with cnt = 0)
-	 (with c = nil)
-	 (with counting = t)
-	 (for actual :from (1- (length str)) :downto 0)
-	 (setf c (char str actual))
-	 (cond
-	   (counting
-	    (cond
-	      ((eql c *text-format-end-char*)
-	       (setf counting nil))
-	      ;; else
-	      (t
-	       (incf cnt))))
-	   ((eql c *text-format-start-char*)
-	    (setf counting t))
-	   (t nil))
-	 (when (and counting (>= cnt (- len n)))
-	   (return (subseq str actual)))
-	 (finally (return str)))))))
+         (with cnt = 0)
+         (with c = nil)
+         (with counting = t)
+         (for actual :from (1- (length str)) :downto 0)
+         (setf c (char str actual))
+         (cond
+           (counting
+            (cond
+              ((eql c *text-format-end-char*)
+               (setf counting nil))
+              ;; else
+              (t
+               (incf cnt))))
+           ((eql c *text-format-start-char*)
+            (setf counting t))
+           (t nil))
+         (when (and counting (>= cnt (- len n)))
+           (return (subseq str actual)))
+         (finally (return str)))))))
 
 
 (defun left-trim-coloured-string (str n)
        str)
       (t
        (iterate
-	 (with cnt = 0)
-	 (with counting = t)
-	 (for c :in-string str)
-	 (for actual :from 0)
-	 (cond
-	   (counting
-	    (cond
-	      ((eql c *text-format-start-char*)
-	       (setf counting nil))
-	      ;; else
-	      (t
-	       (incf cnt))))
-	   ((eql c *text-format-end-char*)
-	    (setf counting t))
-	   (t nil))
-	 (when (and counting (>= cnt n))
-	   (return (subseq str 0 (1+ actual))))
-	 (finally (return str)))))))
+         (with cnt = 0)
+         (with counting = t)
+         (for c :in-string str)
+         (for actual :from 0)
+         (cond
+           (counting
+            (cond
+              ((eql c *text-format-start-char*)
+               (setf counting nil))
+              ;; else
+              (t
+               (incf cnt))))
+           ((eql c *text-format-end-char*)
+            (setf counting t))
+           (t nil))
+         (when (and counting (>= cnt n))
+           (return (subseq str 0 (1+ actual))))
+         (finally (return str)))))))
 
 
 
 (defun colourise (val fg &optional bg)
-  "Given a value, return it as a string wrapped in directives for 
-  {defgeneric dormouse:write-to-window-at} which will make the value appear in 
+  "Given a value, return it as a string wrapped in directives for
+  {defgeneric dormouse:write-to-window-at} which will make the value appear in
   colours FG[,BG] when written to the screen."
   (cond
     (bg
      (format nil "{fg:~A,bg:~A}~A{/}"
-	     (keyword->string fg)
-	     (keyword->string bg)
-	     val))
+             (keyword->string fg)
+             (keyword->string bg)
+             val))
     (t
      (format nil "{fg:~A}~A{/}"
-	     (keyword->string fg)
-	     val))))
+             (keyword->string fg)
+             val))))
 
 
 
 (defun bar-chart (width num denom
-		  &key (text nil) 
-		  (bar-colour :red) (empty-bar-colour :black)
-		  (text-colour :white))
-  "Returns a colourised string which, when printed using 
-  draw-string-at, will produce a string of solid blocks 
-  WIDTH characters long, coloured BAR-COLOUR for NUM/DENOM * the string's 
+                  &key (text nil)
+                  (bar-colour :red) (empty-bar-colour :black)
+                  (text-colour :white))
+  "Returns a colourised string which, when printed using
+  draw-string-at, will produce a string of solid blocks
+  WIDTH characters long, coloured BAR-COLOUR for NUM/DENOM * the string's
   length, and EMPTY-BAR-COLOUR for the rest of the string.
 
 If TEXT is supplied, then some text will appear in the centre of the bar chart,
   (declare (type (integer 1) width) (real num denom))
   (when (zerop denom)
     (setf denom 1))
-  (let ((bar 
-	 (cond
+  (let ((bar
+         (cond
            ((eql text :fraction)
-	    (centre-string (format nil "~D/~D" num denom) width))
+            (centre-string (format nil "~D/~D" num denom) width))
            ((eql text :percent)
-	    (centre-string (format nil "~D%" (floor (* num 100) denom)) width))
+            (centre-string (format nil "~D%" (floor (* num 100) denom)) width))
            ((stringp text)
             (centre-string text width))
            (t   ;; just a bar
             (spaces width))))
-	(filled-spaces (round (* width (/ (constrain num 0 denom) denom)))))
+        (filled-spaces (round (* width (/ (constrain num 0 denom) denom)))))
     (concatenate 'string
                  "{fg:" (keyword->string text-colour)
                  ",bg:" (keyword->string bar-colour) "}"
    (window-alive? :accessor window-alive? :initform t :type boolean
                   :documentation "Set to nil when a window has been destroyed.")
    (window-touching :accessor window-touching :initform (list) :type list
-		    :documentation "List of windows that overlap this window."))
+                    :documentation "List of windows that overlap this window."))
   (:documentation   "* Description: Class whose instances represent windows on
 the screen.
 * Examples: TODO
 * See Also: "))
-	
+
 
 
 (defun screen-width ()
 
 
 (defmethod initialize-instance :after ((win <Window>) &key (hidden? nil)
-				       &allow-other-keys)
-  (setf (window-console win) 
-	(console-new (window-width win) (window-height win)))
-  (console-set-foreground-colour (window-console win)
-				 (colour (window-foreground win)))
-  (console-set-background-colour (window-console win)
-				 (colour (window-background win)))
+                                       &allow-other-keys)
+  (setf (window-console win)
+        (console-new (window-width win) (window-height win)))
+  (console-set-default-foreground (window-console win)
+                                 (colour (window-foreground win)))
+  (console-set-default-background (window-console win)
+                                 (colour (window-background win)))
   (console-set-background-flag (window-console win) :set)
   ;; Translate negative numbers for TLX,TLY to be relative to the
   ;; bottom right corner of the screen.
 (defmethod window-parent ((win <Window>))
   ;; TODO inefficient
   (find-if #'(lambda (parent) (member win (window-children parent)))
-		(all-windows)))
+                (all-windows)))
 
 
 (defmethod destroy-window ((win <Window>))
   (if (find win *window-stack*)
       (hide-window win))
   (when (and (window-console win)
-	     (not (equal *root* (window-console win)))))
+             (not (equal *root* (window-console win)))))
   ;; If it has a parent, remove it from parent's list.
   (let ((parent (window-parent win)))
     (if parent
 (defmethod touch-windows ((win <Window>))
   (dolist (other *window-stack*)
     (when (and (not (equal other win))
-	     (windows-touching? win other))
-	(pushnew other (window-touching win))
-	(pushnew win (window-touching other)))))
+             (windows-touching? win other))
+        (pushnew other (window-touching win))
+        (pushnew win (window-touching other)))))
 
 
 (defmethod untouch-windows ((win <Window>))
-	(dolist (other (window-touching win))
-		(setf (window-touching other) 
-			(remove win (window-touching other) :test #'equal)))
-	(setf (window-touching win) (list)))
-
-	
+        (dolist (other (window-touching win))
+                (setf (window-touching other)
+                        (remove win (window-touching other) :test #'equal)))
+        (setf (window-touching win) (list)))
+
+
 (defmethod move-window ((win <Window>) tlx tly)
   (translate-negative-coordinates tlx tly)
   (untouch-windows win)
 
 
 (defun window-areas-overlap? (a-tlx a-tly a-brx a-bry
-		       b-tlx b-tly b-brx b-bry)
-  "* Arguments: 
+                       b-tlx b-tly b-brx b-bry)
+  "* Arguments:
 - A-TLX, A-TLY: coordinates of top left corner of the first area.
 - A-BRX, A-BRY: coordinates of bottom right corner of the first area.
 - B-TLX, B-TLY: coordinates of top left corner of the second area.
   (translate-negative-coordinates b-tlx b-tly)
   (translate-negative-coordinates b-brx b-bry)
   (not (or (< a-brx b-tlx)
-	   (< a-bry b-tly)
-	   (> a-tlx b-brx)
-	   (> a-tly b-bry))))
+           (< a-bry b-tly)
+           (> a-tlx b-brx)
+           (> a-tly b-bry))))
 
 
 (defmethod window-touches-spot? ((win <Window>) x y)
 
 (defmethod windows-overlying ((win <Window>))
   (remove-if-not #'(lambda (w) (member w (window-touching win)))
-		 (windows-above win)))
+                 (windows-above win)))
 
 
 (defmethod windows-underlying ((win <Window>))
   (remove-if-not #'(lambda (w) (member w (window-touching win)))
-		 (windows-below win)))
+                 (windows-below win)))
 
 
 (defmethod windows-overlapping ((win <Window>) &key (include-window? t))
   (remove-if #'(lambda (win2)
-		 (or (and (not include-window?) (eql win win2))
-		     (not (windows-touching? win win2))))
-	     *window-stack*))
+                 (or (and (not include-window?) (eql win win2))
+                     (not (windows-touching? win win2))))
+             *window-stack*))
 
 
 (defmethod copy-window-to-console ((win <Window>) con)
       ;; (warn "xsrc: ~D ysrc: ~D wsrc: ~D hsrc: ~D xdest: ~D ydest: ~D srcw: ~D srch: ~D destw: ~D desth: ~D~%"
       ;;     0 0 (window-width win) (window-height win)
-      ;;     (window-tlx win) (window-tly win) 
+      ;;     (window-tlx win) (window-tly win)
       ;;     (console-get-width (window-console win))
       ;;     (console-get-height (window-console win))
       ;;     (console-get-width con)
       ;;     )
       ;; (break)
   (console-blit (window-console win) 0 0 (window-width win) (window-height win)
-		con (window-tlx win) (window-tly win) 
-		(window-transparency->fade win) (window-transparency->fade win)))
+                con (window-tlx win) (window-tly win)
+                (window-transparency->fade win) (window-transparency->fade win)))
 
 
 
 
 
 (defun copy-windows-to-console (window-list con)
-  "* Arguments: 
+  "* Arguments:
 - WINDOW-LIST: a list of instances of {defclass dormouse:<Window>}
 - CON: a C console pointer.
 * Returns: None.
 
 
 (defun copy-console-to-console (src dest)
-  "* Arguments: 
+  "* Arguments:
 - SRC, DEST: C console pointers.
 * Returns: None.
 * Description: Copy the entire contents of console SRC onto console DEST."
   (console-blit src 0 0
-		(console-get-width src) (console-get-height src)
-		dest 0 0 1.0 1.0))
+                (console-get-width src) (console-get-height src)
+                dest 0 0 1.0 1.0))
 
 
 (defun transparency->fade (tran)
 
 
 (defun window-transparency->fade (win)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 * Returns: A real number between 0 and 1, representing a TCOD 'fade' value.
 * Description: Given a window WIN, convert the value of its WINDOW-TRANSPARENCY
   (cond
     ((window-framed? win)
      (cond
-	 ((eql win (car *window-stack*))
-	 (console-print-double-frame
-	  (window-console win) 0 0
-	  (window-width win) (window-height win) 
-	  t :set (or (window-title win) "")))
-	 (t
-	 (console-print-frame
-	  (window-console win) 0 0
-	  (window-width win) (window-height win) 
-	  t :set (or (window-title win) ""))))
-	  
+         ((eql win (car *window-stack*))
+         (console-print-double-frame
+          (window-console win) 0 0
+          (window-width win) (window-height win)
+          t :set (or (window-title win) "")))
+         (t
+         (console-print-frame
+          (window-console win) 0 0
+          (window-width win) (window-height win)
+          t :set (or (window-title win) ""))))
+
      (when (window-can-close? win)
        (console-set-char (window-console win) (1- (window-width win))
-			 0 (char-code #\X)))
-	
+                         0 (char-code #\X)))
+
      (when (window-can-resize? win)
-	 (console-set-char (window-console win) (1- (window-width win))
-			   (1- (window-height win)) 188)))
+         (console-set-char (window-console win) (1- (window-width win))
+                           (1- (window-height win)) 188)))
     (t
      (console-rect (window-console win) 0 0
-		   (window-width win) (window-height win) t :set)))
+                   (window-width win) (window-height win) t :set)))
   (when (window-draw-function win)
        (funcall (window-draw-function win) win))
   (when (window-children win)
       (dolist (child (window-children win))
-	(when (or (window-raise-children-with-parent? win)
-		  (not (window-hidden? child)))
-	  (prepare-window child)))))
+        (when (or (window-raise-children-with-parent? win)
+                  (not (window-hidden? child)))
+          (prepare-window child)))))
 
 
 
 (defun prepare-windows-by-type (winclass)
-  "* Arguments: 
+  "* Arguments:
 - WINCLASS: A symbol naming a subclass of {defclass dormouse:<Window>}.
 * Returns: None.
 * Description: Calls {defgeneric dormouse:prepare-window} for each existing
 
 
 (defun top-window-at (x y &key (windows *window-stack*)
-		      (override-modal? nil))
+                      (override-modal? nil))
   "* Arguments:
 - X, Y: Coordinates of a point on the screen (root console).
 - WINDOWS: List of window objects to consider (default is to consider
     (cond
       ((and (not override-modal?) (modal? top))
        (if (window-touches-spot? top x y)
-	   top
-	   ;; else
-	   nil))
+           top
+           ;; else
+           nil))
       (t
        (find-if #'(lambda (win) (and (window-touches-spot? win x y)
-				     (not (ghost-window? win))))
-		windows)))))
+                                     (not (ghost-window? win))))
+                windows)))))
 
 
 
 Return a list of all non-hidden windows that overlie the point at X,Y."
   (translate-negative-coordinates x y)
   (remove-if-not #'(lambda (win) (window-touches-spot? win x y))
-		 *window-stack*))
+                 *window-stack*))
 
 
 (defun window-brx (win)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 * Returns: An X-coordinate.
 * Description:
 
 
 (defun window-bry (win)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 * Returns: A Y-coordinate.
 * Description:
   "Change the dimensions of window WIN to WIDTH x HEIGHT."
   (untouch-windows win)
   (setf (window-console win) (console-new width height))
-  (console-set-foreground-colour (window-console win)
-				 (colour (window-foreground win)))
-  (console-set-background-colour (window-console win)
-				 (colour (window-background win)))
+  (console-set-default-foreground (window-console win)
+                                 (colour (window-foreground win)))
+  (console-set-default-background (window-console win)
+                                 (colour (window-background win)))
   (setf (window-width win) width)
   (setf (window-height win) height)
   (touch-windows win))
 
 (defmethod mouse-drag-window ((win <Window>) (rodent mouse))
   (let ((offsetx (- (mouse-cx rodent) (window-tlx win)))
-	(offsety (- (mouse-cy rodent) (window-tly win)))
-	(tlx 0) (tly 0)
-	(width (window-width win))
-	(height (window-height win))
-	(root-width (console-get-width *root*))
-	(root-height (console-get-height *root*)))
+        (offsety (- (mouse-cy rodent) (window-tly win)))
+        (tlx 0) (tly 0)
+        (width (window-width win))
+        (height (window-height win))
+        (root-width (console-get-width *root*))
+        (root-height (console-get-height *root*)))
     ;; draw everything but the window
     (raise-window win)
     ;; Draw all windows but this one onto SCRATCH.
     (console-flush)
     ;; Save part of root console covered by WIN
     (console-blit *scratch* (window-tlx win) (window-tly win)
-		  width height
-		  *temp-con* 0 0 1.0 1.0)
+                  width height
+                  *temp-con* 0 0 1.0 1.0)
     (copy-console-to-console *scratch* *root*)
     (copy-window-to-console win *root*)
     (console-flush)
       (while (mouse-lbutton (setf rodent (mouse-get-status))))
       ;; Update position of WIN based on mouse position
       (setf tlx (constrain (- (mouse-cx rodent) offsetx)
-			   0 (- root-width width 1)))
+                           0 (- root-width width 1)))
       (setf tly (constrain (- (mouse-cy rodent) offsety)
-			   0 (- root-height height 1)))
+                           0 (- root-height height 1)))
       ;;(format t "~A ~A ~A ~A~%" tlx tly width height)
       (unless (and (= tlx (window-tlx win)) (= tly (window-tly win)))
-	;; copy saved win to root  at WIN's old position (erasing WIN)
-	(console-blit *temp-con* 0 0
-		      width height
-		      *root* (window-tlx win) (window-tly win) 1.0 1.0)
-	;; "move" WIN to the new position
-	(move-window win tlx tly)
-	;; save the part of the root console which WIN covers
-	(console-blit *scratch* tlx tly
-		      width height
-		      *temp-con* 0 0 1.0 1.0)
-	;; copy WIN to root
-	(copy-window-to-console win *root*))
+        ;; copy saved win to root  at WIN's old position (erasing WIN)
+        (console-blit *temp-con* 0 0
+                      width height
+                      *root* (window-tlx win) (window-tly win) 1.0 1.0)
+        ;; "move" WIN to the new position
+        (move-window win tlx tly)
+        ;; save the part of the root console which WIN covers
+        (console-blit *scratch* tlx tly
+                      width height
+                      *temp-con* 0 0 1.0 1.0)
+        ;; copy WIN to root
+        (copy-window-to-console win *root*))
       ;; Refresh root console
       (console-flush))))
 
     (copy-windows-to-console (remove win *window-stack*) *scratch*)
     ;; Save part of root console covered by WIN
     (console-blit *scratch* (window-tlx win) (window-tly win)
-		  (window-width win) (window-height win)
-		  *temp-con* 0 0 1.0 1.0)
+                  (window-width win) (window-height win)
+                  *temp-con* 0 0 1.0 1.0)
     (copy-console-to-console *scratch* *root*)
     (copy-window-to-console win *root*)
     (console-flush)
       (while (mouse-lbutton (setf rodent (mouse-get-status))))
       ;; Update position of WIN based on mouse position.  Don't allow the mouse
       ;; to go above or to left of the top left corner of the window.
-      (setf brx (constrain (mouse-cx rodent) (window-tlx win) 
-			   (1- (console-get-width *root*))))
-      (setf bry (constrain (mouse-cy rodent) (window-tly win) 
-			   (1- (console-get-height *root*))))
+      (setf brx (constrain (mouse-cx rodent) (window-tlx win)
+                           (1- (console-get-width *root*))))
+      (setf bry (constrain (mouse-cy rodent) (window-tly win)
+                           (1- (console-get-height *root*))))
       (unless (and (= brx (window-brx win)) (= bry (window-bry win)))
-	;; copy saved win to root  at WIN's old position (erasing WIN)
-	(console-blit *temp-con* 0 0
-		      (window-width win) (window-height win)
-		      *root* (window-tlx win) (window-tly win) 1.0 1.0)
-	;; Resize WIN (might be smaller)
-	(resize-window win (1+ (- brx (window-tlx win))) 
-		       (1+ (- bry (window-tly win))))
-	(prepare-window win)
-	;; save the part of the root console which WIN now covers
-	(console-blit *scratch* (window-tlx win) (window-tly win)
-		      (window-width win) (window-height win)
-		      *temp-con* 0 0 1.0 1.0)
-	;; copy WIN to root
-	(copy-window-to-console win *root*))
+        ;; copy saved win to root  at WIN's old position (erasing WIN)
+        (console-blit *temp-con* 0 0
+                      (window-width win) (window-height win)
+                      *root* (window-tlx win) (window-tly win) 1.0 1.0)
+        ;; Resize WIN (might be smaller)
+        (resize-window win (1+ (- brx (window-tlx win)))
+                       (1+ (- bry (window-tly win))))
+        (prepare-window win)
+        ;; save the part of the root console which WIN now covers
+        (console-blit *scratch* (window-tlx win) (window-tly win)
+                      (window-width win) (window-height win)
+                      *temp-con* 0 0 1.0 1.0)
+        ;; copy WIN to root
+        (copy-window-to-console win *root*))
       ;; Refresh root console
       (console-flush))))
 
 
 (defmethod raise-window ((win <Window>) &key (redraw *auto-redraw*)
-			 (simple-redraw? nil) &allow-other-keys)
+                         (simple-redraw? nil) &allow-other-keys)
   (setf *window-stack* (remove win *window-stack* :test #'equal))
   (setf *hidden-windows* (remove win *hidden-windows* :test #'equal))
   (setf (window-hidden? win) nil)
   (when (window-children win)
     (dolist (child  (window-children win))
       (when (or (window-raise-children-with-parent? win)
-		(not (window-hidden? child)))
+                (not (window-hidden? child)))
       (raise-window child :redraw redraw :simple-redraw? simple-redraw?))))
   (when redraw
     (if simple-redraw?
-	(copy-window-to-console win *root*)
-	;; else
-	(redraw-window-area win))))
+        (copy-window-to-console win *root*)
+        ;; else
+        (redraw-window-area win))))
 
 
 
   (untouch-windows win)
   (setf *window-stack* (remove win *window-stack* :test #'equal))
   (if (and (window-raise-children-with-parent? win)
-	   (window-children win))
+           (window-children win))
       (dolist (child (window-children win))
-	(hide-window child)))
+        (hide-window child)))
   (cond
     ((window-ephemeral? win)
      (destroy-window win))
 
 
 (defmethod window-draw-char-at ((win <Window>) (ch integer) winx winy
-				&key (background-flag :set)
-				(fg nil) (bg nil) (redraw *auto-redraw*))
+                                &key (background-flag :set)
+                                (fg nil) (bg nil) (redraw *auto-redraw*))
   (console-draw-char-at (window-console win) ch winx winy
-			:background-flag background-flag
-			:fg fg :bg bg)
+                        :background-flag background-flag
+                        :fg fg :bg bg)
   (when redraw
     (redraw-all-at (winx->rootx win winx) (winy->rooty win winy))))
 ;;    (window-redraw-at win (winx->rootx winx) (winy->rooty winy))))
 
 
 (defmethod console-draw-char-at (con (ch integer) winx winy
-			     &key (background-flag :set)
-				(fg nil) (bg nil))
+                             &key (background-flag :set)
+                                (fg nil) (bg nil))
   (cond
     ((and fg bg)
      ;; New in libtcod 1.4.3
      (console-set-char con winx winy ch)
      (cond
        (fg
-        (console-set-fore con winx winy (colour fg)))
+        (console-set-char-foreground con winx winy (colour fg)))
        (bg
-        (console-set-back con winx winy (colour bg) background-flag))))
+        (console-set-char-background con winx winy (colour bg) background-flag))))
     (t
      (console-put-char con winx winy ch background-flag)))
   ;; todo restore old values after printing
 
 
 (defmethod window-draw-char-at ((win <Window>) (ch character) winx winy
-				&key (background-flag :set) (fg nil) (bg nil)
-				(redraw *auto-redraw*))
+                                &key (background-flag :set) (fg nil) (bg nil)
+                                (redraw *auto-redraw*))
   (window-draw-char-at win (char-code ch) winx winy
-		       :background-flag background-flag :fg fg :bg bg
-		       :redraw redraw))
+                       :background-flag background-flag :fg fg :bg bg
+                       :redraw redraw))
 
 
 (defmethod draw-string-at ((win <Window>) str winx winy
-			   &key (fg nil) (bg nil) (background-flag :set)
+                           &key (fg nil) (bg nil) (background-flag :set)
                            (redraw *auto-redraw*))
   (declare (ignorable redraw))
   (cond
     ((or fg bg)
      (if fg
-	 (console-set-foreground-colour (window-console win) (colour fg)))
+         (console-set-default-foreground (window-console win) (colour fg)))
      (if bg
-	 (console-set-background-colour (window-console win) (colour bg)))
+         (console-set-default-background (window-console win) (colour bg)))
      (console-print-ex (window-console win) winx winy
                        background-flag :left
                     (make-coloured-string str :win win))
      (if fg
-	 (console-set-foreground-colour (window-console win)
-					(colour (window-foreground win))))
+         (console-set-default-foreground (window-console win)
+                                        (colour (window-foreground win))))
      (if bg
-	 (console-set-background-colour (window-console win)
-					(colour (window-background win)))))
+         (console-set-default-background (window-console win)
+                                        (colour (window-background win)))))
     (t
      (console-print-ex (window-console win) winx winy
                        background-flag :left
 
 
 (defun rootx->winx (win rootx)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}.
 - ROOTX: An X-coordinate on the screen (root console).
-* Returns: Integer. 
+* Returns: Integer.
 * Description: Given the screen X-coordinate ROOTX, return the X-coordinate
 of the same screen point relative to the top left corner of the window WIN.
 * Examples:
   (- rootx (window-tlx win)))
 
 (defun rooty->winy (win rooty)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}.
 - ROOTY: A Y-coordinate on the screen (root console).
-* Returns: Integer. 
+* Returns: Integer.
 * Description: Given the screen Y-coordinate ROOTY, return the Y-coordinate
 of the same screen point relative to the top left corner of the window WIN.
 * Examples:
   (- rooty (window-tly win)))`<
 
 (defun winx->rootx (win winx)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}.
 - WINX: An X-coordinate relative to the top left corner of WIN.
 * Returns: Integer.
   (+ winx (window-tlx win)))
 
 (defun winy->rooty (win winy)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}.
 - WINY: A Y-coordinate relative to the top left corner of WIN.
 * Returns: Integer.
   (translate-negative-coordinates rootx rooty)
   (if (window-touches-spot? win rootx rooty)
       (console-blit (window-console win)
-		    (rootx->winx win rootx)
-		    (rooty->winy win rooty)
-		    1 1 *root* rootx rooty
-		    (window-transparency->fade win)
+                    (rootx->winx win rootx)
+                    (rooty->winy win rooty)
+                    1 1 *root* rootx rooty
+                    (window-transparency->fade win)
                     (window-transparency->fade win))))
 
 
   (translate-negative-coordinates rootx1 rooty1)
   (translate-negative-coordinates rootx2 rooty2)
   (let* ((tlx (max (window-tlx win1) rootx1))
-	 (tly (max (window-tly win1) rooty1))
-	 (brx (min (window-brx win1) rootx2))
-	 (bry (min (window-bry win1) rooty2)))
+         (tly (max (window-tly win1) rooty1))
+         (brx (min (window-brx win1) rootx2))
+         (bry (min (window-bry win1) rooty2)))
     (console-fill-char *root*
                        #\space
                        tlx tly
                        (- brx (1- tlx)) (- bry (1- tly)))
     (console-blit (window-console win1)
-		  (rootx->winx win1 tlx)
-		  (rooty->winy win1 tly)
-		  (- brx (1- tlx)) (- bry (1- tly))
-		  *root* tlx tly
+                  (rootx->winx win1 tlx)
+                  (rooty->winy win1 tly)
+                  (- brx (1- tlx)) (- bry (1- tly))
+                  *root* tlx tly
                   (or fade (window-transparency->fade win1))
                   (or fade (window-transparency->fade win1))
                   )))
 (defmethod redraw-window-intersection ((win1 <Window>) (win2 <Window>)
                                        &key fade)
   (redraw-window-in-area win1 (window-tlx win2) (window-tly win2)
-			 (window-brx win2) (window-bry win2)
+                         (window-brx win2) (window-bry win2)
                          :fade fade))
 
 
       (t
        (transparency->fade
         (window-transparency-unfocussed win))))))
-     
-    
-     
+
+
+
 (defun redraw-window-area (win &key (draw-window t))
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 - DRAW-WINDOW: Boolean (default: T)
 * Returns: None.
 If DRAW-WINDOW is non-nil, also redraw WIN itself; otherwise just redraw
 all the other windows underlying WIN."
   (unless draw-window
-    (console-set-background-colour *root* (colour :true-black))  ; needed?
+    (console-set-default-background *root* (colour :true-black))  ; needed?
     (console-rect *root* (window-tlx win) (window-tly win)
-		  (window-width win) (window-height win) t :set))
+                  (window-width win) (window-height win) t :set))
   (when (and draw-window (window-children win)) ;
     (dolist (child (window-children win))
       (unless (window-hidden? child)
-	(redraw-window-area child)) :draw-window t))
+        (redraw-window-area child)) :draw-window t))
   (dolist (w (nreverse (windows-overlapping win :include-window? draw-window)))
     (redraw-window-intersection w win
                                 :fade (fade-for-window w)))
 
 
 (defun redraw-all-at (rootx rooty)
-  "* Arguments: 
+  "* Arguments:
 - ROOTX, ROOTY: Coordinates of a point on the screen (root console).
 * Returns: None.
 * Description: Force all windows which touch the screen at ROOTX, ROOTY
 
 
 (defmethod send-to-window ((win <Window>) (data (eql :left-drag))
-			   rodent winx winy)
+                           rodent winx winy)
   (let ((topwin nil))
     ;; draw everything but the window
     (raise-window win)
       (while (mouse-lbutton (setf rodent (mouse-get-status))))
       (setf topwin (top-window-at (mouse-cx rodent) (mouse-cy rodent)))
       (when topwin
-	(raise-window topwin :redraw t))
+        (raise-window topwin :redraw t))
       (console-flush))
     ;; Stopped dragging.
     (when topwin
       (mouse-drag win topwin
-		  winx winy
-		  (rootx->winx topwin (mouse-cx rodent))
-		  (rooty->winy topwin (mouse-cy rodent))))))
+                  winx winy
+                  (rootx->winx topwin (mouse-cx rodent))
+                  (rooty->winy topwin (mouse-cy rodent))))))
 
 
 
   ))
 
 (defun modal? (win)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 * Returns: Boolean.
 * Description: Returns T if WIN inherits from
   (declare (ignore winx winy))
   (when (key-pressed k)
       (case (key-vk k)
-	(:escape
-	 (hide-window win)
-	 k)
-	(otherwise
-	 (call-next-method)))))
+        (:escape
+         (hide-window win)
+         k)
+        (otherwise
+         (call-next-method)))))
 
 
 
   (when (window-prompt win)
     (draw-string-at win (window-prompt win) 1 1))
   (draw-string-at win
-	       (concatenate 'string
-			    "{fg:dark-grey,bg:grey,click:yes}[Yes]{/}   "
-			    "{fg:dark-grey,bg:grey,click:no}[No]{/}")
-	       1 2))
+               (concatenate 'string
+                            "{fg:dark-grey,bg:grey,click:yes}[Yes]{/}   "
+                            "{fg:dark-grey,bg:grey,click:no}[No]{/}")
+               1 2))
 
 
 (defmethod send-to-window :around ((win <Yes/No-Window>) (data (eql :dialog))
-				   str winx winy)
+                                   str winx winy)
   (declare (ignore winx winy))
   (cond
     ((and (string= str "yes")
-	  (window-choice-function win))
+          (window-choice-function win))
      (hide-window win)
      (funcall (window-choice-function win) t))
     ((and (string= str "no")
-	  (window-choice-function win))
+          (window-choice-function win))
      (hide-window win)
      (funcall (window-choice-function win) nil))
     (t
   (when (key-pressed k)
     (cond
       ((and (eql :char (key-vk k))
-	    (member (key-c k) '(#\Y #\y))
-	    (window-choice-function win))
+            (member (key-c k) '(#\Y #\y))
+            (window-choice-function win))
        (hide-window win)
        (funcall (window-choice-function win) t)
        k)
       ((and (eql :char (key-vk k))
-	    (member (key-c k) '(#\N #\n))
-	    (window-choice-function win))
+            (member (key-c k) '(#\N #\n))
+            (window-choice-function win))
        (hide-window win)
        (funcall (window-choice-function win) nil)
        k)
       (t
        (call-next-method)))))
 
-     
+
 ;;;===========================================================================
 ;;; (@> "Ghost-Window")
 ;;;===========================================================================
 
 
 (defun ghost-window? (win)
-  "* Arguments: 
+  "* Arguments:
 - WIN: an instance of {defclass dormouse:<Window>}
 * Returns: Boolean.
 * Description: Returns T if WIN inherits from
 
 
 (defmethod window-items-lines ((win <List-Window>))
-  (apply #'+ 
-	 (mapcar #'(lambda (item) (window-item-lines win item))
-		 (window-items win))))
-
-
-  
+  (apply #'+
+         (mapcar #'(lambda (item) (window-item-lines win item))
+                 (window-items win))))
+
+
+
 (defmethod add-item ((win <List-Window>) item str &optional hotkey)
   (push-end (make-list-item :str str :item item :hotkey hotkey)
-	    (window-items win)))
+            (window-items win)))
 
 
 (defmethod clear-items ((win <List-Window>))
 
 (defmethod window-item-at ((win <List-Window>) winx winy)
   (let ((offset (+ (window-offset win) (1- winy))))
-    (cond 
+    (cond
       ((on-border? win winx winy)
        nil)
       ((> offset (window-items-lines win))
 
 (defmethod prepare-window :after ((win <List-Window>))
   (let* ((pagelen (window-page-length win))
-	 (offset 0))
+         (offset 0))
     ;; Configure window
     (if (>= pagelen (window-items-lines win))
-	(setf (window-offset win) 0))
+        (setf (window-offset win) 0))
     (constrain! (window-cursor win) 0 (window-items-lines win))
     (if (< (window-cursor win) (window-offset win))
-	(setf (window-offset win) (window-cursor win)))
+        (setf (window-offset win) (window-cursor win)))
     (if (>= (window-cursor win) (+ (window-offset win) pagelen))
-	(setf (window-offset win) (- (window-cursor win) (1- pagelen))))
+        (setf (window-offset win) (- (window-cursor win) (1- pagelen))))
     (setf offset (window-offset win))
     ;; Draw window
     (loop for i from offset to (+ offset (1- pagelen))
        when (and (<= 0 i (1- (length (window-items win))))
-		 (nth i (window-items win)))
+                 (nth i (window-items win)))
        do (draw-item-at win (nth i (window-items win))
-			1 (1+ (- i offset))
-			(= i (window-cursor win))))))
+                        1 (1+ (- i offset))
+                        (= i (window-cursor win))))))
 
 
 
 (defmethod draw-item-at ((win <List-Window>) (item list-item) winx winy cursor?)
   (let ((pagewidth (- (window-width win) 2)))
     (draw-string-at win
-		    (format nil "~vA"
-			    pagewidth
-			    (left-trim-coloured-string
-			     (format nil "~A" (list-item-str item))
-			     pagewidth))
-		    winx winy
-		    :bg (if cursor?
-			    (invert-colour
-			     (console-get-back
-			      (window-console win) 0 0))
-			    nil))))
-				
+                    (format nil "~vA"
+                            pagewidth
+                            (left-trim-coloured-string
+                             (format nil "~A" (list-item-str item))
+                             pagewidth))
+                    winx winy
+                    :bg (if cursor?
+                            (invert-colour
+                             (console-get-char-background
+                              (window-console win) 0 0))
+                            nil))))
+
 
 
 (defmethod send-to-window ((win <List-Window>) data parm winx winy)
   (declare (ignore parm))
   (cond
     ((and (on-lower-window-border? win winx winy)
-	  (member data (list :left :right)))
+          (member data (list :left :right)))
      (send-key-to-window win (make-key :vk
-				       (case data
-					 (:left :pagedown)
-					 (:right :pageup)))
-			 winx winy))
+                                       (case data
+                                         (:left :pagedown)
+                                         (:right :pageup)))
+                         winx winy))
     ((and (not (on-border? win winx winy))
-	  (eql data :wheel-up))
+          (eql data :wheel-up))
      (send-key-to-window win (make-key :vk :up) winx winy))
     ((and (not (on-border? win winx winy))
-	  (eql data :wheel-down))
+          (eql data :wheel-down))
      (send-key-to-window win (make-key :vk :down) winx winy))
     ((and (eql data :left)
-	  (not (on-border? win winx winy)))
+          (not (on-border? win winx winy)))
      (let ((newc (- (1- winy) (window-offset win))))
        (if (<= newc (window-items-lines win))
-	   (move-cursor-to win newc)))
+           (move-cursor-to win newc)))
      (prepare-window win)
      (redraw-window-area win))
     (t
 
 
 (defmethod send-to-window ((win <List-Window>) (data (eql :hover))
-			   (parm (eql :unspecified)) winx winy)
+                           (parm (eql :unspecified)) winx winy)
   (send-to-window win :hover (window-item-at win winx winy)
-		  ;;(window-item-at-cursor win)
-		  winx winy))
+                  ;;(window-item-at-cursor win)
+                  winx winy))
 
 
 
 (defmethod move-cursor-to ((win <List-Window>) (cursor integer))
   (let ((oldcursor (window-cursor win)))
     (setf (window-cursor win)
-	  (constrain cursor 0 (max 0 (1- (length (window-items win))))))
+          (constrain cursor 0 (max 0 (1- (length (window-items win))))))
     (when (and (/= oldcursor (window-cursor win))
                (window-item-at-cursor win))
       (cursor-moved-to-item win (window-item-at-cursor win)))))
 (defmethod move-cursor-by ((win <List-Window>) (increment integer))
   (move-cursor-to win (+ (window-cursor win) increment)))
 
-  
+
 
 
 
 (defmethod send-key-to-window :around ((win <List-Window>) (k key) winx winy)
   (when (key-pressed k)
     (let ((pagelen (- (window-height win) 2))
-	  (num-items (length (window-items win))))
+          (num-items (length (window-items win))))
       (case (key-vk k)
-	(:up
-	 (move-cursor-by win -1)  ;;(decf (window-cursor win))
-	 (if (< (window-cursor win) (window-offset win))
-	     (decf (window-offset win))))
-	(:down
-	 (move-cursor-by win 1)  ;;(incf (window-cursor win))
-	 (if (>= (window-cursor win) (+ (window-offset win) pagelen))
-	     (incf (window-offset win))))
-	(:pageup
-	 (decf (window-offset win) pagelen)
-	 (move-cursor-by win (- pagelen)))  ;;(decf (window-cursor win) pagelen))
-	(:pagedown
-	 (incf (window-offset win) pagelen)
-	 (move-cursor-by win pagelen))  ;;(incf (window-cursor win) pagelen))
-	(:home
-	 (setf (window-offset win) 0)
-	 (move-cursor-to win 0))  ;;(setf (window-cursor win) 0))
-	(:end
-	 (setf (window-offset win) (- num-items pagelen))
-	 (move-cursor-to-end win)) ;; (setf (window-cursor win) (1- num-items)))
-	(:enter
-	 (send-to-window win :select
-			 (list-item-item (window-item-at-cursor win))
-			 winx winy))
-	(otherwise
+        (:up
+         (move-cursor-by win -1)  ;;(decf (window-cursor win))
+         (if (< (window-cursor win) (window-offset win))
+             (decf (window-offset win))))
+        (:down
+         (move-cursor-by win 1)  ;;(incf (window-cursor win))
+         (if (>= (window-cursor win) (+ (window-offset win) pagelen))
+             (incf (window-offset win))))
+        (:pageup
+         (decf (window-offset win) pagelen)
+         (move-cursor-by win (- pagelen)))  ;;(decf (window-cursor win) pagelen))
+        (:pagedown
+         (incf (window-offset win) pagelen)
+         (move-cursor-by win pagelen))  ;;(incf (window-cursor win) pagelen))
+        (:home
+         (setf (window-offset win) 0)
+         (move-cursor-to win 0))  ;;(setf (window-cursor win) 0))
+        (:end
+         (setf (window-offset win) (- num-items pagelen))
+         (move-cursor-to-end win)) ;; (setf (window-cursor win) (1- num-items)))
+        (:enter
+         (send-to-window win :select
+                         (list-item-item (window-item-at-cursor win))
+                         winx winy))
+        (otherwise
          (let ((matching (find-if #'(lambda (item)
                                       (and (key-p (list-item-hotkey item))
                                            (same-keys? (list-item-hotkey item) k)))
                                   (window-items win))))
-           (cond 
+           (cond
              (matching
               (move-cursor-to win (position matching (window-items win))))
              (t
               (return-from send-key-to-window (call-next-method)))))))
       ;;(constrain! (window-cursor win) 0 (max 0 (1- num-items)))
       (constrain! (window-offset win)
-		  (1+ (- (window-cursor win) pagelen))
-		  (window-cursor win))
+                  (1+ (- (window-cursor win) pagelen))
+                  (window-cursor win))
       (constrain! (window-offset win) 0 (max 0 (- num-items pagelen)))
       (prepare-window win)
       (redraw-window-area win)
 
 (defmethod move-cursor-to-end ((win <List-Window>))
   (let ((num-items (length (window-items win)))
-	(pagelen (- (window-height win) 2)))
+        (pagelen (- (window-height win) 2)))
     (setf (window-offset win) (- num-items pagelen))
     (move-cursor-to win (1- num-items))
     ;;(constrain! (window-cursor win) 0 (max 0 (1- num-items)))
     (constrain! (window-offset win)
-		(1+ (- (window-cursor win) pagelen))
-		(window-cursor win))
+                (1+ (- (window-cursor win) pagelen))
+                (window-cursor win))
     (constrain! (window-offset win) 0 (max 0 (- num-items pagelen)))))
 
 
   (let ((item (make-list-item :str str :item itemdata :hotkey k)))
     (push-end item (window-all-items win))
     (if (item-matches-filter-string? win item)
-	(call-next-method))))
+        (call-next-method))))
 
 
 
 (defmethod item-matches-filter-string? ((win <Filtered-Window>) item)
   (or (null (filter-string win))
       (search (string-upcase (filter-string win))
-	      (string-upcase (list-item-str item)))))
+              (string-upcase (list-item-str item)))))
 
 
 
 
 (defmethod prepare-window :after ((win <Filtered-Window>))
   (draw-string-at win
-		  ;; Uppercase version of filter-string, padded by *
-		  (format nil "~A~:@([~V,,,'*A]~)~A"
-			  (if (filter-string win) "{fg:dark-grey,bg:white}" "")
-			  (- (window-width win) 4)
-			  (or (filter-string win) "")
-			  (if (filter-string win)
-			      "{/} " ""))
-		  1 (1- (window-height win))))
+                  ;; Uppercase version of filter-string, padded by *
+                  (format nil "~A~:@([~V,,,'*A]~)~A"
+                          (if (filter-string win) "{fg:dark-grey,bg:white}" "")
+                          (- (window-width win) 4)
+                          (or (filter-string win) "")
+                          (if (filter-string win)
+                              "{/} " ""))
+                  1 (1- (window-height win))))
 
 
 
 
 (defmethod send-key-to-window :after ((win <Filtered-Window>) (k key)
-				      winx winy)
+                                      winx winy)
   (declare (ignore winy winx))
   (let ((added? nil))
     (when (key-pressed k)
       (cond
-	((and (eql (key-vk k) :char)
-	      (graphic-char-p (key-c k)))
-	 ;; add char to filter-string
-	 (setf (filter-string win)
-	       (concatenate 'string (filter-string win) (list (key-c k))))
-	 (setf added? t))
-	((eql (key-vk k) :backspace)
-	 ;; remove one char from end of filter-string
-	 (if (> (length (filter-string win)) 0)
-	     (setf (filter-string win)
+        ((and (eql (key-vk k) :char)
+              (graphic-char-p (key-c k)))
+         ;; add char to filter-string
+         (setf (filter-string win)
+               (concatenate 'string (filter-string win) (list (key-c k))))
+         (setf added? t))
+        ((eql (key-vk k) :backspace)
+         ;; remove one char from end of filter-string
+         (if (> (length (filter-string win)) 0)
+             (setf (filter-string win)
                    ;;; STRLEFT
                    (subseq (filter-string win) 0
                            (min (length (filter-string win))
                                 (1- (length (filter-string win))))))))
-	((eql (key-vk k) :delete)
-	 ;; clear filter-string
-	 (setf (filter-string win) nil))
-	(t
-	 (return-from send-key-to-window nil)))
+        ((eql (key-vk k) :delete)
+         ;; clear filter-string
+         (setf (filter-string win) nil))
+        (t
+         (return-from send-key-to-window nil)))
       ;; Still here means we changed filter-string.
       ;; Therefore need to recalculate lines.
       (cond
-	((and (filter-string win)
-	      (string> (filter-string win) ""))
-	 (setf (window-items win)
-	       (iterate
+        ((and (filter-string win)
+              (string> (filter-string win) ""))
+         (setf (window-items win)
+               (iterate
                  (for item in (if added?
                                   (window-items win)
                                   (window-all-items win)))
                      (collect item)
                      ;; else
                      nil))))
-	(t
-	 (setf (window-items win) (copy-list (window-all-items win)))))
+        (t
+         (setf (window-items win) (copy-list (window-all-items win)))))
       (move-cursor-to win 0)
       (setf (window-changed? win) t))))
 
 
 
 (defmethod send-to-window :before ((win <Menu-Window>) (data (eql :hover))
-				   parm winx winy)
+                                   parm winx winy)
   (declare (ignore parm))
   (unless (on-border? win winx winy)
     (move-cursor-to win (+ (window-offset win) (1- winy)))
 
 
 (defmethod send-to-window ((win <Menu-Window>) (data (eql :left))
-			   parm winx winy)
+                           parm winx winy)
   (declare (ignore parm))
   (unless (on-border? win winx winy)
     (move-cursor-to win (+ (window-offset win) (1- winy)))
     (when (list-item-p (window-item-at-cursor win))
       ;; (warn "Menu - selected item ~S"
-      ;; 	    (list-item-item
-      ;; 	     (window-item-at-cursor win)))
+      ;;            (list-item-item
+      ;;             (window-item-at-cursor win)))
       (hide-window win)
       (send-to-window win :select (list-item-item
-				   (window-item-at-cursor win))
-		      winx winy))))
-		    
+                                   (window-item-at-cursor win))
+                      winx winy))))
+
 
 (defmethod send-key-to-window :after ((win <Menu-Window>) (k key) winx winy)
   (when (and (key-pressed k)
-	     (window-item-at-cursor win)
-	     (same-keys? k (list-item-hotkey (window-item-at-cursor win))))
+             (window-item-at-cursor win)
+             (list-item-hotkey (window-item-at-cursor win))
+             (same-keys? k (list-item-hotkey (window-item-at-cursor win))))
     (hide-window win)
     (send-to-window win :select
-		    (list-item-item (window-item-at-cursor win))
-		    winx winy)))
+                    (list-item-item (window-item-at-cursor win))
+                    winx winy)))
 
 
 
 
 (defmethod send-to-window ((win <Menu-Window>) (data (eql :right))
-			   parm winx winy)
+                           parm winx winy)
   (declare (ignore winx winy data parm))
   (hide-window win))
 
 
 
 (defmethod initialize-instance :after ((win <Window-With-Context-Menu>)
-				       &key
-				       (context-menu-initargs
-					'(:tlx 0 :tly 0 :width 15 :height 8
-					  :title "Context"
-					  :foreground :light-blue
-					  :background :dark-grey))
-				       &allow-other-keys)
+                                       &key
+                                       (context-menu-initargs
+                                        '(:tlx 0 :tly 0 :width 15 :height 8
+                                          :title "Context"
+                                          :foreground :light-blue
+                                          :background :dark-grey))
+                                       &allow-other-keys)
   (setf (context-menu win)
-	(apply #'make-instance (context-menu-class win)
-	       :hidden? t context-menu-initargs))
+        (apply #'make-instance (context-menu-class win)
+               :hidden? t context-menu-initargs))
   (push (context-menu win) (window-children win)))
 
 
 
 
 (defmethod raise-window :before ((win <Window-With-Context-Menu>)
-				 &key redraw &allow-other-keys)
+                                 &key redraw &allow-other-keys)
   (declare (ignore redraw))
   (unless (window-hidden? (context-menu win))
     (hide-window (context-menu win))))
 
 
 (defmethod hide-window :before ((win <Window-With-Context-Menu>)
-				 &key redraw &allow-other-keys)
+                                 &key redraw &allow-other-keys)
   (declare (ignore redraw))
   (unless (window-hidden? (context-menu win))
     (hide-window (context-menu win))))
-  
+
 
 
 (defmethod send-to-window :before ((win <Window-With-Context-Menu>)
-				   (data (eql :right))
-				   parm winx winy)
+                                   (data (eql :right))
+                                   parm winx winy)
   (declare (ignore parm))
   (setf (context-item (context-menu win))
-	(get-context-at win winx winy)))
+        (get-context-at win winx winy)))
 
 
 
 (defmethod send-to-window :after ((win <Window-With-Context-Menu>)
-				  (data (eql :right))
-				   parm winx winy)
+                                  (data (eql :right))
+                                   parm winx winy)
   (declare (ignore winx winy parm))
   (cond
     ((window-hidden? (context-menu win))
 
 (defmethod prepare-window :around ((win <Context-Menu>))
   (let ((cursor (window-cursor win))
-	(items (get-menu-items-for-context (window-parent win)
-					   (context-item win))))
+        (items (get-menu-items-for-context (window-parent win)
+                                           (context-item win))))
     (clear-items win)
-    (cond 
+    (cond
       ((null items)
        (resize-window win (window-width win) 3)
        (add-item win nil "(nothing)"))
       (t
        (resize-window win (window-width win) (min (- (screen-height) 2)
-						  (+ (length items) 2)))
+                                                  (+ (length items) 2)))
        (loop for item-desc-binding in items do
-	    (destructuring-bind (item desc &optional binding) item-desc-binding
-	      (add-item win item
-			(format nil "~20A{yellow}~A{/}"
-				desc
-				(if binding
-				    (key->string (binding->key binding))
+            (destructuring-bind (item desc &optional binding) item-desc-binding
+              (add-item win item
+                        (format nil "~20A{yellow}~A{/}"
+                                desc
+                                (if binding
+                                    (key->string (binding->key binding))
                                     ""))
-			(if binding (binding->key binding)))))))
+                        (if binding (binding->key binding)))))))
     (move-cursor-to win (min (length items) cursor))
     (call-next-method)))
 
 
 
 (defmethod send-to-window :after ((win <Context-Menu>)
-				  (data (eql :select))
-				  parm winx winy)
+                                  (data (eql :select))
+                                  parm winx winy)
   (declare (ignore winx winy))
   (command-from-context-menu (window-parent win) parm (context-item win)))
 
 
 (defmethod get-menu-items-for-context ((win <Window-With-Context-Menu>)
-				       context-item)
+                                       context-item)
   (declare (ignore context-item))
   nil)
 
 (defmethod command-from-context-menu ((win <Window-With-Context-Menu>)
-				      command context-item)
+                                      command context-item)
   (declare (ignore command context-item))
   nil)
 
 (defun wrap-coloured-text (text &key width)
   "TODO document"
   (word-wrap text :width width :respect-newlines t
-	     :respect-hyphens t
-	     :exclude-start-char #\{
-	     :exclude-end-char #\}))
+             :respect-hyphens t
+             :exclude-start-char #\{
+             :exclude-end-char #\}))
 
 
 (defmethod wrap-items ((win <Log-Window>))
   (let* ((pagewidth (- (window-width win) 2))
-	 (wrapped (apply #'append
-			 (mapcar #'(lambda (msg)
-				     (wrap-coloured-text msg :width pagewidth))
-				 (window-raw-messages win)))))
+         (wrapped (apply #'append
+                         (mapcar #'(lambda (msg)
+                                     (wrap-coloured-text msg :width pagewidth))
+                                 (window-raw-messages win)))))
     (setf (window-items win)
-	  (mapcar #'(lambda (str) (make-list-item :str str :item nil :hotkey nil))
-		  wrapped))))
+          (mapcar #'(lambda (str) (make-list-item :str str :item nil :hotkey nil))
+                  wrapped))))
 
 
 (defmethod prepare-window :before ((win <Log-Window>))
 
 
 (defmethod draw-item-at ((win <Log-Window>) (item list-item)
-			 winx winy (cursor? (eql t)))
+                         winx winy (cursor? (eql t)))
   (draw-item-at win item winx winy nil))
 
 
   (declare (ignore winx winy))
   (when (key-pressed k)
     (let ((pagelen (- (window-height win) 2))
-	  (num-items (length (window-items win))))
+          (num-items (length (window-items win))))
       (case (key-vk k)
-	(:up
-	 (decf (window-offset win)))
-	(:down
-	 (incf (window-offset win)))
-	(otherwise
-	 (return-from send-key-to-window (call-next-method))))
+        (:up
+         (decf (window-offset win)))
+        (:down
+         (incf (window-offset win)))
+        (otherwise
+         (return-from send-key-to-window (call-next-method))))
       ;; (warn "offset = ~D, cursor = ~D, num-items = ~D"
-      ;; 	    (window-offset win) (window-cursor win) num-items)
+      ;;            (window-offset win) (window-cursor win) num-items)
       (constrain! (window-offset win) 0 (max 0 (- num-items pagelen)))
       (move-cursor-to win (window-offset win))
       ;;(constrain! (window-cursor win) 0 (max 0 (1- num-items)))
       ;; (warn "Now offset = ~D, cursor = ~D, num-items = ~D"
-      ;; 	    (window-offset win) (window-cursor win) num-items)
+      ;;            (window-offset win) (window-cursor win) num-items)
       (prepare-window win)
       (redraw-window-area win))
     k))
       (push-end msg (window-raw-messages win))
       (iterate
         (while (> (length (window-raw-messages win)) (window-max-messages win)))
-	(pop (window-raw-messages win)))
+        (pop (window-raw-messages win)))
       (if (> (length msg) (- (window-width win) 2))
-	  (wrap-items win)
-	  ;; else
-	  (add-item win msg msg nil))
+          (wrap-items win)
+          ;; else
+          (add-item win msg msg nil))
       (move-cursor-to-end win))))
 
 
 
 
 ;;;     (setf (window-offset win) (- (length (window-items win))
-;;; 				 (- (window-height win) 2)))
+;;;                              (- (window-height win) 2)))
 ;;;     (setf (window-cursor win) (1- (length (window-items win))))
 ;;;     (constrain! (window-cursor win) 0 (max 0 (1- (length (window-items win)))))
 ;;;     (constrain! (window-offset win) 0 (max 0 (- (length (window-items win))
-;;; 						(- (window-height win) 2))))
+;;;                                             (- (window-height win) 2))))
 ;;;     (prepare-window win)
 ;;;     (redraw-window-area win)))
 
 ;;; (bottom-message \"Mouse position: (~D, ~D)\" *mouse-x* *mouse-y*)"
   (declare (string fmt))
   (console-rect *root* 0 (1- (console-get-height *root*))
-		(console-get-width *root*) 1 t :set)
+                (console-get-width *root*) 1 t :set)
   (console-print *root* 0 (1- (console-get-height *root*))
                  (format nil "~vA" (console-get-width *root*)
                          (apply #'format nil fmt args))))
   (declare (ignore winx winy))
   (when (key-pressed k)
     (let ((pagelen (- (window-height win) 2))
-	  (num-items (length (window-items win))))
+          (num-items (length (window-items win))))
       (cond
         ((graphic-char-p (key-c k))
          (window-insert-character win (key-c k)))
            (setf (window-input-cursor win) (length (window-input-string win)))
            (render-input-string win)))
         (t
-	 (return-from send-key-to-window (call-next-method))))
+         (return-from send-key-to-window (call-next-method))))
       (constrain! (window-offset win) 0 (max 0 (- num-items pagelen)))
       (move-cursor-to win (window-offset win))
       ;;(constrain! (window-cursor win) 0 (max 0 (1- num-items)))
       ;; (warn "Now offset = ~D, cursor = ~D, num-items = ~D"
-      ;; 	    (window-offset win) (window-cursor win) num-items)
+      ;;            (window-offset win) (window-cursor win) num-items)
       (prepare-window win)
       (redraw-window-area win))
     k))
 
 (defmethod initialize-instance :after ((win <Dialog-Window>) &key)
   (setf (dialog-console win)
-	(console-new (window-width win) (window-height win)))
-  (console-set-foreground-colour (dialog-console win)
-				 (colour +DIALOG-CONSOLE-DEFAULT-FOREGROUND+))
-  (console-set-background-colour (dialog-console win)