mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 20:36:38 +02:00
Add 256 colors support
Changes: - new section "palette" in weechat.conf - new API functions: list_search_pos and list_casesearch_pos
This commit is contained in:
@@ -816,6 +816,41 @@ weechat_lua_api_list_search (lua_State *L)
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_list_search_pos: search position of a string in list
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_list_search_pos (lua_State *L)
|
||||
{
|
||||
const char *weelist, *data;
|
||||
int n, pos;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_search_pos");
|
||||
LUA_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_search_pos");
|
||||
LUA_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
weelist = lua_tostring (lua_current_interpreter, -2);
|
||||
data = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
pos = weechat_list_search_pos (script_str2ptr (weelist), data);
|
||||
|
||||
LUA_RETURN_INT(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_list_casesearch: search a string in list (ignore case)
|
||||
*/
|
||||
@@ -853,6 +888,42 @@ weechat_lua_api_list_casesearch (lua_State *L)
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_list_casesearch_pos: search position of a string in list
|
||||
* (ignore case)
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_list_casesearch_pos (lua_State *L)
|
||||
{
|
||||
const char *weelist, *data;
|
||||
int n, pos;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
|
||||
LUA_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
|
||||
LUA_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
weelist = lua_tostring (lua_current_interpreter, -2);
|
||||
data = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data);
|
||||
|
||||
LUA_RETURN_INT(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_list_get: get item by position
|
||||
*/
|
||||
@@ -7612,7 +7683,9 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "list_new", &weechat_lua_api_list_new },
|
||||
{ "list_add", &weechat_lua_api_list_add },
|
||||
{ "list_search", &weechat_lua_api_list_search },
|
||||
{ "list_search_pos", &weechat_lua_api_list_search_pos },
|
||||
{ "list_casesearch", &weechat_lua_api_list_casesearch },
|
||||
{ "list_casesearch_pos", &weechat_lua_api_list_casesearch_pos },
|
||||
{ "list_get", &weechat_lua_api_list_get },
|
||||
{ "list_set", &weechat_lua_api_list_set },
|
||||
{ "list_next", &weechat_lua_api_list_next },
|
||||
|
||||
@@ -728,6 +728,39 @@ XS (XS_weechat_api_list_search)
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::list_search_pos: search position of a string in list
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_list_search_pos)
|
||||
{
|
||||
char *weelist, *data;
|
||||
int pos;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_search_pos");
|
||||
PERL_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_search_pos");
|
||||
PERL_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
weelist = SvPV (ST (0), PL_na);
|
||||
data = SvPV (ST (1), PL_na);
|
||||
|
||||
pos = weechat_list_search_pos (script_str2ptr (weelist), data);
|
||||
|
||||
PERL_RETURN_INT(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::list_casesearch: search a string in list (ignore case)
|
||||
*/
|
||||
@@ -761,6 +794,40 @@ XS (XS_weechat_api_list_casesearch)
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::list_casesearch_pos: search position of a string in list
|
||||
* (ignore case)
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_list_casesearch_pos)
|
||||
{
|
||||
char *weelist, *data;
|
||||
int pos;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
|
||||
PERL_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
|
||||
PERL_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
weelist = SvPV (ST (0), PL_na);
|
||||
data = SvPV (ST (1), PL_na);
|
||||
|
||||
pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data);
|
||||
|
||||
PERL_RETURN_INT(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::list_get: get item by position
|
||||
*/
|
||||
@@ -6553,7 +6620,9 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::list_new", XS_weechat_api_list_new, "weechat");
|
||||
newXS ("weechat::list_add", XS_weechat_api_list_add, "weechat");
|
||||
newXS ("weechat::list_search", XS_weechat_api_list_search, "weechat");
|
||||
newXS ("weechat::list_search_pos", XS_weechat_api_list_search_pos, "weechat");
|
||||
newXS ("weechat::list_casesearch", XS_weechat_api_list_casesearch, "weechat");
|
||||
newXS ("weechat::list_casesearch_pos", XS_weechat_api_list_casesearch_pos, "weechat");
|
||||
newXS ("weechat::list_get", XS_weechat_api_list_get, "weechat");
|
||||
newXS ("weechat::list_set", XS_weechat_api_list_set, "weechat");
|
||||
newXS ("weechat::list_next", XS_weechat_api_list_next, "weechat");
|
||||
|
||||
@@ -768,6 +768,39 @@ weechat_python_api_list_search (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
*/
|
||||
@@ -802,6 +835,40 @@ weechat_python_api_list_casesearch (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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, "" },
|
||||
|
||||
@@ -830,6 +830,42 @@ weechat_ruby_api_list_search (VALUE class, VALUE weelist, VALUE data)
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_list_search_pos: search position of a string in list
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_list_search_pos (VALUE class, VALUE weelist, VALUE data)
|
||||
{
|
||||
char *c_weelist, *c_data;
|
||||
int pos;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_search_pos");
|
||||
RUBY_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
if (NIL_P (weelist) || NIL_P (data))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_search_pos");
|
||||
RUBY_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
Check_Type (weelist, T_STRING);
|
||||
Check_Type (data, T_STRING);
|
||||
|
||||
c_weelist = StringValuePtr (weelist);
|
||||
c_data = StringValuePtr (data);
|
||||
|
||||
pos = weechat_list_search_pos (script_str2ptr(c_weelist), c_data);
|
||||
|
||||
RUBY_RETURN_INT(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_list_casesearch: search a string in list (ignore case)
|
||||
*/
|
||||
@@ -866,6 +902,43 @@ weechat_ruby_api_list_casesearch (VALUE class, VALUE weelist, VALUE data)
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_list_casesearch_pos: search position of a string in list
|
||||
* (ignore case)
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_list_casesearch_pos (VALUE class, VALUE weelist, VALUE data)
|
||||
{
|
||||
char *c_weelist, *c_data;
|
||||
int pos;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
|
||||
RUBY_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
if (NIL_P (weelist) || NIL_P (data))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
|
||||
RUBY_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
Check_Type (weelist, T_STRING);
|
||||
Check_Type (data, T_STRING);
|
||||
|
||||
c_weelist = StringValuePtr (weelist);
|
||||
c_data = StringValuePtr (data);
|
||||
|
||||
pos = weechat_list_casesearch_pos (script_str2ptr(c_weelist), c_data);
|
||||
|
||||
RUBY_RETURN_INT(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_list_get: get item by position
|
||||
*/
|
||||
@@ -7546,7 +7619,9 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "list_new", &weechat_ruby_api_list_new, 0);
|
||||
rb_define_module_function (ruby_mWeechat, "list_add", &weechat_ruby_api_list_add, 4);
|
||||
rb_define_module_function (ruby_mWeechat, "list_search", &weechat_ruby_api_list_search, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "list_search_pos", &weechat_ruby_api_list_search_pos, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "list_casesearch", &weechat_ruby_api_list_casesearch, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "list_casesearch_pos", &weechat_ruby_api_list_casesearch_pos, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "list_get", &weechat_ruby_api_list_get, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "list_set", &weechat_ruby_api_list_set, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "list_next", &weechat_ruby_api_list_next, 1);
|
||||
|
||||
@@ -931,6 +931,41 @@ weechat_tcl_api_list_search (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_list_search_pos: search position of a string in list
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_list_search_pos (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
char *weelist, *data;
|
||||
int i, pos;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_search_pos");
|
||||
TCL_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_search_pos");
|
||||
TCL_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
weelist = Tcl_GetStringFromObj (objv[1], &i);
|
||||
data = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
pos = weechat_list_search_pos (script_str2ptr (weelist), data);
|
||||
|
||||
TCL_RETURN_INT(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_list_casesearch: search a string in list (ignore case)
|
||||
*/
|
||||
@@ -967,6 +1002,42 @@ weechat_tcl_api_list_casesearch (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_list_casesearch_pos: search position of a string in list
|
||||
* (ignore case)
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_list_casesearch_pos (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
char *weelist, *data;
|
||||
int i, pos;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
|
||||
TCL_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
|
||||
TCL_RETURN_INT(-1);
|
||||
}
|
||||
|
||||
weelist = Tcl_GetStringFromObj (objv[1], &i);
|
||||
data = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data);
|
||||
|
||||
TCL_RETURN_INT(pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_list_get: get item by position
|
||||
*/
|
||||
@@ -7405,8 +7476,12 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
weechat_tcl_api_list_add, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::list_search",
|
||||
weechat_tcl_api_list_search, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::list_search_pos",
|
||||
weechat_tcl_api_list_search_pos, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::list_casesearch",
|
||||
weechat_tcl_api_list_casesearch, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::list_casesearch_pos",
|
||||
weechat_tcl_api_list_casesearch_pos, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::list_get",
|
||||
weechat_tcl_api_list_get, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::list_set",
|
||||
|
||||
Reference in New Issue
Block a user