tuikit/driver/curses.py
changeset 95 05392e369ede
parent 91 de80e140b0ec
child 97 0c2e0c09ba5c
--- a/tuikit/driver/curses.py	Fri Mar 28 10:44:29 2014 +0100
+++ b/tuikit/driver/curses.py	Fri Mar 28 14:58:12 2014 +0100
@@ -79,7 +79,7 @@
 
     def __init__(self):
         Driver.__init__(self)
-        self.log = logging.getLogger('tuikit')
+        self._log = logging.getLogger('tuikit')
         self.stdscr = None
         self.cursor = None
         self.colors = {}     # maps names to curses attributes
@@ -119,21 +119,23 @@
     def clear(self):
         self.stdscr.erase()
 
-    def putch(self, x, y, ch):
+    def putch(self, ch, x, y):
         try:
-            if isinstance(ch, str) and len(ch) == 1:
+            if isinstance(ch, int):
+                self.stdscr.addch(y, x, ch)
+            elif isinstance(ch, str) and len(ch) == 1:
                 self.stdscr.addstr(y, x, ch)
             else:
-                self.stdscr.addch(y, x, ch)
-        except curses.error:
-            pass
+                raise TypeError('Integer or one-char string is required.')
+        except curses.error as e:
+            self._log.exception('putch(%r, %s, %s) error:' % (ch, x, y))
 
     def draw(self, buffer, x=0, y=0):
         for bufy in range(buffer.size.h):
             for bufx in range(buffer.size.w):
                 char, attr_desc = buffer.get(bufx, bufy)
                 self.setattr(attr_desc)
-                self.putch(x + bufx, y + bufy, char)
+                self.putch(char, x + bufx, y + bufy)
 
     def flush(self):
         if self.cursor: