diff --git a/lib/awful.lua b/lib/awful.lua index 9f9c35af9..b6b564608 100644 --- a/lib/awful.lua +++ b/lib/awful.lua @@ -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 diff --git a/lua.c b/lua.c index 36de23aaa..a48f3a64e 100644 --- a/lua.c +++ b/lua.c @@ -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);