diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-07-04 14:18:06 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-07-04 14:18:06 +0000 |
commit | aede5032296f9d2ff9b3de6787c5493254d00e2e (patch) | |
tree | 40d7e51b19bcef998cf74aa0879bf50cb2c87288 /plugins/MirLua/src/m_message.cpp | |
parent | fee85fe9916e603d9fdd7e6c61e1f3380df59d51 (diff) |
MirLua: added module m_message
git-svn-id: http://svn.miranda-ng.org/main/trunk@14487 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_message.cpp')
-rw-r--r-- | plugins/MirLua/src/m_message.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/plugins/MirLua/src/m_message.cpp b/plugins/MirLua/src/m_message.cpp new file mode 100644 index 0000000000..f788b93f19 --- /dev/null +++ b/plugins/MirLua/src/m_message.cpp @@ -0,0 +1,65 @@ +#include "stdafx.h"
+
+static int lua_Paste(lua_State *L)
+{
+ MCONTACT hContect = luaL_checkinteger(L, 1);
+ ptrT text(mir_utf8decodeT(luaL_checkstring(L, 2)));
+
+ MessageWindowInputData mwid = { sizeof(MessageWindowInputData) };
+ mwid.hContact = luaL_checkinteger(L, 1);
+ mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+ MessageWindowData mwd = { sizeof(MessageWindowData) };
+
+ INT_PTR res = ::CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd);
+ lua_pushinteger(L, res);
+ if (res)
+ return 1;
+
+ HWND hEdit = GetDlgItem(mwd.hwndWindow, 1002 /*IDC_MESSAGE*/);
+ if (!hEdit) hEdit = GetDlgItem(mwd.hwndWindow, 1009 /*IDC_CHATMESSAGE*/);
+
+ SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)text);
+
+ return 1;
+}
+
+static int lua_Send(lua_State *L)
+{
+ MCONTACT hContect = luaL_checkinteger(L, 1);
+ ptrT text(mir_utf8decodeT(luaL_checkstring(L, 2)));
+
+ MessageWindowInputData mwid = { sizeof(MessageWindowInputData) };
+ mwid.hContact = luaL_checkinteger(L, 1);
+ mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+ MessageWindowData mwd = { sizeof(MessageWindowData) };
+
+ INT_PTR res = ::CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd);
+ lua_pushinteger(L, res);
+ if (res)
+ return 1;
+
+ HWND hEdit = GetDlgItem(mwd.hwndWindow, 1002 /*IDC_MESSAGE*/);
+ if (!hEdit) hEdit = GetDlgItem(mwd.hwndWindow, 1009 /*IDC_CHATMESSAGE*/);
+
+ SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)text);
+ SendMessage(mwd.hwndWindow, WM_COMMAND, IDOK, 0);
+
+ return 1;
+}
+
+static luaL_Reg messageApi[] =
+{
+ { "Paste", lua_Paste },
+ { "Send", lua_Send },
+
+ { NULL, NULL }
+};
+
+LUAMOD_API int luaopen_m_message(lua_State *L)
+{
+ luaL_newlib(L, messageApi);
+
+ return 1;
+}
|