Merge commit 'madcoder/master'

This commit is contained in:
Julien Danjou 2008-06-25 11:48:22 +02:00
commit fee4116e3d
2 changed files with 24 additions and 2 deletions

View File

@ -15,6 +15,7 @@ else
end
-- Grab environment we need
local string = string
local assert = assert
local loadstring = loadstring
local ipairs = ipairs
@ -702,8 +703,10 @@ function P.prompt(args, textbox, exe_callback, completion_callback)
elseif key == "Right" then
cur_pos = cur_pos + 1
else
command = command:sub(1, cur_pos - 1) .. key .. command:sub(cur_pos)
cur_pos = cur_pos + 1
if string.len(key) == 1 then
command = command:sub(1, cur_pos - 1) .. key .. command:sub(cur_pos)
cur_pos = cur_pos + 1
end
end
if cur_pos < 1 then
cur_pos = 1

19
lua.c
View File

@ -453,6 +453,23 @@ luaA_openlib(lua_State *L, const char *name,
luaL_register(L, name, methods);
}
static int
luaA_mbstrlen(lua_State *L)
{
const char *cmd = luaL_checkstring(L, 1);
lua_pushnumber(L, mbstowcs(NULL, NONULL(cmd), 0));
return 1;
}
static void
luaA_fixups(lua_State *L)
{
lua_getglobal(L, "string");
lua_pushcfunction(L, luaA_mbstrlen);
lua_setfield(L, -2, "len");
lua_pop(L, 1);
}
/** Initialize the Lua VM
*/
void
@ -497,6 +514,8 @@ luaA_init(void)
luaL_openlibs(L);
luaA_fixups(L);
/* Export awesome lib */
luaL_register(L, "awesome", awesome_lib);