1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +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:
Sebastien Helleu
2010-03-02 17:34:49 +01:00
parent 282f786c1a
commit 0543b0ccc7
35 changed files with 935 additions and 235 deletions
+77
View File
@@ -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 },