File tree Expand file tree Collapse file tree 1 file changed +20
-22
lines changed
Expand file tree Collapse file tree 1 file changed +20
-22
lines changed Original file line number Diff line number Diff line change 44See README.md for details.
55"""
66
7+ import tdl
8+
9+ """
10+ Implementation notes:
11+ [ ] tdl.init() needs a window, made 132x60
12+ [ ] Termbox.close() is not implemented, does nothing
13+
14+
15+ """
16+
717class TermboxException (Exception ):
818 def __init__ (self , msg ):
919 self .msg = msg
@@ -121,29 +131,18 @@ def __str__(self):
121131EVENT_RESIZE = 2
122132EVENT_MOUSE = 3
123133
124- cdef class Termbox :
125- cdef int created
126- cdef object _poll_lock
127-
128- def __cinit__ (self ):
129- cdef int ret
134+ class Termbox :
135+ def __init__ (self , width = 132 , height = 60 ):
130136 global __instance
131-
132- self .created = 0
133- self ._poll_lock = threading .Lock ()
134-
135137 if __instance :
136138 raise TermboxException ("It is possible to create only one instance of Termbox" )
137139
138- ret = tb_init ()
139- ret = 1
140- if ret < 0 :
141- raise TermboxException ("Failed to init Termbox" )
142- __instance = self
143- self .created = 1
140+ try :
141+ tdl .init (width , height )
142+ except tdl .TDLException as e :
143+ raise TermboxException (e )
144144
145- def __dealloc__ (self ):
146- self .close ()
145+ __instance = self
147146
148147 def __del__ (self ):
149148 self .close ()
@@ -156,10 +155,9 @@ def __enter__(self):
156155
157156 def close (self ):
158157 global __instance
159- if self .created :
160- tb_shutdown ()
161- self .created = 0
162- __instance = None
158+ # tb_shutdown()
159+ __instance = None
160+ # TBD, does nothing
163161
164162 def present (self ):
165163 """Sync state of the internal cell buffer with the terminal.
You can’t perform that action at this time.
0 commit comments