summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/glibext/bufferline.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-05-11 21:33:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-05-11 21:33:36 (GMT)
commitd2861533cc53fbcc217048bafebf34b1f70ba3aa (patch)
tree28c847a8093761fcaa0916be54445328d843096d /plugins/pychrysalide/glibext/bufferline.c
parent6c9e1b5f7ee0915036d47b83f1e34b87b44b1723 (diff)
Updated the API for buffer caches.
Diffstat (limited to 'plugins/pychrysalide/glibext/bufferline.c')
-rw-r--r--plugins/pychrysalide/glibext/bufferline.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/plugins/pychrysalide/glibext/bufferline.c b/plugins/pychrysalide/glibext/bufferline.c
index 47b2bc4..af3cf1d 100644
--- a/plugins/pychrysalide/glibext/bufferline.c
+++ b/plugins/pychrysalide/glibext/bufferline.c
@@ -155,7 +155,7 @@ static PyObject *py_buffer_line_new(PyTypeObject *type, PyObject *args, PyObject
static PyObject *py_buffer_line_append_text(PyObject *self, PyObject *args)
{
PyObject *result; /* Trouvailles à retourner */
- unsigned long column; /* Indice de colonne */
+ size_t column; /* Indice de colonne */
const char *text; /* Texte à ajouter */
RenderingTagType type; /* Type de rendu attendu */
GObject *creator; /* Eventuel créateur à associer*/
@@ -177,7 +177,7 @@ static PyObject *py_buffer_line_append_text(PyObject *self, PyObject *args)
creator = NULL;
- ret = PyArg_ParseTuple(args, "ksO&|O&", &column, &text,
+ ret = PyArg_ParseTuple(args, "nsO&|O&", &column, &text,
convert_to_rendering_tag_type, &type, convert_to_gobject, &creator);
if (!ret) return NULL;
@@ -228,9 +228,17 @@ static PyObject *py_buffer_line_get_text(PyObject *self, PyObject *args)
line = G_BUFFER_LINE(pygobject_get(self));
text = g_buffer_line_get_text(line, first, end, markup);
- result = PyUnicode_FromString(text);
+ if (text != NULL)
+ {
+ result = PyUnicode_FromString(text);
+ free(text);
+ }
- free(text);
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
return result;
@@ -398,11 +406,6 @@ static bool py_buffer_line_define_constants(PyTypeObject *obj_type)
result &= PyDict_AddULongMacro(obj_type, BLC_FIRST);
result &= PyDict_AddULongMacro(obj_type, BLC_DISPLAY);
- result &= PyDict_AddULongMacro(obj_type, BLF_NONE);
- result &= PyDict_AddULongMacro(obj_type, BLF_HAS_CODE);
- result &= PyDict_AddULongMacro(obj_type, BLF_ENTRYPOINT);
- result &= PyDict_AddULongMacro(obj_type, BLF_BOOKMARK);
-
return result;
}
@@ -509,6 +512,9 @@ bool ensure_python_buffer_line_is_registered(void)
if (!define_line_segment_constants(type))
return false;
+ if (!define_buffer_line_constants(type))
+ return false;
+
if (!py_buffer_line_define_constants(type))
return false;