mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Added autocompleters to python API
This commit is contained in:
parent
98dc1ddb97
commit
cdd10d5b72
@ -28,6 +28,7 @@
|
|||||||
#include "plugins/python_api.h"
|
#include "plugins/python_api.h"
|
||||||
#include "plugins/python_plugins.h"
|
#include "plugins/python_plugins.h"
|
||||||
#include "plugins/callbacks.h"
|
#include "plugins/callbacks.h"
|
||||||
|
#include "plugins/autocompleters.h"
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
python_api_cons_alert(PyObject *self, PyObject *args)
|
python_api_cons_alert(PyObject *self, PyObject *args)
|
||||||
@ -88,6 +89,30 @@ python_api_register_timed(PyObject *self, PyObject *args)
|
|||||||
return Py_BuildValue("");
|
return Py_BuildValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
python_api_register_ac(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
const char *key = NULL;
|
||||||
|
PyObject *items = NULL;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "sO", &key, &items)) {
|
||||||
|
return Py_BuildValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_ssize_t len = PyList_Size(items);
|
||||||
|
char *c_items[len];
|
||||||
|
|
||||||
|
Py_ssize_t i = 0;
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
PyObject *item = PyList_GetItem(items, i);
|
||||||
|
char *c_item = PyString_AsString(item);
|
||||||
|
c_items[i] = c_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
autocompleters_add(key, c_items);
|
||||||
|
return Py_BuildValue("");
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
python_api_notify(PyObject *self, PyObject *args)
|
python_api_notify(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
@ -359,6 +384,7 @@ static PyMethodDef apiMethods[] = {
|
|||||||
{ "cons_show", python_api_cons_show, METH_VARARGS, "Print a line to the console." },
|
{ "cons_show", python_api_cons_show, METH_VARARGS, "Print a line to the console." },
|
||||||
{ "register_command", python_api_register_command, METH_VARARGS, "Register a command." },
|
{ "register_command", python_api_register_command, METH_VARARGS, "Register a command." },
|
||||||
{ "register_timed", python_api_register_timed, METH_VARARGS, "Register a timed function." },
|
{ "register_timed", python_api_register_timed, METH_VARARGS, "Register a timed function." },
|
||||||
|
{ "register_ac", python_api_register_ac, METH_VARARGS, "Register an autocompleter." },
|
||||||
{ "send_line", python_api_send_line, METH_VARARGS, "Send a line of input." },
|
{ "send_line", python_api_send_line, METH_VARARGS, "Send a line of input." },
|
||||||
{ "notify", python_api_notify, METH_VARARGS, "Send desktop notification." },
|
{ "notify", python_api_notify, METH_VARARGS, "Send desktop notification." },
|
||||||
{ "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." },
|
{ "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." },
|
||||||
|
Loading…
Reference in New Issue
Block a user