Make the terminfo database available in the compiled module
This commit is contained in:
parent
d9f33b19bc
commit
ad64472950
3 changed files with 19 additions and 1 deletions
|
|
@ -27,6 +27,7 @@ def compile_terminfo(base):
|
||||||
os.makedirs(odir, exist_ok=True)
|
os.makedirs(odir, exist_ok=True)
|
||||||
ofile = os.path.join(odir, xterm_kitty)
|
ofile = os.path.join(odir, xterm_kitty)
|
||||||
shutil.move(tfile, ofile)
|
shutil.move(tfile, ofile)
|
||||||
|
return ofile
|
||||||
|
|
||||||
|
|
||||||
def generate_terminfo():
|
def generate_terminfo():
|
||||||
|
|
@ -46,7 +47,14 @@ def generate_terminfo():
|
||||||
with open('terminfo/kitty.termcap', 'w') as f:
|
with open('terminfo/kitty.termcap', 'w') as f:
|
||||||
f.write(tcap)
|
f.write(tcap)
|
||||||
|
|
||||||
compile_terminfo(os.path.join(base, 'terminfo'))
|
dbfile = compile_terminfo(os.path.join(base, 'terminfo'))
|
||||||
|
with open(dbfile, 'rb') as f:
|
||||||
|
data = f.read()
|
||||||
|
with open('kitty/terminfo.h', 'w') as f:
|
||||||
|
print(f'static const uint8_t terminfo_data[{len(data)}] = ''{', file=f)
|
||||||
|
for b in data:
|
||||||
|
print(b, end=', ', file=f)
|
||||||
|
print('};', file=f)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -404,6 +404,13 @@ find_in_memoryview(PyObject *self UNUSED, PyObject *args) {
|
||||||
return PyLong_FromSsize_t(ans);
|
return PyLong_FromSsize_t(ans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "terminfo.h"
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
py_terminfo_data(PyObject *self UNUSED, PyObject *args UNUSED) {
|
||||||
|
return PyBytes_FromStringAndSize((const char*)terminfo_data, arraysz(terminfo_data));
|
||||||
|
}
|
||||||
|
|
||||||
static PyMethodDef module_methods[] = {
|
static PyMethodDef module_methods[] = {
|
||||||
METHODB(replace_c0_codes_except_nl_space_tab, METH_O),
|
METHODB(replace_c0_codes_except_nl_space_tab, METH_O),
|
||||||
{"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""},
|
{"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""},
|
||||||
|
|
@ -425,6 +432,7 @@ static PyMethodDef module_methods[] = {
|
||||||
{"shm_open", (PyCFunction)py_shm_open, METH_VARARGS, ""},
|
{"shm_open", (PyCFunction)py_shm_open, METH_VARARGS, ""},
|
||||||
{"shm_unlink", (PyCFunction)py_shm_unlink, METH_VARARGS, ""},
|
{"shm_unlink", (PyCFunction)py_shm_unlink, METH_VARARGS, ""},
|
||||||
{"wrapped_kitten_names", (PyCFunction)wrapped_kittens, METH_NOARGS, ""},
|
{"wrapped_kitten_names", (PyCFunction)wrapped_kittens, METH_NOARGS, ""},
|
||||||
|
{"terminfo_data", (PyCFunction)py_terminfo_data, METH_NOARGS, ""},
|
||||||
{"find_in_memoryview", (PyCFunction)find_in_memoryview, METH_VARARGS, ""},
|
{"find_in_memoryview", (PyCFunction)find_in_memoryview, METH_VARARGS, ""},
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
METHODB(user_cache_dir, METH_NOARGS),
|
METHODB(user_cache_dir, METH_NOARGS),
|
||||||
|
|
|
||||||
2
kitty/terminfo.h
Normal file
2
kitty/terminfo.h
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue