From 2c2b13b63e510af16d3806843a022853f0740ed7 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Tue, 9 Jun 2015 16:16:16 +0000 Subject: 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 --- plugins/MirLua/src/main.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'plugins/MirLua/src/main.cpp') 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 +#include + 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; } -- cgit v1.2.3