mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-07 17:43:53 +02:00
API to easily render a Screen object from python
This commit is contained in:
@@ -496,6 +496,18 @@ update_window_title(Window *w) {
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
simple_render_screen(PyObject UNUSED *self, PyObject *args) {
|
||||
#define simple_render_screen_doc "Render a Screen object, with no cursor"
|
||||
Screen *screen;
|
||||
ssize_t vao_idx, gvao_idx;
|
||||
float xstart, ystart, dx, dy;
|
||||
if (!PyArg_ParseTuple(args, "O!nnffff", &Screen_Type, &screen, &vao_idx, &gvao_idx, &xstart, &ystart, &dx, &dy)) return NULL;
|
||||
static CursorRenderInfo cursor_info = {0};
|
||||
draw_cells(vao_idx, gvao_idx, xstart, ystart, dx, dy, screen, &cursor_info);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
render(double now) {
|
||||
double time_since_last_render = now - last_render_at;
|
||||
@@ -882,7 +894,19 @@ PyTypeObject ChildMonitor_Type = {
|
||||
.tp_new = new,
|
||||
};
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
METHOD(simple_render_screen, METH_VARARGS)
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
bool
|
||||
init_child_monitor(PyObject *module) {
|
||||
if (PyType_Ready(&ChildMonitor_Type) < 0) return false;
|
||||
if (PyModule_AddObject(module, "ChildMonitor", (PyObject *)&ChildMonitor_Type) != 0) return false;
|
||||
Py_INCREF(&ChildMonitor_Type);
|
||||
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
INIT_TYPE(ChildMonitor)
|
||||
// }}}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ static struct PyModuleDef module = {
|
||||
extern int init_LineBuf(PyObject *);
|
||||
extern int init_HistoryBuf(PyObject *);
|
||||
extern int init_Cursor(PyObject *);
|
||||
extern int init_ChildMonitor(PyObject *);
|
||||
extern bool init_child_monitor(PyObject *);
|
||||
extern int init_Line(PyObject *);
|
||||
extern int init_ColorProfile(PyObject *);
|
||||
extern int init_Screen(PyObject *);
|
||||
@@ -160,7 +160,7 @@ PyInit_fast_data_types(void) {
|
||||
if (!init_HistoryBuf(m)) return NULL;
|
||||
if (!init_Line(m)) return NULL;
|
||||
if (!init_Cursor(m)) return NULL;
|
||||
if (!init_ChildMonitor(m)) return NULL;
|
||||
if (!init_child_monitor(m)) return NULL;
|
||||
if (!init_ColorProfile(m)) return NULL;
|
||||
if (!init_Screen(m)) return NULL;
|
||||
if (!init_glfw(m)) return NULL;
|
||||
|
||||
Reference in New Issue
Block a user