diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-12-20 10:13:37 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-12-20 10:13:37 +0100 |
commit | cd7a02bec5ce87e8e1aa26b9fffc3caa0cda8ae8 (patch) | |
tree | 3b662ba9fec186745e48b24b4663555320f93575 /src/plugins/scripts/python | |
parent | e80d6b93a557446a42bf5eb5826798be12c046f0 (diff) | |
download | weechat-cd7a02bec5ce87e8e1aa26b9fffc3caa0cda8ae8.zip |
Add 256 colors support
Changes:
- new section "palette" in weechat.conf
- new API functions: list_search_pos and list_casesearch_pos
Diffstat (limited to 'src/plugins/scripts/python')
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 6429ad383..3aed89013 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -769,6 +769,39 @@ weechat_python_api_list_search (PyObject *self, PyObject *args) } /* + * weechat_python_api_list_search_pos: search position of a string in list + */ + +static PyObject * +weechat_python_api_list_search_pos (PyObject *self, PyObject *args) +{ + char *weelist, *data; + int pos; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script || !python_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_search_pos"); + PYTHON_RETURN_INT(-1); + } + + weelist = NULL; + data = NULL; + + if (!PyArg_ParseTuple (args, "ss", &weelist, &data)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_search_pos"); + PYTHON_RETURN_INT(-1); + } + + pos = weechat_list_search_pos (script_str2ptr (weelist), data); + + PYTHON_RETURN_INT(pos); +} + +/* * weechat_python_api_list_casesearch: search a string in list (ignore case) */ @@ -803,6 +836,40 @@ weechat_python_api_list_casesearch (PyObject *self, PyObject *args) } /* + * weechat_python_api_list_casesearch_pos: search position of a string in list + * (ignore case) + */ + +static PyObject * +weechat_python_api_list_casesearch_pos (PyObject *self, PyObject *args) +{ + char *weelist, *data; + int pos; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script || !python_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + PYTHON_RETURN_INT(-1); + } + + weelist = NULL; + data = NULL; + + if (!PyArg_ParseTuple (args, "ss", &weelist, &data)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + PYTHON_RETURN_INT(-1); + } + + pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data); + + PYTHON_RETURN_INT(pos); +} + +/* * weechat_python_api_list_get: get item by position */ @@ -6886,7 +6953,9 @@ PyMethodDef weechat_python_funcs[] = { "list_new", &weechat_python_api_list_new, METH_VARARGS, "" }, { "list_add", &weechat_python_api_list_add, METH_VARARGS, "" }, { "list_search", &weechat_python_api_list_search, METH_VARARGS, "" }, + { "list_search_pos", &weechat_python_api_list_search_pos, METH_VARARGS, "" }, { "list_casesearch", &weechat_python_api_list_casesearch, METH_VARARGS, "" }, + { "list_casesearch_pos", &weechat_python_api_list_casesearch_pos, METH_VARARGS, "" }, { "list_get", &weechat_python_api_list_get, METH_VARARGS, "" }, { "list_set", &weechat_python_api_list_set, METH_VARARGS, "" }, { "list_next", &weechat_python_api_list_next, METH_VARARGS, "" }, |