-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot call send_message with python string #32
Comments
The third argument to send_message is expected to be a long (see here) not a char* and certainly not a Python string. This seems reasonable since Python doesn't use pointers anyway, so the sptr argument to Scintilla send_message is defined for those few places where a non-pointer argument is used. You might get the Python string converted to char* and then to long using the appropriate ctypes functions and then pass that. But note you can't pass a pointer in a long on windows 64, so its not portable anyway. |
Is it possible to add into geanypy another interface (maybe with same name?) which accepts python strings and does all casting inside C module? I'm looking for any possible solution to call |
It probably could be done |
|
Patch: diff --git a/geanypy/src/geanypy-scintilla.c b/geanypy/src/geanypy-scintilla.c
index 9b3776d..8de6a22 100644
--- a/geanypy/src/geanypy-scintilla.c
+++ b/geanypy/src/geanypy-scintilla.c
@@ -783,6 +783,26 @@ Scintilla_send_message(Scintilla *self, PyObject *args, PyObject *kwargs)
}
+static PyObject *
+Scintilla_send_text_message(Scintilla *self, PyObject *args, PyObject *kwargs)
+{
+ gint msg;
+ glong uptr = 0, ret;
+ const char *sptr = NULL;
+ static gchar *kwlist[] = { "msg", "lparam", "wparam", NULL };
+
+ SCI_RET_IF_FAIL(self);
+
+ if (PyArg_ParseTupleAndKeywords(args, kwargs, "i|lz", kwlist, &msg, &uptr, &sptr))
+ {
+ ret = scintilla_send_message(self->sci, msg, uptr, sptr);
+ return Py_BuildValue("l", ret);
+ }
+
+ Py_RETURN_NONE;
+}
+
+
static PyMethodDef Scintilla_methods[] = {
{ "delete_marker_at_line", (PyCFunction) Scintilla_delete_marker_at_line, METH_KEYWORDS,
"Deletes a line marker." },
@@ -877,6 +897,8 @@ static PyMethodDef Scintilla_methods[] = {
"Begins grouping a set of edits together as one Undo action." },
{ "send_message", (PyCFunction) Scintilla_send_message, METH_KEYWORDS,
"Send a message to the Scintilla widget." },
+ { "send_text_message", (PyCFunction) Scintilla_send_text_message, METH_KEYWORDS,
+ "Send a text message to the Scintilla widget." },
{ NULL }
};
|
For the |
I tested on this: sci.send_text_message(gsc.AUTOCSHOW, 0, None) Works well. |
Geany crashes if Python string passed to SSM. Use this function if last argument of SSM is string. Fixes codebrainz#32
I faced the scintilla_send_message() problem with peasy as well. I decided to not do anything about it for now (you'd need to provide a wrapper for every arg combination) but instead just rely on all necessary functionality being wrapped by Geany' sci_* functions which can be called (and may add value). |
I'm trying to write simple autocomplete plugin:
Problematic line:
ssm(gsc.AUTOCSHOW, len(path), "\n".join(paths))
. Geany crashes if string passed to send_message function.The text was updated successfully, but these errors were encountered: