瀏覽代碼

* Fix get_key_utf8 method, return python string with utf8 char now.

tags/v0.99.beta18
Alex Foulon alxf 13 年之前
父節點
當前提交
c5e2f0eb7d
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. +10
    -2
      python/caca/display.py

+ 10
- 2
python/caca/display.py 查看文件

@@ -219,7 +219,8 @@ class Event(ctypes.Structure):
raise DisplayError, "Not implemented"

def get_key_utf8(self):
""" Return a key press or key release event's UTF-8 value.
""" Return a key press or key release event's UTF-8 value
as python string.
"""
# set buffer for writing utf8 value
buf = ctypes.c_buffer(7)
@@ -229,7 +230,14 @@ class Event(ctypes.Structure):

_lib.caca_get_event_key_utf8(self, buf)

return buf
raw = []
for item in list(buf.raw):
if item == '\x00':
break
else:
raw.append(item)

return "".join(raw)

def get_mouse_button(self):
""" Return a mouse press or mouse release event's button.


Loading…
取消
儲存