tuikit/driver/driver.py
changeset 117 8680c2333546
parent 84 04dfb5ddf031
child 118 8c7970520632
--- a/tuikit/driver/driver.py	Sun Feb 15 17:50:24 2015 +0100
+++ b/tuikit/driver/driver.py	Mon Feb 16 21:17:43 2015 +0100
@@ -27,12 +27,6 @@
         """Clean up the screen etc."""
         pass
 
-    def __enter__(self):
-        self.init()
-
-    def __exit__(self, exc_type, exc_val, exc_tb):
-        self.close()
-
     ## drawing ##
 
     def erase(self):
@@ -56,14 +50,6 @@
         """Set attribute to be used for subsequent draw operations."""
         pass
 
-    def _parse_attr_desc(self, attr_desc):
-        parts = attr_desc.split(',')
-        fgbg = parts[0].split(' on ', 1)
-        fg = fgbg[0].strip().lower()
-        bg = fgbg[1:] and fgbg[1].strip().lower() or 'default'
-        attrs = (part.strip().lower() for part in parts[1:])
-        return fg, bg, attrs
-
     ## cursor ##
 
     def showcursor(self, x, y):
@@ -84,3 +70,22 @@
 
         """
         return []
+
+    ## convenience implementations ##
+
+    def _parse_attr_desc(self, attr_desc):
+        """Convenience implementation of attribute parsing. Not part of API."""
+        parts = attr_desc.split(',')
+        fgbg = parts[0].split(' on ', 1)
+        fg = fgbg[0].strip().lower()
+        bg = fgbg[1:] and fgbg[1].strip().lower() or 'default'
+        attrs = (part.strip().lower() for part in parts[1:])
+        return fg, bg, attrs
+
+    ## with statement support ##
+
+    def __enter__(self):
+        self.init()
+
+    def __exit__(self, exc_type, exc_val, exc_tb):
+        self.close()