diff --git a/kitty/data-types.c b/kitty/data-types.c index 247881ae0..341ff7cdd 100644 --- a/kitty/data-types.c +++ b/kitty/data-types.c @@ -7,8 +7,8 @@ #include "data-types.h" #include "modes.h" -#include "sprites.h" #include +#include #ifdef WITH_PROFILER #include #endif @@ -67,7 +67,6 @@ static PyMethodDef module_methods[] = { {"redirect_std_streams", (PyCFunction)redirect_std_streams, METH_VARARGS, ""}, {"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""}, {"change_wcwidth", (PyCFunction)change_wcwidth_wrap, METH_O, ""}, - SPRITE_FUNC_WRAPPERS #ifdef WITH_PROFILER {"start_profiler", (PyCFunction)start_profiler, METH_VARARGS, ""}, {"stop_profiler", (PyCFunction)stop_profiler, METH_NOARGS, ""}, @@ -84,7 +83,6 @@ static struct PyModuleDef module = { .m_methods = module_methods }; -#include extern bool add_module_gl_constants(PyObject*); extern int init_LineBuf(PyObject *); @@ -100,6 +98,7 @@ extern int init_Window(PyObject *); extern bool init_freetype_library(PyObject*); extern bool init_fontconfig_library(PyObject*); extern bool init_glfw(PyObject *m); +bool init_sprites(PyObject *module); #ifdef __APPLE__ extern int init_CoreText(PyObject *); extern bool init_cocoa(PyObject *module); @@ -124,6 +123,7 @@ PyInit_fast_data_types(void) { if (!init_Screen(m)) return NULL; if (!add_module_gl_constants(m)) return NULL; if (!init_glfw(m)) return NULL; + if (!init_sprites(m)) return NULL; if (!init_Window(m)) return NULL; #ifdef __APPLE__ if (!init_CoreText(m)) return NULL; diff --git a/kitty/sprites.c b/kitty/sprites.c index 462ee30eb..3a3607484 100644 --- a/kitty/sprites.c +++ b/kitty/sprites.c @@ -6,9 +6,19 @@ */ #include "data-types.h" -#include "sprites.h" #include +typedef struct SpritePosition SpritePosition; +struct SpritePosition { + SpritePosition *next; + sprite_index x, y, z; + char_type ch; + combining_type cc; + bool is_second; + bool filled; + bool rendered; +}; + typedef struct { size_t max_array_len, max_texture_size, max_y; unsigned int x, y, z, xnum, ynum; @@ -195,3 +205,23 @@ render_dirty_sprites(PyObject UNUSED *s_) { sprite_map.dirty = false; return ans; } + + +static PyMethodDef module_methods[] = { + {"sprite_map_set_limits", (PyCFunction)sprite_map_set_limits, METH_VARARGS, ""}, \ + {"sprite_map_set_layout", (PyCFunction)sprite_map_set_layout, METH_VARARGS, ""}, \ + {"sprite_map_current_layout", (PyCFunction)sprite_map_current_layout, METH_NOARGS, ""}, \ + {"sprite_map_free", (PyCFunction)sprite_map_free, METH_NOARGS, ""}, \ + {"sprite_map_increment", (PyCFunction)sprite_map_increment, METH_NOARGS, ""}, \ + {"sprite_position_for", (PyCFunction)sprite_position_for, METH_VARARGS, ""}, \ + {"render_dirty_sprites", (PyCFunction)render_dirty_sprites, METH_NOARGS, ""}, \ + + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + + +bool +init_sprites(PyObject *module) { + if (PyModule_AddFunctions(module, module_methods) != 0) return false; + return true; +} diff --git a/kitty/sprites.h b/kitty/sprites.h deleted file mode 100644 index ffae2e5a6..000000000 --- a/kitty/sprites.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2017 Kovid Goyal - * - * Distributed under terms of the GPL3 license. - */ - -#pragma once - -typedef struct SpritePosition SpritePosition; -struct SpritePosition { - SpritePosition *next; - sprite_index x, y, z; - char_type ch; - combining_type cc; - bool is_second; - bool filled; - bool rendered; -}; - - -PyObject* sprite_map_set_limits(PyObject UNUSED *self, PyObject *args); -PyObject* sprite_map_set_layout(PyObject UNUSED *s, PyObject *args); -PyObject* sprite_map_current_layout(PyObject UNUSED *s); -PyObject* sprite_map_free(); -PyObject* sprite_map_increment(); -SpritePosition* sprite_map_position_for(char_type ch, combining_type cc, bool is_second, int *error); -PyObject* sprite_position_for(PyObject UNUSED *self, PyObject *args); -bool update_cell_range_data(ScreenModes *modes, Line *line, unsigned int xstart, unsigned int xmax, unsigned int *data); -PyObject* render_dirty_sprites(PyObject UNUSED *self); - -#define SPRITE_FUNC_WRAPPERS \ - {"sprite_map_set_limits", (PyCFunction)sprite_map_set_limits, METH_VARARGS, ""}, \ - {"sprite_map_set_layout", (PyCFunction)sprite_map_set_layout, METH_VARARGS, ""}, \ - {"sprite_map_current_layout", (PyCFunction)sprite_map_current_layout, METH_NOARGS, ""}, \ - {"sprite_map_free", (PyCFunction)sprite_map_free, METH_NOARGS, ""}, \ - {"sprite_map_increment", (PyCFunction)sprite_map_increment, METH_NOARGS, ""}, \ - {"sprite_position_for", (PyCFunction)sprite_position_for, METH_VARARGS, ""}, \ - {"render_dirty_sprites", (PyCFunction)render_dirty_sprites, METH_NOARGS, ""}, \ -