summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/main.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-06-09 16:16:16 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-06-09 16:16:16 +0000
commit2c2b13b63e510af16d3806843a022853f0740ed7 (patch)
tree1d0a97401251ce0f5c47ee4083b7c259e9ffc49a /plugins/MirLua/src/main.cpp
parent31aeb2d24674a29ea5810a7e5e2e5a7d36bf3300 (diff)
MirLua:
- added debug console - added m_clist module - added examples git-svn-id: http://svn.miranda-ng.org/main/trunk@14079 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/main.cpp')
-rw-r--r--plugins/MirLua/src/main.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp
index a374da2daa..59ba4fda87 100644
--- a/plugins/MirLua/src/main.cpp
+++ b/plugins/MirLua/src/main.cpp
@@ -3,10 +3,14 @@
int hLangpack;
HINSTANCE g_hInstance;
-CMLua *g_mLua;
+CMLua *mLua;
HANDLE hCommonFolderPath;
HANDLE hCustomFolderPath;
+#ifdef _DEBUG
+HANDLE hConsole = NULL;
+#endif
+
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
@@ -52,18 +56,31 @@ void LoadScripts(const TCHAR *scriptDir)
{
mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, fd.cFileName);
PathToRelativeT(fullPath, path);
- g_mLua->Load(T2Utf(path));
+ mLua->Load(T2Utf(path));
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
+#include <io.h>
+#include <fcntl.h>
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
- g_mLua = new CMLua();
+#ifdef _DEBUG
+ if (AllocConsole())
+ {
+ freopen("CONOUT$", "wt", stdout);
+ hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
+ SetConsoleTitle(_T("MirLua Console"));
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
+ }
+#endif
+
+ mLua = new CMLua();
hCommonFolderPath = FoldersRegisterCustomPathT("MirLua", Translate("Common scripts folder"), COMMON_SCRIPTS_PATHT);
hCustomFolderPath = FoldersRegisterCustomPathT("MirLua", Translate("Custom scripts folder"), CUSTOM_SCRIPTS_PATHT);
@@ -73,7 +90,7 @@ extern "C" int __declspec(dllexport) Load(void)
LoadScripts(commonScriptDir);
TCHAR customScriptDir[MAX_PATH];
- FoldersGetCustomPathT(hCommonFolderPath, customScriptDir, SIZEOF(customScriptDir), VARST(CUSTOM_SCRIPTS_PATHT));
+ FoldersGetCustomPathT(hCustomFolderPath, customScriptDir, SIZEOF(customScriptDir), VARST(CUSTOM_SCRIPTS_PATHT));
LoadScripts(customScriptDir);
return 0;
@@ -81,7 +98,13 @@ extern "C" int __declspec(dllexport) Load(void)
extern "C" int __declspec(dllexport) Unload(void)
{
- delete g_mLua;
+#ifdef _DEBUG
+ if (hConsole)
+ CloseHandle(hConsole);
+ FreeConsole();
+#endif
+
+ delete mLua;
return 0;
}