diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MirLua/src/m_hotkeys.cpp | 99 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_module_loader.cpp | 1 | ||||
-rw-r--r-- | plugins/MirLua/src/stdafx.h | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/version.h | 2 |
4 files changed, 105 insertions, 1 deletions
diff --git a/plugins/MirLua/src/m_hotkeys.cpp b/plugins/MirLua/src/m_hotkeys.cpp new file mode 100644 index 0000000000..e998b04a9a --- /dev/null +++ b/plugins/MirLua/src/m_hotkeys.cpp @@ -0,0 +1,99 @@ +#include "stdafx.h"
+
+void MakeHotkey(lua_State *L, HOTKEYDESC &hk)
+{
+ hk.cbSize = sizeof(HOTKEYDESC);
+
+ lua_pushliteral(L, "Flags");
+ lua_gettable(L, -2);
+ hk.dwFlags = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+
+ if (!(hk.dwFlags & HKD_TCHAR))
+ hk.dwFlags |= HKD_TCHAR;
+
+ lua_pushliteral(L, "Name");
+ lua_gettable(L, -2);
+ hk.pszName = mir_utf8decodeA(luaL_checkstring(L, -1));
+ lua_pop(L, 1);
+
+ lua_pushliteral(L, "Description");
+ lua_gettable(L, -2);
+ hk.ptszDescription = mir_utf8decodeT((char*)lua_tostring(L, -1));
+ lua_pop(L, 1);
+
+ lua_pushliteral(L, "Section");
+ lua_gettable(L, -2);
+ hk.ptszSection = mir_utf8decodeT(luaL_optstring(L, -1, MODULE));
+ lua_pop(L, 1);
+
+ lua_pushliteral(L, "Hotkey");
+ lua_gettable(L, -2);
+ hk.DefHotKey = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushliteral(L, "Service");
+ lua_gettable(L, -2);
+ hk.pszService = mir_utf8decodeA(luaL_checkstring(L, -1));
+ lua_pop(L, 1);
+
+ lua_pushliteral(L, "lParam");
+ lua_gettable(L, -2);
+ hk.lParam = (LPARAM)lua_touserdata(L, -1);
+ lua_pop(L, 1);
+}
+
+static int lua_Register(lua_State *L)
+{
+ if (lua_type(L, 1) != LUA_TTABLE)
+ {
+ lua_pushlightuserdata(L, 0);
+ return 1;
+ }
+
+ HOTKEYDESC hk;
+ MakeHotkey(L, hk);
+
+ INT_PTR res = ::CallService("CoreHotkeys/Register", (WPARAM)hScriptsLangpack, (LPARAM)&hk);
+ lua_pushinteger(L, res);
+
+ return 1;
+}
+
+static int lua_Unregister(lua_State *L)
+{
+ const char* name = luaL_checkstring(L, 1);
+
+ INT_PTR res = ::CallService("CoreHotkeys/Unregister", 0, (LPARAM)name);
+ lua_pushinteger(L, res);
+
+ return 1;
+}
+
+static int lua_MakeHotkey(lua_State *L)
+{
+ int mod = luaL_checkinteger(L, 1);
+ int vk = luaL_checkinteger(L, 2);
+
+ WORD res = HOTKEYCODE(mod, vk);
+ lua_pushinteger(L, res);
+
+ return 1;
+}
+
+static luaL_Reg hotkeysApi[] =
+{
+ { "Register", lua_Register },
+ { "Unregister", lua_Unregister },
+
+ { "MakeHotkey", lua_MakeHotkey },
+
+ { NULL, NULL }
+};
+
+LUAMOD_API int luaopen_m_hotkeys(lua_State *L)
+{
+ luaL_newlib(L, hotkeysApi);
+
+ return 1;
+}
diff --git a/plugins/MirLua/src/mlua_module_loader.cpp b/plugins/MirLua/src/mlua_module_loader.cpp index b27424d5ff..4e82793a61 100644 --- a/plugins/MirLua/src/mlua_module_loader.cpp +++ b/plugins/MirLua/src/mlua_module_loader.cpp @@ -21,6 +21,7 @@ void CLuaModuleLoader::LoadModules() PreloadModule(MLUA_DATABASE, luaopen_m_database);
PreloadModule(MLUA_ICOLIB, luaopen_m_icolib);
PreloadModule(MLUA_GENMENU, luaopen_m_genmenu);
+ PreloadModule(MLUA_HOTKEYS, luaopen_m_hotkeys);
PreloadModule(MLUA_MESSAGE, luaopen_m_message);
PreloadModule(MLUA_MSGBUTTONSBAR, luaopen_m_msg_buttonsbar);
PreloadModule(MLUA_POPUP, luaopen_m_popup);
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 96175e0ff0..62eaa25326 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -16,6 +16,7 @@ #include <m_genmenu.h>
#include <m_clist.h>
+#include <m_hotkeys.h>
#include <m_icolib.h>
#include <m_message.h>
#include <m_protocols.h>
@@ -76,6 +77,9 @@ LUAMOD_API int (luaopen_m_icolib)(lua_State *L); #include "m_genmenu.h"
+#define MLUA_HOTKEYS "m_hotkeys"
+LUAMOD_API int (luaopen_m_hotkeys)(lua_State *L);
+
#define MLUA_MESSAGE "m_message"
LUAMOD_API int (luaopen_m_message)(lua_State *L);
diff --git a/plugins/MirLua/src/version.h b/plugins/MirLua/src/version.h index e71e5aa79c..d8967a631e 100644 --- a/plugins/MirLua/src/version.h +++ b/plugins/MirLua/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 4
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
|