about summary refs log tree commit diff stats
path: root/src/plugins/python_api.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-04-07 23:25:47 +0100
committerJames Booth <boothj5@gmail.com>2016-04-07 23:25:47 +0100
commit2f432a942d3c72f5fb3f25775b8ea52cd92b612d (patch)
treebc5d602748104b00da269a455f3887c3d6af938c /src/plugins/python_api.c
parent7ca60846573e8e407a5d2b4384edc90dac9f0857 (diff)
downloadprofani-tty-2f432a942d3c72f5fb3f25775b8ea52cd92b612d.tar.gz
Plugins: Added completer_clear
Diffstat (limited to 'src/plugins/python_api.c')
-rw-r--r--src/plugins/python_api.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c
index 90b72619..d3f684b1 100644
--- a/src/plugins/python_api.c
+++ b/src/plugins/python_api.c
@@ -241,6 +241,22 @@ python_api_completer_remove(PyObject *self, PyObject *args)
     return Py_BuildValue("");
 }
 
+static PyObject *
+python_api_completer_clear(PyObject *self, PyObject *args)
+{
+    const char *key = NULL;
+
+    if (!PyArg_ParseTuple(args, "s", &key)) {
+        return Py_BuildValue("");
+    }
+
+    allow_python_threads();
+    autocompleters_clear(key);
+    disable_python_threads();
+
+    return Py_BuildValue("");
+}
+
 static PyObject*
 python_api_notify(PyObject *self, PyObject *args)
 {
@@ -693,6 +709,7 @@ static PyMethodDef apiMethods[] = {
     { "register_timed", python_api_register_timed, METH_VARARGS, "Register a timed function." },
     { "completer_add", python_api_completer_add, METH_VARARGS, "Add items to an autocompleter." },
     { "completer_remove", python_api_completer_remove, METH_VARARGS, "Remove items from an autocompleter." },
+    { "completer_clear", python_api_completer_clear, METH_VARARGS, "Remove all items from an autocompleter." },
     { "send_line", python_api_send_line, METH_VARARGS, "Send a line of input." },
     { "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." },