Index: main/output.lisp
===================================================================
--- main/output.lisp	(revision main,28)
+++ main/output.lisp	(revision main,31)
@@ -1,5 +1,6 @@
 (defpackage #:tui-output
   (:use #:cl #:cffi #:tui-cursor #:tui-window)
-  (:export #:add-string #:move-and-add-string #:add-clipped-string))
+  (:export #:background #:add-string #:move-and-add-string
+           #:add-clipped-string))
 
 (in-package #:tui-output)
@@ -13,4 +14,27 @@
   (attr chtype)
   (char wchar :count 5))
+
+
+
+(defcfun "wgetbkgrnd" :int
+  (window :pointer)
+  (wch :pointer))
+
+(defcfun "wbkgrnd" :void
+  (window :pointer)
+  (wch :pointer))
+
+;;(defgeneric background (window))
+
+(defgeneric (setf background) (pair window)
+  (:method (pair (window window))
+    (destructuring-bind (ch color) pair
+      (with-foreign-object (wch 'cchar_t)
+        (with-foreign-slots ((attr char) wch cchar_t)
+          (dotimes (i 5)
+            (setf (mem-aref char 'wchar i) 0))
+          (setf attr (cdk::color-pair color)
+                (mem-aref char 'wchar) (char-code ch)))
+        (wbkgrnd (window-pointer window) wch)))))
 
 
@@ -34,4 +58,5 @@
 
 (defun add-clipped-string (window y x s)
+  ;; TODO: double check for ob1 in OVER.
   (multiple-value-bind (maxy maxx) (size window)
     (unless (<= 0 y maxy) (return-from add-clipped-string))
@@ -103,5 +128,5 @@
           (clear-complex-char cc)
           (set-complex-char cc (aref s i))))
-      (wadd-wchnstr window a n))))
+      (wadd-wchnstr (window-pointer window) a n))))
 
 
@@ -122,10 +147,2 @@
   (bl chtype)
   (br chtype))
-
-(defcfun ("wbkgd" c-set-window-background) :int
-  (window :pointer)
-  (ch chtype))
-
-(defcfun "wbkgrnd" :int
-  (window :pointer)
-  (wch :pointer))
