0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| | (function () {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wshShell = new ActiveXObject("WScript.Shell");
var sakuraEditor = Editor.ExpandParameter("$S");
var currentTeXFile = Editor.ExpandParameter("$F");
var suffix = /\.[^.]*$/;
var pdfFile = currentTeXFile.replace(suffix, ".pdf");
var line = Editor.ExpandParameter("$y");
var sumatraPDF = "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe";
var existSumatraPDF = true;
try {
sumatraPDF = wshShell.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\SumatraPDF.exe\\");
} catch (e) {
if (!fso.FileExists(sumatraPDF)) {
sumatraPDF = Editor.InputBox("Input the path to SumatraPDF.exe.", "SumatraPDF.exe", 255);
if (!fso.FileExists(sumatraPDF)) {
sumatraPDF = "rundll32 shell32,ShellExec_RunDLL SumatraPDF";
existSumatraPDF = false;
}
}
}
if (existSumatraPDF) {
sumatraPDF = ["\"", sumatraPDF, "\""].join("");
}
var mainTeXDir = fso.GetParentFolderName(pdfFile);
var cd = "cd /d " + ["\"", mainTeXDir, "\""].join("");
currentTeXFile = ["\"", currentTeXFile, "\""].join("");
var ptex2pdf = "ptex2pdf -u -l -ot \"-no-guess-input-enc -kanji=utf8 -synctex=1\"" + " \"" + fso.GetBaseName(["\"", pdfFile.replace(suffix, ".tex"), "\""].join("")) + "\"";
pdfFile = ["\"", pdfFile, "\""].join("");
var args = sumatraPDF + " -reuse-instance " + pdfFile + " -inverse-search \"\\\"" + sakuraEditor + "\\\" -X=1 -Y=%l \\\"%f\\\"\"" + " -forward-search " + currentTeXFile + " " + line;
var cmd = "cmd /c " + cd + " && " + ptex2pdf + " && echo " + args + " | cmd";
Editor.StatusMsg(cmd, 0);
Editor.FileSave();
Editor.ExecCommand(cmd, 0x81);
}.call(this));
|