Example #1
0
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()
Example #2
0
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()
Example #3
0
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', '')
Example #4
0
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
Example #5
0
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', '')
Example #6
0
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
Example #7
0
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
Example #8
0
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
Example #9
0
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
Example #10
0
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