AkelPad.Include("CommonFunctions.js");
AkelPad.Include("CoderFunctions.js");
AkelPad.Include("TextFunctions.js");
var hWndEdit = AkelPad.GetEditWnd();
if (hWndEdit)
{
var aCommands = AkelPad.GetArgLine().split(" ");
var pSyntax = GetSyntaxAliasExtension(hWndEdit);
var pFile = AkelPad.GetEditFile(0);
var oFileInfo = separateFile(pFile);
for (var i in aCommands)
{
switch (pSyntax + ":" + aCommands[i])
{
// JScript \\
case "js:help":
AkelPad.Call("Scripts::Main", 1, "LanguageHelp.js", "JavaScript.chm");
break;
case "js:help-alt":
AkelPad.Call("Scripts::Main", 1, "LanguageHelp.js", "WSH.chm");
break;
case "js:lint":
AkelPad.Call("Log::Output", 1, AkelPad.GetAkelDir(1) + '/Tools/jsl.exe -process "' + getFileName(pFile) +
'" -conf "' + AkelPad.GetAkelDir(1) + '/Tools/jsl.conf" -nologo -nofilelisting', getParent(pFile),
"^(.+)\t(\\d+)", "/FILE=$1 /GOTOLINE=$2:1", 1251, 1251);
break;
// C#, JScript.NET \\
case "cs:compile": case "cs:run": case "jsnet:compile": case "jsnet:run":
AkelPad.Command(4105 /*Save*/);
//AkelPad.SaveFile(hWndEdit, "", 65001, true);
var pApp = (pSyntax == "cs" ? "csc" : "jsc");
var pCommand = 'C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\' + pApp + '.exe '; // путь к jsc.exe
var pHeader = GetLineText(0);
if (new RegExp("^//! ?" + pApp + "(?:\.exe)? (.+)").exec(pHeader) != null) pCommand += RegExp.$1 + ' ';
AkelPad.Call("Log::Output", 1, pCommand + '"' + getFileName(pFile) + '"', oFileInfo.path);
if (WaitCompiler() == 0 && aCommands[i] == "run")
AkelPad.Exec('"' + oFileInfo.path + oFileInfo.name + '.exe"', oFileInfo.path);
break;
// HTML \\
case "html:help":
AkelPad.Call("Scripts::Main", 1, "LanguageHelp.js", "HTML.chm");
break;
// Gettext \\
case "gettext:compile":
var pProgram = "msgfmt"; // путь к msgfmt.exe
var pOutFile = oFileInfo.name + ".mo";
var pCommand = pProgram + ' "' + oFileInfo.name + '.' + oFileInfo.ext + '" -o "' + pOutFile + '"';
AkelPad.Call("Log::Output", 1, pCommand, oFileInfo.path);
WaitCompiler();
break;
// Wesnoth Markup Language \\
case "wesnoth-wml:lint":
AkelPad.Call("Scripts::Main", 1, "WesnothWML-Check.js");
break;
}
}
}
function WaitCompiler()
{
// ожидание завершения процесса компилятора
var lpState, lpCode, nState = -1, nCode = -1;
if (lpState = AkelPad.MemAlloc(4 /*sizeof(DWORD)*/ ))
{
if (lpCode = AkelPad.MemAlloc(4 /*sizeof(DWORD)*/ ))
{
while (nState != 0)
{
AkelPad.Call("Log::Output", 3, lpState, null, null, null, lpCode);
nState = AkelPad.MemRead(lpState, 3 /*DT_DWORD*/ );
nCode = AkelPad.MemRead(lpCode, 3 /*DT_DWORD*/ );
WScript.Sleep(200);
}
if (nCode == 0) AkelPad.Call("Log::Output", 5, 'Компиляция файла успешно проведена.');
AkelPad.MemFree(lpCode);
}
AkelPad.MemFree(lpState);
}
return nCode;
}