def get_version(): """ Return string with libcaca version information. """ _lib.caca_get_version.restype = ctypes.c_char_p if _PYTHON3: return _bytes_to_str(_lib.caca_get_version()) else: return _lib.caca_get_version()
def utf32_to_utf8(ch): """ Convert a UTF-32 character to UTF-8. ch -- the character to convert """ _lib.caca_utf32_to_utf8.argtypes = [ctypes.c_char_p, ctypes.c_uint32] _lib.caca_utf32_to_utf8.restype = ctypes.c_int buf = ctypes.c_buffer(7) _lib.caca_utf32_to_utf8(buf, ch) if _PYTHON3: return _bytes_to_str(buf.raw).replace('\x00', '') else: return buf.raw.replace('\x00', '')
def get_import_list(): """ Return list of available import formats as tuple (name, description). """ tmplst = [] retlst = [] _lib.caca_get_import_list.restype = ctypes.POINTER(ctypes.c_char_p) autodetect = False for item in _lib.caca_get_import_list(): if item is not None: if item == "": if not autodetect: if _PYTHON3: tmplst.append(_bytes_to_str("\"\"")) else: tmplst.append("\"\"") autodetect = True else: #memory error occured otherwise break else: if _PYTHON3: tmplst.append(_bytes_to_str(item)) else: tmplst.append(item) else: #memory error occured otherwise break for i in range(0, len(tmplst)): if i % 2 == 0: retlst.append((tmplst[i], tmplst[i + 1])) del tmplst return retlst
def get_import_list(): """ Return list of available import formats as tuple (name, description). """ tmplst = [] retlst = [] _lib.caca_get_import_list.restype = ctypes.POINTER(ctypes.c_char_p) autodetect = False for item in _lib.caca_get_import_list(): if item is not None: if item == "": if not autodetect: if _PYTHON3: tmplst.append(_bytes_to_str("\"\"")) else: tmplst.append("\"\"") autodetect = True else: #memory error occured otherwise break else: if _PYTHON3: tmplst.append(_bytes_to_str(item)) else: tmplst.append(item) else: #memory error occured otherwise break for i in range(0, len(tmplst)): if i % 2 == 0: retlst.append((tmplst[i], tmplst[i+1])) del tmplst return retlst
def get_font_list(): """ Return a list of available fonts. """ fl = [] _lib.caca_get_font_list.restype = ctypes.POINTER(ctypes.c_char_p) for item in _lib.caca_get_font_list(): if item is not None and item != "": if _PYTHON3: fl.append(_bytes_to_str(item)) else: fl.append(item) else: #memory error occured otherwise break return fl
def get_display_driver_list(): """ Return a list of available drivers as tuple (name, description). """ tmplst = [] retlst = [] _lib.caca_get_display_driver_list.restype = ctypes.POINTER(ctypes.c_char_p) for item in _lib.caca_get_display_driver_list(): if item is not None and item != "": if _PYTHON3: tmplst.append(_bytes_to_str(item)) else: tmplst.append(item) else: #memory error occured otherwise break for i in range(0, len(tmplst)): if i % 2 == 0: retlst.append((tmplst[i], tmplst[i + 1])) del tmplst return retlst
def get_display_driver_list(): """ Return a list of available drivers as tuple (name, description). """ tmplst = [] retlst = [] _lib.caca_get_display_driver_list.restype = ctypes.POINTER(ctypes.c_char_p) for item in _lib.caca_get_display_driver_list(): if item is not None and item != "": if _PYTHON3: tmplst.append(_bytes_to_str(item)) else: tmplst.append(item) else: #memory error occured otherwise break for i in range(0, len(tmplst)): if i % 2 == 0: retlst.append((tmplst[i], tmplst[i+1])) del tmplst return retlst