77import tdl
88
99"""
10- Implementation notes :
10+ Implementation status :
1111 [ ] tdl.init() needs a window, made 132x60
1212 [ ] Termbox.close() is not implemented, does nothing
1313 [ ] poll_event needs review, because it does not
1414 completely follows the original logic
15-
15+ [ ] peek is stubbed, but not implemented
16+ [ ] not all keys/events are mapped
1617"""
1718
1819class TermboxException (Exception ):
@@ -38,14 +39,10 @@ def __str__(self):
3839KEY_F12 = (0xFFFF - 11 )
3940KEY_INSERT = (0xFFFF - 12 )
4041KEY_DELETE = (0xFFFF - 13 )
41- KEY_HOME = (0xFFFF - 14 )
42- KEY_END = (0xFFFF - 15 )
42+
4343KEY_PGUP = (0xFFFF - 16 )
4444KEY_PGDN = (0xFFFF - 17 )
45- KEY_ARROW_UP = (0xFFFF - 18 )
46- KEY_ARROW_DOWN = (0xFFFF - 19 )
47- KEY_ARROW_LEFT = (0xFFFF - 20 )
48- KEY_ARROW_RIGHT = (0xFFFF - 21 )
45+
4946KEY_MOUSE_LEFT = (0xFFFF - 22 )
5047KEY_MOUSE_RIGHT = (0xFFFF - 23 )
5148KEY_MOUSE_MIDDLE = (0xFFFF - 24 )
@@ -84,7 +81,19 @@ def __str__(self):
8481KEY_CTRL_X = 0x18
8582KEY_CTRL_Y = 0x19
8683KEY_CTRL_Z = 0x1A
87- KEY_ESC = 0x1B
84+
85+
86+ # -- mapped to tdl
87+ KEY_HOME = 'HOME'
88+ KEY_END = 'END'
89+ KEY_ARROW_UP = 'UP'
90+ KEY_ARROW_DOWN = 'DOWN'
91+ KEY_ARROW_LEFT = 'LEFT'
92+ KEY_ARROW_RIGHT = 'RIGHT'
93+ KEY_ESC = 'ESCAPE'
94+ # /--
95+
96+
8897KEY_CTRL_LSQ_BRACKET = 0x1B
8998KEY_CTRL_3 = 0x1B
9099KEY_CTRL_4 = 0x1C
@@ -103,15 +112,18 @@ def __str__(self):
103112
104113# attributes ----------------------
105114
106- DEFAULT = 0x00
107- BLACK = 0x01
108- RED = 0x02
109- GREEN = 0x03
110- YELLOW = 0x04
111- BLUE = 0x05
112- MAGENTA = 0x06
113- CYAN = 0x07
114- WHITE = 0x08
115+ #-- mapped to tdl
116+ DEFAULT = Ellipsis
117+
118+ BLACK = 0x000000
119+ RED = 0xFF0000
120+ GREEN = 0x00FF00
121+ YELLOW = 0xFFFF00
122+ BLUE = 0x0000FF
123+ MAGENTA = 0xFF00FF
124+ CYAN = 0x00FFFF
125+ WHITE = 0xFFFFFF
126+ #/--
115127
116128BOLD = 0x10
117129UNDERLINE = 0x20
@@ -128,7 +140,11 @@ def __str__(self):
128140OUTPUT_256 = 2
129141OUTPUT_216 = 3
130142OUTPUT_GRAYSCALE = 4
131- EVENT_KEY = 1
143+
144+
145+ # -- mapped to tdl
146+ EVENT_KEY = 'KEYDOWN'
147+ # /--
132148EVENT_RESIZE = 2
133149EVENT_MOUSE = 3
134150
@@ -246,7 +262,7 @@ def peek_event(self, timeout=0):
246262 else:
247263 uch = None
248264 """
249- return (e .type , uch , e .key , e .mod , e .w , e .h , e .x , e .y )
265+ pass # return (e.type, uch, e.key, e.mod, e.w, e.h, e.x, e.y)
250266
251267 def poll_event (self ):
252268 """Wait for an event and return it.
0 commit comments