mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 22:06:38 +02:00
Add new option weechat.look.command_chars, add functions string_is_command_char and string_input_for_buffer in plugin and script API
This commit is contained in:
+15
-12
@@ -371,10 +371,10 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
alias_command = malloc (1 + length1 + 1 + length2 + 1);
|
||||
if (alias_command)
|
||||
{
|
||||
if (*ptr_cmd[0] != '/')
|
||||
if (!weechat_string_is_command_char (*ptr_cmd))
|
||||
strcpy (alias_command, "/");
|
||||
else
|
||||
strcpy (alias_command, "");
|
||||
alias_command[0] = '\0';
|
||||
|
||||
strcat (alias_command, *ptr_cmd);
|
||||
strcat (alias_command, " ");
|
||||
@@ -387,7 +387,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*ptr_cmd[0] == '/')
|
||||
if (weechat_string_is_command_char (*ptr_cmd))
|
||||
{
|
||||
alias_run_command (&buffer,
|
||||
(args_replaced) ? args_replaced : *ptr_cmd);
|
||||
@@ -497,9 +497,9 @@ alias_new (const char *name, const char *command)
|
||||
if (!name || !name[0] || !command || !command[0])
|
||||
return NULL;
|
||||
|
||||
while (name[0] == '/')
|
||||
while (weechat_string_is_command_char (name))
|
||||
{
|
||||
name++;
|
||||
name = weechat_utf8_next_char (name);
|
||||
}
|
||||
|
||||
ptr_alias = alias_search (name);
|
||||
@@ -514,7 +514,8 @@ alias_new (const char *name, const char *command)
|
||||
if (str_completion)
|
||||
{
|
||||
snprintf (str_completion, length, "%%%%%s",
|
||||
(command[0] == '/') ? command + 1 : command);
|
||||
(weechat_string_is_command_char (command)) ?
|
||||
weechat_utf8_next_char (command) : command);
|
||||
}
|
||||
new_hook = weechat_hook_command (name, command, NULL, NULL,
|
||||
(str_completion) ? str_completion : NULL,
|
||||
@@ -587,8 +588,8 @@ alias_get_final_command (struct t_alias *alias)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr_alias = alias_search ((alias->command[0] == '/') ?
|
||||
alias->command + 1 : alias->command);
|
||||
ptr_alias = alias_search ((weechat_string_is_command_char (alias->command)) ?
|
||||
weechat_utf8_next_char (alias->command) : alias->command);
|
||||
if (ptr_alias)
|
||||
{
|
||||
alias->running = 1;
|
||||
@@ -596,8 +597,8 @@ alias_get_final_command (struct t_alias *alias)
|
||||
alias->running = 0;
|
||||
return result;
|
||||
}
|
||||
return (alias->command[0] == '/') ?
|
||||
alias->command + 1 : alias->command;
|
||||
return (weechat_string_is_command_char (alias->command)) ?
|
||||
weechat_utf8_next_char (alias->command) : alias->command;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -812,7 +813,8 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
alias_name = (argv[1][0] == '/') ? argv[1] + 1 : argv[1];
|
||||
alias_name = (weechat_string_is_command_char (argv[1])) ?
|
||||
weechat_utf8_next_char (argv[1]) : argv[1];
|
||||
if (argc > 2)
|
||||
{
|
||||
/* Define new alias */
|
||||
@@ -920,7 +922,8 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
alias_name = (argv[i][0] == '/') ? argv[i] + 1 : argv[i];
|
||||
alias_name = (weechat_string_is_command_char (argv[i])) ?
|
||||
weechat_utf8_next_char (argv[i]) : argv[i];
|
||||
ptr_alias = alias_search (alias_name);
|
||||
if (!ptr_alias)
|
||||
{
|
||||
|
||||
@@ -733,10 +733,10 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
index_result = 0;
|
||||
|
||||
/* check if string is a command */
|
||||
if ((ptr_string[0] == '/') && ptr_string[1] && (ptr_string[1] != '/')
|
||||
&& (ptr_string[1] != ' '))
|
||||
if (!weechat_string_input_for_buffer (ptr_string))
|
||||
{
|
||||
ptr_string++;
|
||||
char_size = weechat_utf8_char_size (ptr_string);
|
||||
ptr_string += char_size;
|
||||
pos_space = ptr_string;
|
||||
while (pos_space && pos_space[0] && (pos_space[0] != ' '))
|
||||
{
|
||||
@@ -756,10 +756,11 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
free (result);
|
||||
return NULL;
|
||||
}
|
||||
result[index_result++] = '/';
|
||||
memcpy (result + index_result, aspell_last_modifier_string, char_size);
|
||||
index_result += char_size;
|
||||
strcpy (result + index_result, ptr_string);
|
||||
index_result += strlen (ptr_string);
|
||||
|
||||
|
||||
pos_space[0] = ' ';
|
||||
ptr_string = pos_space;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ irc_command_exec_all_channels (struct t_irc_server *server,
|
||||
if (!command || !command[0])
|
||||
return;
|
||||
|
||||
if (command[0] != '/')
|
||||
if (!weechat_string_is_command_char (command))
|
||||
{
|
||||
length = 1 + strlen (command) + 1;
|
||||
str_command = malloc (length);
|
||||
@@ -240,7 +240,7 @@ irc_command_exec_all_servers (const char *exclude_servers, const char *command)
|
||||
if (!command || !command[0])
|
||||
return;
|
||||
|
||||
if (command[0] != '/')
|
||||
if (!weechat_string_is_command_char (command))
|
||||
{
|
||||
length = 1 + strlen (command) + 1;
|
||||
str_command = malloc (length);
|
||||
|
||||
@@ -162,18 +162,19 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
/* if send unknown commands is enabled and that input data is a command,
|
||||
then send this command to IRC server */
|
||||
if (weechat_config_boolean (irc_config_network_send_unknown_commands)
|
||||
&& (input_data[0] == '/') && (input_data[1] != '/'))
|
||||
&& !weechat_string_input_for_buffer (input_data))
|
||||
{
|
||||
if (ptr_server)
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
|
||||
input_data + 1);
|
||||
weechat_utf8_next_char (input_data));
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
ptr_data = ((input_data[0] == '/') && (input_data[1] == '/')) ?
|
||||
input_data + 1 : input_data;
|
||||
ptr_data = weechat_string_input_for_buffer (input_data);
|
||||
if (!ptr_data)
|
||||
ptr_data = input_data;
|
||||
data_with_colors = irc_color_encode (ptr_data,
|
||||
weechat_config_boolean (irc_config_network_colors_send));
|
||||
|
||||
|
||||
@@ -386,6 +386,8 @@ plugin_load (const char *filename)
|
||||
new_plugin->string_remove_color = &gui_color_decode;
|
||||
new_plugin->string_encode_base64 = &string_encode_base64;
|
||||
new_plugin->string_decode_base64 = &string_decode_base64;
|
||||
new_plugin->string_is_command_char = &string_is_command_char;
|
||||
new_plugin->string_input_for_buffer = &string_input_for_buffer;
|
||||
|
||||
new_plugin->utf8_has_8bits = &utf8_has_8bits;
|
||||
new_plugin->utf8_is_valid = &utf8_is_valid;
|
||||
|
||||
@@ -402,6 +402,81 @@ weechat_lua_api_string_remove_color (lua_State *L)
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_string_is_command_char: check if first char of string is a
|
||||
* command char
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_string_is_command_char (lua_State *L)
|
||||
{
|
||||
const char *string;
|
||||
int n, value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
string = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
string = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
value = weechat_string_is_command_char (string);
|
||||
|
||||
LUA_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_string_input_for_buffer: return string with input text
|
||||
* for buffer or empty string if
|
||||
* it's a command
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_string_input_for_buffer (lua_State *L)
|
||||
{
|
||||
const char *string, *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
string = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
string = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = weechat_string_input_for_buffer (string);
|
||||
|
||||
LUA_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_mkdir_home: create a directory in WeeChat home
|
||||
*/
|
||||
@@ -7232,6 +7307,8 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "gettext", &weechat_lua_api_gettext },
|
||||
{ "ngettext", &weechat_lua_api_ngettext },
|
||||
{ "string_remove_color", &weechat_lua_api_string_remove_color },
|
||||
{ "string_is_command_char", &weechat_lua_api_string_is_command_char },
|
||||
{ "string_input_for_buffer", &weechat_lua_api_string_input_for_buffer },
|
||||
{ "mkdir_home", &weechat_lua_api_mkdir_home },
|
||||
{ "mkdir", &weechat_lua_api_mkdir },
|
||||
{ "mkdir_parents", &weechat_lua_api_mkdir_parents },
|
||||
|
||||
@@ -345,6 +345,66 @@ XS (XS_weechat_api_string_remove_color)
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::string_is_command_char: check if first char of string is a command
|
||||
* char
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_string_is_command_char)
|
||||
{
|
||||
int value;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
value = weechat_string_is_command_char (SvPV (ST (0), PL_na)); /* string */
|
||||
|
||||
PERL_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::string_input_for_buffer: return string with input text for buffer
|
||||
* or empty string if it's a command
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_string_input_for_buffer)
|
||||
{
|
||||
const char *result;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = weechat_string_input_for_buffer (SvPV (ST (0), PL_na)); /* string */
|
||||
|
||||
PERL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::mkdir_home: create a directory in WeeChat home
|
||||
*/
|
||||
@@ -5790,6 +5850,8 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::gettext", XS_weechat_api_gettext, "weechat");
|
||||
newXS ("weechat::ngettext", XS_weechat_api_ngettext, "weechat");
|
||||
newXS ("weechat::string_remove_color", XS_weechat_api_string_remove_color, "weechat");
|
||||
newXS ("weechat::string_is_command_char", XS_weechat_api_string_is_command_char, "weechat");
|
||||
newXS ("weechat::string_input_for_buffer", XS_weechat_api_string_input_for_buffer, "weechat");
|
||||
newXS ("weechat::mkdir_home", XS_weechat_api_mkdir_home, "weechat");
|
||||
newXS ("weechat::mkdir", XS_weechat_api_mkdir, "weechat");
|
||||
newXS ("weechat::mkdir_parents", XS_weechat_api_mkdir_parents, "weechat");
|
||||
|
||||
@@ -350,6 +350,73 @@ weechat_python_api_string_remove_color (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_string_is_command_char: check if first char of string is
|
||||
* a command char
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_string_is_command_char (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *string;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
string = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &string))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
value = weechat_string_is_command_char (string);
|
||||
|
||||
PYTHON_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_string_input_for_buffer: return string with input text
|
||||
* for buffer or empty string if
|
||||
* it's a command
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_string_input_for_buffer (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *string;
|
||||
const char *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
string = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &string))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = weechat_string_input_for_buffer (string);
|
||||
|
||||
PYTHON_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_mkdir_home: create a directory in WeeChat home
|
||||
*/
|
||||
@@ -6081,6 +6148,8 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "gettext", &weechat_python_api_gettext, METH_VARARGS, "" },
|
||||
{ "ngettext", &weechat_python_api_ngettext, METH_VARARGS, "" },
|
||||
{ "string_remove_color", &weechat_python_api_string_remove_color, METH_VARARGS, "" },
|
||||
{ "string_is_command_char", &weechat_python_api_string_is_command_char, METH_VARARGS, "" },
|
||||
{ "string_input_for_buffer", &weechat_python_api_string_input_for_buffer, METH_VARARGS, "" },
|
||||
{ "mkdir_home", &weechat_python_api_mkdir_home, METH_VARARGS, "" },
|
||||
{ "mkdir", &weechat_python_api_mkdir, METH_VARARGS, "" },
|
||||
{ "mkdir_parents", &weechat_python_api_mkdir_parents, METH_VARARGS, "" },
|
||||
|
||||
@@ -407,6 +407,81 @@ weechat_ruby_api_string_remove_color (VALUE class, VALUE string,
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_string_is_command_char: check if first char of string is a
|
||||
* command char
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_string_is_command_char (VALUE class, VALUE string)
|
||||
{
|
||||
char *c_string;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
c_string = NULL;
|
||||
|
||||
if (NIL_P (string))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
Check_Type (string, T_STRING);
|
||||
|
||||
c_string = STR2CSTR (string);
|
||||
|
||||
value = weechat_string_is_command_char (c_string);
|
||||
|
||||
RUBY_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_string_input_for_buffer: return string with input text
|
||||
* for buffer or empty string if
|
||||
* it's a command
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_string_input_for_buffer (VALUE class, VALUE string)
|
||||
{
|
||||
char *c_string;
|
||||
const char *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
c_string = NULL;
|
||||
|
||||
if (NIL_P (string))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (string, T_STRING);
|
||||
|
||||
c_string = STR2CSTR (string);
|
||||
|
||||
result = weechat_string_input_for_buffer (c_string);
|
||||
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_mkdir_home: create a directory in WeeChat home
|
||||
*/
|
||||
@@ -7023,6 +7098,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "gettext", &weechat_ruby_api_gettext, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "ngettext", &weechat_ruby_api_ngettext, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "string_remove_color", &weechat_ruby_api_string_remove_color, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "string_is_command_char", &weechat_ruby_api_string_is_command_char, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "string_input_for_buffer", &weechat_ruby_api_string_input_for_buffer, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir_home", &weechat_ruby_api_mkdir_home, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir", &weechat_ruby_api_mkdir, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir_parents", &weechat_ruby_api_mkdir_parents, 2);
|
||||
|
||||
@@ -446,7 +446,7 @@ weechat_tcl_api_string_remove_color (ClientData clientData, Tcl_Interp *interp,
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
char *result, *replacement, *string;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
@@ -471,6 +471,72 @@ weechat_tcl_api_string_remove_color (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_string_is_command_char: check if first char of string is a
|
||||
* command char
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_string_is_command_char (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
int result, i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "string_is_command_char");
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
result = weechat_string_is_command_char (Tcl_GetStringFromObj (objv[1], &i)); /* string */
|
||||
|
||||
TCL_RETURN_INT(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_string_input_for_buffer: return string with input text
|
||||
* for buffer or empty string if
|
||||
* it's a command
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_string_input_for_buffer (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
const char *result;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "string_input_for_buffer");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = weechat_string_input_for_buffer (Tcl_GetStringFromObj (objv[1], &i));
|
||||
|
||||
TCL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_mkdir_home: create a directory in WeeChat home
|
||||
*/
|
||||
@@ -6552,6 +6618,10 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
weechat_tcl_api_ngettext, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::string_remove_color",
|
||||
weechat_tcl_api_string_remove_color, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::string_is_command_char",
|
||||
weechat_tcl_api_string_is_command_char, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::string_input_for_buffer",
|
||||
weechat_tcl_api_string_input_for_buffer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::mkdir_home",
|
||||
weechat_tcl_api_mkdir_home, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::mkdir",
|
||||
|
||||
@@ -34,7 +34,7 @@ struct t_weelist;
|
||||
struct timeval;
|
||||
|
||||
/* API version (used to check that plugin has same API and can be loaded) */
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20100216-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20100302-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -172,6 +172,8 @@ struct t_weechat_plugin
|
||||
char *(*string_remove_color) (const char *string, const char *replacement);
|
||||
void (*string_encode_base64) (const char *from, int length, char *to);
|
||||
int (*string_decode_base64) (const char *from, char *to);
|
||||
int (*string_is_command_char) (const char *string);
|
||||
const char *(*string_input_for_buffer) (const char *string);
|
||||
|
||||
/* UTF-8 strings */
|
||||
int (*utf8_has_8bits) (const char *string);
|
||||
@@ -723,6 +725,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
weechat_plugin->string_encode_base64(__from, __length, __to)
|
||||
#define weechat_string_decode_base64(__from, __to) \
|
||||
weechat_plugin->string_decode_base64(__from, __to)
|
||||
#define weechat_string_is_command_char(__string) \
|
||||
weechat_plugin->string_is_command_char(__string)
|
||||
#define weechat_string_input_for_buffer(__string) \
|
||||
weechat_plugin->string_input_for_buffer(__string)
|
||||
|
||||
/* UTF-8 strings */
|
||||
#define weechat_utf8_has_8bits(__string) \
|
||||
|
||||
Reference in New Issue
Block a user